Commit 813bc346 authored by James Desjardins's avatar James Desjardins
Browse files

fix various issues with displaying marks in ve_eegplot.

parent de98c728
......@@ -1164,7 +1164,7 @@ else
lowlim = round(g.time*multiplier+1);
highlim = round(min((g.time+g.winlength)*multiplier+2,g.frames));
low_high_range = lowlim:highlim;
zlowhigh = zeros(1,length(low_high_range));
%zlowhigh = zeros(1,length(low_high_range));
% Plot data and update axes
% -------------------------
......@@ -1204,18 +1204,34 @@ else
%% HANDLE MARKING ...
%calculate x ifinterval for channel tags...
% get the y axis limits.
ylims=get(gca,'YLim');
% calculate x interval for channel tags...
figdim=axis;
tag_x_int=figdim(2)*g.inter_tag_int;
% plot channels whose order is < 0.
% PLOT CHANNELS WHOSE ORDER IS < 0.
% get the 'manual' channel mark index (should always be 1).
manual_mark_ind=find(strcmp('manual',{g.chan_marks_struct.label}));
mark_inds=find([g.chan_marks_struct.order]<0);
% get the indexes of channel marks whose order is smaller than 0.
mark_inds=find([g.chan_marks_struct.order]<100);
% get the number of channel marks whose order is smaller than 0.
n_mark_inds=length(mark_inds);
% get the totla number of channel marks.
tot_marks = length(g.chan_marks_struct);
for fi=1:n_mark_inds;
% loop through for each channel mark
for fi=1:tot_marks;
% get the channel indexes flagged by the current (order < 0) mark.
chan_inds=find(g.chan_marks_struct(mark_inds(fi)).flags);
% get the color of the current mark.
tmp_color=g.chan_marks_struct(mark_inds(fi)).line_color;
% if the data are overlayed.
if strcmp(g.plotdata2, 'on');
if length(g.color)==2;
tmp_color=g.color{2};
......@@ -1223,41 +1239,90 @@ else
tmp_color=[.7 .7 .7];
end
end
% establish the x location of the current mark ticks.
plot_p1 = 1+tag_x_int*(tot_marks-(mark_inds(fi)-1));
% establish the y location of the current mark ticks.
plot_p2 = (g.chans-(chan_inds-1))*g.spacing;
% get the color of the current mark tick.
plot_colour = g.chan_marks_struct(mark_inds(fi)).tag_color;
if isempty(findobj('tag',['tagtext_' g.chan_marks_struct(fi).label]));
text(figdim(1)-(.01*figdim(2)-figdim(1))*fi,ylims(2)-0.005,['> ',g.chan_marks_struct(mark_inds(fi)).label], ...
'color',plot_colour, ...
'fontweight','bold', ...
'interpreter','none', ...
'tag',['tagtext_' g.chan_marks_struct(fi).label], ...
'rotation',90);
end
% tmph2 = text([tmplat], ylims(2)-0.005, [EVENTFONT evntxt], ...
% 'color', g.eventcolors{ event2plot(index) }, ...
% 'horizontalalignment', 'left',...
% 'rotation',90);
% loop through each of the current mark channels.
for ci=1:length(chan_inds);
%plot tick...
plot(plot_p1, plot_p2(ci),'<', ...
'MarkerEdgeColor', plot_colour, ...
'MarkerFaceColor', plot_colour, ...
'MarkerSize', 8,'tag',['marker_' num2str(chan_inds(ci)) '_' g.chan_marks_struct(mark_inds(fi)).label]);
%change line color
% if this is the manual mark.. or it is another mark (order <
% 0) that is not flagged as 'manual'.
if fi==manual_mark_ind || ~g.chan_marks_struct(manual_mark_ind).flags(chan_inds(ci));
% establish y index of current channel plot.
tmp_offset=(g.chans-(chan_inds(ci)-1))*g.spacing-(meandata(chan_inds(ci)));
% plot the line for the current mark and channel.
line(1:length(low_high_range), ...
data(chan_inds(ci),low_high_range) + tmp_offset, zlowhigh, ...
data(chan_inds(ci),low_high_range) + tmp_offset, zeros(1,length(low_high_range))+g.chan_marks_struct(fi).order, ...
'color', tmp_color, 'clipping','on','tag',['line_' num2str(chan_inds(ci))]);
end
end
end
ylims=get(gca,'YLim');
% get index for all non-flagged channels.
chan_inds=find(sum([g.chan_marks_struct.flags],2)==0);
% set the color of non-flagged channels.
tmp_color=g.color{:};%[0,0,.3];
% if there is overlayed data.
if strcmp(g.plotdata2, 'on')
if length(g.color)==2
tmp_color=g.color{2};
else
tmp_color=[.7 .7 .7];
end
end
% loop through for each of the non flagged channels.
for ci=1:length(chan_inds);
tmp_offset=(g.chans-(chan_inds(ci)-1))*g.spacing-(meandata(chan_inds(ci)));
line(1:length(low_high_range), ...
data(chan_inds(ci),low_high_range) + tmp_offset, zeros(1,length(low_high_range))+1, ...
'color', tmp_color, 'clipping','on','tag',['line_' num2str(chan_inds(ci))]);
end
% PLOT TIME MARKS.
% establish the inter mark interval.
inter_time_mark_offset=diff(ylims)*g.inter_mark_int;
%inter_time_mark_offset=figdim(4)*g.inter_mark_int;
% establish the y index of of the time marks.
time_marks_offset=diff(ylims)*g.marks_y_loc;
%time_marks_offset=figdim(4)*g.marks_y_loc;
% plot time_info flags.
cmap=[];
j=0;
%for ntf=1:length(time_marks_offset);
% loop through each time mark.
for tmi=1:length(g.time_marks_struct);
% make a two row flag array.
cflags=double([g.time_marks_struct(tmi).flags(lowlim:highlim);g.time_marks_struct(tmi).flags(lowlim:highlim)]);
cdat=cflags;
%cdat=cflags;
% scale values of flags according to marks_col_int.
cdat=g.marks_col_int*round(cflags/g.marks_col_int);
%build the color map for the current time mark.
tmp_cdat=cdat;
uval=unique(cdat);
for ci=1:length(uval);
......@@ -1267,7 +1332,10 @@ else
j=j+length(uval);
cdat=tmp_cdat;
% loop through each of the time mark offsets.
for i=1:length(time_marks_offset)
% plot the surface of the current time mark.
sh=surf(1:size(cflags,2), ...
[ylims(1)+inter_time_mark_offset*tmi+(time_marks_offset(i))-(inter_time_mark_offset*length(g.time_marks_struct)), ...
ylims(1)+inter_time_mark_offset*tmi+(time_marks_offset(i))+inter_time_mark_offset-(inter_time_mark_offset*length(g.time_marks_struct))], ...
......@@ -1275,65 +1343,23 @@ else
'CData',cdat, ...
'LineStyle','none','tag',['mark_' g.time_marks_struct(tmi).label]);
alpha(sh,g.marks_col_alpha);
% add the label of the current time mark (if object empty).
if isempty(findobj('tag',['text_' g.time_marks_struct(tmi).label]));
text(figdim(2),ylims(1)+inter_time_mark_offset*tmi+(time_marks_offset(i))-(inter_time_mark_offset*length(g.time_marks_struct)), ...
g.time_marks_struct(tmi).label,'color',g.time_marks_struct(tmi).color,'interpreter','none','tag',['text_' g.time_marks_struct(tmi).label]);
text(figdim(2), ...
ylims(1)+(inter_time_mark_offset*.5)+inter_time_mark_offset*tmi+(time_marks_offset(i))-(inter_time_mark_offset*length(g.time_marks_struct)), ...
['> ',g.time_marks_struct(tmi).label], ...
'color',g.time_marks_struct(tmi).color, ...
'interpreter','none', ...
'tag',['text_' g.time_marks_struct(tmi).label]);
end
end
end
% apply the color map.
colormap(cmap);
chan_inds=find(sum([g.chan_marks_struct.flags],2)==0);
tmp_color=g.color{:};%[0,0,.3];
if strcmp(g.plotdata2, 'on')
if length(g.color)==2
tmp_color=g.color{2};
else
tmp_color=[.7 .7 .7];
end
end
for ci=1:length(chan_inds);
%change line color
if fi==manual_mark_ind || ~g.chan_marks_struct(manual_mark_ind).flags(chan_inds(ci));
tmp_offset=(g.chans-(chan_inds(ci)-1))*g.spacing-(meandata(chan_inds(ci)));
line(1:length(low_high_range), ...
data(chan_inds(ci),low_high_range) + tmp_offset, zlowhigh, ...
'color', tmp_color, 'clipping','on','tag',['line_' num2str(chan_inds(ci))]);
end
end
% plot channels whose order is > 0.
mark_inds = find([g.chan_marks_struct.order]>0);
manual_mark_ind = strcmp('manual',{g.chan_marks_struct.label});
n_mark_inds=length(mark_inds);
tot_marks = length(g.chan_marks_struct);
for fi=1:length(mark_inds);
chan_inds = [];
chan_inds = find(g.chan_marks_struct(mark_inds(fi)).flags);
tmp_color = g.chan_marks_struct(mark_inds(fi)).line_color;
plot_p1 = 1+tag_x_int*(tot_marks-(mark_inds(fi)-1));
if strcmp(g.plotdata2, 'on')
if length(g.color) == 2
tmp_color = g.color{2};
else
tmp_color = [.7, .7, .7];
end
end
for ci=1:length(chan_inds);
%plot tick...
plot(plot_p1,(g.chans-(chan_inds(ci)-1))*g.spacing,'<', ...
'MarkerEdgeColor', g.chan_marks_struct(mark_inds(fi)).tag_color, ...
'MarkerFaceColor', g.chan_marks_struct(mark_inds(fi)).tag_color, ...
'MarkerSize',8,'tag',['marker_' num2str(chan_inds(ci)) '_' g.chan_marks_struct(mark_inds(fi)).label]);
%plot data
if ~g.chan_marks_struct(manual_mark_ind).flags(chan_inds(ci))
tmp_offset=(g.chans-(chan_inds(ci)-1))*g.spacing-(meandata(chan_inds(ci)));
line(1:length(lowlim:highlim),data(chan_inds(ci),lowlim:highlim) + tmp_offset, ones(1,length(lowlim:highlim))*1000, ...
'color', tmp_color, 'clipping','on','tag',['line_' num2str(chan_inds(ci))]);
end
end
end
% draw selected channels
% draw selected channels (highlights channels marked in winrej period)
% ------------------------
if ~isempty(g.winrej) && size(g.winrej,2) > 2
for tpmi = 1:size(g.winrej,1) % scan rows
......@@ -1591,6 +1617,10 @@ else
case 'draws'
% Redraw EEG and change scale
marker_h=findobj('-regexp','tag','marker_*');delete(marker_h);
mark_h=findobj('-regexp','tag','mark_*');delete(mark_h);
text_h=findobj('-regexp','tag','text_*');delete(text_h);
g = get(gcf,'UserData');
data = get(ax1, 'userdata');
ESpacing = findobj('tag','ESpacing','parent',gcf); % ui handle
......@@ -1617,10 +1647,11 @@ else
% ---------------
set(ESpacing,'string',num2str(g.spacing,4))
set(gcf, 'userdata', g);
ve_eegplot('drawp', 0);
set(ax1,'YLim',[0 (g.chans+1)*g.spacing],'YTick',[0:g.spacing:g.chans*g.spacing])
set(ax1, 'ylim',[g.elecoffset*g.spacing (g.elecoffset+g.dispchans+1)*g.spacing] );
ve_eegplot('drawp', 0);
% update scaling eye (I) if it exists
% -----------------------------------
eyeaxes = findobj('tag','eyeaxes','parent',gcf);
......
......@@ -163,38 +163,34 @@ if nargin < 5
% toggle bad channel
if results{4}==1
% get the labelof channel mark to toggle.
g.quick_chanflag=udf.chan_marks_struct(results{5}).label;
%if ~isfield(g.eloc_file, 'badchan');
% for i=1:length(g.eloc_file);
% g.eloc_file(i).badchan=0;
% end
%end
%ChanLabelStr=results{5};
%if iscell(ChanLabelStr);
% g.eventedit.ChanLabelCell=ChanLabelStr;
%else
% g.eventedit.ChanLabelCell=eval(['{' ChanLabelStr '}']);
%end
% loop though each of the channels to flag.
for i=1:length(g.eventedit.ChanLabelCell);
% get the index of the current channel to toggle.
g.eventedit.ChanIndex=strmatch(g.eventedit.ChanLabelCell{i},{udf.eloc_file.labels},'exact');
%if g.eloc_file(g.eventedit.ChanIndex).badchan==0;
% g.eloc_file(g.eventedit.ChanIndex).badchan=1;
%else
% g.eloc_file(g.eventedit.ChanIndex).badchan=0;
%end
%???? %get indices of all non-zero order channel marks.
mark_inds=find([udf.chan_marks_struct.order]);
% get the length of non-zero order channel marks.
n_mark_inds=length(mark_inds);
% get the index the current mark label.
mark_ind=find(strcmp(g.quick_chanflag,{udf.chan_marks_struct.label}));
%calculate x ifinterval for channel tags...
% establish location for channel tags...
figdim=axis;
tag_x_int=(figdim(2)-1)*udf.inter_tag_int;
chan_inds = linspace(udf.chans,1,udf.chans);
plot_p1 = 1+tag_x_int*mark_ind;
plot_p2 = (udf.chans-(chan_inds-1))*udf.spacing;
% if the current channel is not flagged for the current
% mark label.
if udf.chan_marks_struct(mark_ind).flags(g.eventedit.ChanIndex)==0;
% toggle the flag for the current channel of the chosen mark to 1.
udf.chan_marks_struct(mark_ind).flags(g.eventedit.ChanIndex)=1;
% establish location of channel mark tag.
plot_p1 = 1+tag_x_int*mark_inds(n_mark_inds-(mark_ind-1));
%replot tick...
%plot tick...
plot(plot_p1, plot_p2(chan_inds(g.eventedit.ChanIndex)),'<', ...
'MarkerEdgeColor', udf.chan_marks_struct(mark_ind).tag_color, ...
'MarkerFaceColor', udf.chan_marks_struct(mark_ind).tag_color, ...
......@@ -203,11 +199,19 @@ if nargin < 5
set(findobj(gcf,'tag',['line_' num2str(g.eventedit.ChanIndex)]), ...
'Color',udf.chan_marks_struct(mark_ind).line_color);
else
% if the channel is already flagged for the current mark label.
% ... unmark it.
udf.chan_marks_struct(mark_ind).flags(g.eventedit.ChanIndex)=0;
% get indeces of all non-manual channel marks.
non_manual_ind = find(~strcmp('manual',{udf.chan_marks_struct.label}));
% loop though each of the non-manual channel marks.
for mi=non_manual_ind(1):non_manual_ind(end);
%if the current channel is not marked for any
%label.
if ismember(g.eventedit.ChanIndex,find(sum([udf.chan_marks_struct.flags],2)==0));
% get mark colors.
tmp_color=udf.color{:};
% the data are overlayed.
if strcmp(udf.plotdata2, 'on')
if length(udf.color)==2
tmp_color=udf.color{2};
......@@ -215,10 +219,15 @@ if nargin < 5
tmp_color=[.7 .7 .7];
end
end
% set the color of the current line
delete(findobj(gcf,'tag',['marker_' num2str(g.eventedit.ChanIndex) '_' g.quick_chanflag]));
set(findobj(gcf,'tag',['line_' num2str(g.eventedit.ChanIndex)]), ...
'Color',tmp_color);
% continue to next mi iteration.
continue;
end
% if the current channels is flagged for the
% current non-zdro order mark.
if udf.chan_marks_struct(mi).flags(g.eventedit.ChanIndex)==1;
%replot tick...
delete(findobj(gcf,'tag',['marker_' num2str(g.eventedit.ChanIndex) '_' g.quick_chanflag]));
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment