Skip to content

Commit 271282f

Browse files
committed
fix study calling
1 parent 25ba107 commit 271282f

File tree

3 files changed

+46
-25
lines changed

3 files changed

+46
-25
lines changed

eeg_icalabelstat.m

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
% eeg_icalabelstat - show some stats about IC label
2+
%
3+
% Input:
4+
% EEG - EEGLAB dataset
5+
% threshold - threshold for belonging to a category (default 0.9
6+
% corresponding to 90%
7+
%
8+
% Author: A. Delorme
9+
10+
function eeg_icalabelstat(EEG, threshold)
11+
12+
if nargin < 1
13+
help eeg_icalabelstat;
14+
return;
15+
end
16+
if nargin < 2
17+
threshold = 0.9;
18+
end
19+
20+
ics = EEG.etc.ic_classification.ICLabel;
21+
if length(threshold) == 1, threshold(1:length(ics.classes)) = threshold; end
22+
for iIC = 1:length(ics.classes)
23+
ICfound = find(ics.classifications(:,iIC) > threshold(iIC));
24+
fprintf('%30s: %d/%d components at %d%% threshold\n', sprintf('IClabel class "%s"',ics.classes{iIC}), length(ICfound), size(ics.classifications,1), round(threshold(iIC)*100));
25+
end

pop_icflag.m

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@
3939
end
4040

4141
if nargin < 2
42+
if length(EEG) == 1
43+
eeg_icalabelstat(EEG);
44+
end
45+
4246
cat = { 'Brain' 'Muscle' 'Eye' 'Heart' 'Line Noise' 'Channel Noise' 'Other' };
4347
defaultMin = { '' '0.9' '0.9' '' '' '' '' };
4448
defaultMax = { '' '1' '1' '' '' '' '' };
@@ -58,30 +62,25 @@
5862

5963
res = inputgui(allGeom, allRows);
6064
if isempty(res)
65+
com = '';
6166
return
6267
end
6368

6469
thresh = cellfun(@str2double, res);
6570
thresh = reshape(thresh, 2, 7)';
6671
end
6772

68-
com = sprintf('EEG = pop_icflag(EEG, %s);',vararg2str(thresh));
69-
7073
if length(EEG) > 1
71-
for iEEG = 1:length(EEG)
72-
% run iclabel
73-
EEG(iEEG) = pop_icflag(EEG(iEEG), thresh);
74+
[ EEG, com ] = eeg_eval( 'pop_icflag', EEG, 'params', { thresh } );
75+
else
76+
% perform rejection
77+
flagReject = zeros(1,size(EEG.icaweights,1))';
78+
for iCat = 1:7
79+
tmpReject = EEG.etc.ic_classification.ICLabel.classifications(:,iCat) > thresh(iCat,1) & EEG.etc.ic_classification.ICLabel.classifications(:,iCat) < thresh(iCat,2);
80+
flagReject = flagReject | tmpReject;
7481
end
75-
return
82+
EEG.reject.gcompreject = flagReject;
83+
fprintf('%d components rejected\n', sum(flagReject));
84+
com = sprintf('EEG = pop_icflag(EEG, %s);',vararg2str(thresh));
7685
end
7786

78-
% perform rejection
79-
flagReject = zeros(1,size(EEG.icaweights,1))';
80-
for iCat = 1:7
81-
tmpReject = EEG.etc.ic_classification.ICLabel.classifications(:,iCat) > thresh(iCat,1) & EEG.etc.ic_classification.ICLabel.classifications(:,iCat) < thresh(iCat,2);
82-
flagReject = flagReject | tmpReject;
83-
end
84-
EEG.reject.gcompreject = flagReject;
85-
fprintf('%d components rejected\n', sum(flagReject));
86-
87-

pop_iclabel.m

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,12 @@
6868

6969
end
7070

71-
for iEEG = 1:length(EEG)
72-
% run iclabel
73-
EEG(iEEG) = iclabel(EEG(iEEG), version);
71+
if length(EEG) > 1
72+
[ EEG, com ] = eeg_eval( 'iclabel', EEG, 'params', { version } );
73+
varargout = {com};
74+
else
75+
EEG = iclabel(EEG(iEEG), version);
76+
varargout = {['EEG = pop_iclabel(EEG, ' version ');']};
7477
end
7578

7679
% % visualize with viewprops
@@ -86,12 +89,6 @@
8689
% end
8790
%
8891

89-
% return for EEG.history
90-
if nargout == 2
91-
varargout = {['EEG = pop_iclabel(EEG, ' version ');']};
92-
end
93-
94-
9592
% inputdlg3() - A comprehensive gui automatic builder. This function takes
9693
% text, type of GUI and default value and builds
9794
% automatically a simple graphic interface.

0 commit comments

Comments
 (0)