How to calculate post-pre connectivity matrices for multiple subjects

1 visualización (últimos 30 días)
newbie
newbie el 2 de Ag. de 2019
Editada: KSSV el 2 de Ag. de 2019
Hi all,
I am a newbie in MATLAB and desperately need help. I have connectivity matrices (51x51) for 33 subjects for pre_intervention and post_intervention scans.
I would like to group all the 33 pre_intervention matrices and 33 post_intervention matrices, then calculate:
Gnew= Gpost- Gpre
And run a paired t-test.
The filenames are saved in this format: ABC_MS001_post_taskA_connectivity.mat
ABC_MS001_pre_taskA_connectivity.mat
ABC_MS002_post_taskA_connectivity.mat
ABC)MS002_pre_taskA_connectivity.mat
How can I load the concatenated Gpre to be subtracted from the concatenated Gpost .mat files?

Respuestas (1)

KSSV
KSSV el 2 de Ag. de 2019
Editada: KSSV el 2 de Ag. de 2019
postfiles = dir('*post*.mat') ; m = length(postfiles) ;
prefiles = dir('*pre*.mat') ; n = length(prefiles) ;
post = zeros(51,51,m) ;
pre = zeros(51,51,n) ;
for i = 1:m % as you said both the files are same in number so one loop
load(postfiles(i).name) ;
post(:,:,i) = Gpost ; % name the matrix in the mat file
pre(:,:,i) = Gpre ; % name the matrix in the mat file
end
Gnew= Gpost- Gpre ;

Categorías

Más información sobre Creating and Concatenating Matrices en Help Center y File Exchange.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by