Skip to content

Commit

Permalink
Merge pull request #30 from MagneticParticleImaging/JS/fix-warnings
Browse files Browse the repository at this point in the history
Fix warnings due to removed parameters
  • Loading branch information
nHackel authored Apr 30, 2024
2 parents e34e1c7 + 2394ecc commit 2b910f0
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions src/LeastSquares.jl
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,9 @@ function process(t::Type{<:AbstractMPIRecoAlgorithm}, params::LeastSquaresParame
u = reshape(u, M, L)
c = zeros(N, L)

args = toKwargs(params.solverParams)
reg = prepareRegularization(params.reg, params)
reg, args = prepareRegularization(params.reg, params)
args[:reg] = reg
args[:sparseTrafo] = params.op

solv = createLinearSolver(params.solver, params.S; args..., weights = params.weights)

for l=1:L
Expand All @@ -54,23 +53,34 @@ function process(t::Type{<:AbstractMPIRecoAlgorithm}, params::LeastSquaresParame
end

function prepareRegularization(reg::Vector{R}, regLS::LeastSquaresParameters) where R<:AbstractRegularization
args = toKwargs(regLS.solverParams)
params = regLS.solverParams

result = AbstractRegularization[]
push!(result, reg...)

# Add further constraints
if params.enforceReal && params.enforcePositive
push!(result, PositiveRegularization())
if !any([item isa PositiveRegularization for item reg])
push!(result, PositiveRegularization())
end

filter!(x -> !(x isa RealRegularization), reg)
elseif params.enforceReal
push!(result, RealRegularization())
if !any([item isa RealRegularization for item reg])
push!(result, RealRegularization())
end
end

pop!(args, :enforceReal)
pop!(args, :enforcePositive)

# Add sparsity op
if !isnothing(regLS.op)
result = map(r -> TransformedRegularization(r, regLS.op), result)
end
return result

return result, args
end
#=
function process(t::Type{<:AbstractMPIRecoAlgorithm}, params::LeastSquaresParameters, threadInput::MultiThreadedInput)
Expand Down

0 comments on commit 2b910f0

Please sign in to comment.