MP2RAGEModel#
- class torchsim.models.MP2RAGEModel(diff=None, chunk_size=None, device=None, *args, **kwargs)[source]#
Bases:
AbstractModel
Magnetization Prepared (2) RApid Gradient Echo (MPnRAGE) Model.
This class models Magnetization Prepared RApid Gradient Echo with 2 volumes per segment (MP2RAGE) 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.
- Parameters:
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)
TRmp2rage (float)
nshots (int | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes])
- _engine(T1, TI, flip, TRspgr, TRmp2rage, nshots, M0=1.0, inv_efficiency=1.0)[source]#
Computes the MP2RAGE 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)
TRmp2rage (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 MP2RAGEModel model = MP2RAGEModel() model.set_properties(T1=(200, 1000), inv_efficiency=0.95) model.set_sequence(TI=(500.0, 1500.0), flip=5.0, TRspgr=5.0, TRmp2rage=3000.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, TRmp2rage, nshots)[source]#
Set sequence parameters for the SPGR model.
- Parameters:
TI (npt.ArrayLike) – Inversion time (s) in milliseconds of shape
(2,)
.flip (float | npt.ArrayLike) – Flip angle train in degrees of shape
(2,)
. If scalar, assume same angle for both blocks.TRspgr (float) – Repetition time in milliseconds for each SPGR readout.
TRmp2rage (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, TRmp2rage, 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)
TRmp2rage (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])