This module contains classes for creating sub-sampling masks. The masks are used to sample k-space data in MRI
reconstruction. The masks are created by selecting a subset of samples from the input k-space data.
BaseMaskFunc is the base class to create a sub-sampling mask of a given shape.
Parameters:
accelerations (Union[list[Union[float, int]], tuple[Union[float, int], ...]]) – Amount of under-sampling_mask. An acceleration of 4 retains 25% of the k-space, the method is
given by mask_type. Has to be the same length as center_fractions if uniform_range is not True.
center_fractions (Union[list[float], tuple[float, ...], None]) – Fraction of low-frequency columns (float < 1.0) or number of low-frequence columns
(integer) to be retained. If multiple values are provided, then one of these numbers is chosen uniformly
each time. If uniform_range is True, then two values should be given. Default: None.
uniform_range (bool) – If True then an acceleration will be uniformly sampled between the two values.
Default: False.
accelerations (Union[list[Union[float, int]], tuple[Union[float, int], ...]]) – Amount of under-sampling_mask. An acceleration of 4 retains 25% of the k-space, the method
is given by mask_type. Has to be the same length as center_fractions if uniform_range is not True.
center_fractions (Union[list[float], tuple[float, ...], None]) – Fraction of low-frequency columns (float < 1.0) or number of low-frequence columns
(integer) to be retained. If multiple values are provided, then one of these numbers is chosen uniformly
each time. If uniform_range is True, then two values should be given. Default: None.
uniform_range (bool) – If True then an acceleration will be uniformly sampled between the two values.
Default: False.
shape (tuple[int, ...]) – Shape of the mask to be created. Needs to be at least 3 dimensions. If mode is MaskFuncMode.DYNAMIC,
or MaskFuncMode.MULTISLICE, then the shape should have at least 4 dimensions.
args – Additional arguments to be passed to the mask function.
kwargs – Additional keyword arguments to be passed to the mask function.
or (The subsampling scheme to use. Can be either CIRCUSSamplingMode.CIRCUS_RADIAL)
CIRCUSSamplingMode.CIRCUS_SPIRAL.
accelerations (Union[list[Union[float, int]], tuple[Union[float, int], ...]]) – Amount of under-sampling.
center_fractions (Union[list[float], tuple[float, ...], None]) – Fraction (< 1.0) of low-frequency samples to be retained. If None, it will calculate the acs mask based on the
mask (maximum masked disk in the generated) – None.
uniform_range (bool) – If True then an acceleration will be uniformly sampled between the two values. Default: False.
shape (then a single mask is created independent of the requested)
be (and will)
1 (broadcasted to the shape by expanding other dimensions with)
MaskFuncMode.DYNAMIC
:param :
:param this expects the shape to have more then 3 dimensions:
:param and the mask will be created for each time frame:
:param along the fourth last dimension. Similarly for MaskFuncMode.MULTISLICE:
:param the mask will be created for each:
:param slice along the fourth last dimension. Default: MaskFuncMode.STATIC.
:param References:
:param .. [1] Liu J: a variable density
:type .. [1] Liu J: CIRCUS
:param Saloner D. Accelerated MRI with CIRcular Cartesian UnderSampling: a variable density
:type Saloner D. Accelerated MRI with CIRcular Cartesian UnderSampling: CIRCUS
:param Cartesian sampling strategy for compressed sensing and parallel imaging. Quant Imaging Med Surg.:
:param 2014 Feb;4: 57-67. doi: 10.3978/j.issn.2223-4292.2014.02.01. PMID: 24649436; PMCID: PMC3947985.
:type 2014 Feb;4: 1
or (The subsampling scheme to use. Can be either CIRCUSSamplingMode.CIRCUS_RADIAL)
CIRCUSSamplingMode.CIRCUS_SPIRAL.
accelerations (Union[list[Union[float, int]], tuple[Union[float, int], ...]]) – Amount of under-sampling.
center_fractions (Union[list[float], tuple[float, ...], None]) – Fraction (< 1.0) of low-frequency samples to be retained. If None, it will calculate the acs mask
mask (based on the maximum masked disk in the generated) – None.
uniform_range (bool) – If True then an acceleration will be uniformly sampled between the two values. Default: False.
shape (then a single mask is created independent of the requested)
be (and will)
1 (broadcasted to the shape by expanding other dimensions with)
MaskFuncMode.DYNAMIC
:param :
:param this expects the shape to have more then 3 dimensions:
:param and the mask will be created for each time frame:
:param along the fourth last dimension. Similarly for MaskFuncMode.MULTISLICE:
:param the mask will be created for each:
:param slice along the fourth last dimension. Default: MaskFuncMode.STATIC.
Raises:
NotImplementedError
If the subsampling_scheme is not CIRCUSSamplingMode.CIRCUS_RADIAL or CIRCUSSamplingMode.CIRCUS_SPIRAL.
Implementation of Calgary-Campinas sampling mask function.
Samples are drawn from pre-computed masks provided by the challenge. The masks are available for accelerations of
5 and 10. The masks are available for shapes of \(218 \times 170/174/180\). The masks are downloaded from the
challenge website and cached locally. The masks are loaded based on the shape of the input k-space data. The masks
are randomly selected from the available masks for the given shape. The masks are broadcasted to the shape of the
input k-space data. The autocalibration signal region is generated as a
circular mask centered in the k-space with a radius of 18.
For more information, please refer to the challenge website [1]_.
Similar to FastMRIEquispacedMaskFunc, but instead of center fraction (center_fractions) representing
the fraction of center lines to the original size, here, it represents the actual number of center lines.
Parameters:
accelerations (Union[list[Union[float, int]], tuple[Union[float, int], ...]]) – Amount of under-sampling_mask. An acceleration of 4 retains 25% of the k-space, the method is given by
True. (mask_type. Has to be the same length as center_fractions if uniform_range is not)
center_fractions (Union[list[int], tuple[int, ...]]) – Number of low-frequence (center) columns to be retained.
uniform_range (bool) – If True then an acceleration will be uniformly sampled between the two values. Default: False.
mode (MaskFuncMode) – Mode of the mask function. Can be MaskFuncMode.STATIC, MaskFuncMode.DYNAMIC, or MaskFuncMode.MULTISLICE.
MaskFuncMode.STATIC (If)
shape (then a single mask is created independent of the requested)
be (and will)
1 (broadcasted to the shape by expanding other dimensions with)
MaskFuncMode.DYNAMIC (if applicable. If)
:param :
:param this expects the shape to have more then 3 dimensions:
:param and the mask will be created for each time frame:
:param along the fourth last dimension. Similarly for MaskFuncMode.MULTISLICE:
:param the mask will be created for each:
:param slice along the fourth last dimension. Default: MaskFuncMode.STATIC.
accelerations (Union[list[Union[float, int]], tuple[Union[float, int], ...]]) – Amount of under-sampling_mask. An acceleration of 4 retains 25% of the k-space, the method is given by
True. (mask_type. Has to be the same length as center_fractions if uniform_range is not)
center_fractions (Union[list[int], tuple[int, ...]]) – Number of low-frequence (center) columns to be retained.
uniform_range (bool) – If True then an acceleration will be uniformly sampled between the two values. Default: False.
mode (MaskFuncMode) – Mode of the mask function. Can be MaskFuncMode.STATIC, MaskFuncMode.DYNAMIC, or MaskFuncMode.MULTISLICE.
MaskFuncMode.STATIC (If)
shape (then a single mask is created independent of the requested)
be (and will)
1 (broadcasted to the shape by expanding other dimensions with)
MaskFuncMode.DYNAMIC (if applicable. If)
:param :
:param this expects the shape to have more then 3 dimensions:
:param and the mask will be created for each time frame:
:param along the fourth last dimension. Similarly for MaskFuncMode.MULTISLICE:
:param the mask will be created for each:
:param slice along the fourth last dimension. Default: MaskFuncMode.STATIC.
Cartesian equispaced mask function as implemented in [1]_.
Similar to FastMRIMagicMaskFunc, but instead of center fraction (center_fractions) representing
the fraction of center lines to the original size, here, it represents the actual number of center lines.
References
Parameters:
accelerations (Union[list[Union[float, int]], tuple[Union[float, int], ...]]) – Amount of under-sampling_mask. An acceleration of 4 retains 25% of the k-space, the method is given by
mask_type. Has to be the same length as center_fractions if uniform_range is not True.
center_fractions (Union[list[int], tuple[int, ...]]) – Number of low-frequence (center) columns to be retained.
uniform_range (bool) – If True then an acceleration will be uniformly sampled between the two values. Default: False.
mode (MaskFuncMode) – Mode of the mask function. Can be MaskFuncMode.STATIC, MaskFuncMode.DYNAMIC, or MaskFuncMode.MULTISLICE.
If MaskFuncMode.STATIC, then a single mask is created independent of the requested shape, and will be
broadcasted to the shape by expanding other dimensions with 1, if applicable. If MaskFuncMode.DYNAMIC,
this expects the shape to have more then 3 dimensions, and the mask will be created for each time frame
along the fourth last dimension. Similarly for MaskFuncMode.MULTISLICE, the mask will be created for each
slice along the fourth last dimension. Default: MaskFuncMode.STATIC.
accelerations (Union[list[Union[float, int]], tuple[Union[float, int], ...]]) – Amount of under-sampling_mask. An acceleration of 4 retains 25% of the k-space, the method is given by
True. (mask_type. Has to be the same length as center_fractions if uniform_range is not)
center_fractions (Union[list[int], tuple[int, ...]]) – Number of low-frequence (center) columns to be retained.
uniform_range (bool) – If True then an acceleration will be uniformly sampled between the two values. Default: False.
mode (MaskFuncMode) – Mode of the mask function. Can be MaskFuncMode.STATIC, MaskFuncMode.DYNAMIC, or MaskFuncMode.MULTISLICE.
MaskFuncMode.STATIC (If)
shape (then a single mask is created independent of the requested)
be (and will)
1 (broadcasted to the shape by expanding other dimensions with)
MaskFuncMode.DYNAMIC (if applicable. If)
:param :
:param this expects the shape to have more then 3 dimensions:
:param and the mask will be created for each time frame:
:param along the fourth last dimension. Similarly for MaskFuncMode.MULTISLICE:
:param the mask will be created for each:
:param slice along the fourth last dimension. Default: MaskFuncMode.STATIC.
Similar to FastMRIRandomMaskFunc, but instead of center fraction (center_fractions) representing
the fraction of center lines to the original size, here, it represents the actual number of center lines.
Parameters:
accelerations (Union[list[Union[float, int]], tuple[Union[float, int], ...]]) – Amount of under-sampling_mask. An acceleration of 4 retains 25% of the k-space, the method is given by
mask_type. Has to be the same length as center_fractions if uniform_range is not True.
center_fractions (Union[list[int], tuple[int, ...]]) – Number of low-frequence (center) columns to be retained.
uniform_range (bool) – If True then an acceleration will be uniformly sampled between the two values. Default: False.
mode (MaskFuncMode) – Mode of the mask function. Can be MaskFuncMode.STATIC, MaskFuncMode.DYNAMIC, or MaskFuncMode.MULTISLICE.
If MaskFuncMode.STATIC, then a single mask is created independent of the requested shape, and will be
broadcasted to the shape by expanding other dimensions with 1, if applicable. If MaskFuncMode.DYNAMIC,
this expects the shape to have more then 3 dimensions, and the mask will be created for each time frame
along the fourth last dimension. Similarly for MaskFuncMode.MULTISLICE, the mask will be created for each
slice along the fourth last dimension. Default: MaskFuncMode.STATIC.
accelerations (Union[list[Union[float, int]], tuple[Union[float, int], ...]]) – Amount of under-sampling_mask. An acceleration of 4 retains 25% of the k-space, the method is given by
mask_type. Has to be the same length as center_fractions if uniform_range is not True.
center_fractions (Union[list[int], tuple[int, ...]]) – Number of low-frequence (center) columns to be retained.
uniform_range (bool) – If True then an acceleration will be uniformly sampled between the two values. Default: False.
mode (MaskFuncMode) – Mode of the mask function. Can be MaskFuncMode.STATIC, MaskFuncMode.DYNAMIC, or MaskFuncMode.MULTISLICE.
If MaskFuncMode.STATIC, then a single mask is created independent of the requested shape, and will be
broadcasted to the shape by expanding other dimensions with 1, if applicable. If MaskFuncMode.DYNAMIC,
this expects the shape to have more then 3 dimensions, and the mask will be created for each time frame
along the fourth last dimension. Similarly for MaskFuncMode.MULTISLICE, the mask will be created for each
slice along the fourth last dimension. Default: MaskFuncMode.STATIC.
This is the base class of Cartesian and FastMRI mask functions. The difference between Cartesian and FastMRI
mask functions is that the former uses the number of center lines to be retained, while the latter uses the
fraction of center lines to be retained.
Parameters:
accelerations (Union[list[Union[float, int]], tuple[Union[float, int], ...]]) – Amount of under-sampling_mask. An acceleration of 4 retains 25% of the k-space, the method is given by
mask_type. Has to be the same length as center_fractions if uniform_range is not True.
center_fractions (Union[list[float], tuple[float, ...]]) – Fraction of low-frequency columns (float < 1.0) or number of low-frequence columns (integer) to be retained.
uniform_range (bool) – If True then an acceleration will be uniformly sampled between the two values. Default: False.
mode (MaskFuncMode) – Mode of the mask function. Can be MaskFuncMode.STATIC, MaskFuncMode.DYNAMIC, or MaskFuncMode.MULTISLICE.
If MaskFuncMode.STATIC, then a single mask is created independent of the requested shape, and will be
broadcasted to the shape by expanding other dimensions with 1, if applicable. If MaskFuncMode.DYNAMIC,
this expects the shape to have more then 3 dimensions, and the mask will be created for each time frame
along the fourth last dimension. Similarly for MaskFuncMode.MULTISLICE, the mask will be created for each
slice along the fourth last dimension. Default: MaskFuncMode.STATIC.
accelerations (Union[list[Union[float, int]], tuple[Union[float, int], ...]]) – Amount of under-sampling_mask. An acceleration of 4 retains 25% of the k-space, the method is given by
mask_type. Has to be the same length as center_fractions if uniform_range is not True.
center_fractions (Union[list[float], tuple[float, ...]]) – Fraction of low-frequency columns (float < 1.0) or number of low-frequence columns (integer) to be retained.
uniform_range (bool) – If True then an acceleration will be uniformly sampled between the two values. Default: False.
mode (MaskFuncMode) – Mode of the mask function. Can be MaskFuncMode.STATIC, MaskFuncMode.DYNAMIC, or MaskFuncMode.MULTISLICE.
If MaskFuncMode.STATIC, then a single mask is created independent of the requested shape, and will be
broadcasted to the shape by expanding other dimensions with 1, if applicable. If MaskFuncMode.DYNAMIC,
this expects the shape to have more then 3 dimensions, and the mask will be created for each time frame
along the fourth last dimension. Similarly for MaskFuncMode.MULTISLICE, the mask will be created for each
slice along the fourth last dimension. Default: MaskFuncMode.STATIC.
EquispacedMaskFunc creates a sub-sampling mask of given shape. The mask selects a subset of columns
from the input k-space data. If the k-space data has N columns, the mask picks out:
\(N_{\text{low freqs}} = (N \times \text{center_fraction})\) columns in the center corresponding
to low-frequencies if center_fraction < 1.0, or \(N_{\text{low freqs}} = \text{center_fraction}\)
if center_fraction >= 1 and is integer.
The other columns are selected with equal spacing at a proportion that reaches the desired acceleration
rate taking into consideration the number of low frequencies. This ensures that the expected number of
columns selected is equal to \(\frac{N}{\text{acceleration}}\).
It is possible to use multiple center_fractions and accelerations, in which case one possible
(center_fraction, acceleration) is chosen uniformly at random each time the EquispacedMaskFunc object is called.
Note that this function may not give equispaced samples (documented in
facebookresearch/fastMRI#54), which will require modifications to standard GRAPPA
approaches. Nonetheless, this aspect of the function has been preserved to match the public multicoil data.
Parameters:
accelerations (Union[list[Union[float, int]], tuple[Union[float, int], ...]]) – Amount of under-sampling_mask. An acceleration of 4 retains 25% of the k-space, the method is given by
mask_type. Has to be the same length as center_fractions if uniform_range is not True.
center_fractions (Union[list[Union[float, int]], tuple[Union[float, int], ...]]) – Fraction of low-frequency columns (float < 1.0) or number of low-frequence columns (integer) to be retained.
If multiple values are provided, then one of these numbers is chosen uniformly each time. If uniform_range
is True, then two values should be given. Default: None.
uniform_range (bool) – If True then an acceleration will be uniformly sampled between the two values. Default: False.
mode (MaskFuncMode) – Mode of the mask function. Can be MaskFuncMode.STATIC, MaskFuncMode.DYNAMIC, or MaskFuncMode.MULTISLICE.
MaskFuncMode.STATIC (If)
shape (then a single mask is created independent of the requested)
be (and will)
1 (broadcasted to the shape by expanding other dimensions with)
MaskFuncMode.DYNAMIC (if applicable. If)
:param :
:param this expects the shape to have more then 3 dimensions:
:param and the mask will be created for each time frame:
:param along the fourth last dimension. Similarly for MaskFuncMode.MULTISLICE:
:param the mask will be created for each:
:param slice along the fourth last dimension. Default: MaskFuncMode.STATIC.
accelerations (Union[list[Union[float, int]], tuple[Union[float, int], ...]]) – Amount of under-sampling_mask. An acceleration of 4 retains 25% of the k-space, the method is given by
mask_type. Has to be the same length as center_fractions if uniform_range is not True.
center_fractions (Union[list[Union[float, int]], tuple[Union[float, int], ...]]) – If multiple values are provided, then one of these numbers is chosen uniformly each time. If uniform_range
is True, then two values should be given. Default: None.
uniform_range (bool) – If True then an acceleration will be uniformly sampled between the two values. Default: False.
mode (MaskFuncMode) – Mode of the mask function. Can be MaskFuncMode.STATIC, MaskFuncMode.DYNAMIC, or MaskFuncMode.MULTISLICE.
If MaskFuncMode.STATIC, then a single mask is created independent of the requested shape, and will be
broadcasted to the shape by expanding other dimensions with 1, if applicable. If MaskFuncMode.DYNAMIC,
this expects the shape to have more then 3 dimensions, and the mask will be created for each time frame
along the fourth last dimension. Similarly for MaskFuncMode.MULTISLICE, the mask will be created for each
slice along the fourth last dimension. Default: MaskFuncMode.STATIC.
FastMRIEquispacedMaskFunc creates a sub-sampling mask of given shape. The mask selects a subset of columns
from the input k-space data. If the k-space data has N columns, the mask picks out:
\(N_{\text{low freqs}} = (N \times \text{center_fraction})\) columns in the center corresponding
to low-frequencies.
The other columns are selected with equal spacing at a proportion that reaches the desired acceleration
rate taking into consideration the number of low frequencies. This ensures that the expected number of
columns selected is equal to \(\frac{N}{\text{acceleration}}\).
It is possible to use multiple center_fractions and accelerations, in which case one possible
(center_fraction, acceleration) is chosen uniformly at random each time the EquispacedMaskFunc object is called.
Note that this function may not give equispaced samples (documented in
facebookresearch/fastMRI#54), which will require modifications to standard GRAPPA
approaches. Nonetheless, this aspect of the function has been preserved to match the public multicoil data.
Args:
accelerations: Amount of under-sampling.
center_fractions: Fraction (< 1.0) of low-frequency columns to be retained.
uniform_range: If True then an acceleration will be uniformly sampled between the two values, by default False.
mode: Mode of the mask function. Can be MaskFuncMode.STATIC, MaskFuncMode.DYNAMIC, or MaskFuncMode.MULTISLICE.
If MaskFuncMode.STATIC, then a single mask is created independent of the requested shape, and will be
broadcasted to the shape by expanding other dimensions with 1, if applicable. If MaskFuncMode.DYNAMIC,
this expects the shape to have more then 3 dimensions, and the mask will be created for each time frame
along the fourth last dimension. Similarly for MaskFuncMode.MULTISLICE, the mask will be created for each
slice along the fourth last dimension. Default: MaskFuncMode.STATIC.
accelerations (Union[list[Union[float, int]], tuple[Union[float, int], ...]]) – Amount of under-sampling.
center_fractions (Union[list[float], tuple[float, ...]]) – Fraction (< 1.0) of low-frequency columns to be retained.
uniform_range (bool) – If True then an acceleration will be uniformly sampled between the two values, by default False.
mode (MaskFuncMode) – Mode of the mask function. Can be MaskFuncMode.STATIC, MaskFuncMode.DYNAMIC, or MaskFuncMode.MULTISLICE.
MaskFuncMode.STATIC (If)
shape (then a single mask is created independent of the requested)
be (and will)
1 (broadcasted to the shape by expanding other dimensions with)
MaskFuncMode.DYNAMIC (if applicable. If)
:param :
:param this expects the shape to have more then 3 dimensions:
:param and the mask will be created for each time frame:
:param along the fourth last dimension. Similarly for MaskFuncMode.MULTISLICE:
:param the mask will be created for each:
:param slice along the fourth last dimension. Default: MaskFuncMode.STATIC.
Vertical line mask function as implemented in [1]_.
FastMRIMagicMaskFunc exploits the conjugate symmetry via offset-sampling. It is essentially an
equispaced mask with an offset for the opposite site of the k-space. Since MRI images often exhibit approximate
conjugate k-space symmetry, this mask is generally more efficient than FastMRIEquispacedMaskFunc.
References
Parameters:
accelerations (Union[list[Union[float, int]], tuple[Union[float, int], ...]]) – Amount of under-sampling_mask. An acceleration of 4 retains 25% of the k-space, the method is given by
mask_type. Has to be the same length as center_fractions if uniform_range is not True.
center_fractions (Union[list[float], tuple[float, ...]]) – Fraction (< 1.0) of low-frequency columns to be retained.
uniform_range (bool) – If True then an acceleration will be uniformly sampled between the two values. Default: False.
mode (MaskFuncMode) – Mode of the mask function. Can be MaskFuncMode.STATIC, MaskFuncMode.DYNAMIC, or MaskFuncMode.MULTISLICE.
If MaskFuncMode.STATIC, then a single mask is created independent of the requested shape, and will be
broadcasted to the shape by expanding other dimensions with 1, if applicable. If MaskFuncMode.DYNAMIC,
this expects the shape to have more then 3 dimensions, and the mask will be created for each time frame
along the fourth last dimension. Similarly for MaskFuncMode.MULTISLICE, the mask will be created for each
slice along the fourth last dimension. Default: MaskFuncMode.STATIC.
accelerations (Union[list[Union[float, int]], tuple[Union[float, int], ...]]) – Amount of under-sampling_mask. An acceleration of 4 retains 25% of the k-space, the method is given by
True. (mask_type. Has to be the same length as center_fractions if uniform_range is not)
center_fractions (Union[list[float], tuple[float, ...]]) – Fraction (< 1.0) of low-frequency columns to be retained.
uniform_range (bool) – If True then an acceleration will be uniformly sampled between the two values. Default: False.
shape (then a single mask is created independent of the requested)
be (and will)
1 (broadcasted to the shape by expanding other dimensions with)
MaskFuncMode.DYNAMIC
:param :
:param this expects the shape to have more then 3 dimensions:
:param and the mask will be created for each time frame:
:param along the fourth last dimension. Similarly for MaskFuncMode.MULTISLICE:
:param the mask will be created for each:
:param slice along the fourth last dimension. Default: MaskFuncMode.STATIC.
The mask selects a subset of columns from the input k-space data. If the k-space data has \(N\) columns,
the mask picks out:
\(N_{\text{low freqs}} = (N \times \text{center_fraction})\) columns in the center corresponding
to low-frequencies.
The other columns are selected uniformly at random with a probability equal to:
\(\text{prob} = (N / \text{acceleration} - N_{\text{low freqs}}) / (N - N_{\text{low freqs}})\).
This ensures that the expected number of columns selected is equal to (N / acceleration).
It is possible to use multiple center_fractions and accelerations, in which case one possible
(center_fraction, acceleration) is chosen uniformly at random each time the MaskFunc object is
called.
For example, if accelerations = [4, 8] and center_fractions = [0.08, 0.04], then there
is a 50% probability that 4-fold acceleration with 8% center fraction is selected and a 50%
probability that 8-fold acceleration with 4% center fraction is selected.
Parameters:
accelerations (Union[list[Union[float, int]], tuple[Union[float, int], ...]]) – Amount of under-sampling_mask. An acceleration of 4 retains 25% of the k-space, the method is given by
mask_type. Has to be the same length as center_fractions if uniform_range is not True.
center_fractions (Union[list[float], tuple[float, ...]]) – Fraction of low-frequency columns (float < 1.0) to be retained.
uniform_range (bool) – If True then an acceleration will be uniformly sampled between the two values. Default: False.
mode (MaskFuncMode) – Mode of the mask function. Can be MaskFuncMode.STATIC, MaskFuncMode.DYNAMIC, or MaskFuncMode.MULTISLICE.
If MaskFuncMode.STATIC, then a single mask is created independent of the requested shape, and will be
broadcasted to the shape by expanding other dimensions with 1, if applicable. If MaskFuncMode.DYNAMIC,
this expects the shape to have more then 3 dimensions, and the mask will be created for each time frame
along the fourth last dimension. Similarly for MaskFuncMode.MULTISLICE, the mask will be created for each
slice along the fourth last dimension. Default: MaskFuncMode.STATIC.
accelerations (Union[list[Union[float, int]], tuple[Union[float, int], ...]]) – Amount of under-sampling_mask. An acceleration of 4 retains 25% of the k-space, the method is given by
mask_type. Has to be the same length as center_fractions if uniform_range is not True.
center_fractions (Union[list[float], tuple[float, ...]]) – Fraction of low-frequency columns (float < 1.0) to be retained.
uniform_range (bool) – If True then an acceleration will be uniformly sampled between the two values. Default: False.
mode (MaskFuncMode) – Mode of the mask function. Can be MaskFuncMode.STATIC, MaskFuncMode.DYNAMIC, or MaskFuncMode.MULTISLICE.
If MaskFuncMode.STATIC, then a single mask is created independent of the requested shape, and will be
broadcasted to the shape by expanding other dimensions with 1, if applicable. If MaskFuncMode.DYNAMIC,
this expects the shape to have more then 3 dimensions, and the mask will be created for each time frame
along the fourth last dimension. Similarly for MaskFuncMode.MULTISLICE, the mask will be created for each
slice along the fourth last dimension. Default: MaskFuncMode.STATIC.
shape (then a single mask is created independent of the requested)
be (and will)
1 (broadcasted to the shape by expanding other dimensions with)
MaskFuncMode.DYNAMIC
:param :
:param this expects the shape to have more then 3 dimensions:
:param and the mask will be created for each time frame:
:param along the fourth last dimension. Similarly for MaskFuncMode.MULTISLICE:
:param the mask will be created for each:
:param slice along the fourth last dimension. Default: MaskFuncMode.STATIC.
accelerations (Union[list[Union[float, int]], tuple[Union[float, int], ...]]) – Amount of under-sampling.
center_fractions (Union[list[float], tuple[float, ...]]) – Fraction of low-frequency columns (float < 1.0) to be retained.
uniform_range (bool) – If True then an acceleration will be uniformly sampled between the two values, by default False.
mode (MaskFuncMode) – Mode of the mask function. Can be MaskFuncMode.STATIC, MaskFuncMode.DYNAMIC, or MaskFuncMode.MULTISLICE.
MaskFuncMode.STATIC (If)
shape (then a single mask is created independent of the requested)
be (and will)
1 (broadcasted to the shape by expanding other dimensions with)
MaskFuncMode.DYNAMIC (if applicable. If)
:param :
:param this expects the shape to have more then 3 dimensions:
:param and the mask will be created for each time frame:
:param along the fourth last dimension. Similarly for MaskFuncMode.MULTISLICE:
:param the mask will be created for each:
:param slice along the fourth last dimension. Default: MaskFuncMode.STATIC.
shape (then a single mask is created independent of the requested)
be (and will)
1 (broadcasted to the shape by expanding other dimensions with)
MaskFuncMode.DYNAMIC
:param :
:param this expects the shape to have more then 3 dimensions:
:param and the mask will be created for each time frame:
:param along the fourth last dimension. Similarly for MaskFuncMode.MULTISLICE:
:param the mask will be created for each:
:param slice along the fourth last dimension. Default: MaskFuncMode.STATIC.
shape (then a single mask is created independent of the requested)
be (and will)
1 (broadcasted to the shape by expanding other dimensions with)
MaskFuncMode.DYNAMIC
:param :
:param this expects the shape to have more then 3 dimensions:
:param and the mask will be created for each time frame:
:param along the fourth last dimension. Similarly for MaskFuncMode.MULTISLICE:
:param the mask will be created for each:
:param slice along the fourth last dimension. Default: MaskFuncMode.STATIC.
accelerations (Union[list[Union[float, int]], tuple[Union[float, int], ...]]) – Amount of under-sampling.
center_fractions (Union[list[float], tuple[float, ...]]) – Fraction of low-frequency columns (float < 1.0) or number of low-frequence columns (integer) to be retained.
uniform_range (bool) – If True then an acceleration will be uniformly sampled between the two values, by default False.
accelerations (Union[list[Union[float, int]], tuple[Union[float, int], ...]]) – Amount of under-sampling.
center_fractions (Union[list[float], tuple[float, ...]]) – Fraction of low-frequency columns (float < 1.0) or number of low-frequence columns (integer) to be retained.
uniform_range (bool) – If True then an acceleration will be uniformly sampled between the two values, by default False.
accelerations (Union[list[Union[float, int]], tuple[Union[float, int], ...]]) – Amount of under-sampling.
center_fractions (Union[list[float], tuple[float, ...]]) – Fraction of low-frequency columns (float < 1.0) or number of low-frequence columns (integer) to be retained.
uniform_range (bool) – If True then an acceleration will be uniformly sampled between the two values, by default False.
uniform_range: If True then an acceleration will be uniformly sampled between the two values, by default False.
alpha: 0 < alpha < 1 controls sampling density; 0: uniform density, 1: maximally non-uniform density.
Default: 0.28.
std_scale: The standard deviation scaling of the Gaussian envelope for sampling density. Default: 5.0.
accelerations (Union[list[Union[float, int]], tuple[Union[float, int], ...]]) – Amount of under-sampling.
center_fractions (Union[list[float], tuple[float, ...]]) – Fraction of low-frequency columns (float < 1.0) or number of low-frequence columns (integer) to be retained.
uniform_range (bool) – If True then an acceleration will be uniformly sampled between the two values, by default False.
crop_corner (bool) – If True, the mask is cropped to the corners. Default: False.
uniform_range: If True then an acceleration will be uniformly sampled between the two values, by default False.
crop_corner: If True, the mask is cropped to the corners. Default: False.
accelerations (Union[list[Union[float, int]], tuple[Union[float, int], ...]]) – Amount of under-sampling.
center_fractions (Union[list[float], tuple[float, ...]]) – Fraction of low-frequency columns (float < 1.0) or number of low-frequence columns (integer) to be retained.
uniform_range (bool) – If True then an acceleration will be uniformly sampled between the two values, by default False.
accelerations (Union[list[Union[float, int]], tuple[Union[float, int], ...]]) – Amount of under-sampling.
center_fractions (Union[list[float], tuple[float, ...]]) – Fraction of low-frequency columns (float < 1.0) or number of low-frequence columns (integer) to be retained.
columns (Fraction of low-frequency)
uniform_range (bool) – If True then an acceleration will be uniformly sampled between the two values, by default False.
Vertical line mask function as implemented in [1]_.
MagicMaskFunc exploits the conjugate symmetry via offset-sampling. It is essentially an
equispaced mask with an offset for the opposite site of the k-space. Since MRI images often exhibit approximate
conjugate k-space symmetry, this mask is generally more efficient than EquispacedMaskFunc.
References
Parameters:
accelerations (Union[list[Union[float, int]], tuple[Union[float, int], ...]]) – Amount of under-sampling_mask. An acceleration of 4 retains 25% of the k-space, the method is given by
mask_type. Has to be the same length as center_fractions if uniform_range is not True.
center_fractions (Union[list[Union[float, int]], tuple[Union[float, int], ...]]) – If < 1.0 this corresponds to the fraction of low-frequency columns to be retained.
If >= 1 (integer) this corresponds to the exact number of low-frequency columns to be retained.
uniform_range (bool) – If True then an acceleration will be uniformly sampled between the two values. Default: False.
mode (MaskFuncMode) – Mode of the mask function. Can be MaskFuncMode.STATIC, MaskFuncMode.DYNAMIC, or MaskFuncMode.MULTISLICE.
If MaskFuncMode.STATIC, then a single mask is created independent of the requested shape, and will be
broadcasted to the shape by expanding other dimensions with 1, if applicable. If MaskFuncMode.DYNAMIC,
this expects the shape to have more then 3 dimensions, and the mask will be created for each time frame
along the fourth last dimension. Similarly for MaskFuncMode.MULTISLICE, the mask will be created for each
slice along the fourth last dimension. Default: MaskFuncMode.STATIC.
accelerations (Union[list[Union[float, int]], tuple[Union[float, int], ...]]) – Amount of under-sampling_mask. An acceleration of 4 retains 25% of the k-space, the method is given by
True. (mask_type. Has to be the same length as center_fractions if uniform_range is not)
center_fractions (Union[list[Union[float, int]], tuple[Union[float, int], ...]]) – If < 1.0 this corresponds to the fraction of low-frequency columns to be retained.
retained. (If >= 1.0 this corresponds to the exact number of low-frequency columns to be)
uniform_range (bool) – If True then an acceleration will be uniformly sampled between the two values. Default: False.
mode (MaskFuncMode) – Mode of the mask function. Can be MaskFuncMode.STATIC, MaskFuncMode.DYNAMIC, or MaskFuncMode.MULTISLICE.
MaskFuncMode.STATIC (If)
shape (then a single mask is created independent of the requested)
be (and will)
1 (broadcasted to the shape by expanding other dimensions with)
MaskFuncMode.DYNAMIC (if applicable. If)
:param :
:param this expects the shape to have more then 3 dimensions:
:param and the mask will be created for each time frame:
:param along the fourth last dimension. Similarly for MaskFuncMode.MULTISLICE:
:param the mask will be created for each:
:param slice along the fourth last dimension. Default: MaskFuncMode.STATIC.
accelerations (Union[list[Union[float, int]], tuple[Union[float, int], ...]]) – Amount of under-sampling.
center_fractions (Union[list[float], tuple[float, ...], None]) – Fraction (< 1.0) of low-frequency samples to be retained. If None, it will calculate the acs mask
mask (based on the maximum masked disk in the generated) – None.
uniform_range (bool) – If True then an acceleration will be uniformly sampled between the two values. Default: False.
shape (then a single mask is created independent of the requested)
be (and will)
1 (broadcasted to the shape by expanding other dimensions with)
MaskFuncMode.DYNAMIC
:param :
:param this expects the shape to have more then 3 dimensions:
:param and the mask will be created for each time frame:
:param along the fourth last dimension. Similarly for MaskFuncMode.MULTISLICE:
:param the mask will be created for each:
:param slice along the fourth last dimension. Default: MaskFuncMode.STATIC.
accelerations (Union[list[Union[float, int]], tuple[Union[float, int], ...]]) – Amount of under-sampling.
center_fractions (Union[list[float], tuple[float, ...], None]) – Fraction (< 1.0) of low-frequency samples to be retained. If None, it will calculate the acs mask
mask (based on the maximum masked disk in the generated) – None.
uniform_range (bool) – If True then an acceleration will be uniformly sampled between the two values. Default: False.
shape (then a single mask is created independent of the requested)
be (and will)
1 (broadcasted to the shape by expanding other dimensions with)
MaskFuncMode.DYNAMIC
:param :
:param this expects the shape to have more then 3 dimensions:
:param and the mask will be created for each time frame:
:param along the fourth last dimension. Similarly for MaskFuncMode.MULTISLICE:
:param the mask will be created for each:
:param slice along the fourth last dimension. Default: MaskFuncMode.STATIC.
The mask selects a subset of columns from the input k-space data. If the k-space data has \(N\) columns,
the mask picks out:
\(N_{\text{low freqs}} = (N \times \text{center_fraction})\) columns in the center corresponding
to low-frequencies if center_fraction < 1.0, or \(N_{\text{low freqs}} = \text{center_fraction}\)
if center_fraction >= 1 and is integer.
The other columns are selected uniformly at random with a probability equal to:
\(\text{prob} = (N / \text{acceleration} - N_{\text{low freqs}}) / (N - N_{\text{low freqs}})\).
This ensures that the expected number of columns selected is equal to (N / acceleration).
It is possible to use multiple center_fractions and accelerations, in which case one possible
(center_fraction, acceleration) is chosen uniformly at random each time the MaskFunc object is
called.
For example, if accelerations = [4, 8] and center_fractions = [0.08, 0.04], then there
is a 50% probability that 4-fold acceleration with 8% center fraction is selected and a 50%
probability that 8-fold acceleration with 4% center fraction is selected.
Parameters:
accelerations (Union[list[Union[float, int]], tuple[Union[float, int], ...]]) – Amount of under-sampling_mask. An acceleration of 4 retains 25% of the k-space, the method is given by
mask_type. Has to be the same length as center_fractions if uniform_range is not True.
center_fractions (Union[list[Union[float, int]], tuple[Union[float, int], ...]]) – Fraction of low-frequency columns (float < 1.0) or number of low-frequence columns (integer) to be retained.
provided (If multiple values are)
uniform_range (bool)
True (is) – None.
Default (then two values should be given.) – None.
uniform_range – If True then an acceleration will be uniformly sampled between the two values. Default: False.
mode (MaskFuncMode) – Mode of the mask function. Can be MaskFuncMode.STATIC, MaskFuncMode.DYNAMIC, or MaskFuncMode.MULTISLICE.
If MaskFuncMode.STATIC, then a single mask is created independent of the requested shape, and will be
broadcasted to the shape by expanding other dimensions with 1, if applicable. If MaskFuncMode.DYNAMIC,
this expects the shape to have more then 3 dimensions, and the mask will be created for each time frame
along the fourth last dimension. Similarly for MaskFuncMode.MULTISLICE, the mask will be created for each
slice along the fourth last dimension. Default: MaskFuncMode.STATIC.
accelerations (Union[list[Union[float, int]], tuple[Union[float, int], ...]]) – Amount of under-sampling_mask. An acceleration of 4 retains 25% of the k-space, the method is given by
mask_type. Has to be the same length as center_fractions if uniform_range is not True.
center_fractions (Union[list[Union[float, int]], tuple[Union[float, int], ...]]) – Fraction of low-frequency columns (float < 1.0) or number of low-frequence columns (integer) to be retained.
If multiple values are provided, then one of these numbers is chosen uniformly each time. If uniform_range
is True, then two values should be given. Default: None.
uniform_range (bool) – If True then an acceleration will be uniformly sampled between the two values. Default: False.
mode (MaskFuncMode) – Mode of the mask function. Can be MaskFuncMode.STATIC, MaskFuncMode.DYNAMIC, or MaskFuncMode.MULTISLICE.
If MaskFuncMode.STATIC, then a single mask is created independent of the requested shape, and will be
broadcasted to the shape by expanding other dimensions with 1, if applicable. If MaskFuncMode.DYNAMIC,
this expects the shape to have more then 3 dimensions, and the mask will be created for each time frame
along the fourth last dimension. Similarly for MaskFuncMode.MULTISLICE, the mask will be created for each
slice along the fourth last dimension. Default: MaskFuncMode.STATIC.
shape (Union[list[int], tuple[int, ...]]) – Shape of the mask to be created. The shape should at least 3 dimensions.
return_acs (bool) – Return the autocalibration signal region as a mask.
seed (Union[int, Iterable[int], None]) – Seed for the random number generator. Setting the seed ensures the same mask is generated
each time for the same shape. Default: None.
accelerations (Union[list[Union[float, int]], tuple[Union[float, int], ...]]) – Amount of under-sampling.
center_fractions (Union[list[float], tuple[float, ...], None]) – Fraction (< 1.0) of low-frequency samples to be retained. If None, it will calculate the acs mask
mask (based on the maximum masked disk in the generated) – None.
uniform_range (bool) – If True then an acceleration will be uniformly sampled between the two values. Default: False.
shape (then a single mask is created independent of the requested)
be (and will)
1 (broadcasted to the shape by expanding other dimensions with)
MaskFuncMode.DYNAMIC
:param :
:param this expects the shape to have more then 3 dimensions:
:param and the mask will be created for each time frame:
:param along the fourth last dimension. Similarly for MaskFuncMode.MULTISLICE:
:param the mask will be created for each:
:param slice along the fourth last dimension. Default: MaskFuncMode.STATIC.
accelerations (Union[list[Union[float, int]], tuple[Union[float, int], ...]]) – Amount of under-sampling.
center_fractions (Union[list[float], tuple[float, ...], None]) – Fraction (< 1.0) of low-frequency samples to be retained. If None, it will calculate the acs mask
mask (based on the maximum masked disk in the generated) – None.
uniform_range (bool) – If True then an acceleration will be uniformly sampled between the two values. Default: False.
shape (then a single mask is created independent of the requested)
be (and will)
1 (broadcasted to the shape by expanding other dimensions with)
MaskFuncMode.DYNAMIC
:param :
:param this expects the shape to have more then 3 dimensions:
:param and the mask will be created for each time frame:
:param along the fourth last dimension. Similarly for MaskFuncMode.MULTISLICE:
:param the mask will be created for each:
:param slice along the fourth last dimension. Default: MaskFuncMode.STATIC.
Variable Density Poisson sampling mask function. Based on [1]_.
Parameters:
accelerations (Union[list[Union[float, int]], tuple[Union[float, int], ...]]) – Amount of under-sampling.
center_fractions (Union[list[float], tuple[float, ...]]) – Must have the same length as accelerations. Amount of center fully-sampling.
center_scale='r' (For)
to (then a centered disk area with radius equal)
:param : math:R = sqrt{{n_r}^2 + {n_c}^2} \times r will be fully sampled, where \(n_r\) and \(n_c\)
:param denote the input shape.:
:type mode: MaskFuncMode
:param mode: Mode of the mask function. Can be MaskFuncMode.STATIC, MaskFuncMode.DYNAMIC, or MaskFuncMode.MULTISLICE.
:param If MaskFuncMode.STATIC:
:param then a single mask is created independent of the requested shape:
:param and will be:
:param broadcasted to the shape by expanding other dimensions with 1:
:param if applicable. If MaskFuncMode.DYNAMIC:
:param :
:param this expects the shape to have more then 3 dimensions:
:param and the mask will be created for each time frame:
:param along the fourth last dimension. Similarly for MaskFuncMode.MULTISLICE:
:param the mask will be created for each:
:param slice along the fourth last dimension. Default: MaskFuncMode.STATIC.
:type crop_corner: Optional[bool]
:param crop_corner: If True mask will be disk. Default: False.
:type max_attempts: Optional[int]
:param max_attempts: Maximum rejection samples. Default: 10.
:type tol: Optional[float]
:param tol: Maximum deviation between the generated mask acceleration and the desired acceleration. Default: 0.2.
:type slopes: Union[list[float], tuple[float, ...], None]
:param slopes: An increasing sequence of non-negative floats (of length 2) to be used
:param for the generation of the sampling radius. Default: None.
Note:
Code inspired and modified from [2] with BSD-3 licence, Copyright (c) 2016, Frank Ong, Copyright (c) 2016,
accelerations (Union[list[Union[float, int]], tuple[Union[float, int], ...]]) – Amount of under-sampling.
center_fractions (Union[list[float], tuple[float, ...]]) – Must have the same length as accelerations. Amount of center fully-sampling.
center_scale='r' (For)
to (then a centered disk area with radius equal)
:param : math:R = sqrt{{n_r}^2 + {n_c}^2} times r will be fully sampled, where \(n_r\) and \(n_c\)
:param denote the input shape.:
:type mode: MaskFuncMode
:param mode: Mode of the mask function. Can be MaskFuncMode.STATIC, MaskFuncMode.DYNAMIC, or MaskFuncMode.MULTISLICE.
:param If MaskFuncMode.STATIC:
:param then a single mask is created independent of the requested shape:
:param and will be:
:param broadcasted to the shape by expanding other dimensions with 1:
:param if applicable. If MaskFuncMode.DYNAMIC:
:param :
:param this expects the shape to have more then 3 dimensions:
:param and the mask will be created for each time frame:
:param along the fourth last dimension. Similarly for MaskFuncMode.MULTISLICE:
:param the mask will be created for each:
:param slice along the fourth last dimension. Default: MaskFuncMode.STATIC.
:type crop_corner: Optional[bool]
:param crop_corner: If True mask will be disk. Default: False.
:type max_attempts: Optional[int]
:param max_attempts: Maximum rejection samples. Default: 10.
:type tol: Optional[float]
:param tol: Maximum deviation between the generated mask acceleration and the desired acceleration. Default: 0.2.
:type slopes: Union[list[float], tuple[float, ...], None]
:param slopes: An increasing sequence of non-negative floats (of length 2) to be used
:param for the generation of the sampling radius. Default: None.
accelerations (Union[list[Union[float, int]], tuple[Union[float, int], ...]]) – Amount of under-sampling.
center_fractions (Union[list[Union[float, int]], tuple[Union[float, int], ...], None]) – Fraction of low-frequency columns (float < 1.0) or number of low-frequence columns (integer) to be retained.
provided (If multiple values are)
uniform_range (bool)
True (is) – None.
Default (then two values should be given.) – None.
uniform_range – If True then an acceleration will be uniformly sampled between the two values. Default: False.
mode (MaskFuncMode) – Mode of the mask function. Can be MaskFuncMode.STATIC, MaskFuncMode.DYNAMIC, or MaskFuncMode.MULTISLICE.
MaskFuncMode.STATIC (If)
shape (then a single mask is created independent of the requested)
be (and will)
1 (broadcasted to the shape by expanding other dimensions with)
MaskFuncMode.DYNAMIC (if applicable. If)
:param :
:param this expects the shape to have more then 3 dimensions:
:param and the mask will be created for each time frame:
:param along the fourth last dimension. Similarly for MaskFuncMode.MULTISLICE:
:param the mask will be created for each:
:param slice along the fourth last dimension. Default: MaskFuncMode.STATIC.
:type **kwargs: dict[str, Any]
:param **kwargs: Additional keyword arguments to be passed to the mask function. These will be passed as keyword arguments
:param to the mask function constructor. If the mask function constructor does not accept these arguments:
:param they will:
:param be ignored.:
If input is integer, will return the input. If input is None, will return a random integer seed.
If input is a tuple or list, will return a random integer seed based on the input.
Can be useful for functions that take as input only integer seeds (e.g. cython functions).
Parameters:
seed (Union[None, tuple[int, ...], list[int]]) – Input seed to integerize.