pyfli.sp_analysis.base_reconstructor#

Define shared scaffolding for four-dimensional single-pixel reconstruction solvers.

This module belongs to pyfli.sp_analysis and is part of PyFLI single-pixel camera basis generation, acquisition simulation, and reconstruction solvers. Public API includes classes BaseReconstructor.

Classes

BaseReconstructor(h, w, t, lam[, ...])

Provide shared shape handling and pattern bookkeeping for four-dimensional single- pixel reconstruction.

class BaseReconstructor(h, w, t, lam, differential=True, n_workers=None)[source]#

Bases: ABC

Provide shared shape handling and pattern bookkeeping for four-dimensional single- pixel reconstruction. Subclasses implement concrete inverse solvers.

Parameters:
  • h (np.ndarray) – Image height or spatial dimension used by reconstruction solvers.

  • w (np.ndarray) – Image width or spatial dimension used by reconstruction solvers.

  • t (np.ndarray) – Temporal sample axis used by reconstruction solvers.

  • lam (np.ndarray) – Wavelength or spectral axis used by reconstruction solvers.

  • differential (bool) – Whether the sensing basis uses differential pattern pairs.

  • n_workers (int | None) – Number of worker processes or threads used by parallel solvers.

static dmd_to_sensing_matrix(dmd_patterns, differential)[source]#

Recover the sensing matrix A from DMD {0,1} patterns.

differential=True:

dmd_patterns : (2M, N) stacked [P_pos ; P_neg] in {0, 1} Returns : (M, N) Hadamard matrix H = 2*P_pos - 1 in {-1, +1}

differential=False:
dmd_patterns(M, N) patterns in [0, 1] (Hadamard single-pass

or Fourier DCT), used directly as the sensing matrix.

Returns : (M, N) same array as float64

Parameters:
Return type:

Any

abstractmethod reconstruct_slice(y_slice, A)[source]#

Reconstruct one (H, W) frame. y_slice : (M,) measurements for one (t, lambda) slice A : (M, N) sensing matrix (already converted from DMD patterns) Returns : (H, W)

Parameters:
Return type:

None

reconstruct_4d(measurements, dmd_patterns)[source]#

Reconstruct the full 4D (x, y, T, Lambda) cube from DMD measurements.

Parameters:
  • measurements ((2M, T, Lambda) if differential else (M, T, Lambda)) – Raw single-pixel SPAD detector measurements.

  • dmd_patterns ((2M, H*W) if differential else (M, H*W)) – DMD-compatible {0,1} patterns from BasisPatterns.generate_hadamard() or BasisPatterns.generate_fourier_dct().

Returns:

cube

Return type:

(H, W, T, Lambda)