MRIReco
MRIReco provides the image reconstruction of the framework. Of the packages in this repository, it depends on MRIBase and MRIOperators. It re-exports both, together with RegularizedLeastSquares.jl and AbstractImageReconstruction.jl, so the data types, encoding operators, solvers, regularization terms and the functions for reconstruction plans are available after using MRIReco. MRIFiles, MRISampling, MRICoilSensitivities and MRISimulation are independent of MRIReco and have to be loaded separately.
Reconstruction
Reconstruction Parameters lists the keys of the parameter dictionary.
MRIReco.reconstruction Function
reconstruction(acqData::AcquisitionData, recoParams::Dict)Performs image reconstruction of an AcquisitionData object. Parameters are specified in a dictionary.
Reconstruction types are specified by the key :reco. Valid reconstruction names are:
"direct"- direct Fourier reconstruction (default)"standard"- iterative reconstruction for all contrasts, coils & slices independently"multiEcho"- iterative joint reconstruction of all echo images"multiCoil"- SENSE-type iterative reconstruction"multiCoilMultiEcho"- SENSE-type iterative reconstruction of all echo images"multiCoilMultiEchoSubspace"- SENSE-type iterative reconstruction of the coefficient maps of a temporal basis
The dictionary is merged into the defaults of defaultRecoParams, and :reconSize defaults to the encoding size of acqData. reconstruction then loads the plan of the reconstruction type with MRIRecoPlan. For the iterative reconstructions, a few keys first select the type of a parameter: :densityWeighting => false selects UniformWeightingParameters, :weights selects CustomWeightingParameters, :encodingOps selects CustomEncodingParameters, and a :sparseTrafo with an operator selects CustomSparsityParameters; "direct" does not support these keys and warns that it cannot set the parameter they select. reconstruction then sets the parameters of the same name as the other keys, for example iterations of LeastSquaresSolverParameter for :iterations, and runs the plan.
Other keys that the plan does not have are ignored. If the value of such a key is a parameter object such as UniformWeightingParameters(), an algorithm or a plan, reconstruction warns; with ENV["JULIA_DEBUG"] = "MRIReco", it lists the remaining keys that the plan does not have, :densityWeighting included.
reconstruction(acqData::AcquisitionData, recoParams::Dict, filename::String;
force=false)This method is meant to save the result of reconstruction(acqData, recoParams) in the file filename, or to load it from there if force=false and the file exists. The functions it calls for this are no longer part of MRIReco, so it throws an UndefVarError: right away if force=false and the file exists, otherwise after the reconstruction.
MRIReco.defaultRecoParams Function
defaultRecoParams() -> Dict{Symbol, Any}Return the default parameters of reconstruction: :reco => "direct", :reg => L1Regularization(0.0), :normalizeReg => NoNormalization(), :solver => ADMM, :rho => 5e-2, :iterations => 30 and :arrayType => Array. reconstruction merges the given dictionary into them.
Reconstruction Plans
reconstruction translates the parameter dictionary into a reconstruction plan of AbstractImageReconstruction.jl and runs it. A plan for each reconstruction type is stored in reco_plans/ and can be loaded with MRIRecoPlan, e.g. MRIRecoPlan("multiCoil"), or run directly with reconstruct("multiCoil", acqData; kwargs...). Configure a Reconstruction with Plans shows how to use them.
AbstractImageReconstruction.reconstruct Method
reconstruct(name::AbstractString, acqData::AcquisitionData; modules = getMRIRecoPlanModules(), kwargs...)Perform a reconstruction of acqData with the RecoPlan specified by name. Additional keyword arguments can be passed to the reconstruction plan. modules are the modules whose types the plan file can use, see addMRIRecoPlanModule.
The plan is looked up as the file name.toml in the folders added with addMRIRecoPlanPath, the last added first, and then in the folder reco_plans of MRIReco. Alternatively, name can be the path of a plan file.
Examples
Ireco = reconstruct("standard", acqData; kwargs...)MRIReco.MRIRecoPlan Function
MRIRecoPlan(value, modules = getMRIRecoPlanModules(); kwargs...)Load a RecoPlan and set the keyword arguments if applicable. Value can be the name of a plan or path to plan file.
MRIReco.addMRIRecoPlanModule Method
addMRIRecoPlanModule(mod::Module)Add the mod module to the list of modules which are used for plan loading, so that plan files can use the types that mod exports.
MRIReco.addMRIRecoPlanPath Method
addMRIRecoPlanPath(path)Add the folder path to the folders in which MRIRecoPlan, reconstruct and reconstruction look for plan files. Added folders are searched before the folder reco_plans of MRIReco, the last added first, so a plan file with the name of a built-in plan, for example standard.toml, replaces it. A folder is added only once and only for the current Julia session.
MRIReco.getMRIRecoPlanList Method
getMRIRecoPlanList(; full = false)Retrieve a list of currently known RecoPlans. If full is true then full paths are returned.
MRIReco.getMRIRecoPlanModules Method
getMRIRecoPlanModules()Retrieve a list of currently used modules for plan loading
sourceMRIReco.MRIRecoContext Type
MRIRecoContext{D, arrT, S, Acq}Container for reconstruction context parameters that are used throughout the reconstruction pipeline. Uses a ScopedValue for task-local access.
Fields
reconSize::NTuple{D, Int64}- Size of the reconstructed imagearrayType::Type{arrT}- Array type for computation (Array, JLArray, etc.)storageType::Type{S}- Storage type for operatorsacqData::Acq- Acquisition data ornothing, provides metadata like trajectory infored3d::Bool-trueif 3D-encoded data was converted to 2D slices and the user gave a 3DreconSize; user-supplied volumes (e.g. sensitivity maps) are then in 3D order and need to be permuted
Usage
# Set the context for reconstruction
ctx = MRIRecoContext((128,128), Float64, Array)
# Or with acquisition data
ctx = MRIRecoContext((128,128), acqData, Array)
# Using with() to set scoped value
with(MRIRECO_CONTEXT => ctx) do
# reconstruction code
end
# And then access anywhere in the reconstruction pipeline
function foo(sparsity_params)
rs = ctx_reconSize() # Get from scoped value
ad = ctx_acqData() # Get acquisition data if needed
# ...
endMRIReco.ctx_acqData Method
ctx_acqData() -> Union{AcquisitionData, Nothing}Get the acquisition data from the current MRI reconstruction context. Returns nothing if not set.
sourceMRIReco.ctx_arrayType Method
ctx_arrayType() -> TypeGet the array type from the current MRI reconstruction context.
sourceMRIReco.ctx_reconSize Method
ctx_reconSize() -> NTupleGet the reconstruction size from the current MRI reconstruction context.
sourceMRIReco.ctx_red3d Method
ctx_red3d() -> BoolReturn true if the current reconstruction treats 3D-encoded data that was converted to 2D slices with a 3D reconSize.
MRIReco.ctx_storageType Method
ctx_storageType() -> TypeGet the storage type from the current MRI reconstruction context.
sourceMRIReco.AbstractDirectMRIRecoParameters Type
AbstractDirectMRIRecoParameters <: AbstractMRIRecoParametersAbstract type for direct (non-iterative) MRI reconstruction parameters. Performs a direct Fourier-based image reconstruction.
sourceMRIReco.DirectMRIReco Type
DirectMRIReco{P} <: AbstractDirectMRIRecoAlgorithmThe reconstruction type "direct": a direct image reconstruction which applies the adjoint of the encoding operator to the density-compensated k-space data.
Its parameter is a DirectMRIRecoParameter.
MRIReco.DirectMRIRecoParameter Type
DirectMRIRecoParameter{S, C, W, arrT} <: AbstractDirectMRIRecoParametersParameters of the direct reconstruction DirectMRIReco.
Fields
reconSize::S- Size of the image to reconstruct (default:nothing, the encoding size)cmap::C- Complex correction map of two-dimensional data for off-resonance and relaxation, in the precision of the data, always approximated with"nfft", which works for a map that varies within each slice and sampling times that are not all equal (default:nothing); in the parameter dictionary ofreconstruction, its key is:cmap, not:correctionMapweights::W- Has to staynothing: the reconstruction then weights the data with the density compensation factors, the squares of the weights fromsamplingDensityarrayType::Type{arrT}- Array type of the reconstruction (default:Array)
Iterative Reconstructions
MRIReco.AbstractIterativeRecoParameters Type
AbstractIterativeRecoParameters <: AbstractMRIRecoParametersAbstract base type for iterative reconstruction algorithm parameters. Subtypes must implement callable methods for use with AbstractIterativeMRIRecoContextParameter.
Required Callable Interface
Allocation
(params)(algo, reconSize) -> (Ireco, indices, weights, extra...)Allocates the output array and returns iteration indices and weights.
algo- The algorithmreconSize::NTuple{D, Int64}- Reconstruction sizeReturns a tuple of
(Ireco, indices, weights, extra...)where:Ireco::Array{Complex{T}}- Output image arrayindices- CartesianIndices for iterationweights- Sampling weightsextra...- Optional additional data (e.g., decorrelatedSenseMaps, L_inv for coil recon)
Loop Body
(params)(algo, Ireco, index, weights, extra...)Called once per iteration index. Writes results to Ireco.
algo- The algorithmIreco- Output array to write toindex::CartesianIndex- Current index, such as (rep, slice)weights- Sampling weights from allocationextra...- Optional additional data from allocation
Finalization
(params)(algo, Ireco) -> resultFinalizes and returns the reconstruction result.
algo- The algorithmIreco::Array{Complex{T}}- The filled output arrayReturns final result (typically AxisArray)
MRIReco.AbstractIterativeMRIRecoContextParameter Type
AbstractIterativeMRIRecoContextParameter{P} <: AbstractMRIRecoParametersAbstract base type for iterative reconstruction context parameters. Provides the runtime framework (context, parallelization, allocation) while the inner parameter implements the algorithm-specific loop body.
Type Parameters
P- The inner algorithm parameter type (e.g., AbstractStandardParameters)
MRIReco.SerialIterativeMRIRecoContextParameter Type
SerialIterativeMRIRecoContextParameter{P, RS, AT} <: AbstractIterativeMRIRecoContextParameter{P}Serial (non-parallel) iterative reconstruction context parameter. Uses a simple for loop for iteration.
Type Parameters
P- The inner algorithm parameter typeRS- ReconSize type (NTuple or Nothing)AT- Array type
Fields
reconSize::RS- Reconstruction size (nothing = infer from acqData)arrayType::Type{AT}- Array type for computationparameter::P- Inner algorithm-specific parameter
MRIReco.ThreadedIterativeMRIRecoContextParameter Type
ThreadedIterativeMRIRecoContextParameter{P, RS, AT, S} <: AbstractIterativeMRIRecoContextParameter{P}Threaded iterative reconstruction context parameter using OhMyThreads. Uses @tasks for parallel execution.
Type Parameters
P- The inner algorithm parameter typeRS- ReconSize type (NTuple or Nothing)AT- Array typeS- Scheduler type
Fields
reconSize::RS- Reconstruction size (nothing = infer from acqData)arrayType::Type{AT}- Array type for computationscheduler::S- Task scheduler (nothing = auto-based on arrayType)parameter::P- Inner algorithm-specific parameter
MRIReco.StandardIterativeParameters Type
StandardIterativeParameters{E, W, S} <: AbstractStandardParametersParameters of the iterative reconstruction StandardReconstruction.
Fields
encodingParams::E- Encoding operator parametersweightingParams::W- Sampling weighting parameterssolverParams::S- Least squares solver parameters
Callable Interface
# Allocation - allocates output array and returns iteration indices and weights
(params::StandardIterativeParameters)(algo, reconSize) -> (Ireco, indices, weights)
# Loop body - called per index with weights and output array
(params::StandardIterativeParameters)(algo, Ireco, index, weights)
# Finalization - reshapes and wraps result
(params::StandardIterativeParameters)(algo, Ireco) -> AxisArrayMRIReco.StandardReconstruction Type
StandardReconstruction{P, C} <: AbstractIterativeMRIRecoAlgorithmThe reconstruction type "standard": an iterative image reconstruction which reconstructs the data of all coils, contrasts and slices independently.
Its parameter is an AbstractIterativeMRIRecoContextParameter that holds StandardIterativeParameters; its stored plan uses a ThreadedIterativeMRIRecoContextParameter.
MRIReco.MultiEchoIterativeParameters Type
MultiEchoIterativeParameters{E, W, S} <: AbstractMultiEchoParametersParameters of the iterative reconstruction MultiEchoReconstruction.
Fields
encodingParams::E- Encoding operator parametersweightingParams::W- Sampling weighting parameterssolverParams::S- Least squares solver parameters
Callable Interface
# Allocation - allocates output array and returns iteration indices and weights
(params::MultiEchoIterativeParameters)(algo, reconSize) -> (Ireco, indices, weights)
# Loop body - called per index with weights and output array
(params::MultiEchoIterativeParameters)(algo, Ireco, index, weights)
# Finalization - reshapes and wraps result
(params::MultiEchoIterativeParameters)(algo, Ireco) -> AxisArrayMRIReco.MultiEchoReconstruction Type
MultiEchoReconstruction{P, C} <: AbstractIterativeMRIRecoAlgorithmThe reconstruction type "multiEcho": an iterative image reconstruction which reconstructs all contrasts jointly. Different slices and coil images are reconstructed independently. For more than one contrast, with ADMM, the default solver, or with SplitBregman, give every regularization term a transform, also the default term used without :reg; "nothing" is the identity, for example :sparseTrafo => "nothing" for one term or :sparseTrafo => ["nothing", "nothing"] for two.
Its parameter is an AbstractIterativeMRIRecoContextParameter that holds MultiEchoIterativeParameters; its stored plan uses a ThreadedIterativeMRIRecoContextParameter.
MRIReco.MultiCoilIterativeParameters Type
MultiCoilIterativeParameters{E, W, S, C} <: AbstractMultiCoilParametersParameters of the SENSE-type iterative reconstructions MultiCoilReconstruction, MultiCoilMultiEchoReconstruction and MultiCoilMultiEchoSubspaceReconstruction.
Fields
encodingParams::E- Encoding operator parametersweightingParams::W- Sampling weighting parameterssolverParams::S- Least squares solver parameterscoilParams::C- Coil sensitivity and noise decorrelation parameters
Callable Interface
# Allocation - allocates output array and returns iteration indices, weights, and coil data
(params::MultiCoilIterativeParameters)(algo, reconSize) -> (Ireco, indices, weights, decorrelatedSenseMaps, L_inv)
# Loop body - called per index with weights and output array
(params::MultiCoilIterativeParameters)(algo, Ireco, index, weights, decorrelatedSenseMaps, L_inv)
# Finalization - reshapes and wraps result
(params::MultiCoilIterativeParameters)(algo, Ireco) -> AxisArrayMRIReco.MultiCoilReconstruction Type
MultiCoilReconstruction{P, C} <: AbstractIterativeMRIRecoAlgorithmThe reconstruction type "multiCoil": a SENSE-type iterative image reconstruction. Different slices and contrasts are reconstructed independently.
Its parameter is an AbstractIterativeMRIRecoContextParameter that holds MultiCoilIterativeParameters; its stored plan uses a ThreadedIterativeMRIRecoContextParameter.
MRIReco.MultiCoilMultiEchoReconstruction Type
MultiCoilMultiEchoReconstruction{P, C} <: AbstractIterativeMRIRecoAlgorithmThe reconstruction type "multiCoilMultiEcho": a SENSE-type iterative image reconstruction which reconstructs all contrasts jointly. Different slices are reconstructed independently. For more than one contrast, with ADMM, the default solver, or with SplitBregman, give every regularization term a transform, also the default term used without :reg; "nothing" is the identity, for example :sparseTrafo => "nothing" for one term or :sparseTrafo => ["nothing", "nothing"] for two.
Its parameter is an AbstractIterativeMRIRecoContextParameter that holds MultiCoilIterativeParameters; its stored plan uses a ThreadedIterativeMRIRecoContextParameter.
MRIReco.AbstractSubspaceParameters Type
AbstractSubspaceParameters <: AbstractIterativeRecoParametersAbstract type for subspace-based reconstruction parameters. Subspace methods reconstruct images in a lower-dimensional subspace basis.
sourceMRIReco.MultiCoilMultiEchoSubspaceReconstruction Type
MultiCoilMultiEchoSubspaceReconstruction{P, C} <: AbstractIterativeMRIRecoAlgorithmThe reconstruction type "multiCoilMultiEchoSubspace": a SENSE-type iterative image reconstruction which reconstructs all contrasts jointly using a subspace basis. Its result holds one coefficient map per basis function. Different slices are reconstructed independently. For more than one basis function, with ADMM, the default solver, or with SplitBregman, give every regularization term a transform, also the default term used without :reg; "nothing" is the identity, for example :sparseTrafo => "nothing" for one term or :sparseTrafo => ["nothing", "nothing"] for two.
Its parameter is an AbstractIterativeMRIRecoContextParameter that holds MultiCoilIterativeParameters, whose field encodingParams has to be a SubspaceEncodingParameters with the basis; its stored plan uses a ThreadedIterativeMRIRecoContextParameter.
Parameters
MRIReco.AbstractMRIRecoEncodingParameters Type
AbstractMRIRecoEncodingParameters <: AbstractMRIRecoParametersAbstract base type for encoding operator parameters used in MRI reconstruction.
sourceMRIReco.CustomEncodingParameters Type
CustomEncodingParameters{E} <: AbstractMRIRecoEncodingParametersParameters with user-provided encoding operators.
Type Parameters
E- The type of the encoding operators
Fields
encodingOps::E- Pre-computed encoding operators of"standard"and"multiCoil"as a matrix with one row per contrast and one column per slice. For"multiCoil", the operators include the coil sensitivities, like those ofencodingOps_parallel, and the reconstruction still needs itsCoilParameters; withnoiseData, it decorrelates the data but not these operators.
Callable Interface
(ep::CustomEncodingParameters)(algo, slice::Int, args...)Returns
- The encoding operators for the given slice,
encodingOps[:, slice]
Example
ep = CustomEncodingParameters(; encodingOps=myEncodingOps)MRIReco.EncodingParameters Type
EncodingParameters{C} <: AbstractMRIRecoEncodingParametersParameters for computing encoding operators from acquisition data.
Type Parameters
C- Type ofcorrectionMap, anAbstractArray{<:Complex}orNothing
Fields
All fields are nothing by default, and the operator then uses its own default given below.
correctionMap::C- Complex correction mapzof two-dimensional data for off-resonance and relaxation, in the precision of the data, see Correct Off-Resonance (default: none)method::Union{String, Nothing}- Approximation ofexp(-z t), wheretis the sampling time, for a map that varies within each slice and sampling times that are not all equal:"nfft","leastsquare","hist", which works for a map with only an off-resonance part, or"svd", which works for double-precision data, a map with a spatially varying off-resonance part and profiles with the same sampling times and about ten or more samples per term (default:"nfft"), seeFieldmapNFFTOptoeplitz::Union{Bool, Nothing}- Whether the normal operator uses the Toeplitz approach (default:false)oversamplingFactor::Union{Float64, Nothing}- NFFT oversampling factor (default: 1.25)kernelSize::Union{Int, Nothing}- NFFT kernel size (default: 3)K::Union{Int, Nothing}- Number of terms of"leastsquare"and"hist"and maximum number of terms of"svd"(default: 20);"nfft"determines the number itselfK_tol::Union{Float64, Nothing}- Tolerance with which"svd"chooses the number of terms (default: 1e-3)
method, K and K_tol only take effect with a correction map, and toeplitz, oversamplingFactor and kernelSize only for non-Cartesian data without a correction map.
Callable Interface
(ep::EncodingParameters)(algo, slice::Int)
(ep::EncodingParameters)(algo, slice::Int, senseMaps)Returns
- The encoding operators of the given slice: one per contrast for the reconstructions that treat the contrasts separately, and otherwise one for all contrasts. The second form, used by the reconstructions with coil sensitivities, includes the sensitivities.
Note
- Gets the data, the reconstruction size and the storage type from the
MRIRecoContextof the reconstruction
Example
ep = EncodingParameters()
# With a correction map
ep = EncodingParameters(; correctionMap = cmap, method = "leastsquare", K = 10)MRIReco.SubspaceEncodingParameters Type
SubspaceEncodingParameters{E, B} <: AbstractMRIRecoEncodingParametersEncoding parameters with subspace projection for dimensionality reduction.
Type Parameters
E- The inner encoding parameters typeB- The basis matrix type
Fields
inner::E- Inner encoding parametersbasis::B- Subspace basis matrix with one row per contrast and one column per basis function, in the precision of the data
Callable Interface
(ep::SubspaceEncodingParameters)(algo, slice::Int, args...)Returns
- Encoding operator of
innercomposed with aSubspaceOpof the basis
Example
ep = SubspaceEncodingParameters(; inner=EncodingParameters(), basis=basisMatrix)MRIReco.AbstractMRIRecoWeightingParameters Type
AbstractMRIRecoWeightingParameters <: AbstractMRIRecoParametersAbstract base type for weighting parameters used in MRI reconstruction. Subtypes define how weights are computed for the reconstruction. The iterative reconstructions multiply the encoding operator and the data by them, so they take the place of the square roots of the density compensation factors.
Required Callable Interface
(wp::AbstractMRIRecoWeightingParameters)(::Type{<:AbstractMRIRecoAlgorithm})A subtype must implement this method for Type{<:AbstractMRIRecoAlgorithm}. ctx_acqData and ctx_reconSize give it the data and the image size of the running reconstruction.
Returns
Vector{S}withS = ctx_storageType()- One weight vector per contrast with one weight per sample, the same for all coils, complex and in the precision of the data, in the form thatsamplingDensityreturns
MRIReco.CustomWeightingParameters Type
CustomWeightingParameters{W} <: AbstractMRIRecoWeightingParametersWeighting parameters that use user-provided custom weights.
Type Parameters
W- The type of the weights (typicallyVector{Vector{Complex{<:AbstractFloat}}})
Fields
weights::W- User-provided weights
Description
Allows explicit specification of weighting vectors for data with one coil: a vector of vectors, one per contrast, in the form that samplingDensity returns.
Callable Interface
(wp::CustomWeightingParameters)(::Type{<:AbstractMRIRecoAlgorithm})Returns
- The stored
weightsvector
Validation
Weights are validated during reconstruction to ensure they match the acquisition data structure (same number of contrasts and samples).
Example
weights = [[1.0+0im, 2.0+0im], [3.0+0im, 4.0+0im]]
wp = CustomWeightingParameters(; weights=weights)MRIReco.DensityWeightingParameters Type
DensityWeightingParameters <: AbstractMRIRecoWeightingParametersWeighting parameters that compute density compensation weights from the acquisition data.
Description
Uses the trajectory information in the acquisition data to compute appropriate density compensation weights. This is the default weighting scheme for most reconstructions.
Callable Interface
(wp::DensityWeightingParameters)(::Type{<:AbstractMRIRecoAlgorithm})Returns
Vector{Vector{Complex{T}}}- One weight vector per contrast, fromsamplingDensity
MRIReco.UniformWeightingParameters Type
UniformWeightingParameters <: AbstractMRIRecoWeightingParametersWeighting parameters that use uniform weights for all k-space samples.
Description
For data with one coil, assigns uniform weight 1/sqrt(prod(reconSize)) to each k-space sample.
Callable Interface
(wp::UniformWeightingParameters)(::Type{<:AbstractMRIRecoAlgorithm})Returns
Vector{Vector{Complex{T}}}- One weight vector per contrast
MRIReco.CoilParameters Type
CoilParameters{T, S, N} <: AbstractCoilParameters
CoilParameters(; senseMaps = nothing, noiseData = nothing)Coil sensitivities and noise data of the SENSE-type reconstructions "multiCoil", "multiCoilMultiEcho" and "multiCoilMultiEchoSubspace", as complex arrays in the precision of the data. The constructor needs at least one of the two, and the reconstructions with EncodingParameters need senseMaps.
Fields
senseMaps::S- Coil sensitivities with the dimensions x, y, z or slice, and coil, asespiritreturns them when called on anAcquisitionDatawithnmaps = 1, see Estimate Coil Sensitivities with ESPIRiTnoiseData::N- Noise samples as a matrix of samples × coils; if given, the k-space data and the coil sensitivities are decorrelated, see Noise Decorrelation
MRIReco.CustomSparsityParameters Type
CustomSparsityParameters{L} <: AbstractSparsityParametersParameters specifying custom sparsifying transforms, see Use a Custom Sparsifying Transform.
Fields
sparseTrafo::L- The transform of the first regularization term (anAbstractLinearOperatorsuch asLinearOperator(M)for a matrixM, or a name as forSimpleSparsityParameters) or a vector with one entry per term (default:nothing). Withnothingor a missing entry, a term has no transform.
Examples
CustomSparsityParameters(op) # op for the first term
CustomSparsityParameters([op, nothing]) # op for the first term, none for the second
CustomSparsityParameters() # no transformMRIReco.CustomSparsityParameters Method
(sparsity::CustomSparsityParameters)(algo, numTerms::Int64) -> VectorBuild the transforms of numTerms regularization terms: the given operators, a SparseOp for each name and nothing for each term without a transform. Reconstructions that solve for all contrasts or basis functions at once repeat each transform for every contrast or basis function, so an operator has to act on a single image.
Note
- Gets the reconstruction size and the storage type from the
MRIRecoContextof the reconstruction
MRIReco.LeastSquaresSolverParameter Type
LeastSquaresSolverParameter{SL, R, T} <: SolverParametersParametric solver parameters for iterative MRI reconstruction using RegularizedLeastSquares.
Type Parameters
SL- Solver type: ADMM, CGNR, FISTA, POGM, OptISTA or SplitBregmanR- RegularizationParameters typeT- Floating-point type ofrhoand the tolerances
Fields
Except for solver and regParams, a field is passed to the solver as the keyword argument of the same name, but only if it is not nothing and the solver takes that keyword; otherwise the solver uses its own default.
solver::Type{SL}- Solver type (default:ADMM)regParams::R- Regularization terms and their transforms (default:RegularizationParameters())normalizeReg::AbstractRegularizationNormalization- Scaling of the weights λ of the terms:NoNormalization(),MeasurementBasedNormalization()orSystemMatrixBasedNormalization()(default:NoNormalization())iterations::Int- Maximum iterations; for SplitBregman, the outer iterations (default: 30)rho::T- Penalty parameter of ADMM and SplitBregman and step size of FISTA, POGM and OptISTA (default: 5e-2). FISTA, POGM and OptISTA always receive it, so they do not determine the step size themselves.iterationsInner::Union{Int, Nothing}- Inner iterations of SplitBregman (default:nothing)iterationsCG::Union{Int, Nothing}- CG iterations of ADMM and SplitBregman (default:nothing)absTol::Union{T, Nothing}- Absolute tolerance of ADMM and SplitBregman (default:nothing)relTol::Union{T, Nothing}- Relative tolerance (default:nothing)tolInner::Union{T, Nothing}- Tolerance of the CG iterations of ADMM and SplitBregman (default:nothing)verbose::Bool- Print progress in all solvers except CGNR (default:false)restart::Symbol- Restart of FISTA and POGM::noneor:gradient(default::none)vary_rho::Symbol- Adaptation ofrhoin ADMM::none,:balanceor:PnP(default::none)
Examples
# With L1 + Wavelet regularization
params = LeastSquaresSolverParameter(solver = FISTA,
regParams = RegularizationParameters(
reg = L1Regularization(1e-3),
sparsityParams = SimpleSparsityParameters("Wavelet")
),
iterations = 100
)
# Multiple regularization terms (ADMM)
params = LeastSquaresSolverParameter(solver = ADMM,
regParams = RegularizationParameters(
reg = [L1Regularization(1e-3), L2Regularization(1e-4)],
sparsityParams = SimpleSparsityParameters(["Wavelet", "nothing"])
),
rho = 1e-1
)MRIReco.LeastSquaresSolverParameter Method
(params::LeastSquaresSolverParameter)(algo, b::AbstractVector, A, AHA=normalOperator(A))Solve an inverse problem using the configured solver.
Arguments
algo::AbstractIterativeMRIRecoAlgorithm- The reconstruction algorithmb::AbstractVector- k-space dataA- Forward operatorAHA- Normal operator (optional, computed from A if not provided)
Returns
Reconstructed image vector
Note
- Gets the reconstruction size and the storage type from the
MRIRecoContextof the reconstruction
MRIReco.LeastSquaresSolverParameter Method
(params::LeastSquaresSolverParameter)(algo, A, AHA=normalOperator(A))Create a configured solver for the given problem.
Arguments
algo::AbstractIterativeMRIRecoAlgorithm- The reconstruction algorithmA- Forward operatorAHA- Normal operator (optional, computed from A if not provided)
Returns
A configured AbstractLinearSolver ready for use with solve!
Note
- Gets the reconstruction size and the storage type from the
MRIRecoContextof the reconstruction
MRIReco.RegularizationParameters Type
RegularizationParameters{R, S} <: AbstractImageReconstructionParametersParameters specifying regularization terms and their sparsity transforms.
Type Parameters
R- Regularization type (nothing, AbstractRegularization, or Vector)S- Sparsity parameters type
Fields
reg::R- Regularization term(s). Can benothing, a single term, or a vector (default:nothing).nothingstands forL1Regularization(0.0), which does not regularize and which CGNR does not accept.sparsityParams::S- Sparsifying transforms of the terms, seeSimpleSparsityParametersandCustomSparsityParameters(default:SimpleSparsityParameters()).
Examples
# L1 with wavelet
RegularizationParameters(reg = L1Regularization(1e-3),
sparsityParams = SimpleSparsityParameters("Wavelet"))
# Multiple terms
RegularizationParameters(reg = [L1Regularization(1e-3), L2Regularization(1e-4)],
sparsityParams = SimpleSparsityParameters(["Wavelet", "nothing"]))MRIReco.RegularizationParameters Method
(params::RegularizationParameters)(algo, solver::Type{<:AbstractLinearSolver})Transform the regularization parameters for a specific solver type. ADMM and SplitBregman take several terms; FISTA, POGM and OptISTA take one term; CGNR takes one L2Regularization and ignores its transform. FISTA, POGM, OptISTA and CGNR also take the projections PositiveRegularization and RealRegularization.
Arguments
algo::AbstractIterativeMRIRecoAlgorithm- The reconstruction algorithmsolver::Type{<:AbstractLinearSolver}- The solver type (for example ADMM or FISTA)
Returns
For ADMM and SplitBregman, which take the transforms separately: the tuple
(reg, regTrafo)with one transform per term, the identity of one image for a term without a transformFor the other solvers: the vector of terms, each term with a transform as a
TransformedRegularization
Note
- Gets the reconstruction size and the storage type from the
MRIRecoContextof the reconstruction
MRIReco.SimpleSparsityParameters Type
SimpleSparsityParameters{S} <: AbstractSparsityParametersParameters specifying sparsifying transforms by name, see SparseOp.
Fields
sparseTrafo::S- The transform of the first regularization term ("Wavelet", or"nothing"for the identity) or a vector with one entry per term. With""(the default) ornothing, no term has a transform; in a vector,nothingor a missing entry leaves that term without one. A term without a transform applies to the image itself.
Examples
SimpleSparsityParameters("Wavelet") # Wavelet for the first term
SimpleSparsityParameters(["Wavelet", "nothing"]) # one transform per term
SimpleSparsityParameters() # no transformMRIReco.SimpleSparsityParameters Method
(sparsity::SimpleSparsityParameters)(algo, numTerms::Int64) -> VectorBuild the transforms of numTerms regularization terms: a SparseOp for each name and nothing for each term without a transform. Reconstructions that solve for all contrasts or basis functions at once repeat each transform for every contrast or basis function.
Note
- Gets the reconstruction size and the storage type from the
MRIRecoContextof the reconstruction
MRIReco.SolverParameters Type
SolverParameters <: AbstractMRIRecoParametersAbstract base type for solver parameters in MRIReco. Subtypes define how linear solvers are configured for iterative reconstruction.
sourceDeprecated Reconstruction Functions
Before reconstruction plans, reconstruction called one of the following functions. They are deprecated.
MRIReco.reconstruction_simple Function
Performs iterative image reconstruction independently for the data of all coils, contrasts and slices
Arguments
acqData::AcquisitionData- AcquisitionData objectreconSize::NTuple{2,Int64}- size of image to reconstructreg::Vector{<:AbstractRegularization}- Regularization to be usedsparseTrafo::AbstractLinearOperator- sparsifying transformationweights::Vector{Vector{Complex{<:AbstractFloat}}}- sampling density of the trajectories in acqDatasolver::Type{<:AbstractLinearSolver}- name of the solver to usearrayType- array type to use for the reconstruction, defaults to Array (CPU execution)scheduler- (OhMyThreads) scheduler to use during reconstruction, defaults to dynamic/parallel on CPU, sequential/serial on GPU(
normalize::Bool=false) - adjust regularization parameter according to the size of k-space data(
params::Dict{Symbol,Any}) - Dict with additional parameters
MRIReco.reconstruction_multiEcho Function
Performs a iterative image reconstruction jointly for all contrasts. Different slices and coil images are reconstructed independently.
Arguments
acqData::AcquisitionData- AcquisitionData objectreconSize::NTuple{2,Int64}- size of image to reconstructreg::Vector{<:AbstractRegularization}- Regularization to be usedsparseTrafo::AbstractLinearOperator- sparsifying transformationweights::Vector{Vector{Complex{<:AbstractFloat}}}- sampling density of the trajectories in acqDatasolver::Type{<:AbstractLinearSolver}- name of the solver to usearrayType- array type to use for the reconstruction, defaults to Array (CPU execution)scheduler- (OhMyThreads) scheduler to use during reconstruction, defaults to dynamic/parallel on CPU, sequential/serial on GPU(
normalize::Bool=false) - adjust regularization parameter according to the size of k-space data(
params::Dict{Symbol,Any}) - Dict with additional parameters
MRIReco.reconstruction_multiCoil Function
Performs a SENSE-type iterative image reconstruction. Different slices and contrasts images are reconstructed independently.
Arguments
acqData::AcquisitionData- AcquisitionData objectreconSize::NTuple{2,Int64}- size of image to reconstructreg::Vector{<:AbstractRegularization}- Regularization to be usedsparseTrafo::AbstractLinearOperator- sparsifying transformationweights::Vector{Vector{Complex{<:AbstractFloat}}}- sampling density of the trajectories in acqDataL_inv::Array{Complex{<:AbstractFloat}}- noise decorrelation matrixsolver::Type{<:AbstractLinearSolver}- name of the solver to usesenseMaps::AbstractArray{Complex{<:AbstractFloat}}- coil sensitivitiesarrayType- array type to use for the reconstruction, defaults to Array (CPU execution)scheduler- (OhMyThreads) scheduler to use during reconstruction, defaults to dynamic/parallel on CPU, sequential/serial on GPU(
normalize::Bool=false) - adjust regularization parameter according to the size of k-space data(
params::Dict{Symbol,Any}) - Dict with additional parameters
MRIReco.reconstruction_multiCoilMultiEcho Function
Performs a SENSE-type iterative image reconstruction which reconstructs all contrasts jointly. Different slices are reconstructed independently.
Arguments
acqData::AcquisitionData- AcquisitionData objectreconSize::NTuple{2,Int64}- size of image to reconstructreg::Vector{<:AbstractRegularization}- Regularization to be usedsparseTrafo::AbstractLinearOperator- sparsifying transformationweights::Vector{Vector{Complex{<:AbstractFloat}}}- sampling density of the trajectories in acqDatasolver::Type{<:AbstractLinearSolver}- name of the solver to usesenseMaps::AbstractArray{Complex{<:AbstractFloat}}- coil sensitivitiesarrayType- array type to use for the reconstruction, defaults to Array (CPU execution)scheduler- (OhMyThreads) scheduler to use during reconstruction, defaults to dynamic/parallel on CPU, sequential/serial on GPU(
normalize::Bool=false) - adjust regularization parameter according to the size of k-space data(
params::Dict{Symbol,Any}) - Dict with additional parameters
Tools
MRIReco.remove_oversampling Method
raw = remove_oversampling(rawData::RawAcquisitionData)
remove_oversampling!(rawData::RawAcquisitionData)Removes oversampling from the profiles in a RawAcquisitionData object by creating a deep copy of the input data and applying the remove_oversampling! function.
Arguments
rawData::RawAcquisitionData: TheRawAcquisitionDataobject to process.
Returns
RawAcquisitionData: A newRawAcquisitionDataobject with oversampling removed.
Examples
# Assuming `rawData` is a RawAcquisitionData object
processedData = remove_oversampling(rawData)MRIReco.regrid Method
`regrid(acqData::AcquisitionData{T}, kspaceSize::NTuple{2,Int64}
; cgnr_iter::Int64=3, correctionMap::Array{Complex{T}}=Complex{T}[]) where (D,T)`Regrid non-cartesian k-space data in acqData to a cartesian grid of size kspaceSize. Uses the CGNR method to invert the non-cartesian Fourier encoding.
Arguments:
acqData::AcquisitionData{T}- AcquisitionDataksize::NTuple{2,Int64}- size of the cartesian k-space gridcgnr_iter::Int64=3- number of CGNR iterationscorrectionMao::Array{Complex{T}}- relaxation/b0 map
MRIReco.applySubspace Method
applySubspace(I, basis)computes the echo images from the coefficient maps I of the reconstruction type "multiCoilMultiEchoSubspace", by multiplying the dimension of the coefficient maps with basis'.
I has the dimensions x, y, z, coefficient maps, coils and repetitions. basis is the matrix passed as :basis, with one row per echo and one column per coefficient map, and has the element type of I. The result has the dimensions of I, with the echoes instead of the coefficient maps.
MRIReco.nrmsd Method
nrmsd(I,Ireco)computes the normalized root mean squared error of the image Ireco with respect to the image I.
MRIReco.optimalScalingFactor Method
optimalScalingFactor(I,Ireco)computes the optimal scaling factor α such that || I - α Ireco ||₂ is minimal
sourceMRIReco.covariance Method
covariance(noiseData)computes the covariance matrix of the coils from the noise samples noiseData, an array of size (samples, coils), as noiseData' * noiseData / (N - 1) for N samples.
MRIReco.decorrelateSenseMaps Method
decorrelateSenseMaps(L_inv, senseMaps, numChan)multiplies the coil sensitivities senseMaps, an array of size (x, y, z, coils) with numChan coils, by L_inv' from the right along the coil dimension, reshape(senseMaps, :, numChan) * L_inv', which decorrelates them in the same way as the data. L_inv is the inverse of the lower Cholesky factor of the matrix that covariance returns. If L_inv is nothing, senseMaps is returned unchanged.