Commit ff5d4084 authored by Brad Kennedy's avatar Brad Kennedy
Browse files

VERSION: 1.0.2

    * eegplugin_vised_marks.m: Changed name to Marks

    * marks/branch_func/marks_eeg_regepochs.m: Code formatting

    * vised/branch_func/ve_eegplot.m: Code cleanup/formatting

    * vised/command_func/ve_update.m: Fixed ICA mark copy back

    * vised/pop_func/pop_ve_edit.m: Code cleanup/formatting,
      fixed ICA mark copy update

    * vised/pop_func/pop_vised.m: Code cleanup/formatting
parent 9fa5bf2f
2017-08-18 Brad Kennedy <bk@co60.ca>
* eegplugin_vised_marks.m: Changed name to Marks
* marks/branch_func/marks_eeg_regepochs.m: Code formatting
* vised/branch_func/ve_eegplot.m: Code cleanup/formatting
* vised/command_func/ve_update.m: Fixed ICA mark copy back
* vised/pop_func/pop_ve_edit.m: Code cleanup/formatting,
fixed ICA mark copy update
* vised/pop_func/pop_vised.m: Code cleanup/formatting
2017-07-25 Brad Kennedy <bk@co60.ca>
* CHANGELOG: Change changelog format to actually contain changes
ensure you follow the format and put newer changes above this one
* eegplugin_vised_marks.m: Added version such that it generates it
from the VERSION file in this directory
\ No newline at end of file
from the VERSION file in this directory
v1.0.1
\ No newline at end of file
v1.0.2
......@@ -72,7 +72,6 @@ addpath(genpath(fileparts(which('eegplugin_vised_marks.m'))));
%% vised
% find EEGLAB tools menu.
% ---------------------
filemenu=findobj(fig,'label','File');
editmenu=findobj(fig,'label','Edit');
% Create "pop_vised" callback cmd.
......@@ -80,10 +79,6 @@ editmenu=findobj(fig,'label','Edit');
VisEd_cmd='[EEG,LASTCOM] = pop_vised(EEG,''pop_gui'',''on'');';
finalcmdVE=[try_strings.no_check VisEd_cmd catch_strings.add_to_hist];
%CONFIG
vc_menu=uimenu(filemenu, 'Label', 'Vised configuration','separator','on', ...
'callback','vised_config=pop_edit_vised_config;');
% add "Visual edit" submenu to the "Edit" menu.
%--------------------------------------------------------------------
uimenu(editmenu, 'label', 'Visually edit in scroll plot', 'callback', finalcmdVE);
......@@ -97,7 +92,7 @@ toolsmenu=findobj(fig,'Label','Tools');
%--------------------------------------------------------------------------
% Create "Batch" menu.
% -------------------------------------------------------------------------
marksmenu = uimenu( toolsmenu, 'Label', 'marks','separator','on');
marksmenu = uimenu( toolsmenu, 'Label', 'Marks','separator','on');
% -------------------------------------------------------------------------
......
......@@ -67,17 +67,17 @@ end;
% test input variables
% --------------------
if ~isstruct(EEG) | ~isfield(EEG,'event')
if ~isstruct(EEG) || ~isfield(EEG,'event')
error('first argument must be an EEG structure')
elseif EEG.trials > 1
error('input dataset must be continuous data (1 epoch)');
end
if nargin > 1 && ~isstr(varargin{1})
if nargin > 1 && ~ischar(varargin{1})
options = {};
if nargin >= 2, options = { options{:} 'recurrence' varargin{1} }; end;
if nargin >= 3, options = { options{:} 'limits' varargin{2} }; end;
if nargin >= 4, options = { options{:} 'rmbase' varargin{3} }; end;
if nargin >= 2, options = [ options 'recurrence' varargin{1} ]; end;
if nargin >= 3, options = [ options 'limits' varargin{2} ]; end;
if nargin >= 4, options = [ options 'rmbase' varargin{3} ]; end;
else
options = varargin;
end;
......@@ -86,9 +86,9 @@ g = finputcheck(options, { 'recurrence' 'real' [] 1;
'rmbase' 'real' [] 0;
'eventtype' 'string' {} 'X';
'extractepochs' 'string' { 'on','off' } 'on' }, 'eeg_regepochs');
if isstr(g), error(g); end;
if ischar(g), error(g); end;
if g.recurrence < 0 | g.recurrence > EEG.xmax
if g.recurrence < 0 || g.recurrence > EEG.xmax
error('recurrence_interval out of bounds');
end
......@@ -96,7 +96,7 @@ if nargin < 3
g.limits = [0 g.recurrence];
end
if length(g.limits) ~= 2 | g.limits(2) <= g.limits(1)
if length(g.limits) ~= 2 || g.limits(2) <= g.limits(1)
error('epoch limits must be a 2-vector [minsec maxsec]')
end
......@@ -104,7 +104,7 @@ end
% ---------------------------------
bg = 0; % beginning of data
en = length(EEG.data); % end of data in sec
nu = floor(en/(g.recurrence*EEG.srate)); % number of type 'X' events to add and epoch on
nu = floor(en / (g.recurrence * EEG.srate)); % number of type 'X' events to add and epoch on
% bg = EEG.event(1).latency/EEG.srate; % time in sec of first event
% en = EEG.event(end).latency/EEG.srate; % time in sec of last event
......@@ -116,9 +116,9 @@ end
% print info on commandline
% -------------------------
eplength = g.limits(2)-g.limits(1);
fprintf('The input dataset will be split into %d epochs of %g s\n',nu,eplength);
fprintf('Epochs will overlap by %2.0f%%.\n',(eplength-g.recurrence)/eplength*100);
eplength = g.limits(2) - g.limits(1);
fprintf('The input dataset will be split into %d epochs of %g s\n', nu, eplength);
fprintf('Epochs will overlap by %2.0f%%.\n',(eplength - g.recurrence) / eplength * 100);
% insert events and urevents at the end of the current (ur)event tables
% ---------------------------------------------------------------------
......@@ -131,21 +131,21 @@ end
nurevents = length(EEG.urevent);
for k = 1:nu
if rem(k,40)
if rem(k, 40)
fprintf('.')
else
fprintf('%d',k)
end
if k==40 | ( k>40 & ~rem(k-40,70))
if k == 40 || ( k > 40 && ~rem(k - 40, 70))
fprintf('\n');
end
EEG.event(nevents+k).type = g.eventtype;
EEG.event(nevents+k).latency = round(g.recurrence*(k-1)*EEG.srate+1);
EEG.event(nevents + k).type = g.eventtype;
EEG.event(nevents + k).latency = round(g.recurrence * (k-1) * EEG.srate + 1);
EEG.urevent(nurevents+k).type = g.eventtype;
EEG.urevent(nurevents+k).latency = g.recurrence*(k-1)*EEG.srate+1;
EEG.event(nevents+k).urevent = nurevents+k;
EEG.urevent(nurevents + k).type = g.eventtype;
EEG.urevent(nurevents + k).latency = g.recurrence * (k-1) * EEG.srate + 1;
EEG.event(nevents + k).urevent = nurevents + k;
end
fprintf('\n');
......
......@@ -28,7 +28,7 @@ if nargin < 1
end;
%% GET INPUTS ...
if ~isstruct(EEG) | ~isfield(EEG,'event')
if ~isstruct(EEG) || ~isfield(EEG,'event')
error('first argument must be an EEG structure')
elseif EEG.trials > 1
error('input dataset must be continuous data (1 epoch)');
......@@ -40,46 +40,35 @@ try
for index = 1:length(options)
if iscell(options{index}) && ~iscell(options{index}{1}), options{index} = { options{index} }; end;
end;
if ~isempty( varargin ), g=struct(options{:});
else g= []; end;
g = [];
if ~isempty( varargin )
g=struct(options{:});
end
catch
disp('marks_continuous2epochs() error: calling convention {''key'', value, ... } error'); return;
disp('marks_continuous2epochs() error: calling convention {''key'', value, ... } error');
return;
end;
try g.recurrence; catch, g.recurrence =[1];disp('Using default recurrence of 1 second...');end
try
g.recurrence;
catch
g.recurrence = 1;
disp('Using default recurrence of 1 second...');
end
try g.limits;
catch, g.limits=[0 g.recurrence];
disp(['Using default limits of [',num2str(g.limits),'] seconds based on recurrence value.']);
end
try g.keepboundary; catch, g.keepboundary ='on'; end
try g.rmbase; catch, g.rmbase =[NaN];end
try g.eventtype; catch, g.eventtype ='tmp_cnt2win';end
try g.extractepochs; catch, g.extractepochs ='on';end
%if nargin > 1 && ~isstr(varargin{1})
% options = {};
% if nargin >= 2, options = { options{:} 'recurrence' varargin{1} }; end;
% if nargin >= 3, options = { options{:} 'limits' varargin{2} }; end;
% if nargin >= 5, options = { options{:} 'keepboundary' varargin{3} }; end;
% if nargin >= 4, options = { options{:} 'rmbase' varargin{3} }; end;
%else
% options = varargin;
%end;
%g = finputcheck(options, { 'recurrence' 'real' [] 1;
% 'limits' 'real' [] [0 1];
% 'keepboundary' 'string' {'on','off'} 'on';
% 'rmbase' 'real' [] [NaN];
% 'eventtype' 'string' {} 'tmp_cnt2win';
% 'extractepochs' 'string' { 'on','off' } 'on' }, 'eeg_regepochs');
%if isstr(g), error(g); end;
% CHECK INPUTS
if length(g.limits)~=2;
msg=sprintf('%s\r%s\r%s\r%s\r','"limits" input must have two values representing start point',...
msg=sprintf('%s\n%s\n%s\n%s\n','"limits" input must have two values representing start point',...
'and end point of epochs relative to recurrence.', ...
'(e.g. [-.5 .5] for one second epochs centered on recurrence events)...', ...
'Doing nothing...');
......
......@@ -24,10 +24,10 @@ if nargin < 2
{'Style', 'edit', 'tag', 'edt_rec'}, ...
{'Style', 'text', 'string', 'time limits of epochs around recurrence in seconds (default [0 1]).'}, ...
{'Style', 'edit', 'tag', 'edt_lim'}, ...
{'Style', 'checkbox', 'string', 'Keep boundary events in the epochs when they occure', ...
{'Style', 'checkbox', 'string', 'Keep boundary events in the epochs when they occur', ...
'value',1}, ...
{'Style', 'text', 'string', 'Remove baseline from epochs'}, ...
{'Style', 'edit', 'tag', 'edt_rmbase','string','NaN'}, ...
{'Style', 'edit', 'tag', 'edt_rmbase','string',''}, ...
{'Style', 'text', 'string', 'Label for temporary epoching event.'}, ...
{'Style', 'edit', 'tag', 'edt_lim','string','tmp_cnt2win'}, ...
}, ...
......
This diff is collapsed.
......@@ -3,236 +3,243 @@ function ve_edit(varargin)
%% ONLY FOLLOW THROUGH IF THE CURRENTOBJ IS NOT ESPACING OR EPOSITION...
% Get the figure and axis userdata...
udf=get(gcf,'userdata');
uda=get(gca,'userdata');
udf = get(gcf, 'userdata');
uda = get(gca, 'userdata');
h_eegaxis=findobj('tag','eegaxis','parent',gcf);
h_espacing=findobj('tag','ESpacing','parent',gcf);
h_eposition=findobj('tag','EPosition','parent',gcf);
h_eegaxis = findobj('tag', 'eegaxis', 'parent', gcf);
h_espacing = findobj('tag', 'ESpacing', 'parent', gcf);
h_eposition = findobj('tag', 'EPosition', 'parent', gcf);
current_obj=get(gcf,'CurrentObject');
current_obj = get(gcf, 'CurrentObject');
if ~isempty(current_obj);
if current_obj==h_espacing || current_obj==h_eposition;
return
end
if ~isempty(current_obj) && ((current_obj == h_espacing) || (current_obj == h_eposition))
return
end
%% HANDLE THE INPUTS...
options = varargin;
for index = 1:length(options)
if iscell(options{index}) && ~iscell(options{index}{1}), options{index} = { options{index} }; end;
if iscell(options{index}) && ~iscell(options{index}{1}), options{index} = {options{index}}; end;
end;
g = [];
if ~isempty(varargin)
g = struct(options{:});
end;
if ~isempty( varargin ), g=struct(options{:});
else g=[]; end;
try g.quick_evtmk; catch
try g.quick_evtmk=g.qem; catch, g.quick_evtmk = ''; end;end;
try g.quick_evtmk; catch
try g.quick_evtmk = g.qem; catch, g.quick_evtmk = ''; end; end;
try g.quick_evtrm; catch
try g.quick_evtrm=g.qer; catch, g.quick_evtrm = 'off';end;end;
try g.quick_evtrm; catch
try g.quick_evtrm = g.qer; catch, g.quick_evtrm = 'off'; end; end;
try g.quick_chanflag; catch
try g.quick_chanflag=g.qcf; catch, g.quick_chanflag = ''; end;end;
try g.quick_chanflag; catch
try g.quick_chanflag = g.qcf; catch, g.quick_chanflag = ''; end; end;
try g.select_mark; catch
try g.select_mark=g.sm; catch, g.select_mark ='off'; end;end;
try g.select_mark; catch
try g.select_mark = g.sm; catch, g.select_mark = 'off'; end; end;
try g.add_winrej_mark; catch
try g.add_winrej_mark=g.awm;catch, g.add_winrej_mark =''; end;end;
try g.rm_winrej_mark; catch
try g.rm_winrej_mark=g.rwm; catch, g.rm_winrej_mark =''; end;end;
try g.add_winrej_mark; catch
try g.add_winrej_mark = g.awm; catch, g.add_winrej_mark = ''; end; end;
try g.rm_winrej_mark; catch
try g.rm_winrej_mark = g.rwm; catch, g.rm_winrej_mark = ''; end; end;
try g.add_page_mark; catch
try g.add_page_mark=g.apm; catch, g.add_page_mark =''; end;end;
try g.rm_page_mark; catch
try g.rm_page_mark=g.rpm; catch, g.rm_page_mark =''; end;end;
try g.add_page_mark; catch
try g.add_page_mark = g.apm; catch, g.add_page_mark = ''; end; end;
try g.rm_page_mark; catch
try g.rm_page_mark = g.rpm; catch, g.rm_page_mark = ''; end; end;
try g.page_forward; catch
try g.page_forward=g.pf; catch, g.page_forward ='off'; end;end;
try g.page_forward; catch
try g.page_forward = g.pf; catch, g.page_forward = 'off'; end; end;
try g.data_move; catch
try g.data_move=g.dm; catch, g.data_move ='off'; end;end;
try g.data_move; catch
try g.data_move = g.dm; catch, g.data_move = 'off'; end; end;
%% Store "tmppos" in the "g" structures...
g.tmppos=get(h_eegaxis,'currentpoint');
%% Store "tmppos" in the "g" structures...
g.tmppos = get(h_eegaxis, 'currentpoint');
%% Handle the index of the events...
if ~isfield(udf.events, 'index');
for i=1:length(udf.events);
udf.events(i).index=i;
udf.events(i).proc='none';
end
if ~isfield(udf.events, 'index')
indexes = num2cell(1:numel(udf.events));
[udf.events(:).index] = deal(indexes{:});
[udf.events.proc] = deal('none');
end
%% Define relative starting point for figure window latencies: "EEG.eventedit.WinStartPnt"
if size(uda,3)==1; % define WinStartPt. data point at wich current display window begins.
g.eventedit.WinStartPnt=udf.time*udf.srate;
g.eventedit.EpochIndex=1;
if size(uda, 3) == 1; % define WinStartPt. data point at wich current display window begins.
g.eventedit.WinStartPnt = udf.time * udf.srate;
g.eventedit.EpochIndex = 1;
else
g.eventedit.WindowIndex=udf.time+1;
g.eventedit.WinStartPnt=g.eventedit.WindowIndex*size(uda,2)-(size(uda,2)-1);
g.eventedit.EpochIndex=ceil((g.tmppos(1,1)+g.eventedit.WinStartPnt)/size(uda,2));
g.eventedit.WindowIndex = udf.time + 1;
g.eventedit.WinStartPnt = g.eventedit.WindowIndex * size(uda, 2) - (size(uda, 2) - 1);
g.eventedit.EpochIndex = ceil((g.tmppos(1, 1) + g.eventedit.WinStartPnt)/size(uda, 2));
end;
g.eventedit.PosLat=round(g.tmppos(1,1)+g.eventedit.WinStartPnt);
g.eventedit.PosLat = round(g.tmppos(1, 1)+g.eventedit.WinStartPnt);
%% Identify selected channel.
% By default use the 'Eelec' tex display of eegplot.
tmpChanIndex=strmatch(get(findobj(gcf,'Tag','Eelec'),'string'),{udf.eloc_file.labels},'exact');
if length(tmpChanIndex)==1;
g.eventedit.ChanIndex=tmpChanIndex;
tmpChanIndex = strmatch(get(findobj(gcf, 'Tag', 'Eelec'), 'string'), ...
{udf.eloc_file.labels}, 'exact');
if length(tmpChanIndex) == 1;
g.eventedit.ChanIndex = tmpChanIndex;
else
% Otherwise calculate ChanIndex from tmppos.
nWin=(udf.chans-udf.dispchans)+1;
stepWin=1/nWin;
if udf.dispchans==udf.chans;
curWinStrt=0;
nWin = (udf.chans - udf.dispchans) + 1;
stepWin = 1 / nWin;
if udf.dispchans == udf.chans;
curWinStrt = 0;
else
curWinStrt=floor((1-get(findobj('tag','eegslider'),'value'))/stepWin);
curWinStrt = floor((1 - get(findobj('tag', 'eegslider'), ...
'value'))/stepWin);
end
curWinEnd=curWinStrt+udf.dispchans;
YIndex=floor((tmppos(1,2)/(1/(udf.dispchans+1)))-.5);
g.eventedit.ChanIndex=(curWinEnd-YIndex);
if g.eventedit.ChanIndex==0;
g.eventedit.ChanIndex=1;
curWinEnd = curWinStrt + udf.dispchans;
YIndex = floor((tmppos(1, 2) / (1 / (udf.dispchans + 1)))-.5);
g.eventedit.ChanIndex = (curWinEnd - YIndex);
if g.eventedit.ChanIndex == 0;
g.eventedit.ChanIndex = 1;
end
if g.eventedit.ChanIndex>size(uda,1);
g.eventedit.ChanIndex=size(uda,1);
if g.eventedit.ChanIndex > size(uda, 1);
g.eventedit.ChanIndex = size(uda, 1);
end
end
clear tmpChanIndex
%% Check for event selection.
pntdist=ceil((udf.winlength*udf.srate)*0.002);
pntdist = ceil((udf.winlength * udf.srate)*0.002);
if isfield(g.eventedit, 'SelEventStruct');
g=rmfield(g.eventedit,'SelEventStruct');
g = rmfield(g.eventedit, 'SelEventStruct');
end
j=0;
for i=1:length(udf.events);
if abs(udf.events(i).latency-g.eventedit.PosLat)<pntdist;
j=j+1;
g.eventedit.SelEventStruct(j).index=i;
g.eventedit.SelEventStruct(j).dist=abs(udf.events(i).latency-round(g.tmppos(1,1)+g.eventedit.WinStartPnt));
g.eventedit.SelEventStruct(j).type=udf.events(i).type;
g.eventedit.SelEventStruct(j).latency=udf.events(i).latency;
j = 0;
for i = 1:length(udf.events);
if abs(udf.events(i).latency-g.eventedit.PosLat) < pntdist;
j = j + 1;
g.eventedit.SelEventStruct(j).index = i;
g.eventedit.SelEventStruct(j).dist = abs(udf.events(i).latency - ...
round(g.tmppos(1, 1)+g.eventedit.WinStartPnt));
g.eventedit.SelEventStruct(j).type = udf.events(i).type;
g.eventedit.SelEventStruct(j).latency = udf.events(i).latency;
end
end
%% HANDLE SELECT_MARK...
if strcmp(g.select_mark,'on');
ylims=get(gca,'YLim');
cxpnt=g.eventedit.WinStartPnt+round(g.tmppos(1,1));
if strcmp(g.select_mark, 'on');
ylims = get(gca, 'YLim');
cxpnt = g.eventedit.WinStartPnt + round(g.tmppos(1, 1));
inter_time_mark_offset=diff(ylims)*udf.inter_mark_int;
time_marks_offset=diff(ylims)*udf.marks_y_loc;
for tmi=1:length(udf.time_marks_struct);
for i=1:length(time_marks_offset)
l=ylims(1)+inter_time_mark_offset*tmi+(time_marks_offset(i))-(inter_time_mark_offset*length(udf.time_marks_struct));
h=ylims(1)+inter_time_mark_offset*tmi+(time_marks_offset(i))+inter_time_mark_offset-(inter_time_mark_offset*length(udf.time_marks_struct));
if g.tmppos(1,2)>l&&g.tmppos(1,2)<h;
%disp(['hit mark Y ',num2str(tmi)]);
if udf.time_marks_struct(tmi).flags(cxpnt);
%disp(['hit mark X ' num2str(cxpnt)]);
for pi=1:cxpnt-1;
if udf.time_marks_struct(tmi).flags(cxpnt-pi)==0||cxpnt-pi==0;
bnd(1)=cxpnt-(pi-1);
break
end
inter_time_mark_offset = diff(ylims) * udf.inter_mark_int;
time_marks_offset = diff(ylims) * udf.marks_y_loc;
for tmi = 1:length(udf.time_marks_struct);
for i = 1:length(time_marks_offset)
l = ylims(1) + inter_time_mark_offset * tmi + ...
time_marks_offset(i) - inter_time_mark_offset * ...
length(udf.time_marks_struct);
h = ylims(1) + inter_time_mark_offset * tmi + ...
time_marks_offset(i) + inter_time_mark_offset - ...
inter_time_mark_offset * length(udf.time_marks_struct);
if g.tmppos(1, 2) > l && g.tmppos(1, 2) < h ...
&& udf.time_marks_struct(tmi).flags(cxpnt)
for pi = 1:cxpnt - 1
if udf.time_marks_struct(tmi).flags(cxpnt-pi) == 0 ...
|| cxpnt - pi == 0
bnd(1) = cxpnt - (pi - 1);
break
end
for pi=1:size(uda,2)-cxpnt;
if udf.time_marks_struct(tmi).flags(cxpnt+pi)==0||cxpnt+pi==size(uda,2);
bnd(2)=cxpnt+pi;
break
end
end
if size(udf.winrej,2)==2;
udf.winrej(size(udf.winrej,1)+1,:)=bnd;
else
udf.winrej(size(udf.winrej,1)+1,1:2)=bnd;
udf.winrej(size(udf.winrej,1)+1,3:5)=udf.wincolor;
udf.winrej(size(udf.winrej,1)+1,6:size(udf.winrej,2))=zeros(1,size(udf.winrej,2)-5);
end
for pi = 1:size(uda, 2) - cxpnt;
if udf.time_marks_struct(tmi).flags(cxpnt+pi) == 0 ...
|| cxpnt + pi == size(uda, 2)
bnd(2) = cxpnt + pi;
break
end
set(gcf,'userdata',udf);
ve_eegplot('drawp',0);
end
if size(udf.winrej, 2) == 2;
udf.winrej(size(udf.winrej, 1)+1, :) = bnd;
else
udf.winrej(size(udf.winrej, 1)+1, 1:2) = bnd;
udf.winrej(size(udf.winrej, 1)+1, 3:5) = udf.wincolor;
udf.winrej(size(udf.winrej, 1)+1, 6:size(udf.winrej, 2)) = zeros(1, size(udf.winrej, 2)-5);
end
set(gcf, 'userdata', udf);
ve_eegplot('drawp', 0);
end
end
end
return
end
%% HANDLE ADD/REMOVE MARKS...
if ~isempty(g.add_winrej_mark)||~isempty(g.add_page_mark)||~isempty(g.rm_winrej_mark)||~isempty(g.rm_page_mark)
cxpnt=g.eventedit.WinStartPnt+round(g.tmppos(1,1));
%% HANDLE ADD/REMOVE MARKS...
if ~isempty(g.add_winrej_mark) || ~isempty(g.add_page_mark) || ~isempty(g.rm_winrej_mark) || ~isempty(g.rm_page_mark)
cxpnt = g.eventedit.WinStartPnt + round(g.tmppos(1, 1));
%find mark index
if ~isempty(g.add_winrej_mark)
mark_label=g.add_winrej_mark;
mark_label = g.add_winrej_mark;
elseif ~isempty(g.add_page_mark)
mark_label=g.add_page_mark;
mark_label = g.add_page_mark;
elseif ~isempty(g.rm_winrej_mark);
mark_label=g.rm_winrej_mark;
mark_label = g.rm_winrej_mark;
elseif ~isempty(g.rm_page_mark);
mark_label=g.rm_page_mark;
mark_label = g.rm_page_mark;
end
if strcmp(mark_label,'pop_select')
label_index=pop_chansel({udf.time_marks_struct.label});
if strcmp(mark_label, 'pop_select')
label_index = pop_chansel({udf.time_marks_struct.label});
else
label_index=find(strcmp(mark_label,{udf.time_marks_struct.label}));
label_index = find(strcmp(mark_label, {udf.time_marks_struct.label}));
end
if isempty(label_index);
tmp_marks_struct.time_info=udf.time_marks_struct;
tmp_marks_struct=pop_marks_add_label(tmp_marks_struct,'info_type','time_info', ...
'label',mark_label, ...
'action','add', ...
'message','Fill in the missing information for the mark that you are adding.');
udf.time_marks_struct=tmp_marks_struct.time_info;
label_index=length(udf.time_marks_struct);
tmp_marks_struct.time_info = udf.time_marks_struct;
tmp_marks_struct = pop_marks_add_label(tmp_marks_struct, 'info_type', 'time_info', ...
'label', mark_label, ...
'action', 'add', ...
'message', 'Fill in the missing information for the mark that you are adding.');
udf.time_marks_struct = tmp_marks_struct.time_info;
label_index = length(udf.time_marks_struct);
end
if ~isempty(g.add_page_mark)
udf.time_marks_struct(label_index).flags(g.eventedit.WinStartPnt+1:g.eventedit.WinStartPnt+(udf.winlength*udf.srate))=1;
end
if ~isempty(g.add_page_mark)
udf.time_marks_struct(label_index).flags(