Skip to content

Commit

Permalink
A bunch of minor fixes to statistic_image/cat, and new features for p…
Browse files Browse the repository at this point in the history
…lot_correlation_samefig and barplot_columns
  • Loading branch information
Michael-Sun committed Aug 22, 2024
1 parent 62fe420 commit d8dde45
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 11 deletions.
14 changes: 7 additions & 7 deletions CanlabCore/@statistic_image/cat.m
Original file line number Diff line number Diff line change
Expand Up @@ -109,13 +109,13 @@
obj = replace_empty(obj,'voxels'); % changed to 'voxels' only. SG 2/23/18
obj2 = replace_empty(obj2,'voxels'); % changed to 'voxels' only. SG 2/23/18

if ~isempty(obj)
obj2 = resample_space(obj2, obj);

% Why does resample_space resample the .N field? It shouldn't do that -
% MS 7/17/2024
obj2.N=unique(obj2.N);
end
% if ~isempty(obj)
% obj2 = resample_space(obj2, obj);
%
% % Why does resample_space resample the .N field? It shouldn't do that -
% % MS 7/17/2024
% obj2.N=unique(obj2.N);
% end

% hcat these attributes
fnames = {'source_notes' 'type' 'p' 'p_type' 'ste' 'threshold' 'thr_type' 'sig' 'N' 'dfe' 'image_labels' 'dat'};
Expand Down
17 changes: 15 additions & 2 deletions CanlabCore/Visualization_functions/barplot_columns.m
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
% - 'stars', 'dostars' : plot stars for significance above each column (default)
% Sig. levels are coded as * = p<.05, ** = p<.01, *** = q<.05 FDR across variables tested in this plot
% - 'nostars' : do not plot stars
% - 'custom_p' : Custom cell-array to determine p-values if manually generating plots. Don't abuse this.
%
% Robustness options
% - 'dorob' : do robust IRLS means and correlations
Expand Down Expand Up @@ -146,6 +147,7 @@
% See also: lineplot_columns, barplot_colored, line_plot_multisubject, violinplot
%
% Edited 06/12/2024 Added 'order' option. - Michael Sun, PhD
% Edited 08/22/2024 Added 'custom_p' option. - Michael Sun, PhD

% ..
% Defaults
Expand All @@ -161,6 +163,7 @@
dobars = 1;
dowithin = 0;
custom_se = false;
custom_p = false;
donumber = 0;
dojitter = 1; % jitter is for numbers only
mycolor = [.8 .8 .8];
Expand Down Expand Up @@ -242,6 +245,7 @@

if strcmp(varargin{i}, 'stars') || strcmp(varargin{i}, 'dostars'), dostars = true; end
if strcmp(varargin{i}, 'nostars'), dostars = false; end
if strcmp(varargin{i}, 'custom_p'), PValues = varargin{i+1}; custom_p = true; end

% Robustness options
if strcmp(varargin{i},'dorob'), dorob = 1; end
Expand Down Expand Up @@ -422,6 +426,11 @@

end

if custom_p
P=[PValues{:}]';
end


dat = y; % adjusted data, for plot

if dowithin && ~custom_se
Expand Down Expand Up @@ -526,8 +535,12 @@
Y = enforce_cell_array(y);

% Do not plot indiv points here; we will do later if requested. So use 'noind' option.
violinplot(Y, 'noind', 'facecolor', mycolor, 'edgecolor', mycolor.*.75, 'mc', mycolor.*.5, 'x', xvals, 'medc', [], varargin{:});
legend off
try
violinplot(Y, 'noind', 'facecolor', mycolor, 'edgecolor', mycolor.*.75, 'mc', mycolor.*.5, 'x', xvals, 'medc', [], varargin{:});
legend off
catch
warning('Default violinplot cannot be plotted.')
end

end

Expand Down
4 changes: 2 additions & 2 deletions CanlabCore/Visualization_functions/plot_correlation_samefig.m
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
function [r,str,sig,ploth] = plot_correlation_samefig(xvec,yvec,varargin)
function [r,str,sig,ploth,rp] = plot_correlation_samefig(xvec,yvec,varargin)
% :Usage:
% ::
%
Expand Down Expand Up @@ -61,7 +61,7 @@
xvec = double(xvec);
yvec = double(yvec);

r = [];, str=[];sig=[]; hh=[];
r = [];, str=[];sig=[]; hh=[];, p=[];

if length(varargin) > 0, mylabels = varargin{1}; else mylabels = []; end
if length(varargin) > 1, mycol = varargin{2}; else mycol = 'ko'; end
Expand Down

0 comments on commit d8dde45

Please sign in to comment.