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

Function _read_annotations_fif

mne/annotations.py:2123–2160  ·  view source on GitHub ↗

Read annotations.

(fid, tree)

Source from the content-addressed store, hash-verified

2121
2122
2123def _read_annotations_fif(fid, tree):
2124 """Read annotations."""
2125 annot_data = dir_tree_find(tree, FIFF.FIFFB_MNE_ANNOTATIONS)
2126 if len(annot_data) == 0:
2127 annotations = None
2128 else:
2129 annot_data = annot_data[0]
2130 orig_time = ch_names = extras = None
2131 onset, duration, description = list(), list(), list()
2132 for ent in annot_data["directory"]:
2133 kind = ent.kind
2134 pos = ent.pos
2135 tag = read_tag(fid, pos)
2136 if kind == FIFF.FIFF_MNE_BASELINE_MIN:
2137 onset = tag.data
2138 onset = list() if onset is None else onset
2139 elif kind == FIFF.FIFF_MNE_BASELINE_MAX:
2140 duration = tag.data
2141 duration = list() if duration is None else duration - onset
2142 elif kind == FIFF.FIFF_COMMENT:
2143 description = _safe_name_list(tag.data, "read", "description")
2144 elif kind == FIFF.FIFF_MEAS_DATE:
2145 orig_time = tag.data
2146 try:
2147 orig_time = float(orig_time) # old way
2148 except TypeError:
2149 orig_time = tuple(orig_time) # new way
2150 elif kind == FIFF.FIFF_MNE_EPOCHS_DROP_LOG:
2151 ch_names = tuple(tuple(x) for x in json.loads(tag.data))
2152 elif kind == FIFF.FIFF_FREE_LIST:
2153 extras = json.loads(tag.data)
2154 assert len(onset) == len(duration) == len(description)
2155 if extras is not None:
2156 assert len(extras) == len(onset)
2157 annotations = Annotations(
2158 onset, duration, description, orig_time, ch_names, extras=extras
2159 )
2160 return annotations
2161
2162
2163def _select_annotations_based_on_description(descriptions, event_id, regexp):

Callers 3

_read_one_epoch_fileFunction · 0.85
read_annotationsFunction · 0.85
_read_raw_fileMethod · 0.85

Calls 4

dir_tree_findFunction · 0.85
read_tagFunction · 0.85
_safe_name_listFunction · 0.85
AnnotationsClass · 0.85

Tested by

no test coverage detected