-
Notifications
You must be signed in to change notification settings - Fork 1
/
DTIFit_Check.m
83 lines (68 loc) · 3.11 KB
/
DTIFit_Check.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
% Code used for the preparation and evaluation of the MEMENTO challenge
% organized by Kurt Schilling, Andrada Ianus and Alberto De Luca
% Code author: Alberto De Luca (a.deluca-2@umcutrecht.nl)
% This script evaluates the residuals of test DTI prediction
data = ISBI_LoadSubchallenge1Description('Provided/PGSE_ProtocolDescription.txt','Provided/PGSE_shells_provided_acq_params.txt');
data.Signals = load('Provided/PGSE_shells_provided_signals.txt');
%% As sanity check predict the provided data
IX = data.B <= 1 | abs(data.B-1000) < 10;
data.B = data.B(IX);
data.gx1 = data.gx1(IX);
data.gy1 = data.gy1(IX);
data.gz1 = data.gz1(IX);
data.Signals = data.Signals(IX,:);
test_data = data;
test_data.GroundTrueValues = data.Signals;
%% Perform a DTI fit
DTI_fit = ISBI_ExampleDTI_Fit(data);
%% Calculate metrics
[MD, FA] = ISBI_ExampleDTI_Parameters(DTI_fit);
%% Perform the prediction
PredictedSignals = ISBI_ExampleDTI_Prediction(DTI_fit,test_data);
out_file = 'MySubchallenge1_DTI_PGSE_shells_selfprediction.txt';
fout = fopen(out_file,'wt');
for row=1:size(PredictedSignals,1)
for col=1:size(PredictedSignals,2)
fprintf(fout,'%f\t',PredictedSignals(row,col));
end
fprintf(fout,'\n');
end
fclose(fout);
test_data.Signal = load(out_file);
%% Self-evaluation
ISBI_Subchallenge1_VisualEvaluation(test_data);
[absolute_score,per_signal_score] = ISBI_Subchallenge1_SyntheticEvaluation(test_data);
disp(['The overall score is: ' num2str(absolute_score)]);
for signal_id=1:length(per_signal_score)
disp(['Signal ' num2str(signal_id) ' partial score: ' num2str(per_signal_score(signal_id))]);
end
%% Now, predict the unprovided data
test_data = ISBI_LoadSubchallenge1Description('Provided/PGSE_ProtocolDescription.txt','Provided/PGSE_shells_unprovided_acq_params.txt');
IX = test_data.B <= 1 | abs(test_data.B-1000) < 10;
test_data.B = test_data.B(IX);
test_data.gx1 = test_data.gx1(IX);
test_data.gy1 = test_data.gy1(IX);
test_data.gz1 = test_data.gz1(IX);
%% Perform the prediction
PredictedSignals = ISBI_ExampleDTI_Prediction(DTI_fit,test_data);
out_file = 'MySubchallenge1_PGSE_DTI_shells_prediction.txt';
fout = fopen(out_file,'wt');
for row=1:size(PredictedSignals,1)
for col=1:size(PredictedSignals,2)
fprintf(fout,'%f\t',PredictedSignals(row,col));
end
fprintf(fout,'\n');
end
fclose(fout);
test_data.Signal = load(out_file);
%% Final evaluation - code not provided to the participants
test_data.GroundTrueValues = load('Unprovided/PGSE_shells_unprovided_signals.txt');
% test_data.Signal = test_data.Signal(IX,:);
test_data.GroundTrueValues = test_data.GroundTrueValues(IX,:);
ISBI_Subchallenge1_VisualEvaluation(test_data);
[absolute_score,per_signal_score,residuals_3_moments] = ISBI_Subchallenge1_SyntheticEvaluation(test_data);
disp(['The overall score is: ' num2str(absolute_score)]);
for signal_id=1:length(per_signal_score)
disp(['Signal ' num2str(signal_id) ' partial score: ' num2str(per_signal_score(signal_id))]);
disp(['The 25,50,75th percentile of the residuals are: ' num2str(residuals_3_moments(signal_id,:))]);
end