trinidi.reconstruct#
Some reconstruction functions and classes.
Functions
|
Creates the (N_b, N_t) background basis matrix |
Classes
|
DensityEstimator class |
|
Pseudo forward operator |
|
Pseudo forward operator |
|
Pseudo forward operator F(Z) = ε (Φ * Q(Z) + B_s) |
|
Pseudo forward operator |
|
Pseudo forward operator |
|
A sum of two functionals. |
|
ParameterEstimator class for nuisance parameters. |
|
|
|
ProjectionRegion class. |
- class trinidi.reconstruct.ProjectionRegion(projection_mask)[source]#
Bases:
objectProjectionRegion class.
This class is used to handle the Ω regions indicating the regions where the sample image has no areal density, or uniformly dense areal density. Used for averaging over many pixels.
Initialize a ProjectionRegion object.
If the counting data, Y, has shape projection_shape + (N_A,), the projection_mask array must have size projection_shape + (1,).
- Parameters:
projection_mask (boolean or binary array) – projection_mask array used for averaging.
- class trinidi.reconstruct.FunctionalSum(functional1, functional2)[source]#
Bases:
FunctionalA sum of two functionals.
- class trinidi.reconstruct.Forward_zα1α2θ(input_shape, y_o, D, R, P, jit=True)[source]#
Bases:
OperatorPseudo forward operator
f(z,ε,μ,θ) = ε[ {c_o - b(θ)} * q(z) + μ b(θ)]
c_o = (ω’ C_o) / (ω’v) q(z) = exp(-z D) R b(θ) = exp(θ P)
This gets fitted to c_s = (ω’ C_s) / (ω’v)
- Parameters:
input_shape – Shape of input array.
output_shape – Shape of output array. Defaults to
None. IfNone, output_shape is determined by evaluating self.__call__ on an input array of zeros.eval_fn – Function used in evaluating this
Operator. Defaults toNone. Required unless __init__ is being called from a derived class with an _eval method.input_dtype – dtype for input argument. Defaults to
float32. If theOperatorimplements complex-valued operations, this must be a complex dtype (typicallycomplex64) for correct adjoint and gradient calculation.output_dtype – dtype for output argument. Defaults to
None. IfNone, output_dtype is determined by evaluating self.__call__ on an input array of zeros.jit (
bool) – IfTrue, callOperator.jiton thisOperatorto jit the forward, adjoint, and gram functions. Same as callingOperator.jitafter theOperatoris created.
- Raises:
NotImplementedError – If the eval_fn parameter is not specified and the _eval method is not defined in a derived class.
- class trinidi.reconstruct.Forward_zα1α2θ_arr(N_m, y_o, D, R, P, jit=True)[source]#
Bases:
objectPseudo forward operator
f(z,ε,μ,θ) = ε[ {c_o - b(θ)} * q(z) + μ b(θ)]
c_o = (ω’ C_o) / (ω’v) q(z) = exp(-z D) R b(θ) = exp(θ P)
This gets fitted to c_s = (ω’ C_s) / (ω’v)
- class trinidi.reconstruct.Forward_0α1α2θ(input_shape, y_o, P, jit=True)[source]#
Bases:
OperatorPseudo forward operator
- f(0,ε,μ,θ) = ε[ {c_o - b(θ)} * q(z) + μ b(θ)]
= ε[ c_o + (μ-1) b(θ)]
c_o = (ω’ C_o) / (ω’v) q(0) = exp(-z D) R = 1 b(θ) = exp(θ P)
This gets fitted to c_s = (ω’ C_s) / (ω’v)
- Parameters:
input_shape – Shape of input array.
output_shape – Shape of output array. Defaults to
None. IfNone, output_shape is determined by evaluating self.__call__ on an input array of zeros.eval_fn – Function used in evaluating this
Operator. Defaults toNone. Required unless __init__ is being called from a derived class with an _eval method.input_dtype – dtype for input argument. Defaults to
float32. If theOperatorimplements complex-valued operations, this must be a complex dtype (typicallycomplex64) for correct adjoint and gradient calculation.output_dtype – dtype for output argument. Defaults to
None. IfNone, output_dtype is determined by evaluating self.__call__ on an input array of zeros.jit (
bool) – IfTrue, callOperator.jiton thisOperatorto jit the forward, adjoint, and gram functions. Same as callingOperator.jitafter theOperatoris created.
- Raises:
NotImplementedError – If the eval_fn parameter is not specified and the _eval method is not defined in a derived class.
- class trinidi.reconstruct.Forward_0α1α2θ_arr(N_m, y_o, P, jit=True)[source]#
Bases:
objectPseudo forward operator
- f(0,ε,μ,θ) = ε[ {c_o - b(θ)} * q(z) + μ b(θ)]
= ε[ c_o + (μ-1) b(θ)]
c_o = (ω’ C_o) / (ω’v) q(0) = exp(-z D) R = 1 b(θ) = exp(θ P)
This gets fitted to c_s = (ω’ C_s) / (ω’v)
- trinidi.reconstruct.background_basis(N_b, N_t)[source]#
Creates the (N_b, N_t) background basis matrix
- class trinidi.reconstruct.Preconditioner(D)[source]#
Bases:
object(Z) (D) = (ZC) (C_inverse D) original conditioned where (C_inverse D) has unit norm rows
C = np.diag(np.diag(np.matmul(D, D.T)))**0.5
- class trinidi.reconstruct.ParameterEstimator(Y_o, Y_s, R, D, Ω_z, Ω_0=None, N_b=5, non_negative_z=False, verbose=False, dispperiod=10)[source]#
Bases:
objectParameterEstimator class for nuisance parameters.
projection_shapeis the shape of the detector so usually this will be(N_pixels_x, N_pixels_y)but it may be any shape including singleton shape.N_pnumber of projections,np.prod(projection_shape) = N_p.Y_o,Y_smeasurements have shapeprojection_shape + (N_A,)N_Ais the number of measured TOF bins (TOA’s)Dhas shape(N_F, N_A)N_Fis the number of theoretical TOF bins. \(N_F \geq N_A\)ω_sz,ω_s0have shapeprojection_shape + (1,). \(ω_sz^\top\) has shape(1,) + projection_shape.Rhas shape(N_F, N_A).- Parameters:
Y_o – Open beam measurement.
Y_s – Sample measurement.
D – Cross section dictionary.
ω_sz – Uniformly dense region averaging vector.
ω_s0 – Open beam region averaging vector. When None, parameters will be computed equivalent to β=0.
R – Resolution operator of class ResolutionOperator. When None, R is chosen internally as identity operator.
β – Balancing weight between solving equation for ω_sz (β=0), and solving equation for ω_s0 (β infinite). Equal weight when β=1.0 (default).
- class trinidi.reconstruct.Forward_Z(input_shape, α_1, α_2, Φ, B, D, R, jit=True)[source]#
Bases:
OperatorPseudo forward operator F(Z) = ε (Φ * Q(Z) + B_s)
Q(Z) = exp(-Z D) R B_s = μ B
- Parameters:
input_shape – Shape of input array.
output_shape – Shape of output array. Defaults to
None. IfNone, output_shape is determined by evaluating self.__call__ on an input array of zeros.eval_fn – Function used in evaluating this
Operator. Defaults toNone. Required unless __init__ is being called from a derived class with an _eval method.input_dtype – dtype for input argument. Defaults to
float32. If theOperatorimplements complex-valued operations, this must be a complex dtype (typicallycomplex64) for correct adjoint and gradient calculation.output_dtype – dtype for output argument. Defaults to
None. IfNone, output_dtype is determined by evaluating self.__call__ on an input array of zeros.jit (
bool) – IfTrue, callOperator.jiton thisOperatorto jit the forward, adjoint, and gram functions. Same as callingOperator.jitafter theOperatoris created.
- Raises:
NotImplementedError – If the eval_fn parameter is not specified and the _eval method is not defined in a derived class.
- class trinidi.reconstruct.DensityEstimator(Y_s, par, D=None, R=None, non_negative_Z=False, projection_transform=None, dispperiod=10)[source]#
Bases:
objectDensityEstimator class
Initialize an DensityEstimator object.