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

Function _prep_fine_cal

mne/preprocessing/maxwell.py:2177–2205  ·  view source on GitHub ↗
(info, fine_cal, *, ignore_ref)

Source from the content-addressed store, hash-verified

2175
2176
2177def _prep_fine_cal(info, fine_cal, *, ignore_ref):
2178 from ._fine_cal import read_fine_calibration
2179
2180 _validate_type(fine_cal, (dict, "path-like"))
2181 if not isinstance(fine_cal, dict):
2182 extra = op.basename(str(fine_cal))
2183 fine_cal = read_fine_calibration(fine_cal)
2184 else:
2185 extra = "dict"
2186 logger.info(f" Using fine calibration {extra}")
2187 ch_names = _clean_names(info["ch_names"], remove_whitespace=True)
2188 info_to_cal = dict()
2189 missing = list()
2190 names_clean = _clean_names(fine_cal["ch_names"], remove_whitespace=True)
2191 for ci, (name, name_clean) in enumerate(zip(fine_cal["ch_names"], names_clean)):
2192 if name_clean not in ch_names:
2193 missing.append(name)
2194 else:
2195 oi = ch_names.index(name_clean)
2196 info_to_cal[oi] = ci
2197 meg_picks = pick_types(info, meg=True, exclude=[], ref_meg=not ignore_ref)
2198 if len(info_to_cal) != len(meg_picks):
2199 bad = sorted({ch_names[pick] for pick in meg_picks} - set(names_clean))
2200 raise RuntimeError(
2201 f"Not all MEG channels found in fine calibration file, missing:\n{bad}"
2202 )
2203 if len(missing):
2204 warn(f"Found cal channel{_pl(missing)} not in data: {missing}")
2205 return info_to_cal, fine_cal, ch_names
2206
2207
2208def _update_sensor_geometry(info, fine_cal, ignore_ref):

Callers 2

compute_fine_calibrationFunction · 0.85
_update_sensor_geometryFunction · 0.85

Calls 9

_validate_typeFunction · 0.85
read_fine_calibrationFunction · 0.85
_clean_namesFunction · 0.85
pick_typesFunction · 0.85
setFunction · 0.85
warnFunction · 0.85
_plFunction · 0.85
infoMethod · 0.80
appendMethod · 0.45

Tested by

no test coverage detected