forked from tkkarjal/magia
-
Notifications
You must be signed in to change notification settings - Fork 0
/
magia_check_metadata.m
142 lines (115 loc) · 2.82 KB
/
magia_check_metadata.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
function [I, modeling_options] = magia_check_metadata(image_id, I, modeling_options)
% Checks if the metadata in I and the modeling_options are correctly
% specified, and throws an error message if crucial information is missing.
%% TRACER
tracer = I.tracer;
if(strcmp(tracer,'unknown'))
error('Unknown tracer for %s.',image_id);
end
%% FRAMES
frames = I.frames;
if(isempty(frames) || strcmp(frames,'unknown'))
error('Frames have not been specified for %s.',image_id);
end
frames = parse_frames_string(frames);
if(frames(1,2) - frames(1,1) >= 30)
frames = frames/60;
end
I.frames = frames;
%% FWHM
fwhm = I.fwhm;
if(isnan(fwhm))
fwhm = 8;
I.fwhm = fwhm;
end
%% USE_MRI & MRI
use_mri = I.use_mri;
mri = I.mri;
if(isnan(use_mri))
if(strcmp(mri,'null') || strcmp(mri,'0'))
use_mri = 0;
else
use_mri = 1;
end
end
if(use_mri)
mri_found = magia_check_mri_found(mri);
if(~mri_found)
error('Cannot magia PET study %s because the MRI (%s) that was specified was not found.',image_id,mri);
end
end
I.mri = mri;
I.use_mri = use_mri;
%% FREESURFED
if(use_mri)
freesurfed = magia_check_freesurfed(mri);
I.freesurfed = freesurfed;
end
%% PLASMA
if(~strcmp(modeling_options.model,'suv'))
plasma = I.plasma;
if(isnan(plasma))
plasma = 0;
end
if(plasma)
plasma_found = magia_check_plasma_found(image_id);
if(~plasma_found)
error('Cannot magia the PET study %s because the plasma file could not be found.',image_id);
end
end
I.plasma = plasma;
end
%% RC
rc = I.rc;
if(isnan(rc) || rc == -1)
rc = 1;
I.rc = rc;
end
%% DYN
dyn = I.dynamic;
if(isnan(dyn))
num_frames = size(frames,1);
if(num_frames > 1)
dyn = 1;
else
dyn = 0;
end
I.dynamic = dyn;
end
%% DC
dc = I.dc;
if(isnan(dc) || dc == -1)
error('Cannot magia %s because it was not specified if the data have already been decay-corrected or not.',image_id);
end
%% ROI_SET
%if(use_mri)
% roi_set = 'tracer_default';
%else
roi_set = modeling_options.roi_set;
%end
if(~use_mri && strcmp(roi_set,'tracer_default'))
if(strcmp(tracer,'[18f]fdg'))
roi_set = '[18f]fdg_atlas';
else
roi_set = 'atlas';
end
end
modeling_options.roi_set = roi_set;
%% END_TIME
cut_time = modeling_options.cut_time;
if(iscell(cut_time))
cut_time = cut_time{1};
end
if(isnan(cut_time))
modeling_options.cut_time = 0;
end
%% SUV
if(strcmp(modeling_options.model,'suv'))
dose = I.dose;
weight = I.weight;
if(isnan(weight) || weight <= 0)
error('Could not calculate SUVs for %s because the weight of the subject has not been specified.',image_id);
elseif(isnan(dose) || dose <= 0)
error('Could not calculate SUVs for %s because the injected dose has not been specified.',image_id);
end
end