-
Notifications
You must be signed in to change notification settings - Fork 0
/
Parcel_Correlation_Group_PerPlot.m
103 lines (84 loc) · 3.61 KB
/
Parcel_Correlation_Group_PerPlot.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
function Parcel_Correlation_Group_PerPlot(inputdir,outputdir,corrthres)
% This code generates a group summary plot (of percentages of voxels
% remaining) based on the outputs of Parcel-Correlation_Calc.m.
%
% inputdir: The location of the input files (ends in '/')
% e.g. 'C:\Users\s\OneDriveNU\Active\Lag_Compare_MNI\'
% outputdir: The location of the plot to be saved (ends in '/')
% e.g. 'C:\Users\s\OneDriveNU\Active\Summary_Plots_MNI\'
% corrthres: A list of correlation thresholds used.
% e.g. [-5,0:0.1:0.7]
tic
% prepare to save plots
set(groot,'defaultFigureVisible','off') %Turns off plot display
scrsz = get(0,'ScreenSize');
set(figure,'position',scrsz);
% plot all GM median
% initialize matrix
summary_percentage_task_GM = [];
summary_percentage_rest_GM = [];
summary_percentage_union_GM = [];
% load all mat files
for i = 1:length(corrthres)
summaryplot_name = sprintf('%.0f_summaryvalues_MNI.mat',corrthres(i)*10);
datafile = load(fullfile(inputdir,summaryplot_name));
datafile = datafile.summaryplot;
summary_percentage_task_GM = [summary_percentage_task_GM,datafile(:,4)];
summary_percentage_rest_GM = [summary_percentage_rest_GM,datafile(:,5)];
summary_percentage_union_GM = [summary_percentage_union_GM,datafile(:,6)];
end
% take voxel percentage median across subjects
summary_percentage_task_GM = median(summary_percentage_task_GM);
summary_percentage_rest_GM = median(summary_percentage_rest_GM);
summary_percentage_union_GM = median(summary_percentage_union_GM);
summary_percentage_task_GM = reshape(summary_percentage_task_GM,[],1);
summary_percentage_rest_GM = reshape(summary_percentage_rest_GM,[],1);
summary_percentage_union_GM = reshape(summary_percentage_union_GM,[],1);
x = [1:7];
plot(x,summary_percentage_union_GM*100,'k','LineWidth',3)
% plot parcel median
for mm = 1:9 % 9 lines for 9 parcels
% initialize matrix
summary_percentage_task = [];
summary_percentage_rest = [];
summary_percentage_union = [];
% prepare for boxplot group name
name_short = char('None','0','0.1','0.2','0.3','0.4','0.5');
% load all mat files
pick_parcel_data = [mm:9:81];
for i = 1:length(corrthres)
summaryplot_name = sprintf('%.0f_summaryvalues_MNI.mat',corrthres(i)*10);
datafile = load(fullfile(inputdir,summaryplot_name));
datafile = datafile.summaryplot;
summary_percentage_task = [summary_percentage_task,datafile(pick_parcel_data,4)];
summary_percentage_rest = [summary_percentage_rest,datafile(pick_parcel_data,5)];
summary_percentage_union = [summary_percentage_union,datafile(pick_parcel_data,6)];
end
% take voxel percentage median across subjectss
summary_percentage_task = median(summary_percentage_task);
summary_percentage_rest = median(summary_percentage_rest);
summary_percentage_union = median(summary_percentage_union);
summary_percentage_task = reshape(summary_percentage_task,[],1);
summary_percentage_rest = reshape(summary_percentage_rest,[],1);
summary_percentage_union = reshape(summary_percentage_union,[],1);
x = [1:7];
% plot for voxel percentages
newcolors = {'red','green','blue','cyan','magenta','yellow','#A2142F','#EDB120','#D95319','#77AC30'};
colororder(newcolors)
hold on
plot(x,summary_percentage_union*100,'LineWidth',2)
xlabel('Amplitude thresholds')
ylabel('Voxels remaining (%)')
title('GM-parcel voxels satisfying amplitude threshold')
end
xticklabels({'None','0','0.1','0.2','0.3','0.4','0.5'})
set(gca,'fontsize',18)
ylim([0,100])
axis square
hold off
% save figures
pic = gcf;
picname = sprintf('Summary_percentage_median');
saveas(pic,fullfile(outputdir,picname),'png');
set(groot,'defaultFigureVisible','on')
toc