pyfli.io.utils#

Provide ROI mask loading, hot-pixel detection, and assorted data I/O helpers.

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 DataIOUtils.

Classes

DataIOUtils()

Collect utility methods for ROI loading, mask handling, and hot-pixel detection.

class DataIOUtils[source]#

Bases: object

Collect utility methods for ROI loading, mask handling, and hot-pixel detection. These helpers support detector import and preprocessing workflows.

load_phasors_hdf5(file_path)[source]#

Load phasors hdf5.

Parameters:

file_path (str) – Path to the file being loaded.

Returns:

Tuple containing phasor arrays and metadata read from HDF5.

Return type:

tuple[Any, ]

roiNloader(map_array, file_path, visualize=True)[source]#

Run the ROI nloader routine.

Parameters:
  • map_array (np.ndarray) – Parameter map or mask array being loaded or displayed.

  • file_path (str) – Path to the file being loaded.

  • visualize (bool) – Whether to display the loaded ROI mask.

Returns:

ROI mask or coordinate array loaded from file.

Return type:

np.ndarray

static hot_pixels(background, threshold_sigma=5.0, save_path=None)[source]#

Detect hot pixels from loaded SPAD background data.

Parameters:
  • background (np.ndarray) – Background cube (H, W, T) or stack (N, H, W, T).

  • threshold_sigma (float) – MAD threshold used for hot-pixel detection.

  • save_path (str | None) – Optional path used to save the resulting mask.

Returns:

Hot-pixel map, sum, mean, and median background cubes.

Return type:

tuple[np.ndarray, np.ndarray, np.ndarray, np.ndarray]

detect_hot_pixels(bg_path, threshold_sigma=5.0, save_path=None, gate_group_path=None, gate_prefix=None)[source]#

Detect hot pixels from a SPAD HDF5 file or directory.

Parameters:
  • bg_path (str) – Background HDF5 file or directory.

  • threshold_sigma (float) – MAD threshold used for hot-pixel detection.

  • save_path (str | None) – Optional path used to save the resulting mask.

  • gate_group_path (str | None) – Optional HDF5 gate group.

  • gate_prefix (str | None) – Optional split-gate dataset prefix.

Returns:

Hot-pixel map and background statistics.

Return type:

Any