bioevents package
Submodules
bioevents.colors module
bioevents.event_handling module
- class bioevents.event_handling.Event(on, off=None, tolerances=None)[source]
Bases:
object- default_duration = 1
- property duration
- property off
- property on
- overlaps(other)[source]
Determines whether this event “overlaps” another, based on various criteria.
Notes
It’s important to note that this overlap is not necessarily a “symmetrical” operation. Because the duration and tolerances of THIS event are used, self.overlaps(other) may differ from other.overlaps(self). This is by design, given that a “reference” or “truth” event should govern the acceptance criteria of “predicted” event annotations, and not the other way around.
See also
- property tolerances
- class bioevents.event_handling.EventClassSeries(event_stack: Dict[IntEnum, EventSeries], missing_enum: Optional[IntEnum] = None)[source]
Bases:
EventStackA special type of EventStack wherein every timestamp is expected to have one and only one class
Notes
Useful for performing class confusion or agreement analytic, such as with hypnogram annotations
- as_array(round_method_on=<ufunc 'ceil'>, round_method_off=<ufunc 'floor'>)[source]
Export all events as a list of classes
- epoch_confusion_matrix(other, normalize=None)[source]
Generates a confusion matrix with ‘other’, epoch-by-epoch via boolean logic
- Parameters:
other (EventClassSeries) –
normalize (Optional(bool), default=False) –
- Returns:
mat
- Return type:
pd.DataFrame
- event_confusion_matrix(other, assimilate_events=True)[source]
Generate a class-wise confusion matrix with ‘other’
- Parameters:
other (EventClassSeries) –
assimilate_events (Optional(bool), default=True) – If true, any overlapping Events from either series will be counted as one.
- Returns:
mat
- Return type:
pd.DataFrame
- class bioevents.event_handling.EventSeries(events, duration=None, sampling_rate: float = 1.0)[source]
Bases:
list- append(item)[source]
Overrides built-in default to make sure the Event is concurrent with this series
- as_bools(round_method_on=<ufunc 'ceil'>, round_method_off=<ufunc 'floor'>)[source]
Converts the Events to a boolean array, using parameterizable rounding methods
- compute_agreement(other, normalize=False)[source]
Computes an agreement matrix with the given EventSeries
- Parameters:
other (EventSeries) –
normalize (Optional(bool), default=False) – Normalize results rows by the number of events in the respective “reference” series
- Returns:
mat – 2 x 2 agreement matrix
- Return type:
pd.DataFrame
- debounce(persistence_period: float, min_duration: float) EventSeries[source]
Debounce the given signal to remove short events and merge close ones
- Parameters:
persistence_period (float) – merge any two events separated by less than this number (of samples)
min_duration (float) – after merging close events, remove all events under this duration (in samples)
- Returns:
debounced
- Return type:
References
Description of debouncing applied in engineering context: https://my.eng.utah.edu/~cs5780/debouncing.pdf
- property duration
- epoch_confusion_matrix(other, normalize=None)[source]
Generates a confusion matrix with the given EventSeries epoch-by-epoch via boolean logic
- Parameters:
other (EventSeries) –
normalize (Optional(bool), default=False) –
- Returns:
mat
- Return type:
pd.DataFrame
- event_confusion_matrix(other, normalize=None, assimilate_events=True)[source]
Generates a confusion matrix with the given EventSeries via Event-wise logic
- Parameters:
other (EventSeries) –
normalize (Optional(bool), default=False) –
assimilate_events (Optional(bool), default=True) – If true, any overlapping Events from either series will be counted as one.
- Returns:
mat
- Return type:
pd.DataFrame
- extend(item)[source]
Overrides built-in default to make sure the Events are concurrent with this series
- classmethod from_bools(bools, sampling_rate: float = 1.0)[source]
Converts the given boolean array into a series of discrete Events
- plot(bottom=0, top=1, color=None, as_seconds=True)[source]
Simple plot with events filled between the given y values
- property sampling_rate
- class bioevents.event_handling.EventStack(event_stack: Dict[IntEnum, EventSeries])[source]
Bases:
dict- KEY_ASSIGNED_ENUM = 'AssignedEnum'
- KEY_DURATION = 'duration'
- KEY_EVENT_STACK = 'event_stack'
- KEY_META = 'meta'
- KEY_SAMPLING_RATE = 'sampling_rate'
- property classes
- property duration
- classmethod from_dict(data: dict, intenum: IntEnum) EventStack[source]
- classmethod from_string_keys(event_stack: Dict[str, EventSeries])[source]
- property sampling_rate
- class bioevents.event_handling.MissingDataLabels(value)[source]
Bases:
IntEnumAn enumeration.
- ARTIFACT = -2
- DISAGREE = -3
- MISSING = 0
- UNSCORABLE = -1
- class bioevents.event_handling.OverlapTolerances(diff_on=inf, diff_off=inf, ratio_on=inf, ratio_off=inf)[source]
Bases:
object
bioevents.hypnogram module
Module contents
Top-level package for BioEvents.