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=None, standalone=False)

Get a dict populated with keys needed to initialize the filter if they are not set yet. This dict must have the following structure, but Min, Max, and Options can be skipped or explicitly set to None if they are not used. Value and Type are required. All values provided must be consistent with Type. EventFinder objects MUST include a MetaReader object in settings

settings = {'Parameter 1': {'Type': <int, float, str, bool>,
                                 'Value': <value> or None,
                                 'Options': [<option_1>, <option_2>, ... ] or None,
                                 'Min': <min_value> or None,
                                 'Max': <max_value> or None
                                },
                ...
                }
Parameters:
  • globally_available_plugins (Mapping[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:

Mapping[str, Mapping[str, Union[int, float, str, list[Union[int,float,str,None], None]]]]

Private Methods

IntraCUSUM._define_event_metadata_types()

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

Returns:

a dict of metadata keys and associated base dtypes

Return type:

Mapping[str, Union[int, float, str, bool]]

IntraCUSUM._define_event_metadata_units()

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

Returns:

a dict of metadata keys and associated base dtypes

Return type:

Mapping[str, Union[int, float, str, bool]]

IntraCUSUM._populate_event_metadata(data, samplerate, baseline_mean, baseline_std, sublevel_metadata)

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 (Mapping[str, List[Numeric]]) – the dict of sublevel metadata built by self._populate_sublevel_metadata()

Returns:

a dict of event metadata values

Return type:

Mapping[str, float]