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)
| 92 | |
| 93 | |
| 94 | def 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 | |
| 126 | def write_head_pos(fname, pos): |