NIfTI Phantoms
The classes shown here reflect the content of the .json config file structure.
These files define how various NIfTIs are combined into a phantom.
You can load a complete phantom directly with mr0.TissueDict.load.
But you can also load only the configuration with mr0.NiftiPhantom.load.
This allows you to modify it as needed before loading the phantom or saving the changes.
All classes are dataclasses, augmented with additional functions.
PhantomUnits
Stores the physical units used by the phantom. These are currently fixed to the values used by MR-zero (default values) and are stored for documentation (no conversion is implemented). However, different units and automatic conversion might be implemented in the future.
PhantomUnits(gyro, B0, T1, T2, T2dash, ADC, dB0, B1_tx, B1_rx)
| Parameter | Description | Default unit |
|---|---|---|
gyro | Gyromagnetic ratio | MHz/T |
B0 | Strength of the main magnetic field | T |
T1 | Exponential T1 relaxation | s |
T2 | Exponential T2 relaxation | s |
T2dash | Exponential T2 dephasing | s |
ADC | Apparent Diffusion Coefficient | 10^-3 mm^2/s |
dB0 | Offresonance through B0 fluctuations | Hz |
B1_tx | Fluctuations in B1+ (transmit) field | rel |
B1_rx | Fluctuations in B1- (receive) field | rel |
PhantomUnits.default(): returnPhantomUnitswith the default units given abovePhantomUnits.from_dict(config): load from a dictionary and check if units are validPhantomUnits.to_dict(): convert to a dictionary
PhantomSystem
Describes the physical properties of the MRI experiment.
PhantomSystem(gyro, B0)
| Parameter | Description | Default |
|---|---|---|
gyro | Gyromagnetic ratio, given in units of PhantomUnits.gyro | 42.5764 |
B0 | Strength of the main magnetic field, given in units of PhantomUnits.B0 | 3.0 |
PhantomSystem.from_dict(config): load from a dictionaryPhantomSystem.to_dict(): convert to a dictionary
NiftiRef
Reference to a NIfTI file, including the index to the tissue. NIfTIs can contain multiple 3D volumes, stacked in the 4th dimension. For a description look at the specification.
NiftiRef(file_name, tissue_index)
| Parameter | Description |
|---|---|
file_name | Path to the .nii(.gz) file |
tissue_index | Index along the 4th dimension of the specified NIfTI file |
As given by the spec, NiftiRefs are stored as "path/to/nifti.nii.gz[<index>]" strings:
NiftiRef.parse(config): parse from a stringNiftiRef.to_str(): convert to a string
NiftiMapping
Combination of NiftiRef and a mapping function for simple modifications.
For a description look at the specification.
NiftiMapping(file, func)
NiftiMapping.parse(config): parse from a dictionary (callingNiftiRef.parse)NiftiMapping.to_dict(): convert to a dictionary
NiftiTissue
Definition of a single tissue. Each scalar property is given by a float, NiftiRef or NiftiMapping.
B1_tx and B1_rx are lists to support multi-channel data.
Units are given by PhantomUnits.
NiftiTissue(density, T1, T2, T2dash, ADC, dB0, B1_tx, B1_rx)
| Parameter | Type | Description | Default value |
|---|---|---|---|
density | NiftiRef | Proton density (convention: 0-1) | required |
T1 | Prop | Exponential T1 relaxation | inf |
T2 | Prop | Exponential T2 relaxation | inf |
T2dash | Prop | Exponential T2 dephasing | inf |
ADC | Prop | Apparent Diffusion Coefficient | 0.0 |
dB0 | Prop | B0 fluctuations / offresonance | 0.0 |
B1_tx | list[Prop] | B1+ (transmit) field, per channel | [1.0] |
B1_rx | list[Prop] | B1- (receive) field, per channel | [1.0] |
where Prop = float | NiftiRef | NiftiMapping
NiftiTissue.default(): return aNiftiTissuewith the default units given above - density must be passedNiftiTissue.from_dict(config): load from a dictionaryNiftiTissue.to_dict(): convert to a dictionary
NiftiPhantom
Represents the configuration given by a phantom .json file.
NiftiPhantom(units, system, tissues)
| Parameter | Description |
|---|---|
units | PhantomUnits object |
system | PhantomSystem object |
tissues | Dictionary of tissues; key specifies name, values are NiftiTissue objects |
The class attribute file_type is always "nifti_phantom_v1" and is not a constructor parameter.
NiftiPhantom.default(gyro=42.5764, B0=3): return aNiftiPhantomwithout tissuesNiftiPhantom.load(path): load from.jsonfile, given by the pathNiftiPhantom.save(path): save to a.jsonfile, given by the pathNiftiPhantom.from_dict(config): load from a dictionaryNiftiPhantom.to_dict(): convert to a dictionary