File: mne

package info (click to toggle)
python-mne 0.13.1%2Bdfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 92,032 kB
  • ctags: 8,249
  • sloc: python: 84,750; makefile: 205; sh: 15
file content (39 lines) | stat: -rwxr-xr-x 1,128 bytes parent folder | download
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:]))