From 4e7922531eb0857e9023fdffc5ff8d7b03b51b54 Mon Sep 17 00:00:00 2001 From: Erin Date: Tue, 30 Apr 2024 14:57:41 -0400 Subject: [PATCH] mri lesional analysis --- plots/outcome_plots.m | 6 ++--- tools/unpaired_plot_temporal_paper.m | 35 ++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 3 deletions(-) create mode 100644 tools/unpaired_plot_temporal_paper.m diff --git a/plots/outcome_plots.m b/plots/outcome_plots.m index 2068e2c..aab81f2 100644 --- a/plots/outcome_plots.m +++ b/plots/outcome_plots.m @@ -244,7 +244,7 @@ surg_text(strcmp(T.surg_lat,'right')),... {'Left','Right'},out_text,'para'); %} - out_lat_stats = unpaired_plot(outcome_num(strcmp(T.surg_lat,'left')),... + out_lat_stats = unpaired_plot_temporal_paper(outcome_num(strcmp(T.surg_lat,'left')),... outcome_num(strcmp(T.surg_lat,'right')),... {'Left','Right'},out_text,'para'); set(gca().Children(3),'MarkerSize',10) @@ -359,7 +359,7 @@ % surgery; probability of right for those with right surgery % - stats = unpaired_plot(concordant_lat_scores(good_outcome),concordant_lat_scores(bad_outcome),... + stats = unpaired_plot_temporal_paper(concordant_lat_scores(good_outcome),concordant_lat_scores(bad_outcome),... {good_outcome_text,bad_outcome_text},{'Modeled probability of','concordant laterality'},'para'); set(gca().Children(3),'MarkerSize',10) set(gca().Children(4),'MarkerSize',10) @@ -417,7 +417,7 @@ laser = strcmp(T.surgery,'Laser ablation'); resection = contains(T.surgery,'Resection'); figure - type_stats = unpaired_plot(concordant_lat_scores(laser),concordant_lat_scores(resection),... + type_stats = unpaired_plot_temporal_paper(concordant_lat_scores(laser),concordant_lat_scores(resection),... {'Laser ablation','Resection'},{'Modeled probability of','concordant laterality'},'para'); set(gca().Children(3),'MarkerSize',10) set(gca().Children(4),'MarkerSize',10) diff --git a/tools/unpaired_plot_temporal_paper.m b/tools/unpaired_plot_temporal_paper.m new file mode 100644 index 0000000..36a1427 --- /dev/null +++ b/tools/unpaired_plot_temporal_paper.m @@ -0,0 +1,35 @@ +function stats = unpaired_plot_temporal_paper(a,b,xlabs,ylab,which_test) + +na = length(a); +nb = length(b); +plot(1+randn(na,1)*0.05,a,'o','linewidth',2) +hold on +plot(2+randn(nb,1)*0.05,b,'o','linewidth',2) +xticks([1 2]) +xticklabels(xlabs) +ylabel(ylab) + +switch which_test + case 'non_para' + [p,~,stats_stuff] = ranksum(a,b); + stats.p = p; + stats.ns = [sum(~isnan(a)) sum(~isnan(b))]; + stats.ranksum = stats_stuff.ranksum; + case 'para' + [~,p,~,ostats] = ttest2(a,b); + stats.p = p; + stats.tstat = ostats.tstat; + stats.df = ostats.df; + stats.means = [nanmean(a) nanmean(b)]; + stats.sd = [nanstd(a) nanstd(b)]; +end +yl = ylim; +ybar = yl(1)+(yl(2)-yl(1))*1.1; +ytext = yl(1)+(yl(2)-yl(1))*1.15; +ylnew = [yl(1) yl(1)+(yl(2)-yl(1))*1.2]; +ylim(ylnew) +plot([1 2],[ybar,ybar],'k','linewidth',2) +text(1.5,ytext,get_p_text(p),'fontsize',15,'horizontalalignment','center') +set(gca,'fontsize',15) + +end \ No newline at end of file