Read digitizer data from a FIFF file.
(fid, meas_info, *, return_ch_names=False)
| 164 | |
| 165 | |
| 166 | def _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 |
no test coverage detected