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
simulation(image::Array{T,3}, simParams::Dict) where T<:AbstractFloatSimulate MRI raw data from given image data. All simulation parameters are passed to the function in the form of a dictionary.
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.
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.
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.
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 sequencetr::Vector{Trajectory}- trajectories for all contrastsimage::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 truekargs...- additional keyword arguments
...
sourcesimulation(tr::Trajectory{T}, image::Array{Complex{T}}, correctionMap::Array{Complex{T}} = Complex{T}[];
opName = "fast", senseMaps = [], verbose = true, kargs...) where T<:AbstractFloatsimulates 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 trajectoryimage::Array{Complex{T}}- image to be transformed, with two or three dimensions(
correctionMap) - complex correction map of the size ofimagewith 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), withnz = 1for a two-dimensional image; without them, one coil with sensitivity 1 in double precision. For aFloat32trajectory, give them in single precision, for one coilones(ComplexF32, nx, ny, nz, 1)(
verbose=true) - shows a progress bar(
kargs) - the optionsalpha,m,Kandmethodof the approximation thatFieldmapNFFTOpuses for a correction map that is not zero; other keyword arguments are ignored
MRISimulation.addNoise Function
Adds average white gaussian noise to the signal x
Arguments
x::Vector- signal vector'snr::Float64' - target SNR
return AcquisitionData with white gaussian noise
Arguments
acqData::AcquisitionData- AcquisitionData'snr::Float64' - target SNR
MRISimulation.simulation_fast Function
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 Tsimulates 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 trajectoryimage::Matrix- image to be transformed(
correctionMap) - complex correction map of the size ofimagewith 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 thatFieldmapNFFTOpuses 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 aFloat32trajectory, give them in single precision, for one coilones(ComplexF32, size(image)..., 1, 1)(
kargs) - passed on tosimulationwith a trajectory, for exampleverbose=falseto turn off the progress bar
MRISimulation.simulation_explicit Function
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 Tsimulates the k-space data of image on the trajectory tr with an ExplicitOp. Returns an AcquisitionData.
Arguments
tr::Trajectory- two-dimensional trajectoryimage::Matrix- image to be transformed(
correctionMap) - complex correction map of the size ofimagewith 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 theExplicitOp(
senseMaps=[]) - coil sensitivities of size(size(image)..., 1, number of coils); without them, one coil with sensitivity 1 in double precision. For aFloat32trajectory, give them in single precision, for one coilones(ComplexF32, size(image)..., 1, 1)(
kargs) - passed on tosimulationwith a trajectory, for exampleverbose=falseto turn off the progress bar
Coil Sensitivities, Field Maps and Relaxation
MRISimulation.birdcageSensitivity Method
birdcageSensitivity(N::Int64, ncoils::Int64, relative_radius::Float64)Computes the sensitivity maps for each coils that are arranged in a birdcage manner.
sourceMRISimulation.measured2DSensitivity Method
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.
sourceMRISimulation.quadraticFieldmap Function
quadraticFieldmap(Nx::Int64, Ny::Int64, maxOffresonance::Float64=125.0)Computes a parabolic fieldmap.
sourceMRISimulation.stairsFieldmap Method
Computes a fieldmap consisting of stairs, which has discrete linear ascending/descending values
sourceMRISimulation.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]
...
sourceSequences
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 pulserefocusingAngles :: Vector{Float64}- flip angles of the refocusing pulsesT_rf::Vector{Float64}- times of the refocusing pulses relative to the excitation pulseT_echo:: Vector{Float64}- echo times relative to the excitation pulse
MRISimulation.echoAmplitudes Function
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 sequenceR1::AbstractFloat- R1 value to use (1/T1)R2::AbstractFloat- R2 value to use (1/T2)numStates=nothing- number of dephasing states to consider
MRISimulation.echoTimes Method
echoTimes(seq::MESequence)returns the echo times of an ME Sequence
MRISimulation.flipAngles Method
flipAngles(seq::MESequence)returns the refocusing flip angles of an ME Sequence
MRISimulation.numContrasts Method
numContrasts(seq::MESequence)returns the number of echoes of an ME Sequence
MRISimulation.numEchoes Method
numEchoes(seq::MESequence)returns the number of echos of a ME Sequence
MRISimulation.epgDephasing Method
epgDephasing(F::Vector{T}, n=1) where T = circshift(F[:],n)shifts the transverse dephasing states F corresponding to n dephasing-cycles.
MRISimulation.epgRelaxation Method
epgRelaxation( R1::AbstractFloat, R2::AbstractFloat, t::AbstractFloat, F::Vector{T}, Z::Vector{T}) where Tapplies relaxation matrices to a set of EPG states.
Arguments
R1::AbstractFloat- R1R2::AbstractFloat- R2t::AbstractFloat- length of time interval in sF::Vector{T}- transverse dephasing statsZ::Vector{T}- longitudinal dephasing stats
MRISimulation.epgRotation Method
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 pulseF::Vector{T}- transverse dephasing statsZ::Vector{T}- longitudinal dephasing statsstatesConsidered=nothing- number of dephasing states to consider (nothing means all states are taken into account)phi::Float64=0.0- phase of the RF pulse
MRISimulation.rfRotation Function
rfRotation(alpha, phi=0.)returns the rotation matrix for a pulse with flip angle alpha and phase phi.