Skip to content

Commit

Permalink
Merge branch 'master' into oscar_scale
Browse files Browse the repository at this point in the history
  • Loading branch information
chaithyagr committed Mar 16, 2021
2 parents ada55a8 + c5c1915 commit 500c017
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 20 deletions.
40 changes: 22 additions & 18 deletions mri/operators/fourier/non_cartesian.py
Original file line number Diff line number Diff line change
Expand Up @@ -560,26 +560,29 @@ def __init__(self, samples, shape, implementation='cpu', n_coils=1,
self.shape = shape
self.samples = samples
self.n_coils = n_coils
if implementation == 'cpu':
self.implementation = implementation
self.density_comp = density_comp
self.kwargs = kwargs
if self.implementation == 'cpu':
self.density_comp = density_comp
self.implementation = NFFT(samples=samples, shape=shape,
n_coils=self.n_coils)
elif implementation == 'cuda' or implementation == 'opencl':
self.impl = NFFT(samples=samples, shape=shape,
n_coils=self.n_coils)
elif self.implementation == 'cuda' or self.implementation == 'opencl':
self.density_comp = density_comp
self.implementation = NUFFT(samples=samples, shape=shape,
platform=implementation,
n_coils=self.n_coils)
elif implementation == 'gpuNUFFT':
self.impl = NUFFT(samples=samples, shape=shape,
platform=self.implementation,
n_coils=self.n_coils)
elif self.implementation == 'gpuNUFFT':
if gpunufft_available is False:
raise ValueError('gpuNUFFT library is not installed, '
'please refer to README'
'or use cpu for implementation')
self.implementation = gpuNUFFT(
samples=samples,
shape=shape,
self.impl = gpuNUFFT(
samples=self.samples,
shape=self.shape,
n_coils=self.n_coils,
density_comp=density_comp,
**kwargs
density_comp=self.density_comp,
**self.kwargs
)
else:
raise ValueError('Bad implementation ' + implementation +
Expand All @@ -599,7 +602,7 @@ def op(self, data, *args):
-------
masked Fourier transform of the input image.
"""
return self.implementation.op(data, *args)
return self.impl.op(data, *args)

def adj_op(self, coeffs, *args):
""" This method calculates inverse masked non-uniform Fourier
Expand All @@ -614,14 +617,14 @@ def adj_op(self, coeffs, *args):
-------
inverse discrete Fourier transform of the input coefficients.
"""
if not isinstance(self.implementation, gpuNUFFT) and \
if not isinstance(self.impl, gpuNUFFT) and \
self.density_comp is not None:
return self.implementation.adj_op(
return self.impl.adj_op(
coeffs * self.density_comp,
*args
)
else:
return self.implementation.adj_op(coeffs, *args)
return self.impl.adj_op(coeffs, *args)


class Stacked3DNFFT(OperatorBase):
Expand Down Expand Up @@ -665,6 +668,7 @@ def __init__(self, kspace_loc, shape, implementation='cpu', n_coils=1):
self.num_slices = shape[2]
self.shape = shape
self.samples = kspace_loc
self.implementation = implementation
(kspace_plane_loc, self.z_sample_loc, self.sort_pos, self.idx_mask_z) \
= \
get_stacks_fourier(
Expand All @@ -675,7 +679,7 @@ def __init__(self, kspace_loc, shape, implementation='cpu', n_coils=1):
self.stack_len = len(kspace_plane_loc)
self.plane_fourier_operator = \
NonCartesianFFT(samples=kspace_plane_loc, shape=shape[0:2],
implementation=implementation)
implementation=self.implementation)
self.n_coils = n_coils

def _op(self, data):
Expand Down
4 changes: 2 additions & 2 deletions mri/operators/fourier/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,8 +304,8 @@ def check_if_fourier_op_uses_sense(fourier_op):
"""
from .non_cartesian import NonCartesianFFT, gpuNUFFT
if isinstance(fourier_op, NonCartesianFFT) and \
isinstance(fourier_op.implementation, gpuNUFFT):
return fourier_op.implementation.uses_sense
isinstance(fourier_op.impl, gpuNUFFT):
return fourier_op.impl.uses_sense
else:
return False

Expand Down
3 changes: 3 additions & 0 deletions mri/scripts/gridsearch.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,9 @@ def launch_grid(kspace_data, reconstructor_class, reconstructor_kwargs,
'samples': fourier_op.samples,
'shape': fourier_op.shape,
'n_coils': fourier_op.n_coils,
'implementation': fourier_op.implementation,
'density_comp': fourier_op.density_comp,
**fourier_op.kwargs,
}
}
fourier_op = None
Expand Down

0 comments on commit 500c017

Please sign in to comment.