Skip to content

Commit

Permalink
Merge pull request #114 from fahrenfort/bugfixes
Browse files Browse the repository at this point in the history
FEM updates
  • Loading branch information
fahrenfort authored Apr 16, 2019
2 parents 864d584 + 828b118 commit 425a689
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 620 deletions.
6 changes: 3 additions & 3 deletions eeg_mvpa/adam_plot_BDM_weights.m
Original file line number Diff line number Diff line change
Expand Up @@ -299,11 +299,11 @@
set(gcf,'color','w');
title(title_text,'FontSize', 12);
if strcmp(imgtype,'vec') % chanlocs' +Y
topoplot_jjf(plot_data,convertlocs(chanlocs,'cart2topo'),'maplimits',weightlim,'style','blank','electrodes','on','nosedir',nosedir,'emarker',{'.','k',5,1},'emarker2',{elecs,'.','k',15,1}); %
topoplot_jjf(plot_data,convertlocs(chanlocs,'cart2topo'),'maplimits',weightlim,'style','blank','electrodes','on','plotrad',.65,'nosedir',nosedir,'emarker',{'.','k',5,1},'emarker2',{elecs,'.','k',15,1}); %
elseif strcmp(imgtype,'png')
topoplot_jjf(plot_data,convertlocs(chanlocs,'cart2topo'),'maplimits',weightlim,'style','map','electrodes','off','shading','interp','nosedir',nosedir,'hcolor','none');
topoplot_jjf(plot_data,convertlocs(chanlocs,'cart2topo'),'maplimits',weightlim,'style','map','electrodes','off','plotrad',.65,'shading','interp','nosedir',nosedir,'hcolor','none');
else
topoplot_jjf(plot_data,convertlocs(chanlocs,'cart2topo'),'maplimits',weightlim,'style','map','electrodes','on','nosedir',nosedir,'emarker2',{elecs,'o','k',10,1}); % 'electrodes','ptslabels', 'plotrad',.7
topoplot_jjf(plot_data,convertlocs(chanlocs,'cart2topo'),'maplimits',weightlim,'style','map','electrodes','on','plotrad',.65,'nosedir',nosedir,'emarker2',{elecs,'o','k',10,1}); % 'electrodes','ptslabels', 'plotrad',.7
h = cbar('vert');
set(get(h,'title'),'string',' ');
%h = colorbar;
Expand Down
31 changes: 20 additions & 11 deletions eeg_mvpa/adam_plot_CTF.m
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
%
% The cfg (configuration) input structure can contain the following:
% cfg.plotfield = 'CTF' or 'CTFpercond';
% cfg.plottype = '2D' or '3D'
% cfg.mpcompcor_method = 'cluster_based';
% cfg.tail = 'both';
% cfg.trainlim = [];
Expand All @@ -25,8 +24,10 @@
% cfg.reduce_dims = 'diag', 'avtrain', 'avtest', 'avtraintest', 'avfreq'
% cfg.weightlim = [];
% cfg.colorlim = [];
% cfg.CTFtime = [];
% cfg.BLtime = [];
% cfg.CTFtime = []; indicates the time window over which the CTF should be
% averaged. If empty, the CTF is plotted over time.
% cfg.BLtime = []; indicates a baseline window for which the CTF should be
% plotted
% cfg.ytick = .1;
%
% part of the ADAM toolbox, by J.J.Fahrenfort, VU, 2017/2018
Expand All @@ -43,16 +44,24 @@
plotfield = 'CTF';
folder = '';
startdir = '';
singleplot = false;
singleplot = true;
CTFtime = [];
BLtime = [];
reduce_dims = [];
plottype = '3D';
line_colors = [];
ytick = .05;
ytick = .1;
trainlim = [];
testlim = [];
v2struct(cfg);

containsbaseline = ~isempty(BLtime) && cfg.BLtime(1)<= cfg.BLtime(2);

if isempty(CTFtime)
plottype = '3D';
else
plottype = '2D';
end

% set plot type
if strcmpi(plottype,'3D')
singleplot = false; % cannot plot 3D plots in single graph
Expand All @@ -79,7 +88,7 @@
end
end
nameOfStruct2Update = 'cfg';
cfg = v2struct(line_colors,singleplot,containsbaseline,ytick,nameOfStruct2Update);
cfg = v2struct(plottype,line_colors,singleplot,containsbaseline,ytick,trainlim,testlim,nameOfStruct2Update);

v2struct(stats(1).settings,{'fieldNames','dimord'});

Expand Down Expand Up @@ -156,7 +165,7 @@
avgctfstruct(cStats).condname = stats(cStats).condname;

% put in legend
if ~singleplot || (singleplot && cStats == numel(stats))
if (~singleplot || (singleplot && cStats == numel(stats))) && exist('legend_text','var')
legend(legend_text);
legend boxoff;
end
Expand Down Expand Up @@ -575,9 +584,9 @@
H.mainLine=plot3(1:numel(sigline),ones(size(sigline))*addy,sigline,'k','LineWidth',8);
end
end
if ~all(isnan((sigline)))
wraptext('Due to a bug in the way Matlab exports figures (the ''endcaps'' property in OpenGL is set to''on'' by default), the ''significance lines'' near the time line are not correctly plotted when saving as .eps or .pdf. The workaround is to open these plots in Illustrator, manually select these lines and select ''butt cap'' for these lines (under the ''stroke'' property).');
end
% if ~all(isnan((sigline)))
% wraptext('Due to a bug in the way Matlab exports figures (the ''endcaps'' property in OpenGL is set to''on'' by default), the ''significance lines'' near the time line are not correctly plotted when saving as .eps or .pdf. The workaround is to open these plots in Illustrator, manually select these lines and select ''butt cap'' for these lines (under the ''stroke'' property).');
% end

% NEW
% determine time tick
Expand Down
13 changes: 9 additions & 4 deletions eeg_mvpa/plot_FEM_weights.m → eeg_mvpa/adam_plot_FEM_weights.m
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
function avweightstruct = plot_FEM_weights(stats,cfg)
% plot FEM weights for a specific time range or frequency range
function avweightstruct = adam_plot_FEM_weights(cfg,stats)
% ADAM_PLOT_FEM_WEIGHTS generates topographical maps of classifier forward encoding weights over a
% specified time interval. Requires as input the output of adam_compute_group_MVPA.
%
% J.J.Fahrenfort, VU 2016
% J.J.Fahrenfort, VU 2016, 2019

% main loop
for c=1:numel(stats)
Expand Down Expand Up @@ -29,7 +30,7 @@
timelim = 250; % indicate time or period for which to compute weights in ms, if empty plots time with highest average weight
freqlim = []; % indicate freq or freq range for which to compute weights in ms, if empty plots frequency with heighest average weight
weightlim = []; % indicate color range to plot
normalized = false; % can be false (default) or true (z-scoring is performed)
normalized = true; % can be false (default) or true (z-scoring is performed)
imgtype = [];
indiv_pval = .05;
cluster_pval = .05;
Expand Down Expand Up @@ -175,6 +176,10 @@
end
end

% colormap
cmap = brewermap([],'*RdBu');
colormap(gcf,cmap);

% return the averages
avweightstruct.chanlocs = chanlocs;
avweightstruct.avWeights = avWeights;
Expand Down
Loading

0 comments on commit 425a689

Please sign in to comment.