MRISliceTransform#

class deepinv.datasets.MRISliceTransform(mask_generator=None, seed_mask_generator=True, estimate_coil_maps=False, acs=None, prewhiten=False, normalize=False)[source]#

Bases: MRIMixin

FastMRI raw data preprocessing.

Preprocess raw kspace data:

  • Optionally prewhiten kspace

  • Optionally normalize kspace

  • Optionally generate mask/load existing mask (i.e. for challenge/test sets)

  • Optionally estimate coil maps (applicable only when using with multi-coil MRI physics).

To be used with deepinv.datasets.FastMRISliceDataset. See below for input and output shapes.

Parameters:
  • mask_generator (deepinv.physics.generator.BaseMaskGenerator) – optional mask generator for simulating masked measurements retrospectively.

  • seed_mask_generator (bool) – if True, generated mask for given kspace is always the same. This should be True for test set. For supervised training, set to False for higher diversity in kspace undersampling.

  • estimate_coil_maps (bool, int) – if True, estimate coil maps using deepinv.physics.MultiCoilMRI.estimate_coil_maps().

  • acs (int) – optional number of low frequency lines for autocalibration. If None, look for acs lines in mask_generator attributes (if exists) or in metadata (only available for FastMRI test/challenge data). If unavailable, and ACS required, then raises error.

  • prewhiten (tuple[slice, slice], bool) – if True, prewhiten kspace noise across coils, defaults to using a 30x30 slice in the top left corner. Optionally set tuple of slices for custom location. Defaults to False.

  • normalize (bool) – if True, normalize kspace by 99th percentile of RSS reconstruction of kspace ACS block. if int or float, normalize kspace by normalize / kspace.max().

generate_maps(kspace, metadata=None)[source]#

Estimate coil maps using deepinv.physics.MultiCoilMRI.estimate_coil_maps().

Parameters:
  • kspace (torch.Tensor) – input kspace of shape (2, N, H, W)

  • metadata (dict) – optional metadata.

Returns:

estimated coil maps of shape (N, H, W) and complex dtype

Return type:

Tensor

generate_mask(kspace, seed)[source]#

Simulate mask from mask generator.

Parameters:
  • kspace (torch.Tensor) – input fully-sampled kspace of shape (2, (N,) H, W) where (N,) is optional multicoil

  • seed (str, int) – mask generator seed. Useful for specifying same mask per data sample.

Returns:

mask of shape (C, H, W)

Return type:

Tensor

get_acs(metadata=None)[source]#

Get number of low frequency lines for autocalibration.

First checks acs attribute. Then checks mask_generator.n_center. Then looks in metadata["acs"] if it the acs key is present in the data. Finally, raises error if ACS not set anywhere.

Parameters:

metadata (dict) – metadata dictionary.

Return int:

acs size

normalize_kspace(kspace, metadata=None)[source]#

Normalize kspace by percentile of RSS of ACS.

Parameters:
  • kspace (torch.Tensor) – input kspace of shape (2, (N,) H, W)

  • metadata (dict) – optional metadata.

Returns:

whitened kspace.

Return type:

Tensor

prewhiten_kspace(kspace)[source]#

Prewhiten kspace using Cholesky decomposition.

Parameters:

kspace (torch.Tensor) – input multicoil kspace of shape (2, N, H, W)

Returns:

whitened kspace.

Return type:

Tensor

Examples using MRISliceTransform:#

Tour of MRI functionality in DeepInverse

Tour of MRI functionality in DeepInverse