-
Notifications
You must be signed in to change notification settings - Fork 0
/
pop_d2d_vis_artifacts.m
153 lines (135 loc) · 4.72 KB
/
pop_d2d_vis_artifacts.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
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
%
% GUI for the wrapper function for the vis_artifacts function in the clean_rawdata plugin for EEGLAB
%
% Dusk2Dawn
% Author: Richard Somervail, Istituto Italiano di Tecnologia, 2022
% www.iannettilab.net
%%
function pop_d2d_vis_artifacts(EEG)
%% get info about EEG data
nfiles = length(EEG);
if any( arrayfun( @(x) ~isfield(x.etc,'dusk2dawn'), EEG ) )
if nfiles == 1
errordlg2('Please use the master function (pop_dusk2dawn) or core function (1) first to clean the dataset before running this function' ...
,'Error: Dataset has not been cleaned with Dusk2dawn');
else
errordlg2('Please use the master function (pop_dusk2dawn) or core function (1) first to clean all the datasets before running this function' ...
,'Error: One or more datasets have not been cleaned with Dusk2dawn');
end
return
end
cfg = EEG(1).etc.dusk2dawn.cfg;
pars = cfg.pars; npars = length(pars.labels);
%% predefinitions
space = { {} };
%% define GUI elements - choose which dataset to plot
if nfiles > 1
geo_whichData = [ ...
1 ...
1 ...
];
ui_whichData = { ...
{ 'Style', 'text', 'string', 'Choose which dataset to plot:', 'fontweight', 'bold' } ...
{ 'Style', 'popupmenu', 'string', {EEG.setname}, 'value', 1, 'tag' 'whichData' } ...
};
else
geo_whichData = [];
ui_whichData = [];
end
%% define GUI elements - choose parameters of datasets to plot
if npars > 0
for p = 1:3
if npars >= p
parvals = d2d_getParList(pars.values{p});
parlabel = { 'Style', 'text', 'string', ['parameter ' num2str(p) ': ' pars.labels{p}], 'fontweight', 'normal'};
choosePars{p} = { % row1
parlabel ...
parlabel ...
... % row2
{ 'Style', 'popupmenu', 'string', [{' '}; parvals], 'value', 1, 'tag' ['selL_par_' num2str(p)] } ...
{} ...
{} ...
{ 'Style', 'popupmenu', 'string', parvals, 'value', 1, 'tag' ['selR_par_' num2str(p)] } ...
{} ...
{} ...
};
else
choosePars{p} = [ repmat(space,1,8) ];
end
end
geo_choosePars = { ...
1 ... % title
1 ... % title
1 ...
[1 1] ... % left/right red/blue
[1 1] ... % raw data checkbox
1 ...
[1 1 ] ... % param 1 (top)
ones(1,6) ... % param 1 (bottom)
1 ... %
[1 1 ] ... % param 2 (top)
ones(1,6) ... % param 2 (bottom)
1 ... %
[1 1 ] ... % param 3 (top)
ones(1,6) ... % param 3 (bottom)
};
ui_choosePars = [ ...
{{ 'Style', 'text', 'string', 'Choose which versions of the dataset to plot together:', 'fontweight', 'bold' }} ...
{{ 'Style', 'text', 'string', '-> when you are done click "OK"', 'fontweight', 'bold' }} ...
space ...
{{ 'Style', 'text', 'string', 'plot in red', 'fontangle','italic' ,'fontweight', 'bold' }} ...
{{ 'Style', 'text', 'string', 'plot in blue', 'fontangle','italic' ,'fontweight', 'bold' }} ...
{{ 'Style', 'checkbox', 'string' 'select raw data' 'value' 1 'tag' 'loadRaw' }} ...
space ...
space ...
choosePars{1} ...
space ...
choosePars{2} ...
space ...
choosePars{3} ...
];
else % no parameters to vary
geo_choosePars = [];
ui_choosePars = [];
end
%% build GUI
% assemble final UI list & geometry
geometry = [ ...
1 ...
geo_whichData ...
1 ...
geo_choosePars ...
1 ...
];
uilist = [ ...
space ...
ui_whichData ...
space ...
ui_choosePars ...
space ...
];
%% create GUI
if (npars > 0) || (nfiles > 1) % these are the two conditions in which we need to plot the GUI here
[ tmp1 tmp2 strhalt cfg ] = inputgui( geometry, uilist, ...
[], ['Superimpose the same dataset before/after ASR cleaning -- ' mfilename '()']);
% 'pophelp(pop_d2d_vis_artifacts)', ['Superimpose the same dataset before/after ASR cleaning -- ' mfilename '()']);
% return if cancelled
if ~strcmp(strhalt,'retuninginputui')
return
end
%% GUI outputs
% subtract the initial blank space from each selection
flds = fields(cfg);
for k = 1:length(flds)
if startsWith( flds{k}, 'selL')
cfg.(flds{k}) = cfg.(flds{k}) - 1;
end
end
end
%% call d2d_vis_artifacts
if nfiles > 1
EEG = EEG(cfg.whichData);
end
EEG.data = []; % no need to send the data to lower level functions (it's loaded there anyway)
d2d_vis_artifacts(EEG, cfg);
end