Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

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)
ParameterDescriptionDefault unit
gyroGyromagnetic ratioMHz/T
B0Strength of the main magnetic fieldT
T1Exponential T1 relaxations
T2Exponential T2 relaxations
T2dashExponential T2 dephasings
ADCApparent Diffusion Coefficient10^-3 mm^2/s
dB0Offresonance through B0 fluctuationsHz
B1_txFluctuations in B1+ (transmit) fieldrel
B1_rxFluctuations in B1- (receive) fieldrel
  • PhantomUnits.default(): return PhantomUnits with the default units given above
  • PhantomUnits.from_dict(config): load from a dictionary and check if units are valid
  • PhantomUnits.to_dict(): convert to a dictionary

PhantomSystem

Describes the physical properties of the MRI experiment.

PhantomSystem(gyro, B0)
ParameterDescriptionDefault
gyroGyromagnetic ratio, given in units of PhantomUnits.gyro42.5764
B0Strength of the main magnetic field, given in units of PhantomUnits.B03.0
  • PhantomSystem.from_dict(config): load from a dictionary
  • PhantomSystem.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)
ParameterDescription
file_namePath to the .nii(.gz) file
tissue_indexIndex 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 string
  • NiftiRef.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)
ParameterDescription
fileA NiftiRef
funcA mapping function as str - see spec
  • NiftiMapping.parse(config): parse from a dictionary (calling NiftiRef.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)
ParameterTypeDescriptionDefault value
densityNiftiRefProton density (convention: 0-1)required
T1PropExponential T1 relaxationinf
T2PropExponential T2 relaxationinf
T2dashPropExponential T2 dephasinginf
ADCPropApparent Diffusion Coefficient0.0
dB0PropB0 fluctuations / offresonance0.0
B1_txlist[Prop]B1+ (transmit) field, per channel[1.0]
B1_rxlist[Prop]B1- (receive) field, per channel[1.0]

where Prop = float | NiftiRef | NiftiMapping

  • NiftiTissue.default(): return a NiftiTissue with the default units given above - density must be passed
  • NiftiTissue.from_dict(config): load from a dictionary
  • NiftiTissue.to_dict(): convert to a dictionary

NiftiPhantom

Represents the configuration given by a phantom .json file.

NiftiPhantom(units, system, tissues)
ParameterDescription
unitsPhantomUnits object
systemPhantomSystem object
tissuesDictionary 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 a NiftiPhantom without tissues
  • NiftiPhantom.load(path): load from .json file, given by the path
  • NiftiPhantom.save(path): save to a .json file, given by the path
  • NiftiPhantom.from_dict(config): load from a dictionary
  • NiftiPhantom.to_dict(): convert to a dictionary