MCPcopy Index your code
hub / github.com/mne-tools/mne-python / annotate_nan

Function annotate_nan

mne/preprocessing/_annotate_nan.py:13–38  ·  view source on GitHub ↗

Detect segments with NaN and return a new Annotations instance. Parameters ---------- raw : instance of Raw Data to find segments with NaN values. %(verbose)s Returns ------- annot : instance of Annotations New channel-specific annotations for the data.

(raw, *, verbose=None)

Source from the content-addressed store, hash-verified

11
12@verbose
13def annotate_nan(raw, *, verbose=None):
14 """Detect segments with NaN and return a new Annotations instance.
15
16 Parameters
17 ----------
18 raw : instance of Raw
19 Data to find segments with NaN values.
20 %(verbose)s
21
22 Returns
23 -------
24 annot : instance of Annotations
25 New channel-specific annotations for the data.
26 """
27 data, times = raw.get_data(return_times=True)
28 onsets, durations, ch_names = list(), list(), list()
29 for row, ch_name in zip(data, raw.ch_names):
30 annot = _annotations_from_mask(times, np.isnan(row), "BAD_NAN")
31 onsets.extend(annot.onset)
32 durations.extend(annot.duration)
33 ch_names.extend([[ch_name]] * len(annot))
34 annot = Annotations(
35 onsets, durations, "BAD_NAN", ch_names=ch_names, orig_time=raw.info["meas_date"]
36 )
37 _adjust_onset_meas_date(annot, raw)
38 return annot

Callers 2

test_annotate_nanFunction · 0.90

Calls 5

_annotations_from_maskFunction · 0.85
AnnotationsClass · 0.85
_adjust_onset_meas_dateFunction · 0.85
get_dataMethod · 0.45
extendMethod · 0.45

Tested by 2

test_annotate_nanFunction · 0.72