-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCheck_BeforeAFQ.m
More file actions
166 lines (120 loc) · 4.82 KB
/
Check_BeforeAFQ.m
File metadata and controls
166 lines (120 loc) · 4.82 KB
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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
%% Checking if these subjects have OR and OT files
[homeDir,subDir,JMD,CRD,LHON,Ctl,RP,AMDC] = Tama_subj2;
% Pick up subject
Control = [Ctl,AMDC];
%% Checking file existence
subnumber = [RP,Control];
for ii = 1:length(subnumber)
current_subject = fullfile(homeDir, subDir{subnumber(ii)});
% fiber tract files
fgDir = fullfile(current_subject,'/dwi_2nd/fibers');
Fg = {'LOTD3L2_1206.pdb','LOTD4L4_1206.pdb','LOR1206_D4L4.pdb','ROTD3L2_1206.pdb','ROTD4L4_1206.pdb','ROR1206_D4L4.pdb'};
for jj =1 : length(Fg);
Ex(ii,jj) = exist(fullfile(fgDir, Fg{jj}));
end
% ROI files
RoiDir = fullfile(current_subject,'/dwi_2nd/ROIs');
Roi = { '85_Optic-Chiasm.mat','Lt-LGN4.mat','Rt-LGN4.mat','lh_V1_smooth3mm_NOT.mat','rh_V1_smooth3mm_NOT.mat'};
for kk =1 : length(Roi);
R(ii,kk) = exist(fullfile(RoiDir,Roi{kk}));
end
% copy Optic -chasm ROI
if exist(fullfile(RoiDir,'Optic-Chiasm.mat')) && ~exist(fullfile(RoiDir,'85_Optic-Chiasm.mat'));
cd(RoiDir)
!cp Optic-Chiasm.mat 85_Optic-Chiasm.mat
end
end
%%
% If rois don't exist, you can simply run SO_GetRoisId3(id) %% Tamagawa3 directory
id = R(:,1)==0;
% for
SO_GetRoisId2(subnumber(id))
%% subject dose not have ORs
NeedOR = squeeze(subDir(subnumber(Ex(:,6)==0)));
for jj = 1:length(NeedOR)
fgDir = fullfile(current_subject,'/dwi_2nd/fibers');
end
%% check
subnumber = [RP,Control];
for ii = 1:length(subnumber)
current_subject = fullfile(homeDir, subDir{subnumber(ii)});
% fiber tract files
fgDir = fullfile(current_subject,'/dwi_2nd/fibers');
Fg = {'LOTD4L4_1206.pdb','LOR1206_D4L4.pdb','ROTD4L4_1206.pdb','ROR1206_D4L4.pdb'};
mrvNewGraphWin; hold on;
for jj = 1:length(Fg)
fg = fgRead(fullfile(fgDir,Fg{jj}));
AFQ_RenderFibers(fg,'numfibers',50,'newfig',0)
end
view([0 90])
axis off
axis image
title(subDir{subnumber(ii)})
hold off
end
%% AFQ
load '/sni-storage/wandell/biac2/wandell/data/DWI-Tamagawa-Japan2/RP/AFQ_8RP_14Ctl_0820.mat'
sub_dirs = afq.sub_dirs;
for jj = length(afq.sub_dirs)+1: length(afq.sub_dirs)+length(AMDC)
sub_dirs{jj} = fullfile(homeDir, subDir{AMDC(jj-length(afq.sub_dirs))},'dwi_2nd');
end
% Subject grouping is a little bit funny because afq only takes two groups
% but we have 3. For now we will divide it up this way but we can do more
% later
a = zeros(1,length(sub_dirs));
% b = [16:23,31:33,35:37];
a(1,1:length(RP)) = 1;
sub_group = a;
% sub_group = [1,0];
% Now create and afq structure
% afq = AFQ_Create('sub_dirs', sub_dirs, 'sub_group', sub_group, 'clip2rois', 0);
% if you would like to use ants for normalization
% afq = AFQ_Create('sub_dirs', sub_dirs, 'sub_group', sub_group, 'clip2rois', 0,'normalization','ants');
% % To have afq overwrite the old fibers
% afq = AFQ_set(afq,'overwritesegmentation');
% afq = AFQ_set(afq,'overwritecleaning');
% % afq.params.cutoff=[5 95];
% afq.params.outdir = ...
% fullfile(AFQdata,'/AFQ_results/6LHON_9JMD_8Ctl');
afq = AFQ_set(afq,'outdir','/sni-storage/wandell/biac2/wandell/data/DWI-Tamagawa-Japan2/RP');
afq = AFQ_set(afq,'outname','afq_8RP_25Normal');
% afq.params.outname = 'AFQ_Tama3_11AMDC_mrtrix.mat';
afq.params.run_mode = 'mrtrix';
%% Run AFQ on these subjects
afq = AFQ_run(sub_dirs, sub_group, afq);
%% load afq structure
load '/sni-storage/wandell/biac2/wandell/data/DWI-Tamagawa-Japan2/RP/afq_8RP_25Normal';
%% clip2rois was 'true', so it is needed to be '0'
afq.params.clip2rois = 0;
afq.params.cleanFibers = 0;
afq.params.outname = 'afq_8RP_25Normal_02112015.mat';
%% Add OT and OR
% Fg = {'LOTD3L2_1206.pdb','LOTD4L4_1206.pdb','LOR1206_D4L4.pdb','ROTD3L2_1206.pdb','ROTD4L4_1206.pdb','ROR1206_D4L4.pdb'};
Fg = {'LOTD4L4_1206.pdb','ROTD4L4_1206.pdb','LOR1206_D4L4.pdb','ROR1206_D4L4.pdb'};
% afq = AFQ_AddNewFiberGroup(afq, fgName, roi1Name, roi2Name, [cleanFibers = true], ...
% [computeVals = true], [showFibers = false], [segFgName = 'WholeBrainFG.mat'] ...
% [overwrite = false])
% L-optic tract
fgName = Fg{1};
roi1Name = '85_Optic-Chiasm.mat';
roi2Name = 'Lt-LGN4.mat';
afq = SO_AFQ_AddNewFiberGroup(afq, fgName, roi1Name, roi2Name, 0, 1,0,[],0);
% R-optic tract
fgName = Fg{2};
roi1Name = '85_Optic-Chiasm.mat';
roi2Name = 'Rt-LGN4.mat';
afq = SO_AFQ_AddNewFiberGroup(afq, fgName, roi1Name, roi2Name, 0, 1,0,[],0);
% L-optic radiation
fgName = Fg{3};
roi1Name = 'Lt-LGN4.mat';
roi2Name = 'lh_V1_smooth3mm_NOT.mat';
afq = SO_AFQ_AddNewFiberGroup(afq, fgName, roi1Name, roi2Name, 0, 1,0,[],0);
% R-optic radiation
fgName = Fg{4};
roi1Name = 'Rt-LGN4.mat';
roi2Name = 'rh_V1_smooth3mm_NOT.mat';
afq = SO_AFQ_AddNewFiberGroup(afq, fgName, roi1Name, roi2Name, 0, 1,0,[],0);
%% save afq
save '/sni-storage/wandell/biac2/wandell/data/DWI-Tamagawa-Japan2/RP/afq_8RP_25Normal_02112015.mat'
%% render resuts
% See RP_RP_plot_24C_2