MRFModel#
- class torchsim.models.MRFModel(diff=None, chunk_size=None, device=None, *args, **kwargs)[source]#
Bases:
AbstractModel
SSFP Magnetic Resonance Fingerprinting (MRF) Model.
This class models steady-state free precession (SSFP) MRF signals based on tissue properties, pulse sequence parameters, and experimental conditions. It uses Extended Phase Graph (EPG) formalism to compute the magnetization evolution over time.
- set_properties(T1, T2, M0=1.0, B1=1.0, inv_efficiency=1.0)[source]#
Sets tissue relaxation properties and experimental conditions.
- Parameters:
T1 (float | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes])
T2 (float | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes])
M0 (float | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes])
B1 (float | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes])
inv_efficiency (float | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes])
- set_sequence(flip, TR, TI=0.0, slice_prof=1.0, nstates=10, nreps=1)[source]#
Configures the pulse sequence parameters for the simulation.
- Parameters:
flip (float | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes])
TR (float | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes])
TI (float)
slice_prof (float | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes])
nstates (int)
nreps (int)
- _engine(T1, T2, flip, TR, TI=0.0, M0=1.0, B1=1.0, inv_efficiency=1.0,
slice_prof=1.0, nstates=10, nreps=1)
Computes the MRF signal for given tissue properties and sequence parameters.
Examples
import torch from torchsim.models import MRFModel model = MRFModel() model.set_properties(T1=1000, T2=80, M0=1.0, B1=1.0, inv_efficiency=0.95) model.set_sequence(flip=torch.linspace(5.0, 60.0, 1000), TR=10.0, nstates=20, nreps=1) signal = model()
Methods
__init__
Initialize the model with automatic parameter segregation and engine setup.
forward
Get forward method.
jacobian
Get Jacobian method.
Set tissue and system-specific properties for the MRF model.
Set sequence parameters for the SPGR model.
- set_properties(T1, T2, M0=1.0, B1=1.0, inv_efficiency=1.0)[source]#
Set tissue and system-specific properties for the MRF model.
- Parameters:
T1 (float | npt.ArrayLike) – Longitudinal relaxation time in milliseconds.
T2 (float | npt.ArrayLike) – Transverse relaxation time in milliseconds.
M0 (float or array-like, optional) – Proton density scaling factor, default is
1.0
.B1 (float | npt.ArrayLike, optional) – Flip angle scaling map, default is
1.0
.inv_efficiency (float | npt.ArrayLike, optional) – Inversion efficiency map, default is
1.0
.
- set_sequence(flip, TR, TI=0.0, slice_prof=1.0, nstates=10, nreps=1)[source]#
Set sequence parameters for the SPGR model.
- Parameters:
flip (float | npt.ArrayLike) – Flip angle train in degrees.
TR (float | npt.ArrayLike) – Repetition time in milliseconds.
TI (float, optional) – Inversion time in milliseconds. The default is
0.0
.slice_prof (float | npt.ArrayLike, optional) – Flip angle scaling along slice profile. The default is
1.0
.nstates (int, optional) – Number of EPG states to be retained. The default is
10
.nreps (int, optional) – Number of simulation repetitions. The default is
1
.
- static _engine(T1, T2, flip, TR, TI=0.0, M0=1.0, B1=1.0, inv_efficiency=1.0, slice_prof=1.0, nstates=10, nreps=1)[source]#
Core computational function for the model.
- Parameters:
T1 (float | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes])
T2 (float | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes])
flip (float | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes])
TR (float | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes])
TI (float)
M0 (float | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes])
B1 (float | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes])
inv_efficiency (float | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes])
slice_prof (float | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes])
nstates (int)
nreps (int)