MCPcopy
hub / github.com/mne-tools/mne-python / _check_bad_segment

Method _check_bad_segment

mne/io/base.py:522–566  ·  view source on GitHub ↗

Check if data segment is bad. If the slice is good, returns the data in desired range. If rejected based on annotation, returns description of the bad segment as a string. Parameters ---------- start : int First sample of the slice.

(
        self, start, stop, picks, reject_start, reject_stop, reject_by_annotation=False
    )

Source from the content-addressed store, hash-verified

520 raise NotImplementedError
521
522 def _check_bad_segment(
523 self, start, stop, picks, reject_start, reject_stop, reject_by_annotation=False
524 ):
525 """Check if data segment is bad.
526
527 If the slice is good, returns the data in desired range.
528 If rejected based on annotation, returns description of the
529 bad segment as a string.
530
531 Parameters
532 ----------
533 start : int
534 First sample of the slice.
535 stop : int
536 End of the slice.
537 picks : array of int
538 Channel picks.
539 reject_start : int
540 First sample to check for overlaps with bad annotations.
541 reject_stop : int
542 Last sample to check for overlaps with bad annotations.
543 reject_by_annotation : bool
544 Whether to perform rejection based on annotations.
545 False by default.
546
547 Returns
548 -------
549 data : array | str
550 Data in the desired range (good segment) or description of the bad
551 segment.
552 """
553 if start < 0:
554 return None
555 if reject_by_annotation and len(self.annotations) > 0:
556 annot = self.annotations
557 sfreq = self.info["sfreq"]
558 onset = _sync_onset(self, annot.onset)
559 overlaps = np.where(onset < reject_stop / sfreq)
560 overlaps = np.where(
561 onset[overlaps] + annot.duration[overlaps] > reject_start / sfreq
562 )
563 for descr in annot.description[overlaps]:
564 if descr.lower().startswith("bad"):
565 return descr
566 return self._getitem((picks, slice(start, stop)), return_times=False)
567
568 @verbose
569 def load_data(self, verbose=None):

Callers 1

_get_epoch_from_rawMethod · 0.80

Calls 2

_getitemMethod · 0.95
_sync_onsetFunction · 0.85

Tested by

no test coverage detected