forked from mne-tools/mne-python
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmne
executable file
·39 lines (33 loc) · 1.1 KB
/
mne
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
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
import glob
import subprocess
import os.path as op
import mne
mne_bin_dir = op.dirname(mne.__file__)
valid_commands = sorted(glob.glob(op.join(mne_bin_dir,
'commands', 'mne_*.py')))
valid_commands = [c.split(op.sep)[-1][4:-3] for c in valid_commands]
def print_help():
print("Usage : mne command options\n")
print("Accepted commands :\n")
for c in valid_commands:
print("\t- %s" % c)
print("\nExample : mne browse_raw --raw sample_audvis_raw.fif")
print("\nGetting help example : mne compute_proj_eog -h")
sys.exit(0)
if len(sys.argv) == 1:
print_help()
elif ("help" in sys.argv[1] or "-h" in sys.argv[1]):
print_help()
elif sys.argv[1] == "--version":
print("MNE %s" % mne.__version__)
elif sys.argv[1] not in valid_commands:
print('Invalid command: "%s"\n' % sys.argv[1])
print_help()
sys.exit(0)
else:
cmd = sys.argv[1]
cmd_path = op.join(mne_bin_dir, 'commands', 'mne_%s.py' % cmd)
sys.exit(subprocess.call([sys.executable, cmd_path] + sys.argv[2:]))