forked from lcnbeapp/beapp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbeapp_main.m
More file actions
259 lines (235 loc) · 10.4 KB
/
beapp_main.m
File metadata and controls
259 lines (235 loc) · 10.4 KB
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
253
254
255
256
257
258
259
function beapp_main(grp_proc_info_main)
%~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
% The Batch Electroencephalography Automated Processing Platform (BEAPP)
% Copyright (C) 2015, 2016, 2017, 2018
%
%
% Developed at Boston Children's Hospital Department of Neurology and the
% Laboratories of Cognitive Neuroscience
%
% All rights reserved.
%
% This software is being distributed with the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See GNU General
% Public License for more details.
%
% In no event shall Boston Children’s Hospital (BCH), the BCH Department of
% Neurology, the Laboratories of Cognitive Neuroscience (LCN), or software
% contributors to BEAPP be liable to any party for direct, indirect,
% special, incidental, or consequential damages, including lost profits,
% arising out of the use of this software and its documentation, even if
% Boston Children’s Hospital,the Laboratories of Cognitive Neuroscience,
% and software contributors have been advised of the possibility of such
% damage. Software and documentation is provided “as is.” Boston Children’s
% Hospital, the Laboratories of Cognitive Neuroscience, and software
% contributors are under no obligation to provide maintenance, support,
% updates, enhancements, or modifications.
%
% This program is free software: you can redistribute it and/or modify it
% under the terms of the GNU General Public License (version 3) as
% published by the Free Software Foundation.
%
% You should receive a copy of the GNU General Public License along with
% this program. If not, see <http://www.gnu.org/licenses/>.
%
% Description:
% The Batch Electroencephalography Automated Processing Platform (BEAPP) is a modular,
% MATLAB-based software designed to facilitate flexible batch processing
% of baseline and event related EEG files for artifact removal and analysis.
% BEAPP is designed for users who are comfortable using the MATLAB
% environment to run software but does not require advanced programing
% knowledge.
%
% Contributors to BEAPP:
% April R. Levin, MD (april.levin@childrens.harvard.edu)
% Adriana Méndez Leal (asmendezleal@gmail.com)
% Laurel Gabard-Durnam, PhD (laurel.gabarddurnam@gmail.com)
% Heather M. O'Leary (Heather.oleary1@gmail.com)
%
% Correspondence:
% April R. Levin, MD
% april.levin@childrens.harvard.edu
%
% In publications, please reference:
% Levin AR, Méndez Leal AS, Gabard-Durnam LJ and O’Leary HM (2018)
% BEAPP: The Batch Electroencephalography Automated Processing Platform.
% Front. Neurosci. 12:513. doi: 10.3389/fnins.2018.00513
%
% Additional Credits:
% BEAPP utilizes functionality from the software listed below. Users who choose to run any of this
% software through BEAPP should cite the appropriate papers in any publications.
%
% EEGLAB Version 14.0.0b
% http://sccn.ucsd.edu/wiki/EEGLAB_revision_history_version_14
%
% Delorme A & Makeig S (2004) EEGLAB: an open source toolbox for analysis
% of single-trial EEG dynamics. Journal of Neuroscience Methods 134:9-21
%
% PREP pipeline Version 0.52
% https://github.com/VisLab/EEG-Clean-Tools
%
% Bigdely-Shamlo N, Mullen T, Kothe C, Su K-M and Robbins KA (2015)
% The PREP pipeline: standardized preprocessing for large-scale EEG analysis
% Front. Neuroinform. 9:16. doi: 10.3389/fninf.2015.00016
%
% CSD Toolbox
% http://psychophysiology.cpmc.columbia.edu/Software/CSDtoolbox/
%
% Kayser, J., Tenke, C.E. (2006). Principal components analysis of Laplacian
% waveforms as a generic method for identifying ERP generator patterns: I.
% Evaluation with auditory oddball tasks. Clinical Neurophysiology, 117(2), 348-368
%
% Users using low-resolution (less than 64 channel) montages with the CSD toolbox should also cite:
% Kayser, J., Tenke, C.E. (2006). Principal components analysis of Laplacian
% waveforms as a generic method for identifying ERP generator patterns: II.
% Adequacy of low-density estimates. Clinical Neurophysiology, 117(2), 369-380
%
% HAPP-E Version 1.0
% Gabard-Durnam LJ, Méndez Leal AS, and Levin AR (2017) The Harvard Automated Pre-processing Pipeline for EEG (HAPP-E)
% Manuscript in preparation
% Requirements:
% BEAPP was written in Matlab 2016a. Older versions of Matlab may not
% support certain functions used in BEAPP.
% EEGLAB Version 14.1.2b:
% Delorme A & Makeig S (2004) EEGLAB: an open source toolbox for analysis
% of single-trial EEG dynamics. Journal of Neuroscience Methods 134:9-21
%
% PREP pipeline Version 0.52:
% Bigdely-Shamlo N, Mullen T, Kothe C, Su K-M and Robbins KA (2015)
% The PREP pipeline: standardized preprocessing for large-scale EEG analysis
% Front. Neuroinform. 9:16. doi: 10.3389/fninf.2015.00016
%
% CSD Toolbox:
% Kayser, J., Tenke, C.E. (2006). Principal components analysis of
% Laplacian waveforms as a generic method for identifying ERP generator
% patterns: I. Evaluation with auditory oddball tasks. Clinical Neurophysiology,
% 117(2), 348-368
%
% Users using low-resolution (less than 64 channel) montages with the
% CSD toolbox should also cite: Kayser, J., Tenke, C.E. (2006). Principal
% components analysis of Laplacian waveforms as a generic method for identifying
% ERP generator patterns: II. Adequacy of low-density estimates.
% Clinical Neurophysiology, 117(2), 369-380
%
% HAPPE:
% Gabard-Durnam, L. J., Mendez Leal, A. S., Wilkinson, C. L., & Levin, A. R.
% (2018). The Harvard Automated Processing Pipeline for Electroencephalography
% (HAPPE): standardized processing software for developmental and high-artifact data.
% Frontiers in Neuroscience (2018).
%
% The REST Toolbox:
% Li Dong*, Fali Li, Qiang Liu, Xin Wen, Yongxiu Lai, Peng Xu and Dezhong Yao*.
% MATLAB Toolboxes for Reference Electrode Standardization Technique (REST)
% of Scalp EEG. Frontiers in Neuroscience, 2017:11(601).
%
% MARA:
% Winkler et al., Automatic Classification of Artifactual ICA-Components
% for Artifact Removal in EEG Signals. Behavioral and Brain Functions 7:30 (2011).
%
% CleanLine:
% Mullen, T. (2012). NITRC: CleanLine: Tool/Resource Info.
%
%%~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
% The Batch Electroencephalography Automated Processing Platform (BEAPP)
% Copyright (C) 2015, 2016, 2017, 2018
%
%
% Developed at Boston Children's Hospital Department of Neurology and the
% Laboratories of Cognitive Neuroscience
%
% All rights reserved.
%
% This software is being distributed with the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See GNU General
% Public License for more details.
%
% In no event shall Boston Children’s Hospital (BCH), the BCH Department of
% Neurology, the Laboratories of Cognitive Neuroscience (LCN), or software
% contributors to BEAPP be liable to any party for direct, indirect,
% special, incidental, or consequential damages, including lost profits,
% arising out of the use of this software and its documentation, even if
% Boston Children’s Hospital,the Laboratories of Cognitive Neuroscience,
% and software contributors have been advised of the possibility of such
% damage. Software and documentation is provided “as is.” Boston Children’s
% Hospital, the Laboratories of Cognitive Neuroscience, and software
% contributors are under no obligation to provide maintenance, support,
% updates, enhancements, or modifications.
%
% This program is free software: you can redistribute it and/or modify it
% under the terms of the GNU General Public License (version 3) as
% published by the Free Software Foundation.
%
% You should receive a copy of the GNU General Public License along with
% this program. If not, see <http://www.gnu.org/licenses/>.
%~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
tic;
% set defaults and path, get user inputs if using scripts
if isequal(grp_proc_info_main, 'use_script')
grp_proc_info_main = beapp_configure_settings;
end
% check inputs, set output directories
grp_proc_info_main = prepare_to_run_main (grp_proc_info_main);
% run pipeline modules
if grp_proc_info_main.beapp_toggle_mods{'format','Module_On'}
grp_proc_info_main = batch_beapp_format(grp_proc_info_main);
end
if grp_proc_info_main.beapp_toggle_mods{'prepp','Module_On'}
grp_proc_info_main = batch_beapp_prepp(grp_proc_info_main);
end
if grp_proc_info_main.beapp_toggle_mods{'filt','Module_On'}
grp_proc_info_main = batch_beapp_filt(grp_proc_info_main);
end
if grp_proc_info_main.beapp_toggle_mods{'rsamp','Module_On'}
grp_proc_info_main = batch_beapp_rsamp(grp_proc_info_main);
end
if grp_proc_info_main.beapp_toggle_mods{'ica','Module_On'}
grp_proc_info_main = batch_beapp_ica(grp_proc_info_main);
end
if grp_proc_info_main.beapp_toggle_mods{'rereference','Module_On'}
grp_proc_info_main = batch_beapp_rereference(grp_proc_info_main);
end
if grp_proc_info_main.beapp_toggle_mods{'detrend','Module_On'}
grp_proc_info_main = batch_beapp_detrend(grp_proc_info_main);
end
%create segments/analysis windows from the data according to data type
if grp_proc_info_main.beapp_toggle_mods{'segment','Module_On'}
grp_proc_info_main = batch_beapp_segment(grp_proc_info_main);
end
%% output modules
if grp_proc_info_main.beapp_toggle_mods{'psd','Module_On'}
grp_proc_info_main =batch_beapp_psd(grp_proc_info_main);
end
if grp_proc_info_main.beapp_toggle_mods{'itpc','Module_On'}
grp_proc_info_main = batch_beapp_itpc(grp_proc_info_main);
end
if grp_proc_info_main.beapp_toggle_mods{'topoplot','Module_On'}
grp_proc_info_main = batch_beapp_topoplot(grp_proc_info_main);
end
if grp_proc_info_main.beapp_toggle_mods{'fooof','Module_On'}
batch_beapp_fooof(grp_proc_info_main);
end
if grp_proc_info_main.beapp_toggle_mods{'pac','Module_On'}
batch_beapp_pac(grp_proc_info_main);
end
if grp_proc_info_main.beapp_toggle_mods{'bycycle','Module_On'}
batch_beapp_bycycle(grp_proc_info_main);
end
diary off;
cd(grp_proc_info_main.src_dir{1});
% deletes temporary directories
rowfun(@delete_temp_dirs,grp_proc_info_main.beapp_toggle_mods,'NumOutputs',0);
%end the timer
grp_proc_info_main.proc_etime=toc;
%runtime report is written into out directory
mk_runtime_report(grp_proc_info_main);
%return to the source code directory
if isdir(grp_proc_info_main.beapp_root_dir{1})
disp('Processing completed returning to the BEAPP source code directory');
cd(grp_proc_info_main.beapp_root_dir{1});
else
disp('Processing completed');
end
clearvars;
end