BoundedBlockageFinder

class BoundedBlockageFinder(settings: Optional[dict] = None)

Bases: ClassicBlockageFinder

Subclass of ClassicBlockageFinder that adds baseline range constraints for event detection.

This event finder enforces a user-defined minimum and maximum baseline range and refines the Gaussian baseline fitting procedure accordingly. It filters data outside the specified baseline window and raises errors if the computed baseline falls outside those bounds.

Public Methods

BoundedBlockageFinder.get_empty_settings(globally_available_plugins: Dict[str, List[str]] | None = None, standalone: bool = False) → Dict[str, Dict[str, Any]]

Declare the settings this event finder exposes, on top of the base contract.

Called by poriscope when the plugin is instantiated or reconfigured, to build the settings dialog and to sanity-check whatever the user enters; the accepted values are then readable through self.settings. See get_empty_settings() for the structure of the dict and what Type, Value, Min, Max, Options and Units mean in it, and for the reserved keys the GUI builds file pickers from.

The super() call supplies the mandatory "MetaReader" key, which is how this plugin is wired to its data source, and "Threshold", which the base declares without a unit because the base loop reads it; this plugin sets the unit.

The keys this plugin adds or configures:

  • Threshold (pA) - how far below the fitted baseline the signal must fall for an event to start.

  • Min Duration / Max Duration (us) - events outside this range are rejected.

  • Min Separation (us) - two events closer together than this are rejected rather than merged.

  • Min Baseline / Max Baseline (pA) - the window the baseline fit is restricted to. Samples outside it never reach the histogram, and a fit whose mean lands outside it is refused rather than reported. This is what separates this finder from ClassicBlockageFinder, which takes its range from the chunk’s own extremes.

Parameters:
  • globally_available_plugins (Optional[Dict[str, List[str]]]) – a dict containing all data plugins that exist to date, keyed by metaclass. Must include “MetaReader” as a key, with explicitly set Type MetaReader.

  • standalone (bool) – False if this is called as part of a GUI, True otherwise. Default False

Returns:

the dict that must be filled in to initialize the filter

Return type:

Dict[str, Dict[str, Any]]

Private Methods

BoundedBlockageFinder._get_baseline_stats(data: ndarray[tuple[int, ...], dtype[float64]]) → tuple[float, float]

Get the local mean and standard deviation for a chunk of data.

Unlike ClassicBlockageFinder, the range is the configured Min Baseline to Max Baseline rather than the chunk’s own extremes, so samples outside it never reach the fit, and a fit that lands outside it is refused rather than reported.

Parameters:

data (npt.NDArray[np.float64]) – Chunk of timeseries data to compute statistics on.

Returns:

Tuple of mean and standard deviation.

Return type:

tuple[float, float]

Raises:

ValueError – if no data is found within the configured baseline range, if a baseline histogram width cannot be estimated, or if the fitted baseline falls outside the configured Min/Max Baseline bounds

BoundedBlockageFinder._validate_settings(settings: dict) → None

Validate that the settings dict contains the correct information for use by the subclass.

Parameters:

settings (dict) – Parameters for event detection.

Raises:

ValueError – If the settings dict does not contain the correct information.