-
Notifications
You must be signed in to change notification settings - Fork 5
/
Mean_FA.m
142 lines (136 loc) · 3.58 KB
/
Mean_FA.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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
% 2016/4/18
% author: Changle Zhang
% funtion:sort the data of standard_space change【line 9 line 20 line 80】
clc
clear all;
close all;
pathname='E:\PKU_PSD\output_NC'; %^^change this to make analysis among NC or PSD/or AD
cd(pathname);
% cd('AllAtlasResults');
% load 'WMtractResults_FA.xls';
% cd(pathname);
dirs=dir;
dircell=struct2cell(dirs)';
filenames=dircell(:,1);
savename='MeanFA';%name of save folder
mkdir(savename);
FAcounter=zeros(90,90);
for i=3:14 %3-14(NC)or3-18(PSD)depends on the number of folders^^change this to choice
cd(char(filenames(i)));
cd('Network');
cd('Deterministic');
%dirrs=dir([ , '*.WMtract']);%WMtract file at this standard space
dirrs=dir([ , '*.txt']);%txt file at this standard space
dirrcell=struct2cell(dirrs)';
files=dirrcell(:,1);
for j=1:length(files)
ind=strfind(files(j),'FA_AAL'); %^^change this to make a selection
if isempty(ind{1})==0 %test if it is FA
FA=load(char(files(j)));
FAcounter=FAcounter+FA/16; %^^change this according to number of files
end
end
cd(pathname); %back to main path
end
%threshold value = 0.15
for m=1:90
for n=1:90
if FAcounter(m,n)<=0.15
FAcounter(m,n)=0;
end
end
end
%higher left
for m=1:30
for n=1:30
FAcounter(m,n)=0;
end
end
%lower left
for m=37:90
for n=1:30
FAcounter(m,n)=0;
end
end
%higher right
for m=1:30
for n=37:90
FAcounter(m,n)=0;
end
end
%lower right
for m=37:90
for n=37:90
FAcounter(m,n)=0;
end
end
%构造掩膜板
model=zeros(90,90);
for x=1:90
for y=1:90
if FAcounter(x,y)>0
model(x,y)=1;
end
end
end
pathname='E:\PKU_PSD\output_PSD'; %^^change this to make analysis among NC or PSD/or AD
cd(pathname);
dirs=dir;
dircell=struct2cell(dirs)';
filenames=dircell(:,1);
%掩膜板处理每个矩阵
for i=3:18 %3-14(NC)or3-18(PSD)depends on the number of folders^^change this to choice
sumrow=zeros(1,90);
sumcol=zeros(1,90);
cd(char(filenames(i)));
cd('Network');
cd('Deterministic');
%dirrs=dir([ , '*.WMtract']);%WMtract file at this standard space
dirrs=dir([ , '*.txt']);%txt file at this standard space
dirrcell=struct2cell(dirrs)';
files=dirrcell(:,1);
for j=1:length(files)
ind=strfind(files(j),'FA_AAL'); %^^change this to make a selection
if isempty(ind{1})==0 %test if it is FA
RMZ=load(char(files(j)));
RMZ=RMZ.*model; %加模板处理后得到RMZ
end
end
for s=1:90
sumrow(s)=sum(model(s,:));
sumcol(s)=sum(model(:,s));
end
row1=90-sum(sumcol(:)==0);
col1=90-sum(sumrow(:)==0);
OPT1=zeros(90,col1);%输出矩阵暂存矩阵1
OPT2=zeros(row1,col1);
counter1=1;
counter2=1;
%去除多余的列
for c=1:90
if sumcol(c)>0
OPT1(:,counter1)=RMZ(:,c);
counter1=counter1+1;
end
end
%去除多余的行
for r=1:90
if sumrow(r)>0
OPT2(counter2,:)=OPT1(r,:);
counter2=counter2+1;
end
end
% for q=1:6
% OPT(:,q)=RMZ(:,30+q);
% end
optname=strcat(char(filenames(i)),'FA_full.txt');
%
cd(pathname); %back to main path
save (optname,'OPT2','-ascii');
end
% for i=1:6
% RMZ(:,i)=FAcounter(:,30+i);
% end
% cd (savename);
% save MeanFA_90_6.txt FAcounter -ascii
%xlswrite('MeanFA',FAWMtractcount); %^^change this to make the xls's name