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

Function get_fitting_dig

mne/bem.py:996–1072  ·  view source on GitHub ↗

Get digitization points suitable for sphere fitting. Parameters ---------- %(info_not_none)s %(dig_kinds)s %(exclude_frontal)s Default is True. .. versionadded:: 0.19 %(verbose)s Returns ------- dig : array, shape (n_pts, 3) The digitiza

(info, dig_kinds="auto", exclude_frontal=True, verbose=None)

Source from the content-addressed store, hash-verified

994
995@verbose
996def get_fitting_dig(info, dig_kinds="auto", exclude_frontal=True, verbose=None):
997 """Get digitization points suitable for sphere fitting.
998
999 Parameters
1000 ----------
1001 %(info_not_none)s
1002 %(dig_kinds)s
1003 %(exclude_frontal)s
1004 Default is True.
1005
1006 .. versionadded:: 0.19
1007 %(verbose)s
1008
1009 Returns
1010 -------
1011 dig : array, shape (n_pts, 3)
1012 The digitization points (in head coordinates) to use for fitting.
1013
1014 Notes
1015 -----
1016 This will exclude digitization locations that have ``z < 0 and y > 0``,
1017 i.e. points on the nose and below the nose on the face.
1018
1019 .. versionadded:: 0.14
1020 """
1021 _validate_type(info, "info")
1022 if info.get("dig", None) is None: # "dig" can be missing for fwd/inv
1023 raise RuntimeError(
1024 'Cannot fit headshape without digitization, info["dig"] is None'
1025 )
1026 if isinstance(dig_kinds, str):
1027 if dig_kinds == "auto":
1028 # try "extra" first
1029 try:
1030 return get_fitting_dig(info, "extra")
1031 except ValueError:
1032 pass
1033 return get_fitting_dig(info, ("extra", "eeg"))
1034 else:
1035 dig_kinds = (dig_kinds,)
1036 # convert string args to ints (first make dig_kinds mutable in case tuple)
1037 dig_kinds = list(dig_kinds)
1038 for di, d in enumerate(dig_kinds):
1039 dig_kinds[di] = _dig_kind_dict.get(d, d)
1040 if dig_kinds[di] not in _dig_kind_ints:
1041 raise ValueError(
1042 f"dig_kinds[{di}] ({d}) must be one of {sorted(_dig_kind_dict)}"
1043 )
1044
1045 # get head digization points of the specified kind(s)
1046 dig = [p for p in info["dig"] if p["kind"] in dig_kinds]
1047 if len(dig) == 0:
1048 raise ValueError(f"No digitization points found for dig_kinds={dig_kinds}")
1049 if any(p["coord_frame"] != FIFF.FIFFV_COORD_HEAD for p in dig):
1050 raise RuntimeError(
1051 f"Digitization points dig_kinds={dig_kinds} not in head "
1052 "coordinates, contact mne-python developers"
1053 )

Callers 3

_fit_sphere_to_headshapeFunction · 0.85
dig_mri_distancesFunction · 0.85
_check_sphereFunction · 0.85

Calls 3

_validate_typeFunction · 0.85
_plFunction · 0.85
warnFunction · 0.85

Tested by

no test coverage detected