pyfli.io.data_ops_static#

Provide static readers and corrections for SPAD, TIFF, MAT, SDT, NumPy, and text data.

This module belongs to pyfli.io and is part of PyFLI detector importers, file readers, saving helpers, and processed-data loaders. Public API includes classes StaticDataOps.

Classes

StaticDataOps()

Group static low-level readers and correction routines for detector files.

class StaticDataOps[source]#

Bases: object

Group static low-level readers and correction routines for detector files. The methods cover pile-up correction, hot-pixel interpolation, and MAT, SDT, PTU, TIFF, NumPy, text, ASC, and SPAD HDF5 loading.

static pileup_correction(data, bit_size=10)[source]#

Applies pileup correction to the photon counting data. Formula: corrected = -ln(1 - (measured / max_counts)) * max_counts

Parameters:
Return type:

Any

static spad_hdf5_read(fname, gate_prefix=None, pile_up=True, bit_size=10)[source]#

Read SPAD HDF5 data and normalize it to (H, W, T).

The reader discovers split gate datasets or stacked 3D cubes from HDF5 structure and metadata instead of requiring a fixed “Gate Images” group. gate_prefix remains available as a backwards-compatible discovery hint for existing SwissSPAD2 and SwissSPAD3 callers.

Parameters:
  • fname (str) – HDF5 file containing SPAD image data.

  • gate_prefix (str | None) – Optional split-gate dataset prefix used as a discovery hint.

  • pile_up (bool) – Whether pile-up correction should be applied after loading.

  • bit_size (int) – Detector digitization bit depth used for pile-up correction.

Returns:

SPAD image cube with shape (H, W, T) and float32 dtype.

Return type:

np.ndarray

static hotpixel_correct(data_3d, hp_map)[source]#

Replace each pixel flagged in hp_map with the nanmedian of its 3×3 spatial neighbourhood per time gate. hp_map : 2D bool array (H, W) data_3d : float array (H, W, T)

Parameters:
Return type:

Any

static load_hp_image(hp_path, ref_shape)[source]#

Load a hot pixel mask image (PNG / JPEG / TIFF) → bool (H, W). Auto-rotated if image is (W, H) instead of (H, W). ref_shape : (H, W) tuple from the corresponding data array.

Parameters:
Return type:

Any

static apply_interpolation_mask(data_3d, hp_path=None)[source]#

Identifies hot pixels from a mask file and replaces them with the nanmedian of their 3×3 neighbourhood (excluding the hot pixel itself). Signature unchanged — safe to call from data_operations.py.

Parameters:
Return type:

Any

static load_mat_file(path)[source]#

Load mat file.

Parameters:

path (str) – Filesystem path loaded or saved by the routine.

Returns:

Data array loaded from a MATLAB file.

Return type:

np.ndarray

static load_sdt_file(path)[source]#

Load sdt file.

Parameters:

path (str) – Filesystem path loaded or saved by the routine.

Returns:

Data array loaded from a Becker-Hickl SDT file.

Return type:

np.ndarray

static load_ptu_file(path, channel=0)[source]#

Load ptu file.

Parameters:
  • path (str) – Filesystem path loaded or saved by the routine.

  • channel (int) – Detector channel index to read or decode.

Returns:

Data array loaded from a PicoQuant PTU file. Image-mode (FLIM) files are decoded to a (H, W, T) decay cube: repeated frames are integrated and channel selects one detector channel. Point/non-imaging PTU files fall back to a single decay trace tiled across a 512 x 512 spatial grid, matching load_txt_file()/load_asc_file().

Return type:

np.ndarray

static load_tiff_file(path)[source]#

Load tiff file.

Parameters:

path (str) – Filesystem path loaded or saved by the routine.

Returns:

Data array loaded from a TIFF file.

Return type:

np.ndarray

static load_npy_file(path)[source]#

Load npy file.

Parameters:

path (str) – Filesystem path loaded or saved by the routine.

Returns:

Object produced by load npy file.

Return type:

Any

static load_txt_file(path, target_spatial=(512, 512))[source]#

Load txt file.

Parameters:
  • path (str) – Filesystem path loaded or saved by the routine.

  • target_spatial (tuple[int, ]) – Target spatial shape used when loading text data.

Returns:

Data array loaded from a text file.

Return type:

np.ndarray

static load_asc_file(path, target_spatial=(512, 512))[source]#

Load asc file.

Parameters:
  • path (str) – Filesystem path loaded or saved by the routine.

  • target_spatial (tuple[int, ]) – Target spatial shape used when loading text data.

Returns:

Object produced by load asc file.

Return type:

Any

static SS3HDF5read(fname, pileCorr=True, hot_pixels=True, hp_path=None)[source]#

Read SwissSPAD3 HDF5 data through the shared SPAD loader.

Parameters:
Return type:

Any