ThresholdBlockageFinder

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

Bases: ClassicBlockageFinder

Subclass of ClassicBlockageFinder that imposes much tighter bounds on the start and end time flagged in the output.

This event finder calls the start of the event at the first threshold crossing, and the end of the event at the corresponding threshold crossing at the end through backtracking.

Public Methods

ThresholdBlockageFinder.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 (σ) - how far below the fitted baseline the signal must fall for an event to start, in baseline standard deviations rather than the pA ClassicBlockageFinder takes. That is the one setting that differs, and it makes the threshold follow the noise rather than a fixed current.

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

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

ThresholdBlockageFinder._find_events_in_chunk(data: ndarray[tuple[int, ...], dtype[float64]], mean: float, std: float, offset: int, entry_state: bool = False, first_chunk: bool = False) → Tuple[List[int], List[int], bool]

Find the start and end points of events in the provided chunk of data and returns them as separate lists, along with a boolean indicating whether or not the chunk ended in the middle of an event. Should backtrack data to the baseline, since padding logic will assume that it can use data right up to the start and end found as baseline by default

Parameters:
  • data (npt.NDArray[np.float64]) – Chunk of timeseries data to analyze. Assume it is rectified so that a blockage will always represent a reduction in absolute value.

  • mean (float) – Mean of the baseline on the given chunk. Must be positive.

  • std (float) – Standard deviation of the baseline on the given chunk

  • offset (int) – the index of the start of the chunk in the global dataset

  • entry_state (bool) – Bool indicating whether we start in the middle of an event (True) or not (False)

  • first_chunk (bool) – Bool indicating whether this is the first chunk of data in the series to be analyzed

Raises:

ValueError – If event_params are invalid.

Returns:

Lists of event start and end indices, and boolean entry state.

Return type:

Tuple[List[int], List[int], bool]