-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathicassoStruct.m
executable file
·240 lines (231 loc) · 8 KB
/
icassoStruct.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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
function sR=icassoStruct(X)
%function sR=icassoStruct([X])
%
%PURPOSE
%
%To initiate an Icasso result data structure which is meant for
%storing and keeping organized all data, parameters and results
%when performing the Icasso procedure.
%
%EXAMPLE OF BASIC USAGE
%
% S=icassoStruct(X);
%
%creates an Icasso result structure in workspace variable S. Its
%fields are initially empty except field .signal that contains
%matrix X.
%
%INPUT
%
%[An argument in brackets is optional. If it isn't given or it's
% an empty matrix/string, the function will use a default value.]
%
%[X] (dxN matrix) the original data (signals) consisting of N
% d-dimensional vectors. Icasso centers the data (removes the
% sample mean from it) and stores it in field .signal.
% If the input argument is not given, or it is empty,
% the field is left empty.
%
%OUTPUT
%
% sR (struct) Icasso result structure that contains fields
%
% .mode (string)
% .signal (matrix)
% .index (matrix)
% .fasticaoptions (cell array)
% .A (cell array)
% .W (cell array)
% .whiteningMatrix (matrix)
% .dewhiteningMatrix (matrix)
% .cluster (struct)
% .projection (struct)
%
%DETAILS
%
%The following table presents the fields of Icasso result
%structure. Icasso is a sequential procedure that is split into
%several phases (functions). The table shows the order in which
%the fields are computed, the function that is used to change the
%parameters/results in the field, and lastly the phases that
%the result depends on.
%
%P=parameter that may be a explicit user input or a default parameter
%set by Icasso
%
%Phase Field Function depends on field(s)
%
%(1) .mode icassoEst P
%(1) .signal icassoEst P
%(1) .index icassoEst (ICA results)
%(1) .fasticaoptions icassoEst P
%(1) .A icassoEst (ICA results)
%(1a) .W icassoEst (ICA results)
%(1) .whiteningMatrix icassoEst (ICA results)
%(1b) .dewhiteningMatrix icassoEst (ICA results)
%
%(2a) .cluster.simfcn icassoCluster P
%(2b) .cluster.similarity icassoCluster 1a,1b,2a
%(2c) .cluster.s2d icassoCluster P
%(2d) .cluster.strategy icassoCluster P
%(2e) .cluster.partition icassoCluster 2b-d
%(2f) .cluster.dendrogram icassoCluster 2b-d
%(2g) .cluster.index.R icassoCluster 2b,2c,2e
%
%(3a) .projection.method icassoProjection P
%(3b) .projection.parameters icassoProjection P
%(3c) .projection.coordinates icassoProjection 2b,3a-b
%
%icasso performs the whole process with default parameters
%icassoEst performs phase 1
%icassoExp performs phases 2-3 with default parameters.
%
%(1) Data, ICA parameters, and estimation results
%
% .mode (string)
% type of randomization ('bootstrap'|'randinit'|'both')
%
% .signal (dxN matrix)
% the original data (signal) X (centered) where N is
% the number of samples and d the dimension
%
% .index (Mx2 matrix)
% the left column is the number of the estimation cycle, the
% right one is the number of the estimate on that cycle.
% See also function: icassoGet
%
%The following fields contain parameters and results of the ICA
%estimation using FastICA toolbox. More information can be found,
%e.g., from of function fastica in FastICA toolbox.
%
% .fasticaoptions (cell array)
% contains the options that FastICA uses in estimation.
%
% .A (cell array of matrices)
% contains mixing matrices from each estimation cycle
%
% .W (cell array of matrices)
% contains demixing matrices from each estimation cycle
%
% .whiteningMatrix (matrix)
% whitening matrix for original data (sR.signal)
%
% .dewhiteningMatrix (matrix)
% dewhitening matrix for original data (sR.signal).
%
%(2) Mutual similarities and clustering
%
%Parameters and results of
% -computing similarities S between the estimates, and
% -clustering the estimates
%are stored in field .cluster which has the following subfields:
%
% .cluster.simfcn (string)
% a string option for function icassoCluster
% (icassoSimilarity); it tells how the mutual similarities
% between estimates are computed.
%
% .cluster.similarity (MxM matrix)
% mutual similarities between estimates.
%
% .cluster.s2d (string)
% before clustering and computing the clustering validity index
% the similarity matrix S stored in .cluster.similarity is
% transformed into a dissimilarity matrix. This string is the
% name of the subfunction that makes the transformation: there
% is a function call
% D=feval(sR.cluster.s2d,sR.cluster.similarity);
% inside icassoCluster. Note that the dissimilarity matrix
% is not stored in the Icasso result data struct.
%
% .cluster.strategy (string)
% strategy that was used for hierarchical clustering which is
% done on dissimilarities D
% .cluster.partition (MxM matrix)
% stores the partitions resulting clustering. Each row
% partition(i,:), represents a division of M objects into K(i)
% clusters (classes). On each row, clusters must be labeled
% with integers 1,2,...,K(i), where K(i) is the number of
% clusters that may be different on each row Example:
% partition=[[1 2 3 4];[1 1 1 1];[1 1 2 2]] gives three
% different partitions where partition(1,:) means every object
% being in its own clusters; partition(2,:) means all objects
% being in a single cluster, and in partition(3,:) objects 1&2
% belong to cluster 1 and 3&4 to cluster 2.
%
% .cluster.dendrogram.Z and .cluster.dendrogram.order
% stores information needed for drawing dendrogram and
% similarity matrix visualizations. More details in function
% som_linkage
%
%The following subfields of .cluster contain heuristic validity
%scores for the partitions in .cluster.partition. If the score is
%NaN it means that the validity has not been (or can't be)
%computed.
%
% .cluster.index.R (Mx1 vector)
% computed by subfunction rindex
%
%(3) Projection for visualization
%
%Parameters for performing the visualization projection are results
%of the projection can be found in field .projection.
%
% .projection has the following subfields:
%
% .projection.method (string)
% projection method used in icassoProjection
%
% .projection.parameters (cell array)
% contains parameters used in icassoProjection
%
% .coordinates (Mx2 matrix)
% contains the coordinates of the projected estimates
%
%COPYRIGHT NOTICE
%This function is a part of Icasso software library
%Copyright (C) 2003-2005 Johan Himberg
%
%This program is free software; you can redistribute it and/or
%modify it under the terms of the GNU General Public License
%as published by the Free Software Foundation; either version 2
%of the License, or any later version.
%
%This program is distributed in the hope that it will be useful,
%but WITHOUT ANY WARRANTY; without even the implied warranty of
%MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
%GNU General Public License for more details.
%
%You should have received a copy of the GNU General Public License
%along with this program; if not, write to the Free Software
%Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
%02111-1307, USA.
% ver 1.2 johan 100105
if nargin<1|isempty(X),
X=[];
else
X=remmean(X);
end
sR.mode=[];
sR.signal=X;
sR.index=[];
sR.fasticaoptions=[];
sR.A=[];
sR.W=[];
sR.whiteningMatrix=[];
sR.dewhiteningMatrix=[];
sR.cluster=initClusterStruct;
sR.projection=initProjectionStruct;
function cluster=initClusterStruct
cluster.simfcn=[];
cluster.similarity=[];
cluster.s2d=[];
cluster.strategy=[];
cluster.partition=[];
cluster.dendrogram.Z=[];
cluster.dendrogram.order=[];
cluster.index.R=[];
function projection=initProjectionStruct
projection.method=[];
projection.parameters=[];
projection.coordinates=[];