borsar.utils.detect_overlap

borsar.utils.detect_overlap(segment, annot, sfreq=None)[source]

Detect what percentage of given segment is overlapping with annotations.

Parameters:
segment : list or 1d array

Two-element list or array of [start, stop] values.

annot : mne.Annotation of 2d numpy array

Annotations or 2d array of N x 2 (start, stop) values.

sfreq : float

Sampling frequency (default: None). If not None segment is assumed to be given in samples. annot is transformed to samples using sfreq if it is of mne.Annotations type. If annot is np.ndarray then it is transformed to samples only if its dtype is not ‘int64’ or ‘int32’.

Returns:
overlap : float

Percentage overlap in 0 - 1 range.