-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLocal_cluster_result_reshape.m
122 lines (113 loc) · 3.15 KB
/
Local_cluster_result_reshape.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
function result = Local_cluster_result_reshape(ccdimginfo,result)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
nBatch = length(result.Iqphi);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
not_nans=~isnan(result.dynamicQs{1});
[dpart_list,~]=find(not_nans==1);
not_nans=~isnan(result.staticQs{1});
[spart_list,~]=find(not_nans==1);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
snoq=ccdimginfo.partition.snpt(1);
snophi=ccdimginfo.partition.snpt(2);
dnoq=ccdimginfo.partition.dnpt(1);
dnophi=ccdimginfo.partition.dnpt(2);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% --- reshape some static stuff
fieldnames = {...
'Iqphi',...
'Iqphit'};
for ii=1:nBatch
if isempty(result.Iqphi{ii})
continue;
end
for jj=1:length(fieldnames)
result.(fieldnames{jj}){ii} = reshape_result(...
result.(fieldnames{jj}){ii},...
spart_list(1:end),...
snoq,...
snophi);
end
end
% --- reshape some more static stuff
fieldnames = {...
'staticQs',...
'staticPHIs'};
for ii=1:nBatch
if isempty(result.Iqphi{ii})
continue;
end
for jj=1:length(fieldnames)
a=result.(fieldnames{jj}){ii};
b=a(spart_list);
result.(fieldnames{jj}){ii} = reshape_result(...
b,...
spart_list(1:end),...
snoq,...
snophi);
end
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% --- reshape almost all dynamic stuff
fieldnames = {...
'g2avg',...
'g2avgErr',...
'g2avgFIT1',...
'baselineFIT1',...
'contrastFIT1',...
'tauFIT1',...
'baselineErrFIT1',...
'contrastErrFIT1',...
'tauErrFIT1',...
'g2avgFIT2',...
'baselineFIT2',...
'contrastFIT2',...
'tauFIT2',...
'exponentFIT2',...
'baselineErrFIT2',...
'contrastErrFIT2',...
'tauErrFIT2',...
'exponentErrFIT2'};
for ii=1:nBatch
if isempty(result.Iqphi{ii})
continue;
end
for jj=1:length(fieldnames)
result.(fieldnames{jj}){ii} = reshape_result(...
result.(fieldnames{jj}){ii},...
dpart_list(1:end),...
dnoq,...
dnophi);
end
end
% --- reshape some more dynamic stuff
fieldnames = {...
'dynamicQs',...
'dynamicPHIs'};
for ii=1:nBatch
if isempty(result.Iqphi{ii})
continue;
end
for jj=1:length(fieldnames)
a=result.(fieldnames{jj}){ii};
b=a(dpart_list);
result.(fieldnames{jj}){ii} = reshape_result(...
b,...
dpart_list(1:end),...
dnoq,...
dnophi);
end
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function s1 = reshape_result(s0,list,noq,nophi)
if ndims(s0) == 3
s1 = NaN*ones(noq*nophi,1,size(s0,3));
s1(list,:,:) = s0;
s1 = reshape(s1,noq,nophi,size(s0,3));
elseif ismatrix(s0)
s1 = NaN*ones(noq*nophi,1);
s1(list,:) = s0;
s1 = reshape(s1,noq,nophi);
else
s1 = [];
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%