Skip to content

Commit

Permalink
Fixed plotting of highlights for clusters, see bug 3361. Prevent warn…
Browse files Browse the repository at this point in the history
…ing for dimord could not be determined.
  • Loading branch information
robertoostenveld committed Oct 9, 2017
1 parent eebbe74 commit f0454f8
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
19 changes: 12 additions & 7 deletions ft_clusterplot.m
Expand Up @@ -66,6 +66,8 @@
return
end

ws = ft_warning('off', 'FieldTrip:getdimord:warning_dimord_could_not_be_determined');

% check if the input data is valid for this function
stat = ft_checkdata(stat, 'datatype', {'timelock', 'freq'}, 'feedback', 'yes');

Expand Down Expand Up @@ -239,14 +241,14 @@
probneg = [];
end

fprintf('There are %d clusters smaller than alpha (%g)', Nsigall, cfg.alpha);
fprintf('There are %d clusters smaller than alpha (%g)\n', Nsigall, cfg.alpha);

if is2D
% define time or freq window per cluster
for iPos = 1:length(sigpos)
possum_perclus = sum(sigposCLM(:,:,iPos),1); %sum over chans for each time- or freq-point
ind_min = min(find(possum_perclus~=0));
ind_max = max(find(possum_perclus~=0));
ind_min = find(possum_perclus~=0, 1 );
ind_max = find(possum_perclus~=0, 1, 'last' );
time_perclus = [time(ind_min) time(ind_max)];
if hastime
fprintf('%s%s%s%s%s%s%s%s%s%s%s\n', 'Positive cluster: ',num2str(sigpos(iPos)), ', pvalue: ',num2str(probpos(iPos)), ' (',hlsignpos(iPos), ')', ', t = ',num2str(time_perclus(1)), ' to ',num2str(time_perclus(2)))
Expand All @@ -256,8 +258,8 @@
end
for iNeg = 1:length(signeg)
negsum_perclus = sum(signegCLM(:,:,iNeg),1);
ind_min = min(find(negsum_perclus~=0));
ind_max = max(find(negsum_perclus~=0));
ind_min = find(negsum_perclus~=0, 1 );
ind_max = find(negsum_perclus~=0, 1, 'last' );
time_perclus = [time(ind_min) time(ind_max)];
if hastime
time_perclus = [time(ind_min) time(ind_max)];
Expand All @@ -281,8 +283,8 @@
allsum = negsum;
end

ind_timewin_min = min(find(allsum~=0));
ind_timewin_max = max(find(allsum~=0));
ind_timewin_min = find(allsum~=0, 1 );
ind_timewin_max = find(allsum~=0, 1, 'last' );
timewin = time(ind_timewin_min:ind_timewin_max);

else
Expand Down Expand Up @@ -450,6 +452,9 @@

ft_progress('close');

% return to previous warning settings
ft_warning(ws);

% do the general cleanup and bookkeeping at the end of the function
ft_postamble debug
ft_postamble trackconfig
Expand Down
2 changes: 1 addition & 1 deletion private/topoplot_common.m
Expand Up @@ -192,7 +192,7 @@
if ~iscell(cfg.highlight)
cfg.highlight = {cfg.highlight};
end
if iscell(cfg.highlightchannel) && ~iscell(cfg.highlightchannel{1})
if iscell(cfg.highlightchannel) && ~(iscell(cfg.highlightchannel{1}) || isnumeric(cfg.highlightchannel{1}))
cfg.highlightchannel = {cfg.highlightchannel};
elseif ischar(cfg.highlightchannel)
cfg.highlightchannel = {{cfg.highlightchannel}};
Expand Down

0 comments on commit f0454f8

Please sign in to comment.