forked from mne-tools/mne-bids-pipeline
-
Notifications
You must be signed in to change notification settings - Fork 0
/
06-make_evoked.py
36 lines (24 loc) · 958 Bytes
/
06-make_evoked.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
"""
===============
06. Evoked data
===============
The evoked data sets are created by averaging different conditions.
"""
import os.path as op
import mne
from mne.parallel import parallel_func
import config
def run_evoked(subject):
print("Processing subject: %s" % subject)
meg_subject_dir = op.join(config.meg_dir, subject)
fname_epo = op.join(meg_subject_dir, '%s-epo.fif' % subject)
fname_ave = op.join(meg_subject_dir, '%s-ave.fif' % subject)
print(' Creating evoked datasets')
epochs = mne.read_epochs(fname_epo, preload=True)
evokeds = []
for condition in config.conditions:
evokeds.append(epochs[condition].average())
mne.evoked.write_evokeds(fname_ave, evokeds)
parallel, run_func, _ = parallel_func(run_evoked, n_jobs=config.N_JOBS)
subjects_iterable = [config.subjects] if isinstance(config.subjects, str) else config.subjects
parallel(run_func(subject) for subject in subjects_iterable)