-
Notifications
You must be signed in to change notification settings - Fork 0
/
mask_corr.m
executable file
·61 lines (34 loc) · 1.76 KB
/
mask_corr.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
function []=mask_corr(groupfile,mask)
%Takes as input a groupfile.mat "file" (complete with path!) and a ROI-mask (complete with path!). File can be nifti or .mat containing a field "m.BOLDfile" It then
%computes the average zerolag-correlation across the ROIs of given mask.
if strcmp(groupfile(end-2:end),'nii')
elseif strcmp(groupfile(end-2:end),'mat')
m=load(['' groupfile '']);
if isfield(m,'filenames')
filenames=m.filenames;
mask_subject_average=zeros(1,length(filenames));
for file_no=1:length(filenames)
disp(['Processing file no' num2str(file_no) '.']);
single_subject_file=strcat(m.pathtofiles,filenames{file_no});
m2=load(['' single_subject_file '']);
[ROISCOURSE, INTENS, numberofrois] = coursematrix(m2.BOLDfile,mask);
zerolagmask=mask;
ZL_zerolagmask=zeros(numberofrois,numberofrois);
for roi1=1:numberofrois
for roi2=1:numberofrois
ZL_zerolagmask(roi1,roi2)=corr2(ROISCOURSE(roi1,:),ROISCOURSE(roi2,:));
end
end
ZL_zerolagmask_average=mean(mean(ZL_zerolagmask));
mask_subject_average(file_no)=ZL_zerolagmask_average;
end
end
zerolagmask_average=mean(mask_subject_average);
zerolagmask=strsplit(zerolagmask,filesep);
zerolagmask=zerolagmask{end};
newfile=strcat(groupfile(1:end-4),'_AvgCorr_',zerolagmask(1:end-4),'.mat');
save(newfile,'zerolagmask');
save(newfile,'mask_subject_average','-append');
save(newfile,'zerolagmask_average','-append');
end
end