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.

Parameters:
  • diff (str | tuple[str] | None)

  • chunk_size (int | None)

  • device (str | device | None)

set_properties(T1, M0=1.0, inv_efficiency=1.0)[source]#

Sets tissue relaxation properties and experimental conditions.

Parameters:
set_sequence(nshots, flip, TR, TI=0.0)[source]#

Configures the pulse sequence parameters for the simulation.

Parameters:
_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:

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_properties

Set tissue and system-specific properties for the MRF model.

set_sequence

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.

Parameters:
  • T1 (float | npt.ArrayLike) – Longitudinal relaxation time in milliseconds.

  • M0 (float or array-like, optional) – Proton density scaling factor, default is 1.0.

  • inv_efficiency (float | npt.ArrayLike, optional) – Inversion efficiency map, default is 1.0.

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, assume npre == 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 along z.

static _engine(T1, TI, flip, TRspgr, TRmprage, nshots, M0=1.0, inv_efficiency=1.0)[source]#

Core computational function for the model.

Parameters: