-
Notifications
You must be signed in to change notification settings - Fork 0
/
cw02_NODDI_model.m
180 lines (128 loc) · 5.82 KB
/
cw02_NODDI_model.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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% This script is part of the UCL MedICSS 2022 "Estimation of brain tissue
% microstructure with dMRI" project. The repository of the project is
% available at: https://github.com/CIG-UCL/MedICSS_2022_microImag
%
% Author: Michele Guerreri ([email protected])
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% course work # 2: NODDI model
% The aim of this course work is to get familiar with NODDI model and
% understand how to generate an istance of diffusion signal via this model
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% How to use this code?
% 1. You should read the comments in the script.
% 2. There are some questions through the script, write your answer into the
% dedicated space. Don't worry if you don't know the answer, you are
% here to learn!!
% 3. The code is divided in sections. Every time you start a new section you
% should uncomment the code and complete the missing parts (which are
% highlighted). Then run the section code and go to the next section.
% 4. Repeat step 3. until the end of the script.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 2.0 Cleaning and setup
%{
% As a first thing let's clean our workspace, clear the command window and close
% all open figures:
clc
clear
close all
% Start from the right directory
toCourseWorkDIR()
%}
%% 2.1 NODDI model
%{
% The way to create the NODDI model via the NODDI MATLAB toolbox is using
% the MakeModel() function. The input of the function is the following
% string: 'WatsonSHStickTortIsoV_B0'. The motivations behind this name are
% outside the scope of this course.
noddi = MakeModel('WatsonSHStickTortIsoV_B0');
% "noddi" is a variable of type struct. Explore it and try to understand what
% the different fields refer to. Any guess?
% ANSWER (check this answer after you had a look at the variable):
% 1. "Name" is the string identifying the model.
% 2. "numParams" is the total number of parameters characterizing the
% model.
% 3. "paramsStr" identifies the parameter names.
% 4. "tissuetype" refers to the type of tissues we are looking at. NODDI
% can be used on both invivo and exvivo data.
% 5-8. Are fields that contain useful information. This are particularly
% useful when fitting the model to the data using the toolbox.
% Check the content of noddi.GD.fixed. What does it represent in your
% opinion?
% ANSWER:
% Which are the fixed parameters?
% ANSWER:
%}
%% 2.2 Synthesize signal via NODDI model
%{
% Let's now try to use the model to generate an instance of diffusion
% weighted signal via the NODDI model.
% First we need to define an acquisition protocol. We will use the same
% protocol as the one in course work 1. Define the "acqProtocol" as done
% previously.
bval_path = fullfile('..', '..', 'NODDI_example_dataset/NODDI_protocol.bval');
bvec_path = fullfile('..', '..', 'NODDI_example_dataset/NODDI_protocol.bvec');
acqProtocol = FSL2Protocol(, ); % complete this
% next, we need to assign a value to each of the model parameters.
% ficvf is the fraction of tissue signal from intra-neurite space (aka NDI)
ficvf = 0.6;
% di is the intra-neurite diffusivity. This parameter is usually fixed to 1.7 um2/ms
di = 1.7*1e-9; % mm2/ms
% kappa is a parameter describing the orientation dispersion of the neurites.
% This parameter is connected to the ODI parameter
kappa = 2;
% fiso the fraction of signal from free water (or CSF) compartment (aka FWF)
fiso = 0.1;
% diso is the free water diffusivity. this value is usually fixed to 3.0 um2/ms
diso = 3.0*1e-9; % mm2/ms
% b0 is the signal value without any diffusion weighting.
% the value is the same as the one we estimated in the GCC voxel before.
b0 = 2581;
% theta is the fibre direction polar angle in spherical coordinates
theta = pi/2;
% phi is the fibre direction azimuthal angle in spherical coordinates
phi = 0;
% We use the synthMeas() function to synthetize the DW measures
% let's put the parameters in an array. I started for you from the first
% two...
synthVox_param = [ficvf di ]; % complete this
% let's retrieve the fibre direction in cartesian coordinates
synthVox_fibredir = GetFibreOrientation(); % complete this
% and let' generate the signal
% use the help to see how the function works
synthVox_signal = SynthMeas(); % complete this
% Check the output.
%}
%% 2.3 Synthetic signal visualization
%{
% Try to use the compact voxel data viwer as done in the previous course
% work. Compare the result with that of the GCC voxel.
fig_synth_compact = figure('Position', [400 100 500 800], 'color', [ 1 1 1]);
VoxelDataViewer(, fig_synth_compact); % complete this
ylim([0 1.2])
load(fullfile('coursework_outputs', 'cw1.mat'), 'fig_gcc_compact')
% What differences do you see? Can you explain why?
% ANSWER:
% There is a useful function to visualize both experimental and
% model-generated signals in one step:
% let's load the GCC voxel again
load(fullfile('coursework_outputs', 'cw1.mat'), 'gccVox')
% we need to scale the parameters to make it work
synthVox_param_scaled = scaleModelParams(synthVox_param, noddi);
% create the plot
fig_fitQC = QualityOfFit(gccVox, synthVox_param_scaled, noddi, acqProtocol);
ylim([0 1.2])
% What is going on?
% ANSWER:
% This configuration make comparison between predicted and measured signal
% very easy.
%}
%% 2.4 Save the output
%{
% Before running this section make sure you have finished your analysis as
% this will close all the open figures
% let's now save the variables we created into a mat fi
save(fullfile('coursework_outputs', 'cw2.mat'))
% and close the figures
close all
%}