-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathht_TamagawaPreprocess2.m
More file actions
92 lines (78 loc) · 3.1 KB
/
ht_TamagawaPreprocess2.m
File metadata and controls
92 lines (78 loc) · 3.1 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
function ht_TamagawaPreprocess2(subDir, option)
% Preprocessing the diffusion MRI data obtained by SIEMENS 3T scanner in
% Tamagawa University, Machida, JAPAN
%
% INPUTS:
% subDir: subject directory name
% (ex. 'LHON1-TK-20121130-DWI')
% option: 0: default (single masurement. analyzing 'dwi.nii.gz')
% 1: analyzing first diffusion measure 'dwi1st.nii.gz'
% 2: analyzing second diffusion measure 'dwi2nd.nii.gz'
%
%
% (c) Hiromasa 2012 Stanford VISTA team
if notDefined('subDir')
[~, subDir] = fileparts(pwd);
end
if notDefined('option')
option = 0;
end
%% Set the fullpath to data directory
basedir = '/biac4/wandell/biac2/wandell/data/DWI-Tamagawa-Japan2/';
% cd(basedir)
%% Set the optimal parameter for SIEMENS scan at Tamagawa
dwParams = dtiInitParams;
dwParams.clobber=1;
% This flipping is specifically important for SIEMENS scans
dwParams.rotateBvecsWithCanXform = 1;
dwParams.rotateBvecsWithRx = 0;
% Phase encoding direction is A/P
dwParams.phaseEncodeDir = 2; %default 2
dwParams.flipLrApFlag=0; % default = 0
%% Define folder name for 1st and 2nd scans
dt6_base_names = {'dwi', 'dwi_1st', 'dwi_2nd', 'dwi_3rd','dwi_4th'};
subjectpath = fullfile(basedir, subDir);
cd(subjectpath);
t1File = fullfile(subjectpath, 't1.nii.gz');
%% Set xform to raw t1 File
ni = niftiRead(t1File);
ni1 = niftiSetQto(ni,ni.sto_xyz);
niftiWrite(ni1);
%% mrAnatAverageAcpcNifti
% Make sure that Acpc alighnment was done
%if not finish yet, mrAnatAverageAcpcNifti.m
%% Selecting different file names between 1st and 2nd scans
switch option
case 0,
rawdtiFile = fullfile(subjectpath, 'raw', 'dwi.nii.gz');
dwParams.bvecsFile = fullfile(subjectpath, 'raw', 'dwi.bvec');
dwParams.bvalsFile = fullfile(subjectpath, 'raw', 'dwi.bval');
dwParams.dt6BaseName= dt6_base_names{1};
case 1,
rawdtiFile = fullfile(subjectpath, 'raw', 'dwi1st.nii.gz');
dwParams.bvecsFile = fullfile(subjectpath, 'raw', 'dwi1st.bvec');
dwParams.bvalsFile = fullfile(subjectpath, 'raw', 'dwi1st.bval');
dwParams.dt6BaseName= dt6_base_names{2};
case 2,
rawdtiFile = fullfile(subjectpath, 'raw', 'dwi2nd.nii.gz');
dwParams.bvecsFile = fullfile(subjectpath, 'raw', 'dwi2nd.bvec');
dwParams.bvalsFile = fullfile(subjectpath, 'raw', 'dwi2nd.bval');
dwParams.dt6BaseName= dt6_base_names{3};
case 3,
rawdtiFile = fullfile(subjectpath, 'raw', 'dwi3rd.nii.gz');
dwParams.bvecsFile = fullfile(subjectpath, 'raw', 'dwi3rd.bvec');
dwParams.bvalsFile = fullfile(subjectpath, 'raw', 'dwi3rd.bval');
dwParams.dt6BaseName= dt6_base_names{4};
case 4,
rawdtiFile = fullfile(subjectpath, 'raw', 'dwi4th.nii.gz');
dwParams.bvecsFile = fullfile(subjectpath, 'raw', 'dwi4th.bvec');
dwParams.bvalsFile = fullfile(subjectpath, 'raw', 'dwi4th.bval');
dwParams.dt6BaseName= dt6_base_names{5};
end
%% Set rawdtiFile xform
ni = readFileNifti(rawdtiFile);
ni = niftiSetQto(ni,ni.sto_xyz);
writeFileNifti(ni);
%% Run dtiInit
% Execute dtiInit
[dt6FileName, outBaseDir] = dtiInit(rawdtiFile, t1File, dwParams);