Skip to content

Commit

Permalink
Merge pull request #120 from fahrenfort/bugfixes
Browse files Browse the repository at this point in the history
small updates
  • Loading branch information
fahrenfort authored Jul 1, 2019
2 parents f492f51 + fec16d9 commit f5915b4
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 15 deletions.
2 changes: 1 addition & 1 deletion eeg_mvpa/BDM_and_FEM_FT_EEG.m
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@
matObj = matfile(fname);
end
% slightly different for frequency or raw data
if exist('dim_params','var'); % frequency data
if exist('dim_params','var') % frequency data
dim_params.index{dim_params.timedim} = t; % only read for the current time point
realData = squeeze(matObj.powspctrm(dim_params.index{:}));
if dim_params.trialdim > dim_params.chandim
Expand Down
2 changes: 1 addition & 1 deletion eeg_mvpa/adam_average_MVPA_stats.m
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@
avstats.weights.indivWeights = indivWeights/nStats;
avstats.weights.CTF = CTF/nStats;
avstats.weights.indivCTF = indivCTF/nStats;
for cCond = 1:nConds;
for cCond = 1:nConds
avstats.weights.CTFpercond{cCond} = CTFpercond{cCond}/nStats;
avstats.weights.indivCTFpercond{cCond} = indivCTFpercond{cCond}/nStats;
end
Expand Down
28 changes: 17 additions & 11 deletions eeg_mvpa/adam_average_grouptraining.m
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ function subcompute_group_MVPA(cfg, folder_name)
allfiles(strncmp(allfiles,'.',1)) = []; % remove hidden files

% find unique subject filenames excluding the actual test name
allfiles = cellfun(@(x) regexprep(x,'CLASS_PERF_train_sub_(\w*)_test_', ''), allfiles,'UniformOutput',false);
allfiles = cellfun(@(x) regexprep(x,'CLASS_PERF_train_(\w*)_test_', ''), allfiles,'UniformOutput',false);
allfiles = cellfun(@(x) regexprep(x,'.mat', ''), allfiles,'UniformOutput',false);
subjectfiles = unique(allfiles);

Expand Down Expand Up @@ -215,16 +215,22 @@ function subcompute_group_MVPA(cfg, folder_name)
iterations(strncmp(iterations,'.',1)) = []; % remove hidden files

% initialize subject
matObj = matfile([folder_name filesep channelpool plotFreq{cFreq} filesep 'grouptrain' filesep iterations{1}]);
if ~isempty(whos(matObj,'BDM'))
BDM = matObj.BDM;
ClassOverTimeAv = zeros(size(BDM.ClassOverTime));
WeightsOverTimeAv = zeros(size(BDM.WeightsOverTime));
covPatternsOverTimeAv = zeros(size(BDM.covPatternsOverTime));
corPatternsOverTimeAv = zeros(size(BDM.corPatternsOverTime));
else
error('This function is currently only implementend for BDM, not for FEM. Cannot find BDM variable in data.');
notinitialized = true;
itnr = 1;
while notinitialized
matObj = matfile([folder_name filesep channelpool plotFreq{cFreq} filesep 'grouptrain' filesep iterations{itnr}]);
try
BDM = matObj.BDM;
notinitialized = false;
catch
disp(['cannot read ' folder_name filesep channelpool plotFreq{cFreq} filesep 'grouptrain' filesep iterations{itnr}]);
itnr = itnr + 1;
end
end
ClassOverTimeAv = zeros(size(BDM.ClassOverTime));
WeightsOverTimeAv = zeros(size(BDM.WeightsOverTime));
covPatternsOverTimeAv = zeros(size(BDM.covPatternsOverTime));
corPatternsOverTimeAv = zeros(size(BDM.corPatternsOverTime));

% Only BDM for now, will implement FEM later if useful
% C2_averageAv = [];
Expand Down Expand Up @@ -260,7 +266,7 @@ function subcompute_group_MVPA(cfg, folder_name)
% FEM averaging not currently implemented, may do so later if useful
end
end % end iterations loop
fprintf(1,' successfully averaged %d of %d iterations for subject %d (%s) \n', nIts, nSubj, cSubj, subjectfiles{cSubj});
fprintf(1,' successfully averaged %d of %d iterations for subject %d (%s) \n', nIts, nSubj-1, cSubj, subjectfiles{cSubj});
clear BDM;
% now compute the average for that subject / frequency
BDM.ClassOverTime = ClassOverTimeAv/nIts;
Expand Down
5 changes: 3 additions & 2 deletions eeg_mvpa/adam_plot_MVPA.m
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@
settings = stats(cStats).settings;
if ~isfield(settings,'chance') % backwards compatibility
if any(strcmpi(settings.measuremethod,{'hr-far','dprime','hr','far','mr','cr'})) || strcmpi(settings.measuremethod,'\muV') || ~isempty(strfind(settings.measuremethod,' difference')) || ~isempty(strfind(settings.measuremethod,' correlation')) || strcmpi(plot_model,'FEM')
rawchance = 0; disp('yeah');
rawchance = 0;
elseif strcmpi(settings.measuremethod,'AUC')
rawchance = .5;
else
Expand Down Expand Up @@ -692,11 +692,12 @@
% if we are plotting dif stats together with raw stats, put them on a second axis
if ~isempty(rawstats) && (~isempty(strfind(measuremethod,' difference')) || ~isempty(strfind(measuremethod,' correlation'))) && singleplot
ax = axes('YLim',get(gca,'YLim'),'YTick',get(gca,'YTick'),'YTickLabel',get(gca,'YTickLabel'),'Position',get(gca,'Position'),'YAxisLocation','right','YColor',line_colors{cGraph});
ylabel(measuremethod,'FontSize',fontsize,'Color',line_colors{cGraph});
else
ax = gca;
set(ax,'YTick',yaxis);
ylabel(measuremethod,'FontSize',fontsize);
end
ylabel(measuremethod,'FontSize',fontsize);
ticklabel = regexp(deblank(sprintf(['%0.' num2str(ndec) 'f '],yaxis)),' ','split');
if chance ~= 0 % create labels containing equal character counts when centered on some non-zero value
ticklabel((yaxis == chance)) = {'chance'}; % say "chance".
Expand Down

0 comments on commit f5915b4

Please sign in to comment.