-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMRData.m
More file actions
executable file
·77 lines (73 loc) · 2.35 KB
/
MRData.m
File metadata and controls
executable file
·77 lines (73 loc) · 2.35 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
%% MRData.m
%
% Function that returns the MR data corresponding to the given phantom that
% is modulated by a sensitivity profile, for the given kspace samples.
%
% Matthieu Guerquin-Kern, Biomedical Imaging Group / EPF Lausanne,
% 31-10-2009 (dd-mm-yyyy)
function m = MRData(phantom,s,k)
m = zeros(1,size(k,2));
ind_ell = [];
ind_bez = [];
Nbez = [];
for p = 1:length(phantom.region)
region = phantom.region{p};
switch region.type
case {'ellipse'}
ind_ell = [ind_ell, p];
case {'polygon'}
ind_bez = [ind_bez, p];
Nbez = [Nbez,size(region.vertex,1)];
case {'bezier'}
ind_bez = [ind_bez, p];
Nbez = [Nbez,size(region.control,1)];
otherwise
error('%s: this kind of region is unknown',region.type);
end
end
Nell = numel(ind_ell);
[Nbez,indsort] = sort(Nbez,'ascend');
ind_bez = ind_bez(indsort);clear indsort;
hbar = waitbar(0,'MR_DATA.m -> Estimating time...');
tcum = 0;
tell = 0;
tbez = 0;
if Nell>0
t = clock();
m = m + MRDataEllipse(phantom.region{ind_ell(1)},s,diag(phantom.FOV)*k);
tell = etime(clock(),t);
tcum = tcum + tell;
end
if numel(Nbez)>0
t = clock();
m = m + MRDataBezier(phantom.region{ind_bez(1)},s,diag(phantom.FOV)*k);
t = etime(clock(),t);
tbez = t/Nbez(1);
tcum = tcum + t;
end
t_est = max(Nell*tell + sum(Nbez)*tbez,tcum);
waitbar(tcum/t_est,hbar,sprintf('MR_DATA.m -> Estimated remaning time: %.0f s (total time: %.0f)',t_est-tcum,t_est));
for i = 2:(numel(ind_ell))
p = ind_ell(i);
region = phantom.region{p};
t = clock();
m = m + MRDataEllipse(region,s,diag(phantom.FOV)*k);
t = etime(clock(),t);
tell = (i*tell+t)/(i+1);
tcum = tcum+t;
t_est = max(Nell*mean(tell) + sum(Nbez)*mean(tbez),tcum);
waitbar(tcum/t_est,hbar,sprintf('MR_DATA.m -> Estimated remaning time: %.0f s (total time: %.0f)',t_est-tcum,t_est));
end
for i = 1:(numel(ind_bez)-1)
p = ind_bez(end-i+1);
region = phantom.region{p};
t = clock();
m = m + MRDataBezier(region,s,diag(phantom.FOV)*k);
t = etime(clock(),t);
tbez = (i*tbez+t/Nbez(end-i+1))/(i+1);
tcum = tcum+t;
t_est = max(Nell*mean(tell) + sum(Nbez)*tbez,tcum);
waitbar(tcum/t_est,hbar,sprintf('MR_DATA.m -> Estimated remaning time: %.0f s (total time: %.0f)',t_est-tcum,t_est));
end
close(hbar);
m = prod(phantom.FOV)*m;