-
Notifications
You must be signed in to change notification settings - Fork 1
/
dodo.py
203 lines (168 loc) · 7.38 KB
/
dodo.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
"""
Do-it script to execute the entire pipeline using the doit tool:
All the filenames are defined in config.py
Authors: José C. García Alanis <[email protected]>
License: BSD (3-clause)
Notes
-----
- for more on doit: http://pydoit.org
"""
from config import fname, subjects
# Configuration for the "doit" tool.
DOIT_CONFIG = dict(
# While running scripts, output everything the script is printing to the
# screen.
verbosity=2,
# When the user executes "doit list", list the tasks in the order they are
# defined in this file, instead of alphabetically.
sort='definition'
)
def task_check():
"""Check the system dependencies."""
return dict(
file_dep=['check_system.py'],
targets=[fname.system_check],
actions=['python check_system.py']
)
# This task executes a single analysis script for each subject, giving
# the subject as a command line parameter to the script.
def task_eeg_to_bids():
"""Step 00: Bring data set into a BIDS compliant directory structure."""
# Run the script for each subject in a sub-task.
for subject in subjects:
yield dict(
# This task should come after `task_check`
task_dep=['check'],
# A name for the sub-task: set to the name of the subject
name=subject,
# If any of these files change, the script needs to be re-run. Make
# sure that the script itself is part of this list!
file_dep=[fname.source(subject=subject,
source_type='eeg'),
fname.source(subject=subject,
source_type='demographics'),
'00_eeg_to_bids.py'],
# The files produced by the script
targets=[fname.bids_data(subject=subject)],
# How the script needs to be called. Here we indicate it should
# have one command line parameter: the name of the subject.
actions=['python 00_eeg_to_bids.py %s' % subject]
)
def task_repair_bad_channels():
"""Step 01: Identify and repair bad (i.e., noisy) EEG channels."""
# Run the script for each subject in a sub-task.
for subject in subjects:
yield dict(
# This task should come after `eeg_to_bids`
task_dep=['eeg_to_bids'],
# A name for the sub-task: set to the name of the subject
name=subject,
# If any of these files change, the script needs to be re-run. Make
# sure that the script itself is part of this list!
file_dep=['00_eeg_to_bids.py'],
# The files produced by the script
targets=[fname.output(processing_step='repair_bads',
subject=subject,
file_type='raw.fif')],
# How the script needs to be called. Here we indicate it should
# have one command line parameter: the name of the subject.
actions=['python 01_artefact_detection.py %s' % subject]
)
# This task executes a single analysis script for each subject, giving
# the subject as a command line parameter to the script.
def task_fit_ica():
"""Step 02: Decompose EEG signal into independent components."""
# Run the script for each subject in a sub-task.
for subject in subjects:
yield dict(
# This task should come after `repair_bad_channels`
task_dep=['repair_bad_channels'],
# A name for the sub-task: set to the name of the subject
name=subject,
# If any of these files change, the script needs to be re-run. Make
# sure that the script itself is part of this list!
file_dep=['01_artefact_detection.py'],
# The files produced by the script
targets=[fname.output(processing_step='fit_ica',
subject=subject,
file_type='ica.fif')],
# How the script needs to be called. Here we indicate it should
# have one command line parameter: the name of the subject.
actions=['python 02_fit_ica.py %s' % subject]
)
def task_repair_eeg_artefacts():
"""Step 04: Repair EEG artefacts caused by ocular movements."""
# Run the script for each subject in a sub-task.
for subject in subjects:
yield dict(
# This task should come after `fit_ica`
task_dep=['fit_ica'],
# A name for the sub-task: set to the name of the subject
name=subject,
# If any of these files change, the script needs to be re-run. Make
# sure that the script itself is part of this list!
file_dep=['00_eeg_to_bids.py',
'01_artefact_detection.py',
'02_fit_ica.py'],
# The files produced by the script
targets=[fname.output(processing_step='repaired_with_ica',
subject=subject,
file_type='raw.fif')],
# How the script needs to be called. Here we indicate it should
# have one command line parameter: the name of the subject.
actions=['python 03_repair_eeg_artefacts.py %s' % subject]
)
def task_extract_epochs():
"""Step 05: Extract epochs from continuous EEG."""
# Run the script for each subject in a sub-task.
for subject in subjects:
yield dict(
# This task should come after `fit_ica`
task_dep=['repair_eeg_artefacts'],
# A name for the sub-task: set to the name of the subject
name=subject,
# If any of these files change, the script needs to be re-run. Make
# sure that the script itself is part of this list!
file_dep=['00_eeg_to_bids.py',
'01_artefact_detection.py',
'02_fit_ica.py',
'03_repair_eeg_artefacts.py'],
# The files produced by the script
targets=[fname.output(processing_step='reaction_epochs',
subject=subject,
file_type='epo.fif')],
# How the script needs to be called. Here we indicate it should
# have one command line parameter: the name of the subject.
actions=['python 04_extract_epochs.py %s' % subject]
)
#
# # Here is another example task that averages across subjects.
# def task_example_summary():
# """Step 01: Average across subjects."""
# return dict(
# task_dep=['example_step'], # This task should come after
# `task_example_step`
# file_dep=[fname.output(subject=s) for s in subjects] + [
# '01_grand_average.py'],
# targets=[fname.grand_average],
# actions=['python 01_grand_average.py'],
# )
#
#
# def task_figures():
# """Make all figures. Each figure is a sub-task."""
# # Make figure 1
# yield dict(
# name='figure_example1',
# file_dep=['figure_example1.py'],
# targets=[fname.figure1],
# actions=['python figure_example1.py'],
# )
#
# # Make figure 2
# yield dict(
# name='figure_grand_average',
# file_dep=[fname.grand_average, 'figure_grand_average.py'],
# targets=[fname.figure_grand_average],
# actions=['python figure_grand_average.py'],
# )