Skip to content

MRISimulation ​

MRISimulation simulates MRI data from images, including coil sensitivities, field inhomogeneities and relaxation. MRISimulation depends on MRIBase and MRIOperators. It has to be loaded with using MRISimulation, because MRIReco does not depend on it. The guide Simulate k-Space Data shows how to use these functions.

Simulation ​

MRISimulation.simulation Function
julia
simulation(image::Array{T,3}, simParams::Dict) where T<:AbstractFloat

Simulate MRI raw data from given image data. All simulation parameters are passed to the function in the form of a dictionary.

source
julia
simulation(image::Array{T,3}, simParams::Dict) where T<:Complex{<:AbstractFloat}

Simulate MRI raw data from given image data. All simulation parameters are passed to the function in the form of a dictionary.

source
julia
simulation(image::Array{T,3}, simParams::Dict, filename::String;
           force=false) where T<:Union{Complex{<:AbstractFloat},AbstractFloat}

This method is meant to save the result of simulation(image, simParams) in the file filename, or to load it from there if force=false and the file exists. The functions it calls for this belong to MRIFiles, which MRISimulation does not depend on, so it throws an UndefVarError, also after using MRIFiles: right away if force=false and the file exists, otherwise after the simulation.

source
julia
simulation(image::Array{T,2}, simParams::Dict) where T<:Union{Complex{<:AbstractFloat},AbstractFloat}

Simulate MRI raw data from given image data. All simulation parameters are passed to the function in the form of a dictionary.

source
julia
simulation(seq::AbstractSequence, tr::Vector{Trajectory}, image::Array{T,3}
                ; opName="fast", r1map=[], r2map=[], fmap=[], senseMaps=[]
                , verbose=true, kargs...) where T<:Complex{<:AbstractFloat}

Simulate k-space data for all echoes of a pulse sequence. The echo intensities are simulated using the EPG formalism The Fourier integrals can be evaluated exactly or using NFFT

...

Arguments

  • seq::AbstractSequence - pulse sequence

  • tr::Vector{Trajectory} - trajectories for all contrasts

  • image::Array{T,3} - image to be transformed

  • (r1map=[]) - R1 map of the object (real)

  • (r2map=[]) - R2 map of the object (real) / (R2* for GRE sequences)

  • (fmap=[]) - fieldmap (real)

  • (opName="fast") - name of operator to use ("explicit" or "fast")

  • (senseMaps=[]) - array of coil sensitivities

  • (verbose=true) - prints the progress if true

  • kargs... - additional keyword arguments

...

source
julia
simulation(tr::Trajectory{T}, image::Array{Complex{T}}, correctionMap::Array{Complex{T}} = Complex{T}[];
           opName = "fast", senseMaps = [], verbose = true, kargs...) where T<:AbstractFloat

simulates the k-space data of image on the trajectory tr with the operator that fourierEncodingOp builds for opName with echoImage=false, so the sampling times count from the excitation; slice by slice for a two-dimensional trajectory and at once for a three-dimensional one. Returns an AcquisitionData.

Arguments

  • tr::Trajectory - two- or three-dimensional trajectory

  • image::Array{Complex{T}} - image to be transformed, with two or three dimensions

  • (correctionMap) - complex correction map of the size of image with the relaxation rate R₂* in 1/s as its real part and the off-resonance frequency in rad/s as its imaginary part

  • (opName="fast") - "fast" or "explicit"; Simulate k-Space Data lists the cases in which only "explicit" works, such as a three-dimensional trajectory with a correction map that is not zero

  • (senseMaps=[]) - coil sensitivities of size (nx, ny, nz, number of coils), with nz = 1 for a two-dimensional image; without them, one coil with sensitivity 1 in double precision. For a Float32 trajectory, give them in single precision, for one coil ones(ComplexF32, nx, ny, nz, 1)

  • (verbose=true) - shows a progress bar

  • (kargs) - the options alpha, m, K and method of the approximation that FieldmapNFFTOp uses for a correction map that is not zero; other keyword arguments are ignored

source
MRISimulation.addNoise Function

Adds average white gaussian noise to the signal x

Arguments

  • x::Vector - signal vector

  • 'snr::Float64' - target SNR

source

return AcquisitionData with white gaussian noise

Arguments

  • acqData::AcquisitionData - AcquisitionData

  • 'snr::Float64' - target SNR

source
MRISimulation.simulation_fast Function
julia
simulation_fast(tr::Trajectory{T}, image::Matrix, correctionMap::Array{Complex{T}} = Complex{T}[];
                alpha::Float64 = 1.75, m::Float64 = 4.0, K::Int64 = 16, method = "nfft",
                senseMaps = [], kargs...) where T

simulates the k-space data of image on the trajectory tr with the operator that fourierEncodingOp builds for "fast" with echoImage=false: an FFT or an NFFT, or a FieldmapNFFTOp for a correction map that is not zero. Returns an AcquisitionData.

Arguments

  • tr::Trajectory - two-dimensional trajectory

  • image::Matrix - image to be transformed

  • (correctionMap) - complex correction map of the size of image with the relaxation rate R₂* in 1/s as its real part and the off-resonance frequency in rad/s as its imaginary part

  • (alpha, m, K, method) - options of the approximation that FieldmapNFFTOp uses for a correction map that is not zero; without such a map, they have no effect

  • (senseMaps=[]) - coil sensitivities of size (size(image)..., 1, number of coils); without them, one coil with sensitivity 1 in double precision. For a Float32 trajectory, give them in single precision, for one coil ones(ComplexF32, size(image)..., 1, 1)

  • (kargs) - passed on to simulation with a trajectory, for example verbose=false to turn off the progress bar

source
MRISimulation.simulation_explicit Function
julia
simulation_explicit(tr::Trajectory{T}, image::Matrix, correctionMap::Array{Complex{T}} = Complex{T}[];
                    alpha::Float64 = 1.75, m::Float64 = 4.0, K::Int64 = 16, method = "nfft",
                    senseMaps = [], kargs...) where T

simulates the k-space data of image on the trajectory tr with an ExplicitOp. Returns an AcquisitionData.

Arguments

  • tr::Trajectory - two-dimensional trajectory

  • image::Matrix - image to be transformed

  • (correctionMap) - complex correction map of the size of image with the relaxation rate R₂* in 1/s as its real part and the off-resonance frequency in rad/s as its imaginary part

  • (alpha, m, K, method) - have no effect on the ExplicitOp

  • (senseMaps=[]) - coil sensitivities of size (size(image)..., 1, number of coils); without them, one coil with sensitivity 1 in double precision. For a Float32 trajectory, give them in single precision, for one coil ones(ComplexF32, size(image)..., 1, 1)

  • (kargs) - passed on to simulation with a trajectory, for example verbose=false to turn off the progress bar

source

Coil Sensitivities, Field Maps and Relaxation ​

MRISimulation.birdcageSensitivity Method
julia
birdcageSensitivity(N::Int64, ncoils::Int64, relative_radius::Float64)

Computes the sensitivity maps for each coils that are arranged in a birdcage manner.

source
MRISimulation.measured2DSensitivity Method
julia
measured2DSensitivity(N::Int64, ncoils::Int64; T::Type{<:Complex{<:AbstractFloat}} = ComplexF32)

Computes 2D coil sensitivity maps in image space from actually measured coil profiles, as an array of size (N, N, 1, ncoils) with element type T. At most eight coils are available. The code was originally implemented in the Berkeley Advanced Reconstruction Toolbox (BART) by

M. Uecker et al. Software toolbox and programming library for compressed sens- ing and parallel imaging. In: ISMRM Workshop on Data Sampling and Image Reconstruction, Sedona, 2013.

Checkout the original file:

https://github.com/mrirecon/bart/blob/master/src/simu/sens.c

for more information.

source
MRISimulation.polarFieldmap Function

Computes a polaroid fieldmap.

source
MRISimulation.quadraticFieldmap Function
julia
quadraticFieldmap(Nx::Int64, Ny::Int64, maxOffresonance::Float64=125.0)

Computes a parabolic fieldmap.

source
MRISimulation.stairsFieldmap Method

Computes a fieldmap consisting of stairs, which has discrete linear ascending/descending values

source
MRISimulation.relaxationMap Function

Calculates the relaxationMap based on the pixel values of the image

...

Arguments

  • image::Matrix : Image whose values determine the relaxationrate at each pixel.

  • minRelaxation::Float64=5.0 : minimum relaxationrate measured in [Hz]

  • maxRelaxation::Float64=125.0 : maximum relaxationrate measured in [Hz]

...

source

Sequences ​

MRISimulation.MESequence Type

General Multi-Echo sequence with variable flip angles and TR.

The phase of the excitation pulse has a phase of -90° in order to fulfill CPMG conditions.

For simplicity instantaneous pulses are assumed.

The echoes appear at the times T_echo after the excitation pulse.

Fields

  • excitationAngle::Float64 - flip angle of the excitation pulse

  • refocusingAngles :: Vector{Float64} - flip angles of the refocusing pulses

  • T_rf::Vector{Float64} - times of the refocusing pulses relative to the excitation pulse

  • T_echo:: Vector{Float64} - echo times relative to the excitation pulse

source
MRISimulation.echoAmplitudes Function
julia
echoAmplitudes(seq::MESequence, R1::AbstractFloat, R2::AbstractFloat, numStates=nothing)

calculates echo amplitudes for a given MESequence and given relaxation Rates R1, R2. Calculations are performed using the extended phase graph method. For simplicity instantaneous pulses are assumed. If numStates=nothing all dephasing states will be taken into account

Arguments

  • seq::MESequence - pulse sequence

  • R1::AbstractFloat - R1 value to use (1/T1)

  • R2::AbstractFloat - R2 value to use (1/T2)

  • numStates=nothing - number of dephasing states to consider

source
MRISimulation.echoTimes Method
julia
echoTimes(seq::MESequence)

returns the echo times of an ME Sequence

source
MRISimulation.flipAngles Method
julia
flipAngles(seq::MESequence)

returns the refocusing flip angles of an ME Sequence

source
MRISimulation.numContrasts Method
julia
numContrasts(seq::MESequence)

returns the number of echoes of an ME Sequence

source
MRISimulation.numEchoes Method
julia
numEchoes(seq::MESequence)

returns the number of echos of a ME Sequence

source
MRISimulation.epgDephasing Method
julia
epgDephasing(F::Vector{T}, n=1) where T = circshift(F[:],n)

shifts the transverse dephasing states F corresponding to n dephasing-cycles.

source
MRISimulation.epgRelaxation Method
julia
epgRelaxation( R1::AbstractFloat, R2::AbstractFloat, t::AbstractFloat, F::Vector{T}, Z::Vector{T}) where T

applies relaxation matrices to a set of EPG states.

Arguments

  • R1::AbstractFloat - R1

  • R2::AbstractFloat - R2

  • t::AbstractFloat - length of time interval in s

  • F::Vector{T} - transverse dephasing stats

  • Z::Vector{T} - longitudinal dephasing stats

source
MRISimulation.epgRotation Method
julia
epgRotation(alpha::Float64, F::Vector{T}, Z::Vector{T}; statesConsidered=nothing, phi::Float64=0.0)

applies Bloch-rotation (<=> RF pulse) to a set of EPG states.

Arguments

  • alpha::Float64 - flip angle of the RF pulse

  • F::Vector{T} - transverse dephasing stats

  • Z::Vector{T} - longitudinal dephasing stats

  • statesConsidered=nothing - number of dephasing states to consider (nothing means all states are taken into account)

  • phi::Float64=0.0 - phase of the RF pulse

source
MRISimulation.rfRotation Function
julia
rfRotation(alpha, phi=0.)

returns the rotation matrix for a pulse with flip angle alpha and phase phi.

source