-
Notifications
You must be signed in to change notification settings - Fork 62
/
Copy pathTest_fitting_MET.m
85 lines (73 loc) · 2.07 KB
/
Test_fitting_MET.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
%% File to simulate T2 fitting with different exchange rates
clc;
clear;
close all;
run('/home/gustavo/Downloads/qMRLab-master/startup.m') %download from https://qmrlab.org/
warning ('off','all');
T1 = [1000 500];
T2 = [120 20];
list_kxs = [0:1:20]*1e-3; % list of exchange rates to test;
list_f = [1:40]*1e-2; % list of fractions to test;
for jj=1:length(list_kxs)
ka = list_kxs(jj);
for ii=1:length(list_f)
f = list_f(ii);
esp=5;
angles = pi*ones(1,50);
Npulse = length(angles);
[s,P] = epg_X_CMPG(angles,f,T1,T2,esp,ka,0);
all_s(ii,jj,:) = abs(s(3,:));
end
end
% load presaved model to use for fitting
Model = qMRloadObj('mwf.qmrlab.mat');
Model.Prot.MET2data.Mat = esp*(1:Npulse)';
data = struct();
data.MET2data= reshape(all_s,[length(list_f) length(list_kxs) 1 Npulse]);
data.Mask= ones([length(list_f) length(list_kxs) 1]);
FitResults = FitData(data,Model,0);
save('FitResultsMET')
figure
subplot(1,3,1)
selected = 1:2:length(list_kxs);
plot(list_f,list_f);
hold on
plot(list_f,FitResults.MWF(:,selected)/100,'*','linewidth',1)
xlabel('real fraction')
ylabel('estimated fraction')
legends={};
for ii=1:length(selected)
legends{ii+1}=['ka=' num2str(list_kxs(selected(ii)))];
end
legends{1} = 'Ground truth';
legend(legends);
xlim([0 0.4])
ylim([0 0.4])
title('Fraction estimation')
subplot(1,3,3)
selected = 1:2:length(list_kxs);
plot(list_f,T2(2)*ones(size(list_f)));
hold on
plot(list_f,FitResults.T2MW(:,selected),'*','linewidth',1)
xlabel('fraction')
ylabel('Estimated T2_b (ms)')
legends={};
for ii=1:length(selected)
legends{ii+1}=['ka=' num2str(list_kxs(selected(ii)))];
end
legends{1} = 'Ground truth';
title('T2_b estimation')
subplot(1,3,2)
selected = 1:2:length(list_kxs);
plot(list_f,T2(1)*ones(size(list_f)));
hold on
plot(list_f,FitResults.T2IEW(:,selected),'*','linewidth',1)
xlabel('fraction')
ylabel('Estimated T2_a(ms)')
legends={};
for ii=1:length(selected)
legends{ii+1}=['ka=' num2str(list_kxs(selected(ii)))];
end
legends{1} = 'Ground truth';
% legend(legends);
title('T2_a estimation')