- rewrote some of the SSE functions to use einsum and more idiomatic python
- decided that sse init() should store the psf ffts for use in later computation
- created a Github repo
Cost is
We approximate forward model as 2D circular convolutions so that matrices can be diagonalized and we end up with faster computation.
Assume 2 sources.
- Initialization
Intialization code before CSBS begins
- Iterate
Repeat N times
- for each row of
$A$ - temporarily remove row from
$A$ and compute cost of this reduced$A$
- temporarily remove row from
- permanently remove whichever row of
$A$ incurred the lowest cost
- for each row of
Note: 1 row of A is a row vector of convolution matrices, length
We make a number of optimizations when calculating the SSE cost to make it computationally feasible.
- store “compressed” form of diagonal matrices, PSFs
$Γ_{ij}$ and$Λ$ are diagonal matrices of dimension$(m ⋅ n) × (m ⋅ n)$ . we store the diagonal elements only in a matrix of size$m × n$ We store the PSFs (and DFTs) in their 2D form to avoid flattening/reshaping. Consequency, we have special multiplication and inversion functions which operate on these compressed matrices directly.
- update $Γ = \begin{bmatrix} Γ_{11} & Γ_{12} \ Γ_{21} & Γ_{22} \end{bmatrix}$ instead of recomputing it
$Γ$ changes very little between CSBS iterations. We subtract off the contribution from the removed row of$A$ at the end of each CSBS iteration - dont store duplicate rows in
$A$ $A$ contains many duplicate rows to represent repeated measurements at one measurement plane. We only store one copy of a row in$A$ along with a counter of how many copies of this row are left - use block matrix inversion formula for inverting $\bar{Γ} = \begin{bmatrix} Γ_{11} - λ Λ & Γ_{12} \ Γ_{21} Λ & Γ_{22} - λ \end{bmatrix}$
The elements of
$\bar{Γ}$ are diagonal matrices. We use the block matrix inversion formula to invert it efficiently.
- Initialization
- precompute PSF ffts
- calculate full
$Γ$ matrix and$Λ$
- Iterate
- for each row of
$A$ - temporarily remove row from
$A$ and compute cost:$\trace (Σ_e)$
- temporarily remove row from
- permanently remove whichever row of
$A$ incurred the lowest cost - update
$Γ$ by subtracting contribution from removed row
- for each row of
- fixed block_inv to work with even sized inputs
- added iteration_end function to cost_module
- derived
$Dx^T ⋅ Dx + Dy^T ⋅ Dy$
Then the compressed form of
where
Similarly for
where
Using the property
Substituting back in,
Let
If we let
Today we began work on a mathematical framework to formalize the constraints and goals of the plane selection/exposure time problem.
Parameters we control in the problem.
- exposure time
$τ_k$ - measurement plane locations
$d_k$ - measurement plane transition time
$Δ_j$
Problem optimization goals.
- high SNR (maximize
$τ_k$ ) - Minimize temporal artifacts (minimize
$τ_k$ , minimize$Δ_j$ ) - Capture measurement diversity (maximize order of
$d_k$ )
-------------- -----------------------------
source---+---| microphone |-------| system processing ----+---|-------
| -------------- ------------------------|----
n_2 n_3
-
$n(Ax)$ - shot noise. large input signal increases self interference -
$n_2$ - dark noise (environmental noise). e.g. computer fan -
$n_3$ - read noise (system noise). e.g. ADC noise, self interference
We are trying to image a dynamically changing object. Hence, we cannot keep exposure times very long. We also need to consider the transition time of the detector between measurement planes. Here, we formulate these, and set a condition to satisfy:
- number of measurement planes :
$K$ - exposure time at each measurement plane :
$t_{exp}$ - detector transition time from
$i^{th}$ to$(i+1)^{th}$ measurement plane:$t_{tr}^{i}$ - the time for which the dynamic object can be considered still:
$t_{obj}$
The total time to complete taking measurements should not exceed
$K t_{exp} + ∑_{i=1}^{K-1} t_{tr}^{i} \leq t_{obj}$
Wrote some code to visualize output from CSBS, shown below.
I noticed that with a poor choice of lambda, CSBS sometimes completely kills off other focused measurement planes.