Skip to content

Commit

Permalink
Merge pull request #155 from CEA-COSMIC/documentation
Browse files Browse the repository at this point in the history
Final Documentation Pull Request
  • Loading branch information
chaithyagr authored Jun 30, 2022
2 parents eba5247 + 81f594b commit 78a9492
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 29 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/ci-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ jobs:
python -m pip install git+https://github.com/CEA-COSMIC/ModOpt.git@develop
python -m pip install git+https://github.com/CEA-COSMIC/pysap.git@develop
python -m pip install git+https://github.com/AGrigis/pysphinxdoc.git
python -m pip install coverage nose pytest pytest-cov pycodestyle twine pytest-xdist
python -m pip install coverage nose pytest pytest-cov pycodestyle pydocstyle twine pytest-xdist
python -m pip install pynfft2
python -m pip install --upgrade .
Expand All @@ -57,7 +57,8 @@ jobs:
run: |
pycodestyle mri --ignore="E121,E123,E126,E226,E24,E704,E402,E731,E722,E741,W503,W504,W605"
pycodestyle examples --ignore="E121,E123,E126,E226,E24,E704,E402,E731,E722,E741,W503,W504,W605"
pydocstyle mri --convention=numpy
pydocstyle examples --convention=numpy
- name: Run Tests
shell: bash -l {0}
run: |
Expand Down
10 changes: 5 additions & 5 deletions mri/operators/fourier/cartesian.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class FFT(FourierOperatorBase):
Number of parallel workers to use for Fourier computation
"""
def __init__(self, shape, n_coils=1, samples=None, mask=None, n_jobs=1):
""" Initilize the 'FFT' class.
"""Initialize the `FFT` class.
Parameters
----------
Expand Down Expand Up @@ -87,7 +87,7 @@ def op(self, img):
-------
x: np.ndarray
masked Fourier transform of the input image. For multicoil
images the coils dimension is put first
images the coils dimension is put first.
"""
if self.n_coils == 1:
return self.mask * sp.fft.ifftshift(sp.fft.fftn(
Expand Down Expand Up @@ -116,20 +116,20 @@ def op(self, img):
)

def adj_op(self, x):
""" This method computes the inverse masked Fourier transform of a ND
"""Compute the inverse masked Fourier transform of a ND
image.
Parameters
----------
x: np.ndarray
masked Fourier transform data. For multicoil
images the coils dimension is put first
images the coils dimension is put first.
Returns
-------
img: np.ndarray
inverse ND discrete Fourier transform of the input coefficients.
For multicoil images the coils dimension is put first
For multicoil images the coils dimension is put first.
"""
if self.n_coils == 1:
return sp.fft.fftshift(sp.fft.ifftn(
Expand Down
44 changes: 22 additions & 22 deletions mri/operators/fourier/non_cartesian.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
##########################################################################

"""
Fourier operators for cartesian and non-cartesian space.
Fourier operators for non-Cartesian sampling.
"""

# System import
Expand Down Expand Up @@ -39,10 +39,10 @@


class NFFT:
""" ND non catesian Fast Fourrier Transform class
""" ND Non-uniform Fast Fourrier Transform~(NFFT) class
The NFFT will normalize like the FFT i.e. in a symetric way.
This means that both direct and adjoint operator will be divided by the
square root of the number of samples in the fourier domain.
square root of the number of samples (i.e. measurements) in the Fourier domain.
Attributes
----------
Expand Down Expand Up @@ -71,12 +71,12 @@ def __init__(self, samples, shape, n_coils=1):
receiver coils acquisition. If n_coils > 1, please organize data as
n_coils X data_per_coil
Exemple
Example
-------
>>> import numpy as np
>>> from pysap.data import get_sample_data
>>> from mri.numerics.fourier import NFFT, FFT
>>> from mri.reconstruct.utils import \
>>> from mri.operators.fourier import NFFT, FFT
>>> from mri.fourier.utils import \
convert_mask_to_locations
>>> I = get_sample_data("2d-pmri").data.astype("complex128")
Expand All @@ -91,7 +91,7 @@ def __init__(self, samples, shape, n_coils=1):
1.000000000000005
"""
if samples.shape[-1] != len(shape):
raise ValueError("Samples and Shape dimension doesn't correspond")
raise ValueError("Samples and shape dimensions do not match")
self.samples = samples
if samples.min() < -0.5 or samples.max() >= 0.5:
warnings.warn("Samples will be normalized between [-0.5; 0.5[")
Expand All @@ -108,7 +108,7 @@ def _op(self, img):
return np.copy(self.plan.trafo()) / np.sqrt(self.plan.M)

def op(self, img):
""" This method calculates the masked non-cartesian Fourier transform
""" This method computes the masked non-uniform Fourier transform
of a N-D data.
Parameters
Expand All @@ -134,13 +134,13 @@ def _adj_op(self, x):
return np.copy(self.plan.adjoint()) / np.sqrt(self.plan.M)

def adj_op(self, x):
""" This method calculates inverse masked non-cartesian Fourier
"""Compute inverse masked non-uniform Fourier
transform of a 1-D coefficients array.
Parameters
----------
x: np.ndarray
masked non-cartesian Fourier transform 1D data.
masked non-uniform Fourier transform 1D data.
Returns
-------
Expand All @@ -157,7 +157,7 @@ def adj_op(self, x):


class gpuNUFFT:
""" GPU implementation of N-D non uniform Fast Fourrier Transform class.
""" GPU implementation of N-D Non-uniform Fast Fourrier Transform class.
Attributes
----------
Expand All @@ -180,7 +180,7 @@ def __init__(self, samples, shape, n_coils=1, density_comp=None,
Parameters
----------
samples: np.ndarray
the kspace sample locations in the Fourier domain,
the k-space sample locations in the Fourier domain,
normalized between -0.5 and 0.5
shape: tuple of int
shape of the image
Expand All @@ -189,7 +189,7 @@ def __init__(self, samples, shape, n_coils=1, density_comp=None,
receiver coils acquisition
density_comp: np.ndarray default None.
k-space weighting, density compensation, if not specified
equal weightage is given.
equal weighting is given.
kernel_width: int default 3
interpolation kernel width (usually 3 to 7)
sector_width: int default 8
Expand Down Expand Up @@ -234,8 +234,8 @@ def __init__(self, samples, shape, n_coils=1, density_comp=None,
)

def op(self, image, interpolate_data=False):
""" This method calculates the masked non-cartesian Fourier transform
of a 2D / 3D image.
"""Compute the masked non-uniform Fourier transform
of a 2D image/ 3D volume.
Parameters
----------
Expand Down Expand Up @@ -282,7 +282,7 @@ def adj_op(self, coeff, grid_data=False):
Returns
-------
np.ndarray
adjoint operator of Non Uniform Fourier transform of the
adjoint operator of non-uniform Fourier transform of the
input coefficients.
"""
image = self.operator.adj_op(coeff, grid_data)
Expand All @@ -292,7 +292,7 @@ def adj_op(self, coeff, grid_data=False):
)
else:
image = np.squeeze(image).T
# The recieved data from gpuNUFFT is num_channels x Nx x Ny x Nz,
# The received data from gpuNUFFT is num_channels x Nx x Ny x Nz,
# hence we use squeeze
return np.squeeze(image)

Expand Down Expand Up @@ -348,7 +348,7 @@ def __init__(self, samples, shape, implementation='cpu', n_coils=1,
' chosen. Please choose between "cpu" | "gpuNUFFT"')

def op(self, data, *args):
""" This method calculates the masked non-cartesian Fourier transform
"""Compute the masked non-uniform Fourier transform
of an image.
Parameters
Expand All @@ -363,7 +363,7 @@ def op(self, data, *args):
return self.impl.op(data, *args)

def adj_op(self, coeffs, *args):
""" This method calculates inverse masked non-uniform Fourier
"""Compute the inverse masked non-uniform Fourier
transform of a 1-D coefficients array.
Parameters
Expand Down Expand Up @@ -423,7 +423,7 @@ def __init__(self, kspace_loc, shape, implementation='cpu', n_coils=1):
shape of the image stack in 3D. (N x N x Nz)
implementation: string, 'cpu' or 'gpuNUFFT'
default 'cpu'
string indicating which implemenmtation of Noncartesian FFT
string indicating which implementation of non-uniform FFT
must be carried out. Please refer to Documentation of
NoncartesianFFT
n_coils: int default 1
Expand Down Expand Up @@ -466,7 +466,7 @@ def _op(self, data):
np.sqrt(self.num_slices / self.acq_num_slices)

def op(self, data):
""" This method calculates Fourier transform.
"""Compute the Fourier transform.
Parameters
----------
Expand Down Expand Up @@ -505,7 +505,7 @@ def _adj_op(self, coeff):
return stacked_images * np.sqrt(self.num_slices / self.acq_num_slices)

def adj_op(self, coeff):
""" This method calculates inverse masked non-uniform Fourier
"""Compute the inverse masked non-uniform Fourier
transform of a 1-D coefficients array.
Parameters
Expand Down

0 comments on commit 78a9492

Please sign in to comment.