mrftools package

Subpackages

Submodules

mrftools.dictionaryParameters module

mrftools.reconstructionParameters module

mrftools.sequenceParameters module

class mrftools.sequenceParameters.SequenceParameters(name: str, modules=[], trajectory: typing.Optional[mrftools.trajectoryParameters.TrajectoryParameters] = None, version='dev', sequenceUnits=<mrftools.Types.sequenceUnits.SequenceUnits object>)

Bases: object

A class to manage sequence parameters for MRI simulations.

CastToFloats()

Casts sequence module data to floats.

CastToIntegers()

Casts sequence module data to integers.

ConvertUnits(newUnits)

Converts the sequence units to new specified units.

Parameters

newUnits (SequenceUnits) – New units of time and angle for the sequence.

ExportToJson(baseFilepath='', exportUnits=<mrftools.Types.sequenceUnits.SequenceUnits object>, castToIntegers=True)

Exports the sequence to a JSON file.

Parameters
  • baseFilepath (str, optional) – Base filepath for the JSON file, by default an empty string.

  • exportUnits (SequenceUnits, optional) – Units for exporting the sequence, by default SequenceUnits(Units.MICROSECONDS, Units.CENTIDEGREES).

  • castToIntegers (bool, optional) – Cast module data to integers if True, by default True.

static FromFile(path)

Creates a SequenceParameters object from a JSON file.

Parameters

path (str) – Path to the JSON file.

Returns

A new SequenceParameters object created from the JSON file.

Return type

SequenceParameters

static FromJson(inputJson)

Creates a SequenceParameters object from a JSON input string.

Parameters

inputJson (dict) – JSON input containing sequence information.

Returns

A new SequenceParameters object created from the input JSON.

Return type

SequenceParameters

Simulate(dictionaryEntries, numSpins, device=None)

Simulates the sequence given dictionary entries and number of spins.

Parameters
  • dictionaryEntries (torch.Tensor) – Dictionary entries for simulation.

  • numSpins (int) – Number of spins for simulation.

  • device (torch.device, optional) – Device for computation, by default None.

Returns

A tuple containing simulation results.

Return type

tuple

mrftools.simulationParameters module

class mrftools.simulationParameters.SimulationParameters(sequenceParameters, dictionaryParameters, name='', version='dev', numSpins=1, times=[], timeDomainResults=[], results=[], truncationMatrix=[], truncatedResults=[], singularValues=[])

Bases: object

A class to represent simulation parameters and methods.

CalculateSVD(desiredSVDPower=0.99, truncationNumberOverride=None, clearUncompressedResults=False)

Perform Singular Value Decomposition (SVD) on simulation results.

Parameters
  • desiredSVDPower (float, optional) – Desired SVD power.

  • truncationNumberOverride (int, optional) – Override for truncation number.

  • clearUncompressedResults (bool, optional) – Clear uncompressed results.

Returns

Truncation number and total SVD power.

Return type

tuple

Execute(numBatches=1, device=None)

Execute the simulation.

Parameters
  • numBatches (int, optional) – Number of batches.

  • device – (str, optional): Device for execution.

Returns

Simulation results.

Return type

numpy.ndarray

ExportToJson(baseFilepath='')

Export simulation parameters to a JSON file.

Parameters

baseFilepath (str, optional) – Base filepath for the JSON file.

Returns

None

FindPatternMatches(querySignals, useSVD=False, truncationNumber=25)

Find pattern matches in the simulation.

Parameters
  • querySignals (numpy.ndarray) – Query signals.

  • useSVD (bool, optional) – Use SVD for matching.

  • truncationNumber (int, optional) – Truncation number.

Returns

Indices of matched patterns.

Return type

numpy.ndarray

static FromFile(path)

Create a SimulationParameters instance from a JSON file.

Parameters

path (str) – Path to the JSON file.

Returns

The created SimulationParameters instance.

Return type

SimulationParameters

static FromJson(inputJson)

Create a SimulationParameters instance from a JSON string input.

Parameters

inputJson (dict) – JSON data containing simulation parameters.

Returns

The created SimulationParameters instance.

Return type

SimulationParameters

GetAverageResult(indices)

Get the average result over specified indices.

Parameters

indices (list) – List of indices.

Returns

Average result.

Return type

numpy.ndarray

static GetInnerProducts(querySignals, dictionarySignals)

Calculate inner products between query and dictionary signals.

Parameters
  • querySignals (numpy.ndarray) – Query signals.

  • dictionarySignals (numpy.ndarray) – Dictionary signals.

Returns

Inner products between signals.

Return type

numpy.ndarray

GetPowerFromDesiredTruncationNumber(desiredTruncationNumber)

Get total SVD power from desired truncation number.

Parameters

desiredTruncationNumber (int) – Desired truncation number.

Returns

Total power.

Return type

float

GetTruncationNumberFromDesiredPower(desiredSVDPower)

Get truncation number based on desired SVD power.

Parameters

desiredSVDPower (float) – Desired SVD power.

Returns

Truncation number and total SVD power.

Return type

tuple

Plot(dictionaryEntryNumbers=[], plotTruncated=False, plotTimeDomain=False)

Plot simulation results.

Parameters
  • dictionaryEntryNumbers (list, optional) – List of dictionary entry numbers.

  • plotTruncated (bool, optional) – Plot truncated results.

  • plotTimeDomain (bool, optional) – Plot in the time domain.

Returns

None

mrftools.trajectoryParameters module

class mrftools.trajectoryParameters.GradientWaveform(maxGradStrength, xGrad, yGrad, zGrad=[], gradEndPad=0, dwellTime=2500, units=None)

Bases: object

static FromJson(inputJson)

Create a GradientWaveform instance from a JSON string input.

Parameters

inputJson (dict) – JSON data containing GradientWaveform parameters.

Returns

The created GradientWaveform instance.

Return type

GradientWaveform

class mrftools.trajectoryParameters.TrajectoryParameters(trajectoryType: mrftools.Types.types.TrajectoryType, fov, matrixSize, numShots, gradientWaveform: mrftools.trajectoryParameters.GradientWaveform, kspaceTrajectory=None, densityCompensation=None, name='', version='dev')

Bases: object

ExportToJson(baseFilepath='')

Export trajectory parameters to a JSON file.

Parameters

baseFilepath (str, optional) – Base filepath for the JSON file.

Returns

None

static FromCPPHeader(trajectoryType: mrftools.Types.types.TrajectoryType, headerFile)
static FromFile(path)

Create a TrajectoryParameters instance from a JSON file.

Parameters

path (str) – Path to the JSON file.

Returns

The created TrajectoryParameters instance.

Return type

TrajectoryParameters

static FromJson(inputJson)

Create a TrajectoryParameters instance from a JSON string input.

Parameters

inputJson (dict) – JSON data containing trajectory parameters.

Returns

The created TrajectoryParameters instance.

Return type

TrajectoryParameters

Module contents