Estimate fiducials for a subject. Parameters ---------- %(subject)s %(subjects_dir)s %(verbose)s Returns ------- fids_mri : list List of estimated fiducials (each point in a dict), in the order LPA, nasion, RPA. Notes ----- This takes th
(subject, subjects_dir=None, verbose=None)
| 430 | |
| 431 | @verbose |
| 432 | def get_mni_fiducials(subject, subjects_dir=None, verbose=None): |
| 433 | """Estimate fiducials for a subject. |
| 434 | |
| 435 | Parameters |
| 436 | ---------- |
| 437 | %(subject)s |
| 438 | %(subjects_dir)s |
| 439 | %(verbose)s |
| 440 | |
| 441 | Returns |
| 442 | ------- |
| 443 | fids_mri : list |
| 444 | List of estimated fiducials (each point in a dict), in the order |
| 445 | LPA, nasion, RPA. |
| 446 | |
| 447 | Notes |
| 448 | ----- |
| 449 | This takes the ``fsaverage-fiducials.fif`` file included with MNE—which |
| 450 | contain the LPA, nasion, and RPA for the ``fsaverage`` subject—and |
| 451 | transforms them to the given FreeSurfer subject's MRI space. |
| 452 | The MRI of ``fsaverage`` is already in MNI Talairach space, so applying |
| 453 | the inverse of the given subject's MNI Talairach affine transformation |
| 454 | (``$SUBJECTS_DIR/$SUBJECT/mri/transforms/talairach.xfm``) is used |
| 455 | to estimate the subject's fiducial locations. |
| 456 | |
| 457 | For more details about the coordinate systems and transformations involved, |
| 458 | see https://surfer.nmr.mgh.harvard.edu/fswiki/CoordinateSystems and |
| 459 | :ref:`tut-source-alignment`. |
| 460 | """ |
| 461 | # Eventually we might want to allow using the MNI Talairach with-skull |
| 462 | # transformation rather than the standard brain-based MNI Talaranch |
| 463 | # transformation, and/or project the points onto the head surface |
| 464 | # (if available). |
| 465 | fname_fids_fs = ( |
| 466 | Path(__file__).parent / "data" / "fsaverage" / "fsaverage-fiducials.fif" |
| 467 | ) |
| 468 | |
| 469 | # Read fsaverage fiducials file and subject Talairach. |
| 470 | fids, coord_frame = read_fiducials(fname_fids_fs) |
| 471 | assert coord_frame == FIFF.FIFFV_COORD_MRI |
| 472 | if subject == "fsaverage": |
| 473 | return fids # special short-circuit for fsaverage |
| 474 | mni_mri_t = invert_transform(read_talxfm(subject, subjects_dir)) |
| 475 | for f in fids: |
| 476 | f["r"] = apply_trans(mni_mri_t, f["r"]) |
| 477 | return fids |
| 478 | |
| 479 | |
| 480 | @verbose |