-
Notifications
You must be signed in to change notification settings - Fork 19
/
eegplugin_iclabel.m
60 lines (50 loc) · 2.75 KB
/
eegplugin_iclabel.m
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
function vers = eegplugin_iclabel( fig, try_strings, catch_strings )
%EEGLABPLUGIN_ICLABEL EEGLAB plugin for EEG IC labeling
% Label independent components using ICLabel. Go to
% https://sccn.ucsd.edu/wiki/ICLabel for a tutorial on this plug-in. Go
% to labeling.ucsd.edu/tutorial/about for more information. To report a
% bug or issue, please create an "Issue" post on the GitHub page at
% https://github.com/sccn/ICLabel/issues or send an email to
%
% Results are stored in EEG.etc.ic_classifications.ICLabel. The matrix of
% label vectors is stored under "classifications" and the cell array of
% class names are stored under "classes". The matrix stored under
% "classifications" is organized with each column matching to the
% equivalent element in "classes" and each row matching to the equivalent
% IC. For example, if you want to see what percent ICLabel attributes IC
% 7 to the class "eye", you would look at:
% EEG.etc.ic_classifications.ICLabel.classifications(7, 3)
% since EEG.etc.ic_classifications.ICLabel.classes{3} is "eye".
% version
vers = 'ICLabel1.6';
% input check
if nargin < 3
error('eegplugin_iclabel requires 3 arguments');
end
% add items to EEGLAB tools menu
plotmenu = findobj(fig, 'tag', 'tools');
iclabelmenu = uimenu( plotmenu, 'label', 'Classify components using ICLabel','userdata', 'startup:off;study:on;roi:off');
lightMenuFlag = isempty(findobj(fig, 'Label', 'Reject data epochs'));
if lightMenuFlag, set(iclabelmenu, 'position', 9); else set(iclabelmenu, 'position', 12); end
viewpropcom = [ 'try, pop_viewprops(EEG, 0); catch,' ...
'try, vp_path = fullfile(fileparts(which(''iclabel'')), ''viewprops'');' ...
'addpath(vp_path); if length(EEG) == 1, LASTCOM = pop_viewprops(EEG, 0); end;' ...
'disp(''ICLabel: Install the viewprops eeglab plugin to create IC visualizations like these elsewhere.''),' ...
'catch, end; end;'];
if ~isfield(try_strings, 'check_ica_chanlocs')
try_strings.check_ica_chanlocs = try_strings.check_ica;
end
uimenu( iclabelmenu, 'label', 'Label components', ...
'callback', [try_strings.check_ica_chanlocs ...
'[EEG, LASTCOM] = pop_iclabel(EEG);' ...
catch_strings.store_and_hist ...
'if ~isempty(LASTCOM),' ...
viewpropcom ' end' ], 'userdata', 'startup:off;study:on');
uimenu( iclabelmenu, 'label', 'Flag components as artifacts', ...
'callback', [try_strings.check_ica_chanlocs '[EEG, LASTCOM] = pop_icflag(EEG);' catch_strings.store_and_hist ], 'userdata', 'startup:off;study:on');
uimenu( iclabelmenu, 'label', 'View extended component properties', ...
'callback', viewpropcom );
% activate matconvnet
activate_matconvnet();
end