forked from BottiniLab/GridFT
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgft2_config.py
253 lines (229 loc) · 12.5 KB
/
gft2_config.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
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
"""
configuration settings for gridft2 study
@author: giuliano giari, [email protected]
"""
# ------------------------------------------------- initialization --------------------------------------------------- #
import os, sys
import matplotlib as mpl
from matplotlib import cm
import numpy as np
opt = dict()
# ------------------------------------------------------ paths ------------------------------------------------------- #
if sys.platform == 'linux':
# we have to check whether we are on the cluster or the meg server
if os.path.exists('/mnt/storage/tier2/robbot/ProjectData/MEGRID/'):
# we are on the meg server
rootpath = '/mnt/storage/tier2/robbot/ProjectData/MEGRID/'
opt['fifPath'] = f'{rootpath}fif/'
opt['maxPath'] = f'{rootpath}derivatives/max/'
opt['bidsPath'] = rootpath
else: # we are on the cluster
rootpath = '/mnt/storage/tier2/ROBBOT-extra/Projects/MEGRID/'
# we keep the raw data on a different storage space
opt['fifPath'] = '/mnt/storage/tier2/ROBBOT/ProjectData/MEGRID/fif/'
opt['maxPath'] = '/mnt/storage/tier2/ROBBOT/ProjectData/MEGRID/derivatives/max/'
opt['fsPath'] = '/mnt/storage/tier2/ROBBOT/ProjectData/MEGRID/freesurfer/'
opt['mriPath'] = '/mnt/storage/tier2/ROBBOT/ProjectData/MEGRID/mri/'
opt['bidsPath'] = '/mnt/storage/tier2/ROBBOT/ProjectData/MEGRID/'
elif sys.platform == 'darwin':
# we are on my mac
rootpath = '/Volumes/Projects/MEGRID/'
opt['bidsPath'] = '/Volumes/ProjectData/MEGRID/'
opt['fifPath'] = '/Users/giulianogiari/Desktop/fif/'
opt['mriPath'] = '/Users/giulianogiari/Desktop/mri/'
opt['maxPath'] = '/Users/giulianogiari/Desktop/derivatives/max/'
opt['fsPath'] = '/Volumes/ProjectData/MEGRID/freesurfer/'
opt['derPath'] = f'{rootpath}derivatives/'
opt['prgPath'] = f'{rootpath}prg/analysis/'
opt['logPath'] = f'{rootpath}derivatives/log/'
opt['badPath'] = f'{rootpath}bad/'
opt['frqPath'] = f'{rootpath}derivatives/frq/'
opt['eyePath'] = f'{rootpath}derivatives/eye/'
opt['epoPath'] = f'{rootpath}derivatives/epo/'
opt['prePath'] = f'{rootpath}derivatives/pre/'
opt['infoPath'] = f'{rootpath}info/'
opt['figPath'] = f'{rootpath}derivatives/fig/'
opt['stcPath'] = f'{rootpath}derivatives/stc/'
opt['srcPath'] = f'{rootpath}derivatives/src/'
opt['behPath'] = f"{opt['bidsPath']}beh/"
# ----------------------------------------------- experiment 1 ------------------------------------------------------- #
opt['exp_1'] = {}
opt['exp_1']['subj_list'] = [f'sub-{sub_id}' for sub_id in ['19970805EEAT', '19970127MLAG', '19931222BLON',
'19820925PEGA', '19870521NRIA', '19940408MROS',
'19950121SRKN', '19940921BRFL', '19961224AAMN',
'19981201VRII', '19960711EEBN', '20020627GBVD',
'20010614DMCA', '19941010LCTY', '19940605SVTR',
'19930322ATBA', '19910513IACR', '20010802LLLO',
'20010926GABI', '19940721MRBU', '19970416RGBR',
'19851030GBGL', '19970323DNZN', '19990209CRSA']
]
opt['exp_1']['to_exclude'] = [f'sub-{sub_id}' for sub_id in ['19931222BLON', '20020627GBVD']]
opt['exp_1']['no_mri'] = [f'sub-{sub_id}' for sub_id in ['19950121SRKN', '19961224AAMN']]
opt['exp_1']['ses_list'] = ['dots', 'lines', 'anat']
# ----------------------------------------------- experiment 2 ------------------------------------------------------- #
opt['exp_2'] = {}
opt['exp_2']['subj_list'] = [f'sub-{sub_id}' for sub_id in ['20000613BTBA', '19970522LINU', '20010722LLFL',
'19990729ANVN', '19960405EAFR', '20000217MCZN',
'19940521MRVN', '19961115GAPD', '19890618CAOM',
'19960904LUAT', '20011101DBBU', '19991017CIMN',
'20011224FARN', '19950621MRPV', '19950920MRRS',
'19961230RSTN', '20000519MRDM', '20011214CAAD',
'20000819NDAR', '19960330TTMD', '19901203ATBZ',
'19940424SFOH', '19930812ANVC', '20010710ANAB']
]
opt['exp_2']['to_exclude'] = [f'sub-{sub_id}' for sub_id in ['20010722LLFL', '20000519MRDM']]
opt['exp_2']['no_mri'] = []
opt['exp_2']['ses_list'] = ['meg', 'anat']
# ------------------------------------------------- events ----------------------------------------------------------- #
opt['baserate_hz'] = 6
opt['baserate_ms'] = 166
opt['event_id'] = {'ang_res_15': 15, 'ang_res_30': 30, 'trial_end': 99, 'long_break_start': 150,
'long_break_end': 199, 'test_phase': 130, 'button_red': 253, 'button_blue': 254,
'empty': 1}
opt['ang_res'] = [15, 30]
opt['cycle_time'] = {'15': 4, '30': 2}
opt['n_cycles'] = {'15': 11, '30': 22}
opt['n_trj'] = 264
opt['n_trls'] = 48
opt['n_trj_in_cycle'] = {'15': 24, '30': 12}
opt['n_blocks'] = 6
opt['foi'] = {'15': {'4': 1, '6': 1.5, '8': 2},
'30': {'4': 2, '6': 3}}
opt['cont_list'] = {'15': ['6>4', '6>8'],
'30': ['6>4']}
# ----------------------------------------------- preprocessing ------------------------------------------------------ #
# filters
opt['hp'] = .1
opt['lp'] = 40
# epochs
opt['tmin'] = -0.5 # s
opt['tmax'] = 44 # s
opt['diode_tolerance'] = 150 # samples
opt['reject_trls'] = True
opt['realign_trj'] = True
opt['starting_trj'] = 1
# number of segments into which to divide the time series
# it makes that this is a multiple of the number of cycles
# e.g. 15°: 4s (40s trial) --> 5 segments of 8 seconds (2 cycles);
# 30°: 2s (42s trial) --> 7 segments of 6 seconds (3 cycles).
opt['seg_info'] = {'15': {'n_seg': 5, 'seg_len': 8}, '30': {'n_seg': 7, 'seg_len': 6}}
opt['seg_overlap'] = 0 # in samples
# -------------------------------------------------- frequency ------------------------------------------------------- #
# fft
opt['frq_do'] = ['task']
opt['frq_foi_lims'] = [.1, 15]
opt['frq_out_fft'] = 'complex'
opt['frq_n_seg'] = 1 # this assumes that the segmentation has been done alrady
opt['frq_taper'] = 'boxcar' # boxcar to apply no taper,
# see https://docs.scipy.org/doc/scipy/reference/generated/scipy.signal.get_window.html#scipy.signal.get_window for options
# coherence
opt['coh_do'] = ['task']
opt['coh_method'] = 'ding'
# ------------------------------------------------ source space ------------------------------------------------------ #
opt['src_type'] = 'vol'
opt['src_bem_spacing'] = 4
opt['src_vol_spacing'] = 5. # distance in mm between source points
opt['src_smooth'] = 'nearest' # https://mne.tools/stable/overview/implementation.html#about-smoothing
# ----------------------------------------------- source analysis ---------------------------------------------------- #
opt['stc_method'] = 'LCMV'
opt['stc_out'] = 'max-power'
opt['stc_n_jobs'] = 5 # number of parallel jobs in source analysis
opt['stc_lambda'] = 0.05 # lambda parameter for beamformer
opt['stc_ch_type'] = 'meg'
opt['stc_realign_trj'] = True
opt['stc_cov_data'] = 'noise'
opt['stc_cov_method'] = 'empirical'
# reduce rank of the covariance matrix after tsss (Westner, 2022)
opt['stc_cov_rank'] = 'nfree' # rank of the covariance matrix, nfree to calculate the actual df otherwise as mne
# empty room cov options
opt['stc_cov_empty_data'] = 'raw'
# ------------------------------------------------- eye tracker ------------------------------------------------------ #
opt['eye_id'] = 'right'
opt['eye_blink'] = 'zero'
# https://wiki.cimec.unitn.it/tiki-index.php?page=EYE+LINK+1000+PLUS
opt['eye_chan'] = {'RX': 'MISC001', # (Right eye, X axis)',
'RY': 'MISC002', # (Right eye, Y axis)',
'RP': 'MISC003', # (Right eye, Pupil size)',
'LX': 'MISC004', # (Left eye, X axis)',
'LY': 'MISC005', # (Left eye, Y axis)',
'LP': 'MISC006'} # (Left eye, Pupil size)'}
# coordinates of the fixation window, obtained in util_estimate_fixwin.m
# x is fixationWindow(1) and fixationWindow(3)
# while y is fixationWindow(2) and fixationWindow(4)
opt['fixWin'] = [608.3400, 429.0700, 831.6600, 650.9300]
# opt['fixWin'] = [695, 515, 744, 564] # 1 deg
opt['fixWinSize'] = 4.5
opt['fixation_thresh'] = .8
opt['hmap_method'] = 'kde'
opt['hmap_downsampling'] = 1
# ------------------------------------------------- statistics ------------------------------------------------------- #
opt['cluster_method'] = 'cluster'
opt['ch_type_cluster'] = ['mag']
opt['tail'] = 0
opt['n_perms'] = 10000
opt['p_thresh'] = 0.05
opt['roi_list'] = ['entorhinal', 'hippocampus', 'parahippocampal', # regions of interest
'lateraloccipital', 'precentral', 'pericalcarine'] # control regions
# -------------------------------------------------- plotting -------------------------------------------------------- #
# change matplotlib defaults
# https://matplotlib.org/stable/tutorials/introductory/customizing.html
# https://matplotlib.org/stable/tutorials/introductory/customizing.html#the-default-matplotlibrc-file
plot_style = 'paper'
if plot_style == 'paper':
mpl.rc('axes', linewidth=1)
mpl.rc('ytick', direction='in')
mpl.rc('xtick', direction='in')
mpl.rc('ytick.major', width=1)
mpl.rc('xtick.major', width=1)
mpl.rc('savefig', dpi= 500)
mpl.rc('font', family='sans-serif', weight=500)
mpl.rc({'font.sans-serif': 'Arial'})
mpl.rc('axes.spines', right= False, top=False)
mpl.rc('figure', frameon= False)
else:
mpl.rc('axes', linewidth=5, titleweight='bold', labelweight='bold')
mpl.rc('ytick', direction='in')
mpl.rc('xtick', direction='in')
mpl.rc('ytick.major', width=3)
mpl.rc('xtick.major', width=3)
mpl.rc('savefig', dpi= 500)
mpl.rc('font', family='sans-serif', weight=500)
mpl.rc({'font.sans-serif': 'Arial'})
mpl.rc('axes.spines', right=False, top=False)
mpl.rc('figure', frameon=False)
# colors
cmap_rois = cm.get_cmap('Blues')
opt['colors'] = dict()
opt['cmap_rois'] = {'rh': cmap_rois(.75), 'lh': cmap_rois(.95)}
opt['colors']['beh'] = dict()
opt['colors']['beh']['dots'] = [cm.get_cmap('Greens')(.9), cm.get_cmap('Greens')(.75), cm.get_cmap('Greens')(.6)]
opt['colors']['beh']['lines'] = [cm.get_cmap('Blues')(.9), cm.get_cmap('Blues')(.75), cm.get_cmap('Blues')(.6)]
opt['colors']['beh']['meg'] = [cm.get_cmap('Reds')(.9), cm.get_cmap('Reds')(.75), cm.get_cmap('Reds')(.6)]
opt['colors']['fold'] = dict()
opt['colors']['fold']['dots+lines'] = {4: cm.get_cmap('magma')(.25), 6: cm.get_cmap('magma')(.55), 8: cm.get_cmap('magma')(.8)}
opt['colors']['fold']['dots'] = {4: cm.get_cmap('magma')(.25), 6: cm.get_cmap('magma')(.55), 8: cm.get_cmap('magma')(.8)}
opt['colors']['fold']['lines'] = {4: cm.get_cmap('magma')(.25), 6: cm.get_cmap('magma')(.55), 8: cm.get_cmap('magma')(.8)}
opt['colors']['fold']['meg'] = {4: cm.get_cmap('magma')(.35), 6: cm.get_cmap('magma')(.6), 8: cm.get_cmap('magma')(.9)}
opt['colors']['topo'] = 'RdBu_r'
opt['colors']['topo_marker'] = np.array([255, 213, 0])/255
opt['colors']['fit'] = dict()
opt['colors']['fit']['QL'] = np.array([16, 79, 85])/255
opt['colors']['fit']['LQ'] = np.array([234, 221, 166])/255
opt['colors']['eye-grid'] = dict()
opt['colors']['eye-grid']['rh'] = np.array([160, 200, 166]) / 255
opt['colors']['eye-grid']['lh'] = np.array([16, 79, 100]) / 255
opt['colors']['pink'] = np.array([204, 158, 245]) / 255
# ------------------------------------------------ create folders ---------------------------------------------------- #
# loop through these folders and create them if they dont exist
for k, v in opt.items():
if 'Path' in k:
if not os.path.exists(v):
os.mkdir(v)
# create subject specific log directories
for exp_id in ['1', '2']:
for sub_id in opt[f'exp_{exp_id}']['subj_list']:
if not os.path.exists(f"{opt['logPath']}{sub_id}/"):
os.mkdir(f"{opt['logPath']}{sub_id}/")
for ses_id in opt[f'exp_{exp_id}']['ses_list']:
if not os.path.exists(f"{opt['logPath']}{sub_id}/ses-{ses_id}/"):
os.mkdir(f"{opt['logPath']}{sub_id}/ses-{ses_id}/")