snake.mrd_utils.loader
#
Loader of MRD data.
Module Contents#
Classes#
Base class for MRD data loader. |
|
Load cartesian MRD files k-space frames iteratively. |
|
Non Cartesian Dataloader. |
Functions#
Read the header of the MRD file. |
|
Parse the header to populate SimConfig from an MRD Header. |
|
Parse the waveform information from the MRD file. |
Data#
API#
- snake.mrd_utils.loader.read_mrd_header(filename: _typeshed.AnyPath | ismrmrd.Dataset) ismrmrd.xsd.ismrmrdHeader [source]#
Read the header of the MRD file.
- class snake.mrd_utils.loader.MRDLoader(filename: _typeshed.AnyPath, dataset_name: str = 'dataset', writeable: bool = False, swmr: bool = False)[source]#
Bases:
snake._meta.LogMixin
Base class for MRD data loader.
This is to be used as a context manager.
It reimplements most of the methods of the mrd.Dataset class, and adds some useful wrappers. With this dataloader, you can open the dataset in readonly mode, which is not possible with mrd.
Initialization
- iter_frames(start: int | None = None, stop: int | None = None, step: int | None = None, shot_dim: bool = False) collections.abc.Generator[tuple[int, numpy.typing.NDArray[numpy.float32], numpy.typing.NDArray[numpy.complex64]], None, None] [source]#
Iterate over kspace frames of the dataset.
- Parameters:
- Yields:
tuple[int, np.ndarray, np.ndarray] β The index of the frame, the trajectory and the kspace data.
- abstract get_kspace_frame(idx: int) tuple[numpy.typing.NDArray[numpy.float32], numpy.typing.NDArray[numpy.complex64]] [source]#
Get k-space frame trajectory/mask and data.
- header() ismrmrd.xsd.ismrmrdHeader #
Get the header from the mrd file.
- property _dataset: h5py.Dataset#
Get MRD dataset.
- property n_shots: int#
Number of samples in a single acquisition.
Notes
for EPI this is the number of phase encoding lines in the EPI zigzag.
- class snake.mrd_utils.loader.CartesianFrameDataLoader(filename: _typeshed.AnyPath, dataset_name: str = 'dataset', writeable: bool = False, swmr: bool = False)[source]#
Bases:
snake.mrd_utils.loader.MRDLoader
Load cartesian MRD files k-space frames iteratively.
- Parameters:
filename (source for the MRD file.)
Examples
>>> for mask, kspace in CartesianFrameDataLoader("test.mrd"): image = ifft(kspace)
Initialization
- get_kspace_frame(idx: int) tuple[numpy.ndarray, numpy.ndarray] [source]#
Get the k-space frame.
- class snake.mrd_utils.loader.NonCartesianFrameDataLoader(filename: _typeshed.AnyPath, dataset_name: str = 'dataset', writeable: bool = False, swmr: bool = False)[source]#
Bases:
snake.mrd_utils.loader.MRDLoader
Non Cartesian Dataloader.
Iterate over the acquisition of the MRD file.
Examples
>>> from mrinufft import get_operator >>> dataloader = NonCartesianFrameDataLoader("test.mrd") >>> for mask, kspace in data_loader: ... nufft = get_operator("finufft")(traj, ... shape=dataloader.shape, n_coils=dataloader.n_coils) ... image = nufft.adj_op(kspace)
Initialization