-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdtiInit_and_AFQ_for_andrew
50 lines (40 loc) · 1.6 KB
/
dtiInit_and_AFQ_for_andrew
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
%% Processing pipeline for the O3D project.
% Dependencies
addpath(genpath('vistasoft'))
addpath(genpath('afq'))% project/lifebid/code/franco/afq
addpath(genpath('encode'))
% dtiInit preprocessing for HCP7 ONLY
dwParams = dtiInitParams;
dwParams.rotateBvecsWithRx = 1;
dwParams.rotateBvecsWithCanXform = 1;
dwParams.bvecsFile = fullfile(baseDir,'raw','bvecs_real');
dwParams.bvalsFile = fullfile(baseDir,'raw','bvals');
dwParams.eddyCorrect = -1;
dwParams.dwOutMm = [1.05 1.05 1.05];
dwParams.phaseEncodeDir = 2;
dwParams.outDir = fullfile(projdir1);
[dt6FileName, outBaseDir] = dtiInit(sprintf('data_b%s.nii.gz', bvals), 't1_acpc_bet.nii.gz', dwParams)
% The process above will generate a dt6.mat file and few preprocessed DWI files.
%% Generate atractogrpahy using MRTRIX
%
% We will also need MRTRIX, on Karst
% module unload mrtrix
% module load mrtrix/0.2.12
% Run LiFE
L = 360;
fe = feConnectomeInit(dwiFile,fgFileName,feFileName,[],dwiFile,t1File,L,[1,0]);
Niter = 500;
fe = feSet(fe,'fit',feFitModel(feGet(fe,'model'),feGet(fe,'dsigdemeaned'),'bbnnls',Niter,'preconditioner'));
fg = feGet(fe, 'fibers acpc');
w = feGet(fe,'fiber weights');
% Save the FE structure to disk.
save('path/to/fe/filename.mat','fe')
clear fe
% Save fascicles top disk after removing bad fascicles.
wholeBrainConnectome = ['path-to-whole-brain-connectome.mat'];
fg = fgExtract(fg, w > 0);
fgWrite(fg, wholeBrainConnectome)
% Run AFQ to segment
[fascicles,classification,fg,fg_classified] = feAfqSegment(dtFile, wholeBrainConnectome);
% Save results to disk
save('file-path-toAFQ-results.mat','fascicles','classification','fg_classified');