Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add quick utils functions to get B and C matrices from off-resonance maps #124

Open
4 tasks
chaithyagr opened this issue Jun 4, 2024 · 3 comments
Open
4 tasks
Assignees
Labels
feature request New feature or request

Comments

@chaithyagr
Copy link
Member

Currently, in

class MRIFourierCorrected(FourierOperatorBase):
"""Fourier Operator with B0 Inhomogeneities compensation.
This is a wrapper around the Fourier Operator to compensate for the
B0 inhomogeneities in the k-space.
Parameters
----------
fourier_op: object of class FourierBase
the fourier operator to wrap
B: numpy.ndarray
C: numpy.ndarray
indices: numpy.ndarray
backend: str, default 'cpu'
the backend to use for computations. Either 'cpu' or 'gpu'.
"""
def __init__(self, fourier_op, B, C, indices, backend="cpu"):
if backend == "gpu" and not CUPY_AVAILABLE:
raise RuntimeError("Cupy is required for gpu computations.")
if backend == "gpu":
self.xp = cp
elif backend == "cpu":
self.xp = np
else:
raise ValueError("Unsupported backend.")
self._fourier_op = fourier_op
if not fourier_op.uses_sense:
raise ValueError("please use smaps.")
self.n_samples = fourier_op.n_samples
self.n_coils = fourier_op.n_coils
self.shape = fourier_op.shape
self.smaps = fourier_op.smaps
self.n_interpolators = len(C)
self.B = self.xp.array(B)
self.B = self.xp.tile(self.B, (self._fourier_op.n_samples // len(B), 1))
self.C = self.xp.array(C)
self.indices = indices

we just generate the fourier_op which takes the B and C values into account.

  • It might help to also include a function in mrinufft.operators.off_resonance called get_interpolators_from_fieldmap.
  • Also, it might further help to be able to get fourier correction possible directly from the init function itself like MRIFourierCorrected(fourier_op, b0_field, mask)
  • It could be useful to allow for autodiff to pass through this new fourier op, currently we only support cupy or numpy, it might help to check if we have autograd enabled on based fourier_op and enable it as well (we just need to have tensors as torch tensors.
  • A bit distant, but it could help to have the off-resonance estimation from k-space data as function. Although, this is a bit distant and I really feel it should belong to pysap-mri.
@paquiteau
Copy link
Member

I fully agree with you.

Getting the off resonance map from the k space data could be done in the extras module, just as we propose it for the smaps estimation.

We may also wish to have autodiff support around this as well ?

@chaithyagr
Copy link
Member Author

Sure. But note that the estimation isnt trivial, it is computationally expensive (for now). @Daval-G you think these codes can be open sourced though? I wanted to confirm that.

@philouc
Copy link
Collaborator

philouc commented Jun 5, 2024

I agree with @paquiteau : Estimation of off-resonance effects from k-space data should be carried out separately, as it depends on the phase information usually extracted from the image domain and TE value.

@paquiteau paquiteau added the feature request New feature or request label Jun 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants