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

Function read_head_pos

mne/chpi.py:94–123  ·  view source on GitHub ↗

Read MaxFilter-formatted head position parameters. Parameters ---------- fname : path-like The filename to read. This can be produced by e.g., ``maxfilter -headpos .pos``. Returns ------- quats : array, shape (n_pos, 10) The position and quater

(fname)

Source from the content-addressed store, hash-verified

92
93
94def read_head_pos(fname):
95 """Read MaxFilter-formatted head position parameters.
96
97 Parameters
98 ----------
99 fname : path-like
100 The filename to read. This can be produced by e.g.,
101 ``maxfilter -headpos <name>.pos``.
102
103 Returns
104 -------
105 quats : array, shape (n_pos, 10)
106 The position and quaternion parameters from cHPI fitting.
107 See :func:`mne.chpi.compute_head_pos` for details on the columns.
108
109 See Also
110 --------
111 write_head_pos
112 head_pos_to_trans_rot_t
113
114 Notes
115 -----
116 .. versionadded:: 0.12
117 """
118 _check_fname(fname, must_exist=True, overwrite="read")
119 data = np.loadtxt(fname, skiprows=1) # first line is header, skip it
120 data = _reshape_view(data, (-1, 10)) # ensure it's the right size even if empty
121 if np.isnan(data).any(): # make sure we didn't do something dumb
122 raise RuntimeError(f"positions could not be read properly from {fname}")
123 return data
124
125
126def write_head_pos(fname, pos):

Calls 2

_check_fnameFunction · 0.85
_reshape_viewFunction · 0.85