Skip to content

Commit

Permalink
mri lesional analysis
Browse files Browse the repository at this point in the history
  • Loading branch information
erinconrad committed Apr 30, 2024
1 parent 9a5e885 commit 4e79225
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 3 deletions.
6 changes: 3 additions & 3 deletions plots/outcome_plots.m
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
35 changes: 35 additions & 0 deletions tools/unpaired_plot_temporal_paper.m
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 4e79225

Please sign in to comment.