[074d3d]: / mne / commands / mne_coreg.py

Download this file

117 lines (100 with data), 2.8 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
# Authors: The MNE-Python contributors.
# License: BSD-3-Clause
# Copyright the MNE-Python contributors.
"""Open the coregistration GUI.
Examples
--------
.. code-block:: console
$ mne coreg
"""
import os.path as op
import mne
def run():
"""Run command."""
from mne.commands.utils import _add_verbose_flag, get_optparser
parser = get_optparser(__file__)
parser.add_option(
"-d",
"--subjects-dir",
dest="subjects_dir",
default=None,
help="Subjects directory",
)
parser.add_option(
"-s", "--subject", dest="subject", default=None, help="Subject name"
)
parser.add_option(
"-f",
"--fiff",
dest="inst",
default=None,
help="FIFF file with digitizer data for coregistration",
)
parser.add_option(
"--head-opacity",
type=float,
default=None,
dest="head_opacity",
help="The opacity of the head surface, in the range [0, 1].",
)
parser.add_option(
"--high-res-head",
action="store_true",
default=False,
dest="high_res_head",
help="Use a high-resolution head surface.",
)
parser.add_option(
"--low-res-head",
action="store_true",
default=False,
dest="low_res_head",
help="Use a low-resolution head surface.",
)
parser.add_option(
"--trans",
dest="trans",
default=None,
help='Head<->MRI transform FIF file ("-trans.fif")',
)
parser.add_option(
"--interaction",
type=str,
default=None,
dest="interaction",
help='Interaction style to use, can be "trackball" or "terrain".',
)
_add_verbose_flag(parser)
options, args = parser.parse_args()
if options.low_res_head:
if options.high_res_head:
raise ValueError(
"Can't specify --high-res-head and --low-res-head at the same time."
)
head_high_res = False
elif options.high_res_head:
head_high_res = True
else:
head_high_res = None
# expanduser allows ~ for --subjects-dir
subjects_dir = options.subjects_dir
if subjects_dir is not None:
subjects_dir = op.expanduser(subjects_dir)
trans = options.trans
if trans is not None:
trans = op.expanduser(trans)
import faulthandler
faulthandler.enable()
mne.gui.coregistration(
inst=options.inst,
subject=options.subject,
subjects_dir=subjects_dir,
head_opacity=options.head_opacity,
head_high_res=head_high_res,
trans=trans,
interaction=options.interaction,
show=True,
block=True,
verbose=options.verbose,
)
mne.utils.run_command_if_main()