% locate all text file name and folder
files = dir('**/*.txt');
% variables preallocation
age = zeros(1,length(files)/2);
gender = zeros(1,length(files)/2);
idx2 = 1; % indexing variable for age
idx3 = 1; % indexing variable for gender
for i = 1:length(files)
if(contains(files(i).name,'age')) % load age text files
age(idx2) = importdata(fullfile(files(i).folder,files(i).name));
idx2 = idx2+1;
else % load gender text files
gender(idx3) = importdata(fullfile(files(i).folder,files(i).name));
idx3 = idx3+1;
end
end
% locate all .mat (ROI) file name and folder
files2 = dir('**/*.mat');
% variables preallocation
rd_S9_wrrest_F2_avg_ROIs = zeros(length(files)/2,47,145);
rd_S9_wrrest_F3_avg_ROIs = zeros(length(files)/2,47,145);
cor_F2 = zeros(length(files)/2,145,145);
cor_F3 = zeros(length(files)/2,145,145);
idx2 = 1; % indexing variable for F2_ROI
idx3 = 1; % indexing variable for F3_ROI
for j = 1:length(files2)
if(contains(files2(j).name,'rd_S9_wrrest_F2_avg_ROIs')) % load F2_ROI mat files
data = importdata(fullfile(files2(j).folder,files2(j).name));
rd_S9_wrrest_F2_avg_ROIs(idx2,:,:) = data; % save ROI to variable
cor_F2(idx2,:,:) = corr(data); % calculate correlation matrix
idx2 = idx2+1;
else % load F3_ROI mat files
data = importdata(fullfile(files2(j).folder,files2(j).name));
rd_S9_wrrest_F3_avg_ROIs(idx3,:,:) = data; % save ROI to variable
cor_F3(idx3,:,:) = corr(data); % calculate correlation matrix
idx3 = idx3+1;
end
end
% variables preallocation
hrF = zeros(length(files)/2,size(cor_F2,2));
prF = zeros(length(files)/2,size(cor_F2,2));
% T-test for correlations
for i = 1:size(cor_F2,1)
[hF,pF]=ttest2(cor_F2(i,:,:),cor_F3(i,:,:));
hrF(i,:) = reshape(hF,145,1);
prF(i,:) = reshape(pF,145,1);
end
%Combining age and gender(both groups)
combine_age_gender=[age;gender];
%Transpose of combined age and gender
Tcombine_age_gender=(combine_age_gender)';
%Separating age of males and females
maleind = (Tcombine_age_gender(:,2)<>
maleage = Tcombine_age_gender(maleind,1);
femaleind = (Tcombine_age_gender(:,2)>1);
femaleage = Tcombine_age_gender(femaleind,1);
NEED TO DO THE FOLLOWING
%for F2
%Correlation matrix for all males
%mean of
corr
matrix for all males (145x145)
%Correlation matrix for all females (145x145)
%mean of
corr
matrix for all females (145x145)
%h-value(145x145)
%p-value (145x145)
%Use
imagesc
for all the steps above and show interpretation
%for F3
%Correlation matrix for all males (145x145)
%mean of
corr
matrix for all males (145x145)
%Correlation matrix for all females (145x145)
%mean of
corr
matrix for all females (145x145)
%h-value(145x145)
%p-value (145x145)
%Use
imagesc
for all the steps above and show interpretation
This will be helpful:
After the correlation matrices are done, the next step will be to compare the correlation matrix between two groups. This groups in your case are male and female.
You can identify the groups and corresponding subjects from the gender variables.
you can use find command to identify
index
of subjects that have gender as 1 or 2.
this index can be stored in two variables such as index_male index_female
After you have the index, it will be something like following.
For i=1: x (where x represent the row dimension of
corr
matrix)
for j=1:y (where y represent the column of
corr
matrix)
[h(i,j), p(i,j)]=ttest2(corrmatrix(index_male,i,j), corrmatrix(index_female, i , j)
end
end