API for Solvers
This page contains documentation of the public API of the AbstractImageReconstruction. In the Julia REPL one can access this documentation by entering the help mode with ?
Algorithm and Parameters
AbstractImageReconstruction.AbstractImageReconstructionAlgorithm
— TypeAbstractImageReconstructionAlgorithm
Abstract type for image reconstruction algorithms. Must implement put!
and take!
functions. Serialization expects a constructor with a single AbstractImageReconstructionParameters
argument.
AbstractImageReconstruction.reconstruct
— Functionreconstruct(algo::T, u) where {T<:AbstractImageReconstructionAlgorithm}
Reconstruct an image from input u
using algorithm algo
. The àlgo
will be lock
ed until the result is available or an error occurs.
Base.put!
— Methodput!(algo::AbstractImageReconstructionAlgorithm, inputs...)
Perform image reonstruction with algorithm algo
on given ìnputs
. Depending on the algorithm this might block. Result is stored and can be retrieved with take!
.
Base.take!
— Methodtake!(algo::AbstractImageReconstructionAlgorithm)
Remove and return a stored result from the algorithm algo
. Blocks until a result is available.
Base.lock
— Methodlock(algo::AbstractImageReconstructionAlgorithm)
Acquire a lock on the algorithm algo
. If the lock is already acquired, wait until it is released.
Each lock
must be matched with a unlock
.
Base.unlock
— Methodunlock(algo::AbstractImageReconstructionAlgorithm)
Release a lock on the algorithm algo
.
Base.isready
— Methodisready(algo::AbstractImageReconstructionAlgorithm)
Determine if the algorithm algo
has a result available.
Base.wait
— Methodwait(algo::AbstractImageReconstructionAlgorithm)
Wait for a result to be available from the specified algo
.
AbstractImageReconstruction.AbstractImageReconstructionParameters
— TypeAbstractImageReconstructionParameters
Abstract type for image reconstruction parameters. An algorithm consists of one ore more process
steps, each can have its own parameters. Parameters can be arbitrarly nested.
AbstractImageReconstruction.process
— Functionprocess(algo::Union{A, Type{A}}, param::AbstractImageReconstructionParameters, inputs...) where A <: AbstractImageReconstructionAlgorithm
Process inputs
with algorithm algo
and parameters param
. Returns the result of the processing step. If not implemented for an instance of algo
, the default implementation is called with the type of algo
.
AbstractImageReconstruction.parameter
— Functionparameter(algo::AbstractImageReconstructionAlgorithm)
Return the parameters of the algorithm algo
.
RecoPlan
AbstractImageReconstruction.RecoPlan
— TypeRecoPlan{T <: Union{AbstractImageReconstructionParameters, AbstractImageReconstructionAlgorithm}}
Configuration template for an image reconstruction algorithm or paremeters of type T
. A RecoPlan{T}
has the same properties with type checking as T
with the exception that properties can be missing and nested algorithms and parameters can again be RecoPlan
s.
Plans can be nested and form a tree. A parent plan can be accessed with parent
and set with parent!
. Algorithms and parameters can be converted to a plan with toPlan
.
Plans feature serialization with toTOML
, toPlan
and loadPlan
and the ability to attach callbacks to property changes with Òbservables
and on
.
Base.propertynames
— Methodpropertynames(plan::RecoPlan{T}) where {T}
Return a tupel of configurable properties of T
. Unlike propertynames(T)
this does not include properties starting with _
.
Base.getproperty
— Methodgetproperty(plan::RecoPlan{T}, name::Symbol) where {T}
Get the property name
of plan
. Equivalent to plan.name
.
Base.getindex
— Methodgetindex(plan::RecoPlan{T}, name::Symbol) where {T}
Return the Observable
for the name
property of plan
. Equivalent to plan[name]
.
Base.setproperty!
— Methodsetproperty!(plan::RecoPlan{T}, name::Symbol, x::X) where {T, X}
Set the property name
of plan
to x
. Equivalent to plan.name = x
. Triggers callbacks attached to the property.
AbstractImageReconstruction.setAll!
— FunctionsetAll!(plan::RecoPlan{T}, name::Symbol, x) where {T<:AbstractImageReconstructionParameters}
Recursively set the property name
of each nested RecoPlan
of plan
to x
.
AbstractImageReconstruction.clear!
— Functionclear!(plan::RecoPlan{T}, preserve::Bool = true) where {T<:AbstractImageReconstructionParameters}
Clear all properties of plan
. If preserve
is true
, nested RecoPlan
s are preserved.
Base.ismissing
— Methodismissing(plan::RecoPlan, name::Symbol)
Indicate if the property name
of plan
is missing.
Observables.on
— Methodon(f, plan::RecoPlan, property::Symbol; kwargs...)
Adds function f
as listener to property
of plan
. The function is called whenever the property is changed with setproperty!
.
Observables.off
— Methodoff(plan::RecoPlan, property::Symbol, f)
Remove f
from the listeners of property
of plan
.
AbstractImageReconstruction.build
— Functionbuild(plan::RecoPlan{T}) where {T}
Recursively build a plan from a RecoPlan
by converting all properties to their actual values using keyword argument constructors.
AbstractImageReconstruction.toPlan
— FunctiontoPlan(param::Union{AbstractImageReconstructionParameters, AbstractImageReconstructionAlgorithm})
Convert an AbstractImageReconstructionParameters
or AbstractImageReconstructionAlgorithm
to a (nested) RecoPlan
.
AbstractImageReconstruction.savePlan
— FunctionsavePlan(file::Union{AbstractString, IO}, plan::RecoPlan)
Save the plan
to the file
in TOML format. See also loadPlan
, toTOML
, toDict
.
AbstractImageReconstruction.loadPlan
— FunctionloadPlan(filename::Union{AbstractString, IO}, modules::Vector{Module})
Load a RecoPlan
from a TOML file. The modules
argument is a vector of modules that contain the types used in the plan. After loading the plan, the listeners are attached to the properties using loadListener!
.
AbstractImageReconstruction.loadListener!
— FunctionloadListener!(plan, name::Symbol, dict, modDict)
Load a listener from dict
and attach it to property name
of plan
Base.parent
— Methodparent(plan::RecoPlan)
Return the parent of plan
.
AbstractImageReconstruction.parent!
— Methodparent!(plan::RecoPlan, parent::RecoPlan)
Set the parent of plan
to parent
.
AbstractImageReconstruction.parentproperty
— Functionparentproperty(plan::RecoPlan)
Return the property name of plan
in its parent, s.t. getproperty(parent(plan), parentproperty(plan)) === plan
. Return nothing
if plan
has no parent.
AbstractImageReconstruction.parentproperties
— Functionparentproperties(plan::RecoPlan)
Return a vector of property names of plan
in its parent, s.t. getproperty(parent(plan), last(parentproperties(plan))) === plan
. Return an empty vector if plan
has no parent.
Miscellaneous
AbstractImageReconstruction.LinkedPropertyListener
— TypeLinkedPropertyListener(fn, target::RecoPlan, targetProp, source::RecoPlan, sourceProp)
Connect two properties of RecoPlans
. Set target.targetProp
to fn(source.sourceProp)
whenever source.sourceProp
changes and target.targetProp
was not changed outside of the listener.
AbstractImageReconstruction.ProcessResultCache
— TypeProcessResultCache(params::AbstractImageReconstructionParameters; maxsize = 1, kwargs...)
Cache of size maxsize
for the result of process
methods. The cache is based on the hash
of the inputs of the process
function. Cache is shared between all algorithms constructed from the same plan. The cache is transparent for properties of the underlying parameter. Cache can be invalidated by calling empty!
on the cache.
Base.hash
— Methodhash(parameter::AbstractImageReconstructionParameters, h)
Default hash function for image reconstruction paramters. Uses nameof
the parameter and all fields not starting with _
to compute the hash.
AbstractImageReconstruction.toKwargs
— MethodtoKwargs(value::AbstractImageReconstructionParameters; kwargs...)
Convert a AbstractImageReconstructionParameters
to a Dict{Symbol, Any}
of each property.
Optional keyword arguments:
- flatten::Vector{DataType}: Types to flatten, per default only
AbstractImageReconstructionParameters
are flattened. - ignore::Vector{Symbol}: Properties to ignore.
- default::Dict{Symbol, Any}: Default values for properties that are missing.
- overwrite::Dict{Symbol, Any}: Overwrite values for properties.
AbstractImageReconstruction.fromKwargs
— FunctionfromKwargs(type::Type{T}; kwargs...) where {T}
Create a new instance of type
from the keyword arguments. Only properties that are part of type
are considered.
AbstractImageReconstruction.toDict
— FunctiontoDict(value)
Recursively convert value
to a Dict{String, Any}
using toDict!
.
AbstractImageReconstruction.toDict!
— FunctiontoDict!(dict, value)
Extracts metadata such as the module and type name from value
and adds it to dict
. The value-representation of value
is added using toDictValue!
.
AbstractImageReconstruction.toDictValue
— FunctiontoDictValue(value)
Transform value
to a value-representation in a dict that can later be serialized as a TOML file.
AbstractImageReconstruction.toDictValue!
— FunctiontoDictValue!(dict, value)
Extracts the value-representation of value
and adds it to dict
. The default implementation for structs with fields adds each field of the argument as a key-value pair with the value being provided by the toDictValue
function.
toDictValue!(dict, plan::RecoPlan)
Adds the properties of plan
to dict
using toDictValue
for each not missing field. Additionally, adds each listener::AbstractPlanListener to the dict.