Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/Algorithms/HandsFreeAlgorithms/HandsFreeSinglePatch.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/Algorithms/MultiPatchAlgorithms/MultiPatchAlgorithm.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions src/Algorithms/SinglePatchAlgorithms/SinglePatchAlgorithm.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 2 additions & 1 deletion src/SystemMatrix/SystemMatrix.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
14 changes: 12 additions & 2 deletions src/Weighting.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions test/Reconstruction.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down
Loading