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

Function write_head_pos

mne/chpi.py:126–159  ·  view source on GitHub ↗

Write MaxFilter-formatted head position parameters. Parameters ---------- fname : path-like The filename to write. pos : array, shape (n_pos, 10) The position and quaternion parameters from cHPI fitting. See :func:`mne.chpi.compute_head_pos` for details on th

(fname, pos)

Source from the content-addressed store, hash-verified

124
125
126def write_head_pos(fname, pos):
127 """Write MaxFilter-formatted head position parameters.
128
129 Parameters
130 ----------
131 fname : path-like
132 The filename to write.
133 pos : array, shape (n_pos, 10)
134 The position and quaternion parameters from cHPI fitting.
135 See :func:`mne.chpi.compute_head_pos` for details on the columns.
136
137 See Also
138 --------
139 read_head_pos
140 head_pos_to_trans_rot_t
141
142 Notes
143 -----
144 .. versionadded:: 0.12
145 """
146 _check_fname(fname, overwrite=True)
147 pos = np.array(pos, np.float64)
148 if pos.ndim != 2 or pos.shape[1] != 10:
149 raise ValueError(
150 f"pos must be a 2D array of shape (N, 10), got shape {pos.shape}"
151 )
152 with open(fname, "wb") as fid:
153 fid.write(
154 " Time q1 q2 q3 q4 q5 "
155 "q6 g-value error velocity\n".encode("ASCII")
156 )
157 for p in pos:
158 fmts = ["% 9.3f"] + ["% 8.5f"] * 9
159 fid.write(((" " + " ".join(fmts) + "\n") % tuple(p)).encode("ASCII"))
160
161
162def head_pos_to_trans_rot_t(quats):

Callers 2

test_read_write_head_posFunction · 0.90
test_simulate_raw_sphereFunction · 0.90

Calls 2

_check_fnameFunction · 0.85
writeMethod · 0.80

Tested by 2

test_read_write_head_posFunction · 0.72
test_simulate_raw_sphereFunction · 0.72