MPRAGEModel#
- class torchsim.models.MPRAGEModel(diff=None, chunk_size=None, device=None, *args, **kwargs)[source]#
Bases:
AbstractModel
Magnetization Prepared RApid Gradient Echo (MPnRAGE) Model.
This class models Magnetization Prepared RApid Gradient Echo (MPRAGE) 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.
Assume that signal is sampled at center of k-space only.
- set_properties(T1, M0=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])
M0 (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(nshots, flip, TR, TI=0.0)[source]#
Configures the pulse sequence parameters for the simulation.
- _engine(T1, TI, flip, TRspgr, nshots, M0=1.0, inv_efficiency=1.0)[source]#
Computes the MPRAGE signal for given tissue properties and sequence parameters.
- Parameters:
T1 (float | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes])
TI (_SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | 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])
TRspgr (float)
TRmprage (float)
nshots (int | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | float | 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])
inv_efficiency (float | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes])
Examples
from torchsim.models import MPRAGEModel model = MPRAGEModel() model.set_properties(T1=(200, 1000), inv_efficiency=0.95) model.set_sequence(TI=500.0, flip=5.0, TRspgr=5.0, nshots=128) 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, M0=1.0, inv_efficiency=1.0)[source]#
Set tissue and system-specific properties for the MRF model.
- set_sequence(TI, flip, TRspgr, nshots)[source]#
Set sequence parameters for the SPGR model.
- Parameters:
TI (float) – Inversion time in milliseconds of shape
(2,)
.flip (float | npt.ArrayLike) – Flip angle train in degrees.
TRspgr (float) – Repetition time in milliseconds for each SPGR readout.
TRmprage (float) – Repetition time in milliseconds for the whole inversion block.
nshots (int | npt.ArrayLike) – Number of SPGR readout within the inversion block of shape
(npre, npost)
If scalar, assumenpre == npost == 0.5 * nshots
. Usually, this is the number of slice encoding lines(nshots = nz / Rz)
, i.e., the number of slices divided by the total acceleration factor alongz
.
- static _engine(T1, TI, flip, TRspgr, TRmprage, nshots, M0=1.0, inv_efficiency=1.0)[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])
TI (_SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | 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])
TRspgr (float)
TRmprage (float)
nshots (int | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | float | 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])
inv_efficiency (float | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes])