Skip to content

Commit

Permalink
Improve readme
Browse files Browse the repository at this point in the history
  • Loading branch information
guanhuaw committed Jul 22, 2024
1 parent 4497f65 commit 85c7722
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 33 deletions.
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ A Py***Torch***-based differentiable ***I***mage ***R***econstruction ***T***ool

The work is inspired by [MIRT](https://github.com/JeffFessler/mirt), a well-acclaimed toolbox for medical imaging reconstruction.

The main objective is to facilitate rapid, data-driven image reconstruction using CPUs and GPUs through fast prototyping and iteration. Researchers can conveniently develop new model-based and learning-based methods (e.g., unrolled neural networks) with abstraction layers. The availability of auto-differentiation enables optimization of imaging protocols and reconstruction parameters using gradient methods.
The main objective is to facilitate rapid, data-driven medical image reconstruction using CPUs and GPUs, for fast prototyping. Researchers can conveniently develop new model-based and learning-based methods (e.g., unrolled neural networks) with abstraction layers. The availability of auto-differentiation enables optimization of imaging protocols and reconstruction parameters using gradient methods.

Documentation: https://mirtorch.readthedocs.io/en/latest/

Expand All @@ -26,13 +26,13 @@ To install the `MIRTorch` package, after cloning the repo, please try `pip insta

The `LinearMap` class overloads common matrix operations, such as `+, - , *`.

Instances include basic linear operations (like convolution), classical imaging processing, and MRI system matrix (Cartesian and Non-Cartesian, sensitivity- and B0-informed system models). ***NEW!*** MIRTorch recently adds the support for SPPET and CT.
Instances include basic linear operations (like convolution), classical imaging processing, and MRI system matrix (Cartesian and Non-Cartesian, sensitivity- and B0-informed system models). ***NEW!*** MIRTorch recently adds the support for SPECT and CT.

Since the Jacobian matrix of a linear operator is itself, the toolbox can actively calculate such Jacobians during backpropagation, avoiding the large cache cost required by auto-differentiation.

When defining linear operators, please make sure that all torch tensors are on the same device and compatible. For example, `torch.cfloat` are compatible with `torch.float` but not `torch.double`. Similarly, `torch.chalf` is compatible with `torch.half`.
When the data is image, there are 2 empirical formats: `[num_batch, num_channel, nx, ny, (nz)]` and `[nx, ny, (nz)]`.
For some LinearMaps, there is a boolean `batchmode` to control it.
For some LinearMaps, there is a boolean `batchmode` to control the shape.

#### Proximal operators

Expand Down Expand Up @@ -81,7 +81,7 @@ This work is inspired by (but not limited to):

* PyLops: https://github.com/PyLops/pylops

If the code is useful to your research, please cite:
If the code is useful to your research, please consider citing:

```bibtex
@article{wang:22:bjork,
Expand All @@ -102,6 +102,7 @@ If the code is useful to your research, please cite:
year={2022}
}
```
If you use the SPECT code, please consider citing:

```bibtex
@ARTICLE{li:23:tet,
Expand Down
40 changes: 11 additions & 29 deletions mirtorch/linear/mri.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"""

import math
from typing import Sequence, Union, List
from typing import Union, List

import numpy as np
import torch
Expand All @@ -29,8 +29,8 @@ class FFTCn(LinearMap):

def __init__(
self,
size_in: Sequence[int],
size_out: Sequence[int],
size_in: List[int],
size_out: List[int],
dims: Union[int, List[int]] | None = None,
norm: str = "ortho",
):
Expand All @@ -39,14 +39,17 @@ def __init__(
self.dims = dims

@torch.jit.script
def _apply(self: LinearMap, x: Tensor) -> Tensor:
x = ifftshift(x, self.dims)
x = fftn(x, dim=self.dims, norm=self.norm)
x = fftshift(x, self.dims)
def fwd(x: Tensor, dims: Union[int, List[int]], norm: str) -> Tensor:
x = ifftshift(x, dims)
x = fftn(x, dim=dims, norm=norm)
x = fftshift(x, dims)
return x

def _apply(self, x: Tensor) -> Tensor:
return x

@torch.jit.script
def _apply_adjoint(self: LinearMap, x: Tensor) -> Tensor:
def _apply_adjoint(self, x: Tensor) -> Tensor:
x = ifftshift(x, self.dims)
if self.norm == "ortho":
x = ifftn(x, dim=self.dims, norm="ortho")
Expand Down Expand Up @@ -691,24 +694,3 @@ def mri_exp_approx(b0, bins, lseg, t):
ct = np.transpose(np.exp(-np.expand_dims(tl, axis=1) @ b0_v))

return b, ct, tl


# def tukey_filer(LinearMap):
# r"""
# A Tukey filter to counteract Gibbs ringing artifacts
# Parameters:
# size_in: the signal size [nbatch, nchannel, nx (ny, nz ...)]
# width: the window length [wdx (wdy, wdz) ...]
# alpha(s): control parameters of the tukey window
# Returns:
#
# """
#
# def __init__(self,
# size_in: Sequence[int],
# width: Sequence[int],
# alpha: Sequence[int]
# ):
# self.width = width
# self.alpha = alpha
# super(tukey_filer, self).__init__(tuple(size_in), tuple(size_in))

0 comments on commit 85c7722

Please sign in to comment.