forked from MariusKlug/zapline-plus
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pop_zapline_plus.m
38 lines (30 loc) · 2.44 KB
/
pop_zapline_plus.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
% Author: Arnaud Delorme
function [EEG, com] = pop_zapline_plus(EEG, varargin)
com = '';
if nargin < 2
cb_auto = [ 'set(findobj(gcbf, ''userdata'', ''comp''), ''enable'', fastif(get(gcbo, ''value''), ''off'', ''on''));' ...
'if get(gcbo, ''value''), set(findobj(gcbf, ''tag'', ''comp''), ''string'', ''''); else set(findobj(gcbf, ''tag'', ''comp''), ''string'', ''3''); end' ];
promptstr = { ...
{ 'style' 'text' 'string' 'Enter line noise frequency (empty is auto):' } ...
{ 'style' 'edit' 'string' '' 'tag' 'freq' } ...
{ 'style' 'text' 'string' 'Enter auto noise detector threshold (lower detects more, recommended 3 to 10):' } ...
{ 'style' 'edit' 'string' '7' 'tag' 'detectorthreshold' } ...
{ 'style' 'checkbox' 'string' 'Divide data in chunks' 'value' 1 'tag' 'chunks' } ...
{ 'style' 'checkbox' 'string' 'Automatically detect the number of noise components' 'value' 1 'tag' 'autodetect' 'callback' cb_auto } ...
{ 'style' 'text' 'string' 'Or enter the number of components:' 'userdata' 'comp' 'enable' 'off'} ...
{ 'style' 'edit' 'string' '' 'tag' 'comp' 'userdata' 'comp' 'enable' 'off' } ...
{ 'style' 'checkbox' 'string' 'Plot results' 'value' 1 'tag' 'plot' } ...
};
geometry = {[2 0.5] [2 0.5] [1] [1] [2 0.5] [1] };
[~,~,~,res] = inputgui( 'geometry', geometry, 'geomvert', [1 1 1 1 1 1], 'uilist', promptstr, 'helpcom', 'pophelp(''pop_zapline_plus'')', 'title', 'Process data with Zapline-plus');
if isempty(res), return; end
options = { 'noisefreqs' str2num( [ '[' res.freq ']' ] )};
if ~isempty(res.detectorthreshold), options = [ options { 'coarseFreqDetectPowerDiff' str2num( [ '[' res.detectorthreshold ']' ] ) } ]; end
if res.chunks, options = [ options { 'chunkLength' 0 } ]; else options = [ options { 'chunkLength' 1e9 } ]; end
if res.autodetect, options = [ options { 'adaptiveNremove' 1 'fixedNremove' 1 } ]; else options = [ options { 'adaptiveNremove' 0 'fixedNremove' str2double(res.comp) } ]; end
if ~res.plot, options = [ options { 'plotResults' 0 } ]; end
else
options = varargin;
end
EEG = clean_data_with_zapline_plus_eeglab_wrapper(EEG, struct(options{:})); %, param);
com = sprintf('EEG = pop_zapline_plus(EEG, %s);', vararg2str(options));