-
Notifications
You must be signed in to change notification settings - Fork 0
/
doOffsetClusterCorrelationExpansion_forHDCCE.m
144 lines (106 loc) · 4.37 KB
/
doOffsetClusterCorrelationExpansion_forHDCCE.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
143
144
% Cluster expansion somewhere between CE and CCE:
% v = prod( 1 + v' )
% v' = vC/prod( 1 + v'C') - 1, for C' in C.
function [Signals, ...
AuxiliarySignal_1,AuxiliarySignal_2, ...
AuxiliarySignal_3,AuxiliarySignal_4,...
AuxiliarySignal_5,AuxiliarySignal_6] = ...
doOffsetClusterCorrelationExpansion_forHDCCE(...
Coherences_1,Coherences_2,Coherences_3,Coherences_4,Coherences_5,Coherences_6,Clusters, ...
SubclusterIndices_2,SubclusterIndices_3,SubclusterIndices_4,SubclusterIndices_5,SubclusterIndices_6,...
timepoints,dimensionality, order,numberClusters, Nuclei_Abundance)
% Coherences_n(iCluster,timepoints)
% SubclusterIndices_clusterSize(jCluster,subCluster_size, iCluster) =
% the jth cluster of size subCluster_size that is a subcluster of
% the ith cluster of size clusterSize.
% In a valid cluster, all indices must be natural numbers.
%
% pass = test_subclusters(Clusters, SubclusterIndices_2,SubclusterIndices_3,SubclusterIndices_4,false);
% if ~pass
% error('Incorrect Subcluster');
% end
% Initialize data.
code_maxSize = 6;
maxSize = min(code_maxSize,order);
AuxiliarySignal_1 = Coherences_1./Coherences_1(:,1);
AuxiliarySignal_2 = Coherences_2./Coherences_2(:,1);
AuxiliarySignal_3 = Coherences_3./Coherences_3(:,1);
AuxiliarySignal_4 = Coherences_4./Coherences_4(:,1);
AuxiliarySignal_5 = Coherences_5./Coherences_5(:,1);
AuxiliarySignal_6 = Coherences_6./Coherences_6(:,1);
Signals = ones(code_maxSize,timepoints^dimensionality);
%--------------------------------------------------------------------------
% 1-Clusters
%--------------------------------------------------------------------------
cluster_order = 1;
AuxiliarySignal_1 = AuxiliarySignal_1 - 1;
if order<cluster_order, return; end
for iCluster=1:numberClusters(cluster_order)
% Update cluster signals.
for iorder=cluster_order:maxSize
% The isotope probability is used to determine the likelihood a
% particular cluster will contain the assumed spins.
% If the cluster does not contain all spinful nuclei,
% the auxiliarary signal will be unity.
this_cluster = Clusters(iCluster,1:cluster_order,cluster_order);
if this_cluster(1)==0
continue;
end
% v(t) = v'(t)*( (1-p) + p*v''(t) ) = v'(t)*( 1 + p*( v''(t) -1 ) ).
Signals(iorder,:) = Signals(iorder,:).*( AuxiliarySignal_1(iCluster,:) + 1);
end
end
%--------------------------------------------------------------------------
% 2-Clusters
%--------------------------------------------------------------------------
cluster_order = 2;
if order<cluster_order, return; end
for iCluster=1:numberClusters(cluster_order)
% Remove 1-cluster correlations
for subcluster_index = SubclusterIndices_2(:,1,iCluster)'
if subcluster_index <= 0
continue;
end
AuxiliarySignal_2(iCluster,:) = AuxiliarySignal_2(iCluster,:)./( AuxiliarySignal_1(subcluster_index,:) + 1);
end
AuxiliarySignal_2(iCluster,:) = AuxiliarySignal_2(iCluster,:) - 1;
% Update cluster signals.
for iorder=cluster_order:maxSize
this_cluster = Clusters(iCluster,1:cluster_order,cluster_order);
if this_cluster(1)==0
continue;
end
Signals(iorder,:) = Signals(iorder,:).*(AuxiliarySignal_2(iCluster,:) + 1);
end
end
%--------------------------------------------------------------------------
% 3-Clusters
%--------------------------------------------------------------------------
cluster_order = 3;
if order<cluster_order, return; end
for iCluster=1:numberClusters(cluster_order)
% Remove 1-cluster correlations
for subcluster_index = SubclusterIndices_3(:,1,iCluster)'
if subcluster_index <= 0
continue;
end
AuxiliarySignal_3(iCluster,:) = AuxiliarySignal_3(iCluster,:)./( AuxiliarySignal_1(subcluster_index,:) + 1);
end
% Remove 2-cluster correlations
for subcluster_index = SubclusterIndices_3(:,2,iCluster)'
if subcluster_index <= 0
continue;
end
AuxiliarySignal_3(iCluster,:) = AuxiliarySignal_3(iCluster,:)./(AuxiliarySignal_2(subcluster_index,:) + 1);
end
AuxiliarySignal_3(iCluster,:) = AuxiliarySignal_3(iCluster,:) - 1;
% Update cluster signals.
for iorder=cluster_order:maxSize
this_cluster = Clusters(iCluster,1:cluster_order,cluster_order);
if this_cluster(1)==0
continue;
end
Signals(iorder,:) = Signals(iorder,:).*(AuxiliarySignal_3(iCluster,:) + 1);
end
end
end