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

Function _read_dig_fif

mne/_fiff/_digitization.py:166–200  ·  view source on GitHub ↗

Read digitizer data from a FIFF file.

(fid, meas_info, *, return_ch_names=False)

Source from the content-addressed store, hash-verified

164
165
166def _read_dig_fif(fid, meas_info, *, return_ch_names=False):
167 """Read digitizer data from a FIFF file."""
168 isotrak = dir_tree_find(meas_info, FIFF.FIFFB_ISOTRAK)
169 dig = None
170 ch_names = None
171 if len(isotrak) == 0:
172 logger.info("Isotrak not found")
173 elif len(isotrak) > 1:
174 warn("Multiple Isotrak found")
175 else:
176 isotrak = isotrak[0]
177 coord_frame = FIFF.FIFFV_COORD_HEAD
178 dig = []
179 for k in range(isotrak["nent"]):
180 kind = isotrak["directory"][k].kind
181 pos = isotrak["directory"][k].pos
182 if kind == FIFF.FIFF_DIG_POINT:
183 tag = read_tag(fid, pos)
184 dig.append(tag.data)
185 elif kind == FIFF.FIFF_DIG_STRING:
186 tag = read_tag(fid, pos)
187 dig.extend(tag.data)
188 elif kind == FIFF.FIFF_MNE_COORD_FRAME:
189 tag = read_tag(fid, pos)
190 coord_frame = int(tag.data.item())
191 coord_frame = _coord_frame_named.get(coord_frame, coord_frame)
192 elif kind == FIFF.FIFF_MNE_CH_NAME_LIST:
193 tag = read_tag(fid, pos)
194 ch_names = _safe_name_list(tag.data, "read", "ch_names")
195 for d in dig:
196 d["coord_frame"] = coord_frame
197 out = _format_dig_points(dig)
198 if return_ch_names:
199 out = (out, ch_names)
200 return out
201
202
203@verbose

Callers 3

read_fiducialsFunction · 0.85
read_meas_infoFunction · 0.85
read_dig_fifFunction · 0.85

Calls 8

dir_tree_findFunction · 0.85
warnFunction · 0.85
read_tagFunction · 0.85
_safe_name_listFunction · 0.85
_format_dig_pointsFunction · 0.85
infoMethod · 0.80
appendMethod · 0.45
extendMethod · 0.45

Tested by

no test coverage detected