-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFPVSWORD_make_SourceSpace.py
executable file
·85 lines (51 loc) · 2 KB
/
FPVSWORD_make_SourceSpace.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
#!/imaging/local/software/mne_python/mne1.4.0_1/bin/python
"""
Prepare Source Spaces for FPVS Frequency Sweep.
==========================================
OH, January 2020
"""
# TO DO: turn into function, use info from config file for FPVS
import sys
import os
from os import path as op
import numpy as np
from copy import deepcopy
# import matplotlib
# matplotlib.use('Agg') # for running graphics on cluster ### EDIT
from matplotlib import pyplot as plt
from importlib import reload
import mne
import config_fpvswords as config
reload(config)
print(mne.__version__)
filename = "/imaging/local/software/mne_python/set_MNE_2.7.3_FS_6.0.0_environ.py"
# for Python 3 instead of execfile
exec(compile(open(filename, "rb").read(), filename, 'exec'))
subjects_dir = config.subjects_dir
def make_source_space(sbj_id):
""" Make Source Space. """
subject = config.mri_subjects[sbj_id]
if subject == '':
print('No subject name for MRI specified - doing nothing now.')
return
### set up source space
src = mne.setup_source_space(subject, spacing=config.src_spacing,
subjects_dir=subjects_dir,
add_dist=True)
# check if bem directory exists, and create it if not
bem_path = op.join(subjects_dir, subject, 'bem')
if not os.path.isdir(bem_path):
print('Creating directory %s.' % bem_path)
os.mkdir(bem_path)
src_fname = op.join(subjects_dir, subject, 'bem', subject + '_' + str(config.src_spacing) + '-src.fif')
print("###\nWriting source spaces to " + src_fname + "\n###")
mne.write_source_spaces(src_fname, src, overwrite=True)
# get all input arguments except first
if len(sys.argv) == 1:
sbj_ids = np.arange(0, len(config.map_subjects)) + 1
else:
# get list of subjects IDs to process
sbj_ids = [int(aa) for aa in sys.argv[1:]]
for ss in sbj_ids:
make_source_space(ss)
print('Done.')