das.event_utils#
Utilities for handling events.
- das.event_utils.detect_events(event_probability: numpy.ndarray, thres: float = 0.5, min_dist: int = 100, index: int = 0) Tuple[numpy.ndarray, numpy.ndarray] [source]#
Detect events as peaks in probabilitiy.
- Parameters
event_probability ([np.ndarray]) – [T, nb_classes]
thres (float, optional) – [description]. Defaults to 0.5.
min_dist (int, optional) – [description]. Defaults to 100 samples.
index – (int, Optional): List of indices into axis 1 for which to compute the labels. Defaults to None (use all indices).
- Returns
index of each detected event event_confidence: event_probability at the event_index
- Return type
event_indices
- das.event_utils.evaluate_eventtimes(eventtimes_true, eventtimes_pred, samplerate, tol=0.01)[source]#
[summary]
- Parameters
eventtimes_true ([type]) – in seconds
eventtimes_pred ([type]) – in seconds
samplerate (float) – in Hz
tol (int, optional) – in seconds [description]. Defaults to 0.01 seconds.
- Returns
[description]
- Return type
[type]
- das.event_utils.event_interval_filter(events: Iterable, event_dist_min: float = 0, event_dist_max: float = inf) Iterable [source]#
[summary]
- Parameters
events (Iterable) – Iterable (list, np.array) of event times in seconds.
event_dist_min (float, optional) – [description]. Defaults to 0 second.
event_dist_max (float, optional) – [description]. Defaults to np.inf seconds.
- Returns
indices of events to keep
events[good_event_indices]
.- Return type
good_event_indices (Iterable)
- das.event_utils.find_nearest(array, values)[source]#
Find nearest occurrence of each item of values in array.
- Parameters
array – find nearest in this list
values – queries
- Returns
nearest val in array to each item in values idx: index of nearest val in array to each item in values dist: distance to nearest val in array for each item in values NOTE: Returns nan-arrays of the same size as values if
array
is empty.- Return type
val
- das.event_utils.match_events(eventindices_true, eventindices_pred, tol=100)[source]#
Find events eventindices_pred that match those (within tol) in eventindices_true.
- Parameters
eventindices_true – list of reference event indices
eventindices_pred – list of detected event indices
tol – n samples within which events are deemed identical
- Returns
masked array copy of eventindices_pred, mask=True indicates entries in pred not closest within tol in true nearest_dist: dist of each eventindices_pred to the nearest true_event
- Return type
nearest_event