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. |
|
Extract the affine matrix from the header of an MRD.Image. |
Data#
API#
- snake.mrd_utils.loader.GenericPath = None#
- snake.mrd_utils.loader.read_mrd_header(filename: snake.mrd_utils.loader.GenericPath | ismrmrd.Dataset) ismrmrd.xsd.ismrmrdHeader [source]#
Read the header of the MRD file.
- class snake.mrd_utils.loader.MRDLoader(filename: snake.mrd_utils.loader.GenericPath, 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.
- 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.
- get_smaps(resample: bool = True) numpy.typing.NDArray[numpy.complex64] | None [source]#
Load the sensitivity maps from the dataset.
- Parameters:
resample (bool) β If resample is True (default), the sensitivity maps are resampled using the affine transformation
sim_conf. (describe in the phantom and)
- Returns:
None (if no Smaps is found)
NDArray (The coils sensitivity maps)
- class snake.mrd_utils.loader.CartesianFrameDataLoader(filename: snake.mrd_utils.loader.GenericPath, 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: snake.mrd_utils.loader.GenericPath, 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
- snake.mrd_utils.loader.parse_sim_conf(header: ismrmrd.xsd.ismrmrdHeader) snake.core.SimConfig [source]#
Parse the header to populate SimConfig from an MRD Header.