%% Confusion matrices comparing voxel-based vs [aal3,schaefer,mental] - BRAIN & BEHAV SCORES % 3 confusion matrices showing correlations between NORMALISED AVERAGED Br & Beh % scores on modes of (all Pearson) voxel-wise & network, voxel-wise & AAL, % and voxel-wise & voxel-wise-mental analyses. clear;clc % After running all 4 models, you have to change the paths below accordingly. basedir_main = 'C:\Users\Konstantinos Tsirlis\Dropbox\My Desktop\Mourao - Miranda\ABCD results\abcdAll_noA\framework\spls_fair20-5_fair_modeA_pub_noAnom_new_common_bmi\res\'; basedir_aal3 = 'C:\Users\Konstantinos Tsirlis\Dropbox\My Desktop\Mourao - Miranda\ABCD results\abcdAll_noA_aal3\framework\spls_fair20-5_fair_modeA_pub_aal3_new_noAnom_common_bmi\res\'; basedir_schaefer = 'C:\Users\Konstantinos Tsirlis\Dropbox\My Desktop\Mourao - Miranda\ABCD results\abcdAll_noA_schaeferbuckchoi\framework\spls_fair20-5_fair_modeA_pub_schaeferbuckchoi_noAnom_common_bmi\res\'; basedir_mental = 'C:\Users\Konstantinos Tsirlis\Dropbox\My Desktop\Mourao - Miranda\ABCD results\abcdAll_noA\framework\spls_fair20-5_fair_modeA_pub_noAnom_new_common_bmi_mental\res\'; cd(basedir_main) P_mean_main = table(); for i = 1:(length(dir('level*'))) cd(['level' num2str(i)]) load('P.mat') P = reshape(P,[11288,2]); P = (P-mean(P))./std(P); P_mean_main.(['mode' num2str(i)]) = mean([P(:,1) P(:,2)],2); cd(basedir_main) end cd(basedir_aal3) P_mean_aal3 = table(); for i = 1:(length(dir('level*'))) cd(['level' num2str(i)]) load('P.mat') P = reshape(P,[11288,2]); P = (P-mean(P))./std(P); P_mean_aal3.(['mode' num2str(i)]) = mean([P(:,1) P(:,2)],2); cd(basedir_aal3) end cd(basedir_schaefer) P_mean_schaefer = table(); for i = 1:(length(dir('level*'))) cd(['level' num2str(i)]) load('P.mat') P = reshape(P,[11288,2]); P = (P-mean(P))./std(P); P_mean_schaefer.(['mode' num2str(i)]) = mean([P(:,1) P(:,2)],2); cd(basedir_schaefer) end cd(basedir_mental) P_mean_mental = table(); for i = 1:(length(dir('level*'))) cd(['level' num2str(i)]) load('P.mat') P = reshape(P,[11288,2]); P = (P-mean(P))./std(P); P_mean_mental.(['mode' num2str(i)]) = mean([P(:,1) P(:,2)],2); cd(basedir_mental) end cd(basedir_main) for i = 1:size(P_mean_main,2) for j = 1:size(P_mean_aal3,2) main_aal3_correls(i,j) = corr(P_mean_main{:,i},P_mean_aal3{:,j}); end end for i = 1:size(P_mean_main,2) for j = 1:size(P_mean_schaefer,2) main_schaefer_correls(i,j) = corr(P_mean_main{:,i},P_mean_schaefer{:,j}); end end for i = 1:size(P_mean_main,2) for j = 1:size(P_mean_mental,2) main_mental_correls(i,j) = corr(P_mean_main{:,i},P_mean_mental{:,j}); end end figure('Units', 'Normalized', 'OuterPosition', [0.4 0 0.5 0.78]); pos = [0.22 0.2 0.6 0.56]; axes('Position', pos,'linewidth',2) % You need to change the legends of the modes according to the new ones, in case they are different. xvalues = {'Mode 1','Mode 2','Mode 3'}; yvalues = {'Mode 1','Mode 2','Mode 3', 'Mode 4','Mode 5','Mode 6'}; h = heatmap(xvalues,yvalues,main_aal3_correls,'ColorMap',redbluecmap,'gridvisible',0); h.Title = 'Brain & Psychosocial score correlations'; h.YLabel = 'Voxel-wise analysis'; h.XLabel = 'Anatomical parcellation analysis'; h.CellLabelFormat = '%.2f'; set(gca, 'FontSize', 30, 'FontName', 'Arial'); saveas(gcf, ['heatmap_main_vs_aal3_brain_behav.png']); figure('Units', 'Normalized', 'OuterPosition', [0.4 0 0.5 0.78]); pos = [0.22 0.2 0.6 0.56]; axes('Position', pos,'linewidth',2) % You need to change the legends of the modes according to the new ones, in case they are different. xvalues = {'Mode 1','Mode 2','Mode 3'}; yvalues = {'Mode 1','Mode 2','Mode 3', 'Mode 4','Mode 5','Mode 6'}; h = heatmap(xvalues,yvalues,main_schaefer_correls,'ColorMap',redbluecmap,'gridvisible',0); h.Title = 'Brain & Psychosocial score correlations'; h.YLabel = 'Voxel-wise analysis'; h.XLabel = 'Network-based parcellation analysis'; h.CellLabelFormat = '%.2f'; set(gca, 'FontSize', 30, 'FontName', 'Arial'); saveas(gcf, ['heatmap_main_vs_schaefer_brain_behav.png']); % Dirty hack color for proper color-scaling, add a 7th dummy mode to adjust % color-scaling, and then discard it with manual image processing. P_mean_main.mode7 = P_mean_mental.mode2; for i = 1:size(P_mean_main,2) for j = 1:size(P_mean_mental,2) main_mental_correls(i,j) = corr(P_mean_main{:,i},P_mean_mental{:,j}); end end figure('Units', 'Normalized', 'OuterPosition', [0.4 0 0.5 0.78]); pos = [0.22 0.2 0.6 0.56]; axes('Position', pos,'linewidth',2) % You need to change the legends of the modes according to the new ones, in case they are different. xvalues = {'Mode 1','Mode 2','Mode 3'}; yvalues = {'Mode 1','Mode 2','Mode 3', 'Mode 4','Mode 5','Mode 6', 'Mode 7'}; h = heatmap(xvalues,yvalues,main_mental_correls,'ColorMap',redbluecmap,'gridvisible',0); h.Title = 'Brain & Psychosocial score correlations'; h.YLabel = '"Main" Voxel-wise analysis'; h.XLabel = '"Mental" Voxel-wise analysis'; h.CellLabelFormat = '%.2f'; set(gca, 'FontSize', 30, 'FontName', 'Arial'); saveas(gcf, ['heatmap_main_vs_mental_brain_behav.png']); %% Confusion matrices comparing voxel-based vs [aal3,schaefer,mental] - BRAIN SCORES clear;clc % After running all 4 models, you have to change the paths below accordingly. basedir_main = 'C:\Users\Konstantinos Tsirlis\Dropbox\My Desktop\Mourao - Miranda\ABCD results\abcdAll_noA\framework\spls_fair20-5_fair_modeA_pub_noAnom_new_common_bmi\res\'; basedir_aal3 = 'C:\Users\Konstantinos Tsirlis\Dropbox\My Desktop\Mourao - Miranda\ABCD results\abcdAll_noA_aal3\framework\spls_fair20-5_fair_modeA_pub_aal3_new_noAnom_common_bmi\res\'; basedir_schaefer = 'C:\Users\Konstantinos Tsirlis\Dropbox\My Desktop\Mourao - Miranda\ABCD results\abcdAll_noA_schaeferbuckchoi\framework\spls_fair20-5_fair_modeA_pub_schaeferbuckchoi_noAnom_common_bmi\res\'; basedir_mental = 'C:\Users\Konstantinos Tsirlis\Dropbox\My Desktop\Mourao - Miranda\ABCD results\abcdAll_noA\framework\spls_fair20-5_fair_modeA_pub_noAnom_new_common_bmi_mental\res\'; cd(basedir_main) P_mean_main = table(); for i = 1:(length(dir('level*'))) cd(['level' num2str(i)]) load('P.mat') P = reshape(P,[11288,2]); P = (P-mean(P))./std(P); P_mean_main.(['mode' num2str(i)]) = P(:,1); cd(basedir_main) end cd(basedir_aal3) P_mean_aal3 = table(); for i = 1:(length(dir('level*'))) cd(['level' num2str(i)]) load('P.mat') P = reshape(P,[11288,2]); P = (P-mean(P))./std(P); P_mean_aal3.(['mode' num2str(i)]) = P(:,1); cd(basedir_aal3) end cd(basedir_schaefer) P_mean_schaefer = table(); for i = 1:(length(dir('level*'))) cd(['level' num2str(i)]) load('P.mat') P = reshape(P,[11288,2]); P = (P-mean(P))./std(P); P_mean_schaefer.(['mode' num2str(i)]) = P(:,1); cd(basedir_schaefer) end cd(basedir_mental) P_mean_mental = table(); for i = 1:(length(dir('level*'))) cd(['level' num2str(i)]) load('P.mat') P = reshape(P,[11288,2]); P = (P-mean(P))./std(P); P_mean_mental.(['mode' num2str(i)]) = P(:,1); cd(basedir_mental) end cd(basedir_main) for i = 1:size(P_mean_main,2) for j = 1:size(P_mean_aal3,2) main_aal3_correls(i,j) = corr(P_mean_main{:,i},P_mean_aal3{:,j}); end end for i = 1:size(P_mean_main,2) for j = 1:size(P_mean_schaefer,2) main_schaefer_correls(i,j) = corr(P_mean_main{:,i},P_mean_schaefer{:,j}); end end for i = 1:size(P_mean_main,2) for j = 1:size(P_mean_mental,2) main_mental_correls(i,j) = corr(P_mean_main{:,i},P_mean_mental{:,j}); end end figure('Units', 'Normalized', 'OuterPosition', [0.4 0 0.5 0.78]); pos = [0.22 0.2 0.6 0.56]; axes('Position', pos,'linewidth',2) % You need to change the legends of the modes according to the new ones, in case they are different. xvalues = {'Mode 1','Mode 2','Mode 3'}; yvalues = {'Mode 1','Mode 2','Mode 3', 'Mode 4','Mode 5','Mode 6'}; h = heatmap(xvalues,yvalues,main_aal3_correls,'ColorMap',redbluecmap,'gridvisible',0); h.Title = 'Brain score correlations'; h.YLabel = 'Voxel-wise analysis'; h.XLabel = 'Anatomical parcellation analysis'; h.CellLabelFormat = '%.2f'; set(gca, 'FontSize', 30, 'FontName', 'Arial'); saveas(gcf, ['heatmap_main_vs_aal3_brain.png']); figure('Units', 'Normalized', 'OuterPosition', [0.4 0 0.5 0.78]); pos = [0.22 0.2 0.6 0.56]; axes('Position', pos,'linewidth',2) % You need to change the legends of the modes according to the new ones, in case they are different. xvalues = {'Mode 1','Mode 2','Mode 3'}; yvalues = {'Mode 1','Mode 2','Mode 3', 'Mode 4','Mode 5','Mode 6'}; h = heatmap(xvalues,yvalues,main_schaefer_correls,'ColorMap',redbluecmap,'gridvisible',0); h.Title = 'Brain score correlations'; h.YLabel = 'Voxel-wise analysis'; h.XLabel = 'Network-based parcellation analysis'; h.CellLabelFormat = '%.2f'; set(gca, 'FontSize', 30, 'FontName', 'Arial'); saveas(gcf, ['heatmap_main_vs_schaefer_brain.png']); % Dirty hack color for proper color-scaling, add a 7th dummy mode to adjust % color-scaling, and then discard it with manual image processing. P_mean_main.mode7 = -P_mean_main.mode5; for i = 1:size(P_mean_main,2) for j = 1:size(P_mean_mental,2) main_mental_correls(i,j) = corr(P_mean_main{:,i},P_mean_mental{:,j}); end end figure('Units', 'Normalized', 'OuterPosition', [0.4 0 0.5 0.78]); pos = [0.22 0.2 0.6 0.56]; axes('Position', pos,'linewidth',2) % You need to change the legends of the modes according to the new ones, in case they are different. xvalues = {'Mode 1','Mode 2','Mode 3'}; yvalues = {'Mode 1','Mode 2','Mode 3', 'Mode 4','Mode 5','Mode 6','Mode 7'}; h = heatmap(xvalues,yvalues,main_mental_correls,'ColorMap',redbluecmap,'gridvisible',0); h.Title = 'Brain score correlations'; h.YLabel = 'Voxel-wise analysis'; h.XLabel = '"Mental" Voxel-wise analysis'; h.CellLabelFormat = '%.2f'; set(gca, 'FontSize', 30, 'FontName', 'Arial'); saveas(gcf, ['heatmap_main_vs_mental_brain.png']); %% Confusion matrices comparing voxel-based vs [aal3,schaefer] - BEHAV SCORES clear;clc % After running all 4 models, you have to change the paths below accordingly. basedir_main = 'C:\Users\Konstantinos Tsirlis\Dropbox\My Desktop\Mourao - Miranda\ABCD results\abcdAll_noA\framework\spls_fair20-5_fair_modeA_pub_noAnom_new_common_bmi\res\'; basedir_aal3 = 'C:\Users\Konstantinos Tsirlis\Dropbox\My Desktop\Mourao - Miranda\ABCD results\abcdAll_noA_aal3\framework\spls_fair20-5_fair_modeA_pub_aal3_new_noAnom_common_bmi\res\'; basedir_schaefer = 'C:\Users\Konstantinos Tsirlis\Dropbox\My Desktop\Mourao - Miranda\ABCD results\abcdAll_noA_schaeferbuckchoi\framework\spls_fair20-5_fair_modeA_pub_schaeferbuckchoi_noAnom_common_bmi\res\'; basedir_mental = 'C:\Users\Konstantinos Tsirlis\Dropbox\My Desktop\Mourao - Miranda\ABCD results\abcdAll_noA\framework\spls_fair20-5_fair_modeA_pub_noAnom_new_common_bmi_mental\res\'; cd(basedir_main) P_mean_main = table(); for i = 1:(length(dir('level*'))) cd(['level' num2str(i)]) load('P.mat') P = reshape(P,[11288,2]); P = (P-mean(P))./std(P); P_mean_main.(['mode' num2str(i)]) = P(:,2); cd(basedir_main) end cd(basedir_aal3) P_mean_aal3 = table(); for i = 1:(length(dir('level*'))) cd(['level' num2str(i)]) load('P.mat') P = reshape(P,[11288,2]); P = (P-mean(P))./std(P); P_mean_aal3.(['mode' num2str(i)]) = P(:,2); cd(basedir_aal3) end cd(basedir_schaefer) P_mean_schaefer = table(); for i = 1:(length(dir('level*'))) cd(['level' num2str(i)]) load('P.mat') P = reshape(P,[11288,2]); P = (P-mean(P))./std(P); P_mean_schaefer.(['mode' num2str(i)]) = P(:,2); cd(basedir_schaefer) end cd(basedir_mental) P_mean_mental = table(); for i = 1:(length(dir('level*'))) cd(['level' num2str(i)]) load('P.mat') P = reshape(P,[11288,2]); P = (P-mean(P))./std(P); P_mean_mental.(['mode' num2str(i)]) = P(:,2); cd(basedir_mental) end cd(basedir_main) for i = 1:size(P_mean_main,2) for j = 1:size(P_mean_aal3,2) main_aal3_correls(i,j) = corr(P_mean_main{:,i},P_mean_aal3{:,j}); end end for i = 1:size(P_mean_main,2) for j = 1:size(P_mean_schaefer,2) main_schaefer_correls(i,j) = corr(P_mean_main{:,i},P_mean_schaefer{:,j}); end end for i = 1:size(P_mean_main,2) for j = 1:size(P_mean_mental,2) main_mental_correls(i,j) = corr(P_mean_main{:,i},P_mean_mental{:,j}); end end figure('Units', 'Normalized', 'OuterPosition', [0.4 0 0.5 0.78]); pos = [0.22 0.2 0.6 0.56]; axes('Position', pos,'linewidth',2) % You need to change the legends of the modes according to the new ones, in case they are different. xvalues = {'Mode 1','Mode 2','Mode 3'}; yvalues = {'Mode 1','Mode 2','Mode 3', 'Mode 4','Mode 5','Mode 6'}; h = heatmap(xvalues,yvalues,main_aal3_correls,'ColorMap',redbluecmap,'gridvisible',0); h.Title = 'Psychosocial score correlations'; h.YLabel = 'Voxel-wise analysis'; h.XLabel = 'Anatomical parcellation analysis'; h.CellLabelFormat = '%.2f'; set(gca, 'FontSize', 30, 'FontName', 'Arial'); saveas(gcf, ['heatmap_main_vs_aal3_behav.png']); figure('Units', 'Normalized', 'OuterPosition', [0.4 0 0.5 0.78]); pos = [0.22 0.2 0.6 0.56]; axes('Position', pos,'linewidth',2) % You need to change the legends of the modes according to the new ones, in case they are different. xvalues = {'Mode 1','Mode 2','Mode 3'}; yvalues = {'Mode 1','Mode 2','Mode 3', 'Mode 4','Mode 5','Mode 6'}; h = heatmap(xvalues,yvalues,main_schaefer_correls,'ColorMap',redbluecmap,'gridvisible',0); h.Title = 'Psychosocial score correlations'; h.YLabel = 'Voxel-wise analysis'; h.XLabel = 'Network-based parcellation analysis'; h.CellLabelFormat = '%.2f'; set(gca, 'FontSize', 30, 'FontName', 'Arial'); saveas(gcf, ['heatmap_main_vs_schaefer_behav.png']); % Dirty hack color for proper color-scaling, add a 7th dummy mode to adjust % color-scaling, and then discard it with manual image processing. P_mean_main.mode7 = -P_mean_main.mode2; for i = 1:size(P_mean_main,2) for j = 1:size(P_mean_mental,2) main_mental_correls(i,j) = corr(P_mean_main{:,i},P_mean_mental{:,j}); end end figure('Units', 'Normalized', 'OuterPosition', [0.4 0 0.5 0.78]); pos = [0.22 0.2 0.6 0.56]; axes('Position', pos,'linewidth',2) % You need to change the legends of the modes according to the new ones, in case they are different. xvalues = {'Mode 1','Mode 2','Mode 3'}; yvalues = {'Mode 1','Mode 2','Mode 3', 'Mode 4','Mode 5','Mode 6','Mode 7'}; h = heatmap(xvalues,yvalues,main_mental_correls,'ColorMap',redbluecmap,'gridvisible',0); h.Title = 'Psychosocial score correlations'; h.YLabel = 'Voxel-wise analysis'; h.XLabel = '"Mental" Voxel-wise analysis'; h.CellLabelFormat = '%.2f'; set(gca, 'FontSize', 30, 'FontName', 'Arial'); saveas(gcf, ['heatmap_main_vs_mental_behav.png']);