MRDLoader#

class snake.mrd_utils.loader.MRDLoader(filename, dataset_name='dataset', writeable=False, swmr=False)[source]#

Bases: 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.

Methods

__init__

get_all_dynamic

Get all dynamic data.

get_coil_cov

Load the coil covariance from the dataset.

get_dynamic

Get dynamic data.

get_kspace_frame

Get k-space frame trajectory/mask and data.

get_phantom

Load the phantom from the dataset.

get_sim_conf

Parse the sim config.

get_smaps

Load the sensitivity maps from the dataset.

iter_frames

Iterate over kspace frames of the dataset.

Attributes

header

Get the header from the mrd file.

log

Logger.

n_acquisition

Number of acquisition in the dataset.

n_coils

Number of coils.

n_frames

Number of frames.

n_sample

Number of samples in a single acquisition.

n_shots

Number of samples in a single acquisition.

Parameters:
iter_frames(start=None, stop=None, step=None)[source]#

Iterate over kspace frames of the dataset.

Parameters:
  • start (int | None)

  • stop (int | None)

  • step (int | None)

Return type:

Generator[tuple[int, ndarray[Any, dtype[_ScalarType_co]], ndarray[Any, dtype[_ScalarType_co]]], None, None]

get_kspace_frame(idx)[source]#

Get k-space frame trajectory/mask and data.

Parameters:

idx (int)

Return type:

tuple[ndarray[Any, dtype[_ScalarType_co]], ndarray[Any, dtype[_ScalarType_co]]]

_read_xml_header()[source]#

Read the header of the MRD file.

Return type:

ismrmrdHeader

property header: ismrmrdHeader#

Get the header from the mrd file.

property _dataset: Dataset#

Get MRD dataset.

property n_frames: int#

Number of frames.

property n_coils: int#

Number of coils.

property n_acquisition: int#

Number of acquisition in the dataset.

property n_sample: int#

Number of samples in a single acquisition.

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_phantom(imnum=0)[source]#

Load the phantom from the dataset.

Parameters:

imnum (int)

Return type:

Phantom

get_dynamic(waveform_num)[source]#

Get dynamic data.

Parameters:

waveform_num (int)

Return type:

DynamicData

get_all_dynamic()[source]#

Get all dynamic data.

Return type:

list[DynamicData]

get_sim_conf()[source]#

Parse the sim config.

Return type:

SimConfig

get_smaps()[source]#

Load the sensitivity maps from the dataset.

Return type:

ndarray[Any, dtype[_ScalarType_co]] | None

get_coil_cov(default=None)[source]#

Load the coil covariance from the dataset.

Parameters:

default (ndarray[Any, dtype[_ScalarType_co]] | None)

Return type:

ndarray[Any, dtype[_ScalarType_co]] | None