-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfunc_integrated.m
206 lines (193 loc) · 6.48 KB
/
func_integrated.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
function [Duplicate,InputSz1,InputSz2,InputSz3,Init_dim,SET] = func_integrated(Parm);
% [Duplicate,InputSz1,InputSz2,InputSz3,Init_dim,SET] = func_integrated(Parm);
% Prepare data in an integrated way; i.e., by combining various methods
% e.g.
% Parm.UseIntegrate = 'yes';
% Parm.integrate = {'tsne','euclidean','tsne','hamming',...
% 'umap','assignment','blur'};
Parm.Assignment='no';
Parm.Blur='no';
Tsne = strcmpi(Parm.integrate,'tsne');
Assign = strcmpi(Parm.integrate,'assignment');
Blur = strcmpi(Parm.integrate,'blur');
Gb = strcmpi(Parm.integrate,'gabor');
MethodFile_generated = 'no';
if sum(Tsne)>0
cnt=1;
for j=1:length(Parm.integrate)
if Tsne(j)==1
if j<length(Parm.integrate)
Dist{cnt} = Parm.integrate(j+1);
cnt=cnt+1;
else
disp('Error: No distance of tsne is assigned!');
end
end
end
Parm.Method='tsne';
for j=1:length(Dist)
Parm.Dist = cell2mat(Dist{j});
[InputSz1,InputSz2,InputSz3,Init_dim,SET] = func_Prepare_Data(Parm);
if Parm.Norm==1
MethodOut=load('Out1.mat');
elseif Parm.Norm==2
MethodOut=load('Out2.mat');
end
if sum(Gb)>0
GaborOut = GaborFilter(MethodOut,20);
save('GaborOut.mat','-struct','GaborOut','-v7.3');
clear GaborOut
end
if sum(Blur)>0
BlurOut = BlurTech_for_Out(MethodOut,20);
save('BlurOut.mat','-struct','BlurOut','-v7.3');
clear BlurOut
end
if sum(Assign)>0
AssignOut = Map_Assignment(MethodOut,Parm);
save('AssignOut.mat','-struct','AssignOut','-v7.3');
clear AssignOut
end
if sum(Blur)>0 & sum(Assign)>0
AssignOut=load('AssignOut.mat');
BlurOutAssign = BlurTech_for_Out(AssignOut,20);
save('BlurOutAssign.mat','-struct','BlurOutAssign','-v7.3');
clear BlurOutAssign AssignOut
end
%merging (xp yp values will not longer be correct)
if sum(Blur)>0
BlurOut=load('BlurOut.mat');
MethodOut = merge(MethodOut,BlurOut);
clear BlurOut
unix(['rm BlurOut.mat']);
end
if sum(Assign)>0
AssignOut=load('AssignOut.mat');
MethodOut = merge(MethodOut,AssignOut);
clear AssignOut
unix(['rm AssignOut.mat']);
end
if sum(Blur)>0 & sum(Assign)>0
BlurOutAssign=load('BlurOutAssign.mat');
MethodOut = merge(MethodOut,BlurOutAssign);
clear BlurOutAssign
unix(['rm BlurOutAssign.mat']);
end
if sum(Gb)>0
GaborOut=load('GaborOut.mat');
MethodOut = merge(MethodOut,GaborOut);
clear GaborOut
unix(['rm GaborOut.mat']);
end
if j==1
save('MethodOut.mat','-struct','MethodOut','-v7.3');
MethodFile_generated = 'yes';
clear MethodOut
else
MethodOutprev = load('MethodOut.mat');
MethodOut = merge(MethodOut,MethodOutprev);
clear MethodOutprev
save('MethodOut.mat','-struct','MethodOut','-v7.3');
clear MethodOut
end
end
end
Methods={'umap','kpca','pca'};
if strcmp(Parm.TightRep.Perm,'yes')==1
Methods={'umap','kpca','pca','direct'};
end
for k=1:length(Methods)
other=strcmpi(Parm.integrate,Methods{k});
if sum(other)>0
Parm.Method=Methods{k};
[InputSz1,InputSz2,InputSz3,Init_dim,SET] = func_Prepare_Data(Parm);
if Parm.Norm==1
MethodOut=load('Out1.mat');
elseif Parm.Norm==2
MethodOut=load('Out2.mat');
end
if sum(Gb)>0
GaborOut = GaborFilter(MethodOut,20);
save('GaborOut.mat','-struct','GaborOut','-v7.3');
clear GaborOut
end
if sum(Blur)>0
BlurOut = BlurTech_for_Out(MethodOut,20);
save('BlurOut.mat','-struct','BlurOut','-v7.3');
clear BlurOut
end
if sum(Assign)>0
AssignOut = Map_Assignment(MethodOut,Parm);
save('AssignOut.mat','-struct','AssignOut','-v7.3');
clear AssignOut
end
if sum(Blur)>0 & sum(Assign)>0
AssignOut=load('AssignOut.mat');
BlurOutAssign = BlurTech_for_Out(AssignOut,20);
save('BlurOutAssign.mat','-struct','BlurOutAssign','-v7.3');
clear BlurOutAssign AssignOut
end
%merging (xp yp values will not longer be correct)
if sum(Blur)>0
BlurOut=load('BlurOut.mat');
MethodOut = merge(MethodOut,BlurOut);
clear BlurOut
unix(['rm BlurOut.mat']);
end
if sum(Assign)>0
AssignOut=load('AssignOut.mat');
MethodOut = merge(MethodOut,AssignOut);
clear AssignOut
unix(['rm AssignOut.mat']);
end
if sum(Blur)>0 & sum(Assign)>0
BlurOutAssign=load('BlurOutAssign.mat');
MethodOut = merge(MethodOut,BlurOutAssign);
clear BlurOutAssign
unix(['rm BlurOutAssign.mat']);
end
if sum(Gb)>0
GaborOut=load('GaborOut.mat');
MethodOut = merge(MethodOut,GaborOut);
clear GaborOut
unix(['rm GaborOut.mat']);
end
if strcmp(MethodFile_generated,'no')
MethodOut.Method=define_integrated_method(Parm);
save('MethodOut.mat','-struct','MethodOut','-v7.3');
clear MethodOut
MethodFile_generated='yes';
else
MethodOutprev = load('MethodOut.mat');
MethodOut = merge(MethodOut,MethodOutprev);
clear MethodOutprev
MethodOut.Method=define_integrated_method(Parm);
save('MethodOut.mat','-struct','MethodOut','-v7.3');
clear MethodOut
end
end
end
if Parm.Norm==1
unix(['mv MethodOut.mat Out1.mat']);
elseif Parm.Norm==2
unix(['mv MethodOut.mat Out2.mat']);
end
Umap=strcmpi(Parm.integrate,'umap');
Kpca=strcmpi(Parm.integrate,'kpca');
Pca=strcmpi(Parm.integrate,'pca');
if strcmp(Parm.TightRep.Perm,'yes')==1
Direct=strcmpi(Parm.integrate,'direct');
end
Duplicate = sum(Tsne)+any(Umap)+any(Kpca)+any(Pca);
if strcmp(Parm.TightRep.Perm,'yes')==1
Duplicate = sum(Tsne)+any(Umap)+any(Kpca)+any(Pca)+any(Direct);
end
Duplicate = any(Assign)*Duplicate + Duplicate;
Duplicate = any(Blur)*Duplicate + Duplicate;
if strcmp(Parm.TightRep.Perm,'yes')==0
Duplicate = Duplicate + any(Gb)*(sum(Tsne) + sum(Umap) + ...
sum(Kpca) + sum(Pca));
else
Duplicate = Duplicate + any(Gb)*(sum(Tsne) + sum(Umap) + ...
sum(Kpca) + sum(Pca) + sum(Direct));
end