Data module¶
Transform function template¶
-
activemri.data.
transform_template
(kspace: List[numpy.ndarray] = None, mask: torch.Tensor = None, ground_truth: torch.Tensor = None, attrs: List[Dict[str, Any]] = None, fname: List[str] = None, slice_id: List[int] = None)¶ Template for transform functions.
- Parameters
kspace (-) – A list of complex numpy arrays, one per k-space in the batch. The length is the
batch_size
, and array shapes areH x W x 2
for single coil data, andC x H x W x 2
for multicoil data, whereH
denotes k-space height,W
denotes k-space width, andC
is the number of coils. Note that the width can differ between batch elements, ifnum_cols
is set to a tuple when creating the environment.mask (-) – A tensor of binary column masks, where 1s indicate that the corresponding k-space column should be selected. The shape is
batch_size x 1 x maxW
, for single coil data, andbatch_size x 1 x 1 x maxW
for multicoil data. HeremaxW
is the maximum k-space width returned by the environment.ground_truth (-) – A tensor of ground truth 2D images. The shape is
batch_size x 320 x 320
.attrs (-) – A list of dictionaries with the attributes read from the fastMRI for each image.
fname (-) – A list of the filenames where the images where read from.
slice_id (-) – A list with the slice ids in the files where each image was read from.
- Returns
A tuple with any number of inputs required by the reconstructor model.
- Return type
tuple(Any…)
Custom transforms¶
activemri.data.transforms.py¶
Transform functions to process fastMRI data for reconstruction models.
-
activemri.data.transforms.
fastmri_unet_transform_multicoil
(kspace=None, mask=None, ground_truth=None, attrs=None, fname=None, slice_id=None)¶ Transform to use as input to fastMRI’s Unet model for multicoil data.
This is an adapted version of the code found in fastMRI.
-
activemri.data.transforms.
fastmri_unet_transform_singlecoil
(kspace=None, mask=None, ground_truth=None, attrs=None, fname=None, slice_id=None)¶ Transform to use as input to fastMRI’s Unet model for singlecoil data.
This is an adapted version of the code found in fastMRI.
-
activemri.data.transforms.
raw_transform_miccai2020
(kspace=None, mask=None, **_kwargs)¶ Transform to produce input for reconstructor used in Pineda et al. MICCAI’20.
Produces a zero-filled reconstruction and a mask that serve as a input to models of type
activemri.models.cvpr10_reconstructor.CVPR19Reconstructor
. The mask is almost equal to the mask passed as argument, except that high-frequency padding columns are set to 1, and the mask is reshaped to be compatible with the reconstructor.- Parameters
kspace (
np.ndarray
) – The array containing the k-space data returned by the dataset.mask (
torch.Tensor
) – The masks to apply to the k-space.
- Returns
- A tuple containing:
torch.Tensor
: The zero-filled reconstructor that will be passed to the reconstructor.torch.Tensor
: The mask to use as input to the reconstructor.
- Return type
tuple