Skip to content

Commit

Permalink
Updates to Meta_cluster_tools barplots and Meta_results_batch_script
Browse files Browse the repository at this point in the history
Some compat with new Matlab versions (2020b). CanlabCore also updated.
  • Loading branch information
torwager committed May 8, 2022
1 parent e0aa831 commit 48145b4
Show file tree
Hide file tree
Showing 3 changed files with 496 additions and 107 deletions.
44 changes: 28 additions & 16 deletions densityUtility3/Meta_cluster_tools.m
Original file line number Diff line number Diff line change
Expand Up @@ -40,19 +40,19 @@
% ------------------------------------------------------
% count studies by condition and plot [optional]
%
% [prop_by_condition,se,num_by_condition,n] = Meta_cluster_tools('count_by_condition',dat,Xi,w,doplot,[xnames],[seriesnames], [colors])
% [prop_by_condition,se,num_by_condition,n, table_obj] = Meta_cluster_tools('count_by_condition',dat,Xi,w,doplot,[xnames],[seriesnames], [colors])
%
% [prop_by_condition,se,num_by_condition,n] = Meta_cluster_tools('count_by_condition',studybyset,MC_Setup.Xi,MC_Setup.wts,1)
% [prop_by_condition,se,num_by_condition,n, table_obj] = Meta_cluster_tools('count_by_condition',studybyset,MC_Setup.Xi,MC_Setup.wts,1)
%
% [prop_by_condition,se,num_by_condition,n] = ...
% [prop_by_condition,se,num_by_condition,n, table_obj] = ...
% Meta_cluster_tools('count_by_condition',studybyroi,MC_Setup.Xi,MC_Setup.wts,1, ...
% {'Right' 'Left'},MC_Setup.connames(1:5),{[1 0 0] [0 1 0] [1 0 1] [1 1 0] [0 0 1]});
%
% Xi = SOMResults.Xi(:,9:13);
% nms = SOMResults.alltasknms(9:13)
% w = SOMResults.w;
% colors = {[1 0 0] [0 1 0] [1 0 1] [1 1 0] [0 0 1]};
% [prop_by_condition,se,num_by_condition,n] = ...
% [prop_by_condition,se,num_by_condition,n, table_obj] = ...
% Meta_cluster_tools('count_by_condition',studybyroi,Xi,w,1, ...
% {'Right' 'Left'},nms,colors);
%
Expand All @@ -65,7 +65,7 @@
% R = Meta_Chisq_new('compute',MC_Setup,'mask',mask);
% R = Meta_Chisq_new('write',R);
% [studybyroi,studybyset] = Meta_cluster_tools('getdata',cl,R.dat,R.volInfo);
% [prop_by_condition,se,num_by_condition,n] = Meta_cluster_tools('count_by_condition',studybyset,R.Xi,R.w,1);
% [prop_by_condition,se,num_by_condition,n, table_obj] = Meta_cluster_tools('count_by_condition',studybyset,R.Xi,R.w,1);
% ------------------------------------------------------

switch meth
Expand All @@ -92,14 +92,14 @@
end

case 'count_by_condition'
%[prop_by_condition,se,num_by_condition,n] = Meta_cluster_tools('count_by_condition',dat,Xi,w,doplot,[xnames],[seriesnames], [colors])
%[prop_by_condition,se,num_by_condition,n] = count_by_condition(dat,Xi,w,doplot)
%[prop_by_condition,se,num_by_condition,n, table_obj] = Meta_cluster_tools('count_by_condition',dat,Xi,w,doplot,[regionnames],[seriesnames], [colors])
%[prop_by_condition,se,num_by_condition,n, table_obj] = count_by_condition(dat,Xi,w,doplot)

if length(varargin) < 4, varargin{4} = 0; end
if length(varargin) < 5, varargin{5} = []; end
if length(varargin) < 6, varargin{6} = []; end
if length(varargin) < 7, varargin{7} = []; end %colors
[varargout{1},varargout{2},varargout{3},varargout{4}] = count_by_condition(varargin{1},varargin{2},varargin{3},varargin{4},varargin{5},varargin{6},varargin{7});
[varargout{1},varargout{2},varargout{3},varargout{4}, varargout{5}] = count_by_condition(varargin{1},varargin{2},varargin{3},varargin{4},varargin{5},varargin{6},varargin{7});


case 'activation_table'
Expand Down Expand Up @@ -177,7 +177,7 @@
[studybyroi,studybyset] = Meta_cluster_tools('getdata',cl,MC_Setup.unweighted_study_data,MC_Setup.volInfo);

disp('Counting studies by condition')
[prop_by_condition,se,num_by_condition,n] = Meta_cluster_tools('count_by_condition',studybyroi,MC_Setup.Xi,MC_Setup.wts,doplot);
[prop_by_condition,se,num_by_condition,n, table_obj] = Meta_cluster_tools('count_by_condition',studybyroi,MC_Setup.Xi,MC_Setup.wts,doplot);

% get field names for conditions
fnames = MC_Setup.Xinms;
Expand Down Expand Up @@ -255,7 +255,7 @@
% -------------------------------------------------------------------------
% -------------------------------------------------------------------------

function [prop_by_condition,se,num_by_condition,n] = count_by_condition(dat,Xi,w,doplot,varargin)
function [prop_by_condition,se,num_by_condition,n, table_obj] = count_by_condition(dat,Xi,w,doplot,varargin)

if nargin < 4, doplot = 0; end

Expand All @@ -273,21 +273,33 @@
se = ( (prop_by_condition .* (1-prop_by_condition) ) ./ n ).^.5;

if doplot
xnames = [];
seriesnames = [];
mycolors = [];
if length(varargin) > 0, xnames = varargin{1}; end
if length(varargin) > 1, seriesnames = varargin{2}; end
if length(varargin) > 2, mycolors = varargin{3}; end

xnames = repmat({'Region'}, 1, size(prop_by_condition, 1));
seriesnames = repmat({'Cond'}, 1, size(prop_by_condition, 2));
mycolors = scn_standard_colors(size(prop_by_condition, 2));

if length(varargin) > 0 && ~isempty(varargin{1}), xnames = varargin{1}; end
if length(varargin) > 1 && ~isempty(varargin{2}), seriesnames = varargin{2}; end
if length(varargin) > 2 && ~isempty(varargin{3}), mycolors = varargin{3}; end

create_figure('barplot');
fprintf('Sample size is %3.0f\n', size(Xi, 1));

barplot_grouped(prop_by_condition, se, xnames, seriesnames, 'inputmeans', 'colors', mycolors);

ylabel('Proportion of studies activating');

end

% Table of contrast data
table_obj = table();

propdat = mat2cell(prop_by_condition, size(prop_by_condition, 1), ones(1, length(seriesnames)));
sedat = mat2cell(se, size(prop_by_condition, 1), ones(1, length(seriesnames)));

senames = cellfun(@(x) ['SE_' x], seriesnames, 'UniformOutput', false);
table_obj = table(xnames', propdat{:}, sedat{:}, 'Variablenames', [{'Region'} seriesnames senames]);

end


Expand Down
Loading

0 comments on commit 48145b4

Please sign in to comment.