diff --git a/src/Algorithms/HandsFreeAlgorithms/HandsFreeSinglePatch.jl b/src/Algorithms/HandsFreeAlgorithms/HandsFreeSinglePatch.jl index 25513cb..1eec9a3 100644 --- a/src/Algorithms/HandsFreeAlgorithms/HandsFreeSinglePatch.jl +++ b/src/Algorithms/HandsFreeAlgorithms/HandsFreeSinglePatch.jl @@ -16,8 +16,8 @@ function prepareSystemMatrix(reco::SinglePatchHandsFreeReconstructionParameter{L return freqs, sf, grid, reco.arrayType end -function prepareWeights(reco::SinglePatchHandsFreeReconstructionParameter{L,arrT,SP,W}, freqs, sf) where {L, arrT, SP, W<:AbstractWeightingParameters} - return process(AbstractMPIRecoAlgorithm, reco.weightingParams, freqs, sf, nothing, reco.arrayType) +function prepareWeights(reco::SinglePatchHandsFreeReconstructionParameter{L,arrT,SP,W}, freqs, S) where {L, arrT, SP, W<:AbstractWeightingParameters} + return process(AbstractMPIRecoAlgorithm, reco.weightingParams, freqs, reco.sf, S, nothing, reco.arrayType) end function process(algo::SinglePatchReconstructionAlgorithm, params::SinglePatchHandsFreeReconstructionParameter, u) diff --git a/src/Algorithms/MultiPatchAlgorithms/MultiPatchAlgorithm.jl b/src/Algorithms/MultiPatchAlgorithms/MultiPatchAlgorithm.jl index 214b237..df7c6c6 100644 --- a/src/Algorithms/MultiPatchAlgorithms/MultiPatchAlgorithm.jl +++ b/src/Algorithms/MultiPatchAlgorithms/MultiPatchAlgorithm.jl @@ -87,7 +87,7 @@ function process(algo::MultiPatchReconstructionAlgorithm, params::Union{OP, Proc # Kinda of hacky. MultiPatch parameters don't map nicely to the SinglePatch inspired pre, reco, post structure # Have to create weights before ffop is (potentially) moved to GPU, as GPU arrays don't have efficient hash implementations # Which makes this process expensive to cache - weights = process(typeof(algo), weightingParams, frequencies, result, nothing, algo.arrayType) + weights = process(typeof(algo), weightingParams, frequencies, algo.sf, result, nothing, algo.arrayType) resultXPU = process(typeof(algo), params, result, algo.arrayType) return resultXPU, weights end diff --git a/src/Algorithms/MultiPatchAlgorithms/MultiPatchPeriodicMotion.jl b/src/Algorithms/MultiPatchAlgorithms/MultiPatchPeriodicMotion.jl index da3964b..1154378 100644 --- a/src/Algorithms/MultiPatchAlgorithms/MultiPatchPeriodicMotion.jl +++ b/src/Algorithms/MultiPatchAlgorithms/MultiPatchPeriodicMotion.jl @@ -76,7 +76,7 @@ function process(algoT::Type{<:MultiPatchReconstructionAlgorithm}, params::Perio FFPos=ffPos_[:,resortedInd[:,1]], mapping=mapping, FFPosSF=ffPos_[:,resortedInd[:,1]], bgCorrection = false, tfCorrection = params.tfCorrection) - weights = process(algoT, params.weightingParams, frequencies, ffOp, nothing, Array) + weights = process(algoT, params.weightingParams, frequencies, sf, ffOp, nothing, Array) return uReco, ffOp, weights end diff --git a/src/Algorithms/SinglePatchAlgorithms/SinglePatchAlgorithm.jl b/src/Algorithms/SinglePatchAlgorithms/SinglePatchAlgorithm.jl index b454a7e..3ae3195 100644 --- a/src/Algorithms/SinglePatchAlgorithms/SinglePatchAlgorithm.jl +++ b/src/Algorithms/SinglePatchAlgorithms/SinglePatchAlgorithm.jl @@ -38,8 +38,8 @@ function prepareSystemMatrix(reco::SinglePatchReconstructionParameter{L,S}) wher return freqs, sf, grid, reco.arrayType end -function prepareWeights(reco::SinglePatchReconstructionParameter{L,S,arrT,SP,R,W}, freqs, sf) where {L, S, arrT, SP, R, W<:AbstractWeightingParameters} - return process(AbstractMPIRecoAlgorithm, reco.weightingParams, freqs, sf, nothing, reco.arrayType) +function prepareWeights(reco::SinglePatchReconstructionParameter{L,S,arrT,SP,R,W}, freqs, S_) where {L, S, arrT, SP, R, W<:AbstractWeightingParameters} + return process(AbstractMPIRecoAlgorithm, reco.weightingParams, freqs, reco.sf, S_, nothing, reco.arrayType) end Base.lock(algo::SinglePatchReconstructionAlgorithm) = lock(algo.output) diff --git a/src/SystemMatrix/SystemMatrix.jl b/src/SystemMatrix/SystemMatrix.jl index baebb81..e8fcba5 100644 --- a/src/SystemMatrix/SystemMatrix.jl +++ b/src/SystemMatrix/SystemMatrix.jl @@ -67,8 +67,9 @@ function process(t::Type{<:AbstractMPIRecoAlgorithm}, params::DenseSystemMatixLo return frequencies, process(t, params, sf, frequencies)... end function process(t::Type{<:AbstractMPIRecoAlgorithm}, params::DenseSystemMatixLoadingParameter, sf::MPIFile, frequencies::Vector{CartesianIndex{2}}) + @info "Start Loading SM" S, grid = getSF(sf, frequencies, nothing; toKwargs(params, default = Dict{Symbol, Any}(:tfCorrection => rxHasTransferFunction(sf)))...) - @info "Loading SM" + @info "Done Loading SM" return S, grid end diff --git a/src/Weighting.jl b/src/Weighting.jl index 3c40775..a286134 100644 --- a/src/Weighting.jl +++ b/src/Weighting.jl @@ -2,8 +2,8 @@ export getWeights, WeightingType, setFreqToZero export AbstractWeightingParameters abstract type AbstractWeightingParameters <: AbstractMPIRecoParameters end -function process(type::Type{<:AbstractMPIRecoAlgorithm}, params::AbstractWeightingParameters, freqs, op = nothing, u = nothing, arrayType = Array) - result = process(type, params, freqs, op, u) +function process(type::Type{<:AbstractMPIRecoAlgorithm}, params::AbstractWeightingParameters, freqs, sf = nothing, S = nothing, u = nothing, arrayType = Array) + result = process(type, params, freqs, sf, S, u, arrayType) if !isnothing(result) result = map(real(eltype(algo.S)), result) end @@ -40,6 +40,16 @@ function process(::Type{<:AbstractMPIRecoAlgorithm}, params::WhiteningWeightingP return weights end +export SMWhiteningWeightingParameters +Base.@kwdef struct SMWhiteningWeightingParameters <: AbstractWeightingParameters + # NOP +end +function process(::Type{<:AbstractMPIRecoAlgorithm}, params::SMWhiteningWeightingParameters, freqs::Vector{CartesianIndex{2}}, sf, args...) + noise = noiseEstimate(sf,frequencies=freqs) + weights = minimum(abs.(vec(noise))) ./ abs.(vec(noise)) + return weights +end + export RowNormWeightingParameters Base.@kwdef struct RowNormWeightingParameters <: AbstractWeightingParameters # NOP diff --git a/test/Reconstruction.jl b/test/Reconstruction.jl index af44ac6..be440e1 100644 --- a/test/Reconstruction.jl +++ b/test/Reconstruction.jl @@ -115,6 +115,10 @@ c8 = reconstruct("SinglePatch", b; params...) exportImage(joinpath(imgdir, "Reconstruction8.png"), Array(c8[1,:,:,1,1])) @test compareImg("Reconstruction8.png") + + params[:weightingParams] = SMWhiteningWeightingParameters() + c8a = reconstruct("SinglePatch", b; params...) + @test isapprox(arraydata(c8), arraydata(c8a)) c9a = reconstruct("SinglePatch", b; params..., reg = [L2Regularization(0.0)], weightingParams = NoWeightingParameters()) c9b = reconstruct("SinglePatch", b; params..., reg = [L2Regularization(0.0)], weightingParams = RowNormWeightingParameters())