Skip to content

Commit e948ab4

Browse files
committed
remove avg reref from preprocessing but keep in plotting
1 parent cac0150 commit e948ab4

File tree

2 files changed

+27
-13
lines changed

2 files changed

+27
-13
lines changed

eeg_nemar_preprocess.m

+16-12
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@
5959
disp(status_tbl)
6060
status = table2array(status_tbl);
6161

62+
splitted = split(EEG.filename(1:end-4),'_');
63+
modality = splitted{end};
64+
6265
fprintf('Running pipeline sequence %s\n', strjoin(opt.pipeline, '->'));
6366
try
6467
for i=1:numel(opt.pipeline)
@@ -88,18 +91,18 @@
8891
rm_chan_types = {'AUDIO','MEG','EOG','ECG','EMG','EYEGAZE','GSR','HEOG','MISC','PPG','PUPIL','REF','RESP','SYSCLOCK','TEMP','TRIG','VEOG'};
8992
if isfield(EEG.chanlocs, 'type')
9093
EEG = pop_select(EEG, 'rmchantype', rm_chan_types);
91-
types = {EEG.chanlocs.type};
92-
eeg_indices = strmatch('EEG', types)';
93-
if ~isempty(eeg_indices)
94-
EEG = pop_select(EEG, 'chantype', 'EEG');
95-
else
96-
warning("No EEG channel type detected (for first EEG file). Keeping all channels");
97-
end
94+
if strcmp(modality, 'eeg')
95+
types = {EEG.chanlocs.type};
96+
eeg_indices = strmatch('EEG', types)';
97+
if ~isempty(eeg_indices)
98+
EEG = pop_select(EEG, 'chantype', 'EEG');
99+
else
100+
warning("No EEG channel type detected (for first EEG file). Keeping all channels");
101+
end
102+
end
98103
else
99-
warning("Channel type not detected (for first EEG file)");
104+
warning("Channel type not detected (for first recording file)");
100105
end
101-
% ALLEEG = pop_select( ALLEEG,'nochannel',{'VEOG', 'Misc', 'ECG', 'M2'});
102-
103106
status_tbl.remove_chan = 1;
104107
end
105108

@@ -120,12 +123,12 @@
120123
'LineNoiseCriterion',4,'Highpass',[0.75 1.25] ,'BurstCriterion',20, ...
121124
'WindowCriterion',0.25,'BurstRejection','on','Distance','Euclidian', ...
122125
'WindowCriterionTolerances',[-Inf 7] ,'fusechanrej',1}; % based on Arnaud paper
123-
% ALLEEG = parexec(ALLEEG, 'pop_clean_rawdata', opt.logdir, options{:});
124126
EEG = pop_clean_rawdata( EEG, options{:});
125127

126128
status_tbl.cleanraw = 1;
127129
end
128130

131+
%{
129132
if strcmp(operation, "avg_ref")
130133
if resume && status_tbl.avg_ref
131134
fprintf('Skipping avg_ref\n');
@@ -138,6 +141,7 @@
138141
139142
status_tbl.avg_ref = 1;
140143
end
144+
%}
141145

142146
if strcmp(operation, "runica")
143147
if resume && status_tbl.runica
@@ -154,7 +158,7 @@
154158
status_tbl.runica = 1;
155159
end
156160

157-
if strcmp(operation, "iclabel")
161+
if strcmp(operation, "iclabel") && strcmp(modality, 'eeg')
158162
if resume && status_tbl.iclabel
159163
fprintf('Skipping iclabel\n');
160164
continue

eeg_nemar_vis.m

+11-1
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@
5656

5757
fprintf('Plots: %s\n', strjoin(opt.plots, ', '));
5858

59+
splitted = split(EEG.filename(1:end-4), '_');
60+
modality = splitted{end};
61+
5962
try
6063
for i=1:numel(opt.plots)
6164
plot = opt.plots{i};
@@ -72,7 +75,7 @@
7275
plot_IC_activation(EEG);
7376
end
7477

75-
if strcmp(plot, 'icmap')
78+
if strcmp(plot, 'icmap') && ~strcmp(modality, 'ieeg')
7679
plot_ICLabel(EEG);
7780
end
7881

@@ -151,6 +154,10 @@ function plot_spectra(EEG, varargin)
151154
g = finputcheck(varargin, { 'freq' 'integer' [] [6, 10, 22]; ...
152155
'freqrange' 'integer' [] [1 70]; ...
153156
'percent' 'integer' [], 10});
157+
158+
% average reference before plotting
159+
EEG = pop_reref(EEG,[], 'interpchan', []);
160+
154161
% spectopo plot
155162
[spec, freqs] = spectopo(EEG.data, 0, EEG.srate, 'freqrange', g.freqrange, 'title', '', 'chanlocs', EEG.chanlocs, 'percent', g.percent,'plot', 'off');
156163
[~,ind50]=min(abs(freqs-50));
@@ -180,6 +187,9 @@ function plot_IC_activation(EEG)
180187
error('No IC decomposition found for EEG')
181188
end
182189

190+
% average reference before plotting
191+
EEG = pop_reref(EEG,[], 'interpchan', []);
192+
183193
EEG = pop_icflag(EEG,[0.75 1;NaN NaN;NaN NaN;NaN NaN;NaN NaN;NaN NaN;NaN NaN]);
184194
% IC activations plot
185195
iclocs = EEG.chanlocs;

0 commit comments

Comments
 (0)