forked from olafhauk/EMEG_Utilities
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Fiff_HeadPositions.py
executable file
·63 lines (46 loc) · 1.71 KB
/
Fiff_HeadPositions.py
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
#!/imaging/local/software/miniconda/envs/mne0.18/bin/python
"""
=========================================================================================
Plot head positions (translation and rotation) from MEG raw data determined by Maxfilter.
"pos"-files from Maxfilter (option -hp) are required as input.
For more help, type Fiff_HeadPositions -h.
Based on MNE-Python.
Look here for an example:
https://martinos.org/mne/stable/auto_examples/preprocessing/plot_head_positions.html
=========================================================================================
"""
# Olaf Hauk, Python 3, July 2019
print(__doc__)
###
# PARSE INPUT ARGUMENTS
###
from sys import argv, exit
import argparse
from matplotlib import pyplot as plt
import mne
print('MNE %s.\n' % mne.__version__)
if len(argv)==1:
# display help message when no args are passed.
exit(1)
print(mne)
parser = argparse.ArgumentParser(description='MEG head positions.')
parser.add_argument('--FileRaw', help='Input filename.')
parser.add_argument('--FileOut', help='Output filename for figure (default: do not save).\
If specified, figure will not be shown on screen.', default='')
parser.add_argument('--mode', help='traces|field (default: traces).', default='traces')
args = parser.parse_args()
###
# PROCESS DATA
###
if args.FileOut != '':
plt.ion()
# Read head position from Maxfilter output
print('Reading positions from %s.' % args.FileRaw)
pos = mne.chpi.read_head_pos(args.FileRaw)
# Visualise head positions
print('Visualising positions.')
fig = mne.viz.plot_head_positions(pos, mode=args.mode)
# if filename for figure specified in command line
if args.FileOut != '':
print('Saving figure to %s.' % args.FileOut)
fig.savefig(args.FileOut)