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

Download this file

135 lines (118 with data), 3.2 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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
# Authors: The MNE-Python contributors.
# License: BSD-3-Clause
# Copyright the MNE-Python contributors.
"""Create BEM surfaces using the watershed algorithm included with FreeSurfer.
Examples
--------
.. code-block:: console
$ mne watershed_bem -s sample
"""
import sys
import mne
from mne.bem import make_watershed_bem
from mne.utils import _check_option
def run():
"""Run command."""
from mne.commands.utils import _add_verbose_flag, get_optparser
parser = get_optparser(__file__)
parser.add_option(
"-s", "--subject", dest="subject", help="Subject name (required)", default=None
)
parser.add_option(
"-d",
"--subjects-dir",
dest="subjects_dir",
help="Subjects directory",
default=None,
)
parser.add_option(
"-o",
"--overwrite",
dest="overwrite",
help="Write over existing files",
action="store_true",
)
parser.add_option(
"-v", "--volume", dest="volume", help="Defaults to T1", default="T1"
)
parser.add_option(
"-a",
"--atlas",
dest="atlas",
help="Specify the --atlas option for mri_watershed",
default=False,
action="store_true",
)
parser.add_option(
"-g",
"--gcaatlas",
dest="gcaatlas",
help="Specify the --brain_atlas option for mri_watershed",
default=False,
action="store_true",
)
parser.add_option(
"-p",
"--preflood",
dest="preflood",
help="Change the preflood height",
default=None,
)
parser.add_option(
"--copy",
dest="copy",
help="Use copies instead of symlinks for surfaces",
action="store_true",
)
parser.add_option(
"-t",
"--T1",
dest="T1",
help="Whether or not to pass the -T1 flag "
"(can be true, false, 0, or 1). "
"By default it takes the same value as gcaatlas.",
default=None,
)
parser.add_option(
"-b",
"--brainmask",
dest="brainmask",
help="The filename for the brainmask output file "
"relative to the "
"$SUBJECTS_DIR/$SUBJECT/bem/watershed/ directory.",
default="ws",
)
_add_verbose_flag(parser)
options, args = parser.parse_args()
if options.subject is None:
parser.print_help()
sys.exit(1)
subject = options.subject
subjects_dir = options.subjects_dir
overwrite = options.overwrite
volume = options.volume
atlas = options.atlas
gcaatlas = options.gcaatlas
preflood = options.preflood
copy = options.copy
brainmask = options.brainmask
T1 = options.T1
if T1 is not None:
T1 = T1.lower()
_check_option("--T1", T1, ("true", "false", "0", "1"))
T1 = T1 in ("true", "1")
verbose = options.verbose
make_watershed_bem(
subject=subject,
subjects_dir=subjects_dir,
overwrite=overwrite,
volume=volume,
atlas=atlas,
gcaatlas=gcaatlas,
preflood=preflood,
copy=copy,
T1=T1,
brainmask=brainmask,
verbose=verbose,
)
mne.utils.run_command_if_main()