MPnRAGEModel#
- class torchsim.models.MPnRAGEModel(diff=None, chunk_size=None, device=None, *args, **kwargs)[source]#
Bases:
AbstractModel
Magnetization Prepared (n) RApid Gradient Echo (MPnRAGE) Model.
This class models Magnetization Prepared RApid Gradient Echo with n volumes per segment (MPnRAGE) 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, 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])
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(nshots, flip, TR, TI=0.0, slice_prof=1.0)[source]#
Configures the pulse sequence parameters for the simulation.
- _engine(T1, flip, TR, TI=0.0, M0=1.0, B1=1.0, inv_efficiency=1.0,
slice_prof=1.0)
Computes the MPnRAGE signal for given tissue properties and sequence parameters.
Examples
from torchsim.models import MPnRAGEModel model = MPnRAGEModel() model.set_properties(T1=1000, inv_efficiency=0.95) model.set_sequence(nshots=128, flip=5.0, TR=10.0) 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, 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.
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(nshots, flip, TR, TI=0.0, slice_prof=1.0)[source]#
Set sequence parameters for the SPGR model.
- Parameters:
nshots (int) – Number of SPGR shots per inversion block.
flip (float) – Flip angle train in degrees.
TR (float) – 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
.
- static _engine(T1, nshots, flip, TR, TI=0.0, M0=1.0, B1=1.0, inv_efficiency=1.0, slice_prof=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])
nshots (int)
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])