forked from olafhauk/EEGMEGResolutionAtlas
-
Notifications
You must be signed in to change notification settings - Fork 0
/
WH_Res_make_snapshots.py
executable file
·168 lines (131 loc) · 7.3 KB
/
WH_Res_make_snapshots.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
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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
"""
=========================================================
Make snapshots from STC files using mne_make_movie
Set up MNE environment in linux shell first
=========================================================
"""
# OH, May 2019
print __doc__
import os
from os import path as op
outpath = '/group/erp/data/olaf.hauk/MEG/WakemanHensonEMEG/Resolution/ResolutionMetrics/Figures' # output directory for images
inpath = '/group/erp/data/olaf.hauk/MEG/WakemanHensonEMEG/Resolution/ResolutionMetrics/fsaverage'
# List of STC files, with thresholds for visualisation in mne_make_movie (min, mid, max)
filelist = [
# ### Peak localisation Error, raw distributions
# ['PSF_MNE_011_locerr_peak_EEGMEG_loo0_dep0', 0, 2.5, 5.],
# ['PSF_MNE_011_locerr_peak_EEGMEG_loo0_dep80', 0, 2.5, 5.],
# ['PSF_sLORETA_011_locerr_peak_EEGMEG_loo0_dep0', 0, 2.5, 5.],
# ['PSF_dSPM_011_locerr_peak_EEGMEG_loo0_dep0', 0, 2.5, 5.],
# ['PSF_LCMV_011_locerr_peak_EEGMEG_loo0_dep0', 0, 2.5, 5.],
# ['CTF_MNE_011_locerr_peak_EEGMEG_loo0_dep0', 0, 2.5, 5.],
# ['CTF_MNE_011_locerr_peak_EEGMEG_loo0_dep80', 0, 2.5, 5.],
# ['CTF_sLORETA_011_locerr_peak_EEGMEG_loo0_dep0', 0, 2.5, 5.],
# ['CTF_dSPM_011_locerr_peak_EEGMEG_loo0_dep0', 0, 2.5, 5.],
# ['CTF_LCMV_011_locerr_peak_EEGMEG_loo0_dep0', 0, 2.5, 5.],
['PSF_MNE_011_locerr_peak_MEG_loo0_dep0', 0, 2.5, 5.],
['PSF_MNE_011_locerr_peak_EEGMEG-MEG_loo0_dep0', 0, 0.5, 1.],
# ### Peak localisation Error, constrasts
# ['PSF_MNE-dSPM_011_locerr_peak_EEGMEG_loo0_dep0', 0, 2.5, 5.],
# ['PSF_MNE-sLORETA_011_locerr_peak_EEGMEG_loo0_dep0', 0, 2.5, 5.],
# ['PSF_MNE-LCMV_011_locerr_peak_EEGMEG_loo0_dep0', 0, 2.5, 5.],
# ['PSF_dep0-80_011_locerr_peak_EEGMEG_loo0', 0, 2.5, 5.],
# ['CTF_MNE-dSPM_011_locerr_peak_EEGMEG_loo0_dep0', 0, 2.5, 5.],
# ['CTF_MNE-sLORETA_011_locerr_peak_EEGMEG_loo0_dep0', 0, 2.5, 5.],
# ['CTF_MNE-LCMV_011_locerr_peak_EEGMEG_loo0_dep0', 0, 2.5, 5.],
# ['CTF_dep0-80_011_locerr_peak_EEGMEG_loo0', 0, 2.5, 5.],
# ### Spatial Deviation, raw distributions
# ['PSF_MNE_011_width_sd_EEGMEG_loo0_dep0', 0, 1.5, 3.],
# ['PSF_MNE_011_width_sd_EEGMEG_loo0_dep80', 0, 1.5, 3.],
# ['PSF_sLORETA_011_width_sd_EEGMEG_loo0_dep0', 0, 1.5, 3.],
# ['PSF_dSPM_011_width_sd_EEGMEG_loo0_dep0', 0, 1.5, 3.],
# ['PSF_LCMV_011_width_sd_EEGMEG_loo0_dep0', 0, 1.5, 3.],
# ['CTF_MNE_011_width_sd_EEGMEG_loo0_dep0', 0, 1.5, 3.],
# ['CTF_MNE_011_width_sd_EEGMEG_loo0_dep80', 0, 1.5, 3.],
# ['CTF_sLORETA_011_width_sd_EEGMEG_loo0_dep0', 0, 1.5, 3.],
# ['CTF_dSPM_011_width_sd_EEGMEG_loo0_dep0', 0, 1.5, 3.],
# ['CTF_LCMV_011_width_sd_EEGMEG_loo0_dep0', 0, 1.5, 3.],
['PSF_MNE_011_width_sd_MEG_loo0_dep0', 0, 1.5, 3.],
['PSF_MNE_011_width_sd_EEGMEG-MEG_loo0_dep0', 0, 1.5, 3.],
# ### Spatial Deviation, constrasts
# ['PSF_MNE-dSPM_011_width_sd_EEGMEG_loo0_dep0', 0, 1.5, 3.],
# ['PSF_MNE-sLORETA_011_width_sd_EEGMEG_loo0_dep0', 0, 1.5, 3.],
# ['PSF_MNE-LCMV_011_width_sd_EEGMEG_loo0_dep0', 0, 1.5, 3.],
# ['PSF_dep0-80_011_width_sd_EEGMEG_loo0', 0, 1.5, 3.],
# ['CTF_MNE-dSPM_011_width_sd_EEGMEG_loo0_dep0', 0, 1.5, 3.],
# ['CTF_MNE-sLORETA_011_width_sd_EEGMEG_loo0_dep0', 0, 1.5, 3.],
# ['CTF_MNE-LCMV_011_width_sd_EEGMEG_loo0_dep0', 0, 1.5, 3.],
# ['CTF_dep0-80_011_width_sd_EEGMEG_loo0', 0, 1.5, 3.],
# ### Maximum Radius, raw distributions
# ['PSF_MNE_011_width_maxrad_EEGMEG_loo0_dep0', 0, 4., 8.],
# ['PSF_MNE_011_width_maxrad_EEGMEG_loo0_dep80', 0, 4., 8.],
# ['PSF_sLORETA_011_width_maxrad_EEGMEG_loo0_dep0', 0, 4., 8.],
# ['PSF_dSPM_011_width_maxrad_EEGMEG_loo0_dep0', 0, 4., 8.],
# ['PSF_LCMV_011_width_maxrad_EEGMEG_loo0_dep0', 0, 4., 8.],
# ['CTF_MNE_011_width_maxrad_EEGMEG_loo0_dep0', 0, 4., 8.],
# ['CTF_MNE_011_width_maxrad_EEGMEG_loo0_dep80', 0, 4., 8.],
# ['CTF_sLORETA_011_width_maxrad_EEGMEG_loo0_dep0', 0, 4., 8.],
# ['CTF_dSPM_011_width_maxrad_EEGMEG_loo0_dep0', 0, 4., 8.],
# ['CTF_LCMV_011_width_maxrad_EEGMEG_loo0_dep0', 0, 4., 8.],
# ### Maximum Radius, constrasts
# ['PSF_MNE-dSPM_011_width_maxrad_EEGMEG_loo0_dep0', 0, 2.5, 5.],
# ['PSF_MNE-sLORETA_011_width_maxrad_EEGMEG_loo0_dep0', 0, 2.5, 5.],
# ['PSF_MNE-LCMV_011_width_maxrad_EEGMEG_loo0_dep0', 0, 2.5, 5.],
# ['PSF_dep0-80_011_width_maxrad_EEGMEG_loo0', 0, 2.5, 5.],
# ['CTF_MNE-dSPM_011_width_maxrad_EEGMEG_loo0_dep0', 0, 2.5, 5.],
# ['CTF_MNE-sLORETA_011_width_maxrad_EEGMEG_loo0_dep0', 0, 2.5, 5.],
# ['CTF_MNE-LCMV_011_width_maxrad_EEGMEG_loo0_dep0', 0, 2.5, 5.],
# ['CTF_dep0-80_011_width_maxrad_EEGMEG_loo0', 0, 2.5, 5.],
# ### Overall Amplitude, raw distributions
# ['PSF_MNE_011_amplitude_sum_EEGMEG_loo0_dep0', 0, .5, 1.],
# ['PSF_MNE_011_amplitude_sum_EEGMEG_loo0_dep80', 0, .5, 1.],
# ['PSF_sLORETA_011_amplitude_sum_EEGMEG_loo0_dep0', 0, .5, 1.],
# ['PSF_dSPM_011_amplitude_sum_EEGMEG_loo0_dep0', 0, .5, 1.],
# ['PSF_LCMV_011_amplitude_sum_EEGMEG_loo0_dep0', 0, .5, 1.],
# ['CTF_MNE_011_amplitude_sum_EEGMEG_loo0_dep0', 0, .5, 1.],
# ['CTF_MNE_011_amplitude_sum_EEGMEG_loo0_dep80', 0, .5, 1.],
# ['CTF_sLORETA_011_amplitude_sum_EEGMEG_loo0_dep0', 0, .5, 1.],
# ['CTF_dSPM_011_amplitude_sum_EEGMEG_loo0_dep0', 0, .5, 1.],
# ['CTF_LCMV_011_amplitude_sum_EEGMEG_loo0_dep0', 0, .5, 1.],
['PSF_MNE_011_amplitude_sum_MEG_loo0_dep0', 0, .5, 1.],
['PSF_MNE_011_amplitude_sum_EEGMEG-MEG_loo0_dep0', 0, .25, 0.5]
# ### Overall Amplitude, constrasts
# ['PSF_MNE-dSPM_011_amplitude_sum_EEGMEG_loo0_dep0', 0, .25, .5],
# ['PSF_MNE-sLORETA_011_amplitude_sum_EEGMEG_loo0_dep0', 0, .25, .5],
# ['PSF_MNE-LCMV_011_amplitude_sum_EEGMEG_loo0_dep0', 0, .25, .5],
# ['PSF_dep0-80_011_amplitude_sum_EEGMEG_loo0', 0, .25, .5],
# ['CTF_MNE-dSPM_011_amplitude_sum_EEGMEG_loo0_dep0', 0, .25, .5],
# ['CTF_MNE-sLORETA_011_amplitude_sum_EEGMEG_loo0_dep0', 0, .25, .5],
# ['CTF_MNE-LCMV_011_amplitude_sum_EEGMEG_loo0_dep0', 0, .25, .5],
# ['CTF_dep0-80_011_amplitude_sum_EEGMEG_loo0', 0, .25, .5]
]
# parameters for mne_make_movie common to all files
subject = '--subject fsaverage'
smooth = '--smooth 5'
pick = '--pick 0'
spm = '--spm'
comments = '--nocomments'
print('Visualising %d files.' % len(filelist))
# Keep track of error from mne_make_movie output
errors = []
for ff in filelist:
filein = op.join(inpath, ff[0])
fileout = op.join(outpath, ff[0])
# parameters for mne_make_movie for individual files
stcin = '--stcin %s' % filein
jpg = '--jpg %s' % fileout
fthresh = '--fthresh %f --fmid %f --fmax %f' % (ff[1], ff[2], ff[3])
# create string for mne_make_movie command
cmd = 'mne_make_movie %s %s %s %s %s %s %s %s' % (subject, smooth, pick, spm, comments, stcin, jpg, fthresh)
# execute mne_make_movie command in linux
osout = os.system(cmd)
# if error occurs, keep track
if not osout==0:
errors.append([ff, osout])
if not errors == []:
print('\n\nThe following errors occurred while executing mne_make_movie:\n')
for ee in errors:
print('%s, %s' % (ee[0][0], ee[1]))
else:
print('No errors occurred while executing mne_make_movie!')
# Done all