Convert pos from head coordinate system to MRI ones. Parameters ---------- pos : array, shape (n_pos, 3) The coordinates (in m) in head coordinate system. %(subject)s mri_head_t : instance of Transform MRI<->Head coordinate transformation. %(subjects_dir)s
(
pos,
subject,
mri_head_t,
subjects_dir=None,
*,
kind="mri",
unscale=False,
verbose=None,
)
| 273 | |
| 274 | @verbose |
| 275 | def head_to_mri( |
| 276 | pos, |
| 277 | subject, |
| 278 | mri_head_t, |
| 279 | subjects_dir=None, |
| 280 | *, |
| 281 | kind="mri", |
| 282 | unscale=False, |
| 283 | verbose=None, |
| 284 | ): |
| 285 | """Convert pos from head coordinate system to MRI ones. |
| 286 | |
| 287 | Parameters |
| 288 | ---------- |
| 289 | pos : array, shape (n_pos, 3) |
| 290 | The coordinates (in m) in head coordinate system. |
| 291 | %(subject)s |
| 292 | mri_head_t : instance of Transform |
| 293 | MRI<->Head coordinate transformation. |
| 294 | %(subjects_dir)s |
| 295 | kind : str |
| 296 | The MRI coordinate frame kind, can be ``'mri'`` (default) for |
| 297 | FreeSurfer surface RAS or ``'ras'`` (default in 1.2) to use MRI RAS |
| 298 | (scanner RAS). |
| 299 | |
| 300 | .. versionadded:: 1.2 |
| 301 | unscale : bool |
| 302 | For surrogate MRIs (e.g., scaled using ``mne coreg``), if True |
| 303 | (default False), use the MRI scaling parameters to obtain points in |
| 304 | the original/surrogate subject's MRI space. |
| 305 | |
| 306 | .. versionadded:: 1.2 |
| 307 | %(verbose)s |
| 308 | |
| 309 | Returns |
| 310 | ------- |
| 311 | coordinates : array, shape (n_pos, 3) |
| 312 | The MRI RAS coordinates (in mm) of pos. |
| 313 | |
| 314 | Notes |
| 315 | ----- |
| 316 | This function requires nibabel. |
| 317 | """ |
| 318 | from .coreg import read_mri_cfg |
| 319 | |
| 320 | _validate_type(kind, str, "kind") |
| 321 | _check_option("kind", kind, ("ras", "mri")) |
| 322 | subjects_dir = get_subjects_dir(subjects_dir, raise_error=True) |
| 323 | t1_fname = subjects_dir / subject / "mri" / "T1.mgz" |
| 324 | head_mri_t = _ensure_trans(mri_head_t, "head", "mri") |
| 325 | if kind == "ras": |
| 326 | _, _, mri_ras_t, _, _ = _read_mri_info(t1_fname) |
| 327 | head_ras_t = combine_transforms(head_mri_t, mri_ras_t, "head", "ras") |
| 328 | head_dest_t = head_ras_t |
| 329 | else: |
| 330 | assert kind == "mri" |
| 331 | head_dest_t = head_mri_t |
| 332 | pos_dest = apply_trans(head_dest_t, pos) |
no test coverage detected