IntraCUSUM¶
class IntraCUSUM(settings: Optional[dict] = None)
Bases: CUSUM
Abstract base class to analyze and flag the start and end times of regions of interest in a timeseries for further analysis.
Public Methods¶
- IntraCUSUM.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 fitter 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. Seeget_empty_settings()for the structure of the dict and whatType,Value,Min,Max,OptionsandUnitsmean in it, and for the reserved keys the GUI builds file pickers from.The
super()call supplies the mandatory"MetaEventLoader"key, which is how this plugin is wired to its data source.The keys this plugin adds:
Step Size(pA),Sensitivity,Rise Time(us) andMax Sublevels- as inCUSUM, which this fitter extends.Intraevent Threshold(pA) - the depth below the event’s own carrier level at which an intra-event excursion is recognised, as opposed to a sublevel.Intraevent Hysteresis(pA) - how far the signal must come back up before that excursion is considered over, so noise at the threshold does not split one excursion into several.
- Parameters:
globally_available_plugins (Optional[Dict[str, List[str]]]) – a dict containing all data plugins that exist to date, keyed by metaclass. Must include “MetaEventLoader” as a key, with explicitly set Type MetaEventLoader.
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:
Private Methods¶
- IntraCUSUM._define_event_metadata_types() Dict[str, Type[int | float | str | bool]]¶
Build a dict of metadata along with associated datatypes for use by the database writer downstream. Keys must match columns defined in _populate_event_metadata() All of this metadata must be populated during fitting. Options for dtypes are int, float, str, bool
- IntraCUSUM._define_event_metadata_units() Dict[str, str | None]¶
Build a dict of metadata units, or None if unitless. Keys must match columns defined in _populate_event_metadata() All of this metadata must be populated during fitting.
- IntraCUSUM._populate_event_metadata(data: ndarray[tuple[int, ...], dtype[float64]], samplerate: float, baseline_mean: float | None, baseline_std: float | None, sublevel_metadata: Dict[str, List[int | float | number]]) Dict[str, int | float | str | bool]¶
Assemble a list of metadata to save in the event database later. Note that keys ‘start_time_s’ and ‘index’ are already handled in the base class and should not be touched here.
- Parameters:
data (npt.NDArray[np.float64]) – an array of data from which to extract the locations of sublevel transitions
samplerate (float) – the sampling rate
baseline_mean (Optional[float]) – the local mean value of the baseline current
baseline_std (Optional[float]) – the local standard deviation of the baseline current
sublevel_metadata (Dict[str, List[Numeric]]) – the dict of sublevel metadata built by self._populate_sublevel_metadata()
- Returns:
a dict of event metadata values
- Return type:
- Raises:
ValueError – if baseline_mean is not provided, since intra-event thresholds cannot be computed without it