snake.core.phantom.static
#
Module to create phantom for simulation.
Module Contents#
Classes#
A Phantom consist of all spatial maps that are used in the simulation. |
Data#
API#
- snake.core.phantom.static.SNAKE_CACHE_DIR = 'join(...)'#
- class snake.core.phantom.static.Phantom[source]#
A Phantom consist of all spatial maps that are used in the simulation.
It is a dataclass that contains the tissue masks, properties, labels, and spatial maps of the phantom.
The tissue masks are a 3D array with the shape (n_tissues, x, y, z), where n_tissues is the number of tissues.
The properties are a 2D array with the shape (n_tissues, n_properties), where n_properties is the number of properties.
The labels are a 1D array with the shape (n_tissues,) containing the names of the tissues.
The sensitivity maps are a 4D array with the shape (n_coils, x, y, z), where n_coils is the number of coils.
The affine matrix is a 2D array with the shape (4, 4) containing the affine transformation matrix.
- masks: numpy.typing.NDArray[numpy.float32] = None#
- labels: numpy.typing.NDArray[numpy.string_] = None#
- props: numpy.typing.NDArray[numpy.float32] = None#
- affine: numpy.typing.NDArray[numpy.float32] = 'field(...)'#
- add_tissue(tissue_name: str, mask: numpy.typing.NDArray[numpy.float32], props: numpy.typing.NDArray[numpy.float32], phantom_name: str | None = None) snake.core.phantom.static.Phantom [source]#
Add a tissue to the phantom. Creates a new Phantom object.
- make_smaps(n_coils: int = None, sim_conf: snake.core.simulation.SimConfig = None, antenna: str = 'birdcage') None [source]#
Get coil sensitivity maps for the phantom.
- classmethod from_brainweb(sub_id: int, sim_conf: snake.core.simulation.SimConfig, tissue_file: str | snake.core.phantom.utils.TissueFile = TissueFile.tissue_1T5, tissue_select: list[str] | None = None, tissue_ignore: list[str] | None = None, output_res: float | snake._meta.ThreeFloats = 0.5, cache_dir: str | None = None) snake.core.phantom.static.Phantom [source]#
Get the Brainweb Phantom.
- classmethod from_mrd_dataset(dataset: snake.mrd_utils.loader.MRDLoader | os.PathLike, imnum: int = 0) snake.core.phantom.static.Phantom [source]#
Load the phantom from a mrd dataset.
- to_mrd_dataset(dataset: ismrmrd.Dataset | _typeshed.GenericPath) ismrmrd.Dataset [source]#
Add the phantom as an image to the dataset.
Give access the tissue masks and properties in shared memory.
Add a copy of the phantom in shared memory.
- masks2nifti() nibabel.nifti1.Nifti1Image [source]#
Return the masks of the phantom as a Nifti object.
- to_nifti(filename: str | _typeshed.GenericPath = None) tuple[_typeshed.GenericPath, _typeshed.GenericPath | None] [source]#
Save the phantom as a pair of niftis file.
- classmethod from_nifti(mask_nifti: nibabel.nifti1.Nifti1Image | _typeshed.GenericPath, props: numpy.typing.NDArray[numpy.float32] = None, labels: numpy.typing.NDArray[numpy.string_] = None, smaps: nibabel.nifti1.Nifti1Image | _typeshed.GenericPath | None = None) snake.core.phantom.static.Phantom [source]#
Create a phantom from nifti files.
- contrast(*, TR: float | None = None, TE: float | None = None, FA: float | None = None, sequence: Literal[GRE] = 'GRE', sim_conf: snake.core.simulation.SimConfig | None = None, resample: bool = True, aggregate: bool = True, use_gpu: bool = True) numpy.typing.NDArray[numpy.float32] [source]#
Compute the contrast of the phantom for a given sequence.
- Parameters:
TR (float)
TE (float)
FA (float)
sim_conf (SimConfig) β Other way to provide sequence parameters
aggregate (bool, optional default=True) β Sum all the tissues contrast for getting a single image.
sequence="GRE" β Default value, no other value is currently supported.
Results
-------
NDArray β The contrast of the tissues.
- resample(new_affine: numpy.typing.NDArray, new_shape: snake._meta.ThreeInts, use_gpu: bool = False, **kwargs: Any) snake.core.phantom.static.Phantom [source]#
Resample the phantom to a new shape and affine matrix.
- Parameters:
new_affine (NDArray) β The new affine matrix.
new_shape (ThreeInts) β The new shape of the phantom.
use_gpu (bool, optional) β Use the GPU for the resampling, by default False.
- __deepcopy__(memo: Any) snake.core.phantom.static.Phantom [source]#
Create a copy of the phantom.
- copy() snake.core.phantom.static.Phantom [source]#
Return deep copy of the Phantom.