Mercurial > hg > camir-aes2014
comparison toolboxes/MIRtoolbox1.3.2/somtoolbox/sompak_rb_control.m @ 0:e9a9cd732c1e tip
first hg version after svn
author | wolffd |
---|---|
date | Tue, 10 Feb 2015 15:05:51 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:e9a9cd732c1e |
---|---|
1 function varargout=sompak_rb_control(str) | |
2 | |
3 %SOMPAK_RB_CONTROL An auxiliary function for SOMPAK_*_GUI functions. | |
4 % | |
5 % This is an auxiliary function for SOMPAK_GUI, SOMPAK_INIT_GUI, | |
6 % SOMPAK_SAMMON_GUI and SOMPAK_TRAIN_GUI functions. It controls the | |
7 % radio buttons in the GUIs. | |
8 % | |
9 % See also SOMPAK_GUI, SOMPAK_INIT_GUI, SOMPAK_SAMMON_GUI, SOMPAK_TRAIN_GUI. | |
10 | |
11 % Contributed to SOM Toolbox vs2, February 2nd, 2000 by Juha Parhankangas | |
12 % Copyright (c) by Juha Parhankangas | |
13 % http://www.cis.hut.fi/projects/somtoolbox/ | |
14 | |
15 % Juha Parhankangas 050100 | |
16 | |
17 data=get(gcf,'UserData'); | |
18 switch str | |
19 case {'rand','linear'} | |
20 h=cat(2,findobj(get(gcf,'Children'),'Tag','RANDOM'),... | |
21 findobj(get(gcf,'Children'),'Tag','LINEAR')); | |
22 set(h,'Value',0); | |
23 set(gcbo,'Value',1); | |
24 data.inittype=str; | |
25 case {'bubble','gaussian'} | |
26 h=cat(2,findobj(get(gcf,'Children'),'Tag','BUBBLE'),... | |
27 findobj(get(gcf,'Children'),'Tag','GAUSSIAN')); | |
28 set(h,'Value',0); | |
29 set(gcbo,'Value',1); | |
30 data.neigh=str; | |
31 case {'hexa','rect'} | |
32 h=cat(2,findobj(get(gcf,'Children'),'Tag','HEXA'),... | |
33 findobj(get(gcf,'Children'),'Tag','RECT')); | |
34 set(h,'Value',0); | |
35 set(gcbo,'Value',1); | |
36 data.topol=str; | |
37 case {'out_ft'} | |
38 value=get(gcbo,'Value'); | |
39 switch value | |
40 case 1 | |
41 h=findobj(get(gcf,'Children'),'Tag','OUT_FILE'); | |
42 data.out_file_type=''; | |
43 set(h,'String',''); | |
44 case 2 | |
45 data.out_file_type='box'; | |
46 case 3 | |
47 data.out_file_type='pak'; | |
48 end | |
49 case {'input_ft'} | |
50 value=get(gcbo,'Value'); | |
51 switch value | |
52 case 1 | |
53 data.input_file_type=''; | |
54 case 2 | |
55 data.input_file_type='box'; | |
56 case 3 | |
57 data.input_file_type='pak'; | |
58 end | |
59 case {'map_ft'} | |
60 value=get(gcbo,'Value'); | |
61 switch value | |
62 case 1 | |
63 data.map_type=''; | |
64 case 2 | |
65 data.map_type='box'; | |
66 case 3 | |
67 data.map_type='pak'; | |
68 end | |
69 case {'out_file'} | |
70 if isempty(data.out_file_type) | |
71 data.out_file=''; | |
72 h=findobj(get(gcf,'Children'),'Tag','OUT_FILE'); | |
73 set(h,'String',''); | |
74 else | |
75 data.out_file=get(findobj(get(gcf,'Children'),'Tag','OUT_FILE'),'String'); | |
76 if isempty(data.out_file) | |
77 h=findobj(get(gcf,'Children'),'Tag','OUT_FILE_TYPE'); | |
78 set(h,'Value',1); | |
79 end | |
80 end | |
81 | |
82 case {'out_var'} | |
83 h=findobj(get(gcf,'Children'),'Tag','OUT_VAR'); | |
84 if ~isempty(get(h,'String')) | |
85 data.out_var=get(h,'String'); | |
86 else | |
87 data.out_var=[]; | |
88 set(h,'String','''ans'''); | |
89 end | |
90 case {'xdim'} | |
91 h=findobj(get(gcf,'Children'),'Tag','XDIM'); | |
92 data.xdim=str2num(get(h,'String')); | |
93 case {'ydim'} | |
94 h=findobj(get(gcf,'Children'),'Tag','YDIM'); | |
95 data.ydim=str2num(get(h,'String')); | |
96 case {'radius'} | |
97 h=findobj(get(gcf,'Children'),'Tag','RADIUS'); | |
98 data.radius=str2num(get(h,'String')); | |
99 case {'data'} | |
100 h=findobj(get(gcf,'Children'),'Tag','DATA'); | |
101 data.data=get(h,'String'); | |
102 case {'rlen'} | |
103 h=findobj(get(gcf,'Children'),'Tag','RLEN'); | |
104 data.rlen=str2num(get(h,'String')); | |
105 case {'alpha'} | |
106 h=findobj(get(gcf,'Children'),'Tag','ALPHA'); | |
107 data.alpha=str2num(get(h,'String')); | |
108 case {'map'} | |
109 h=findobj(get(gcf,'Children'),'Tag','MAP'); | |
110 data.map=get(h,'String'); | |
111 case 'init_ok' | |
112 if isempty(data.xdim) | ~is_positive_integer(data.xdim) | |
113 errordlg('Argument ''xdim'' must be positive integer.'); | |
114 return; | |
115 end | |
116 if isempty(data.ydim) | ~is_positive_integer(data.ydim) | |
117 errordlg('Argument ''ydim'' must be positive integer.'); | |
118 return; | |
119 end | |
120 if isempty(data.data) | |
121 errordlg('Argument ''Workspace data'' must be a string.'); | |
122 return; | |
123 end | |
124 | |
125 if isempty(data.input_file_type) | |
126 sData=evalin('base',data.data); | |
127 else | |
128 sData=data.data; | |
129 end | |
130 if isempty(data.out_file) | |
131 if ~isempty(data.out_file_type) | |
132 errordlg('Argument ''Output file'' is not defined.'); | |
133 return; | |
134 end | |
135 data.out_file=[]; | |
136 end | |
137 answer=sompak_init(sData,... | |
138 data.input_file_type,... | |
139 data.inittype,... | |
140 data.out_file,... | |
141 data.out_file_type,... | |
142 data.xdim,... | |
143 data.ydim,... | |
144 data.topol,... | |
145 data.neigh); | |
146 if any(strcmp(data.out_var,{'ans','''ans'''})) | isstr(answer) | |
147 varargout{1}=answer; | |
148 else | |
149 assignin('base',data.out_var,answer); | |
150 disp(sprintf('Map is set to workspace as ''%s''.',data.out_var)); | |
151 end | |
152 close(findobj(get(0,'Children'),'Tag','InitGUI')); | |
153 return; | |
154 case 'train_ok' | |
155 if isempty(data.rlen) | ~is_positive_integer(data.rlen) | |
156 errordlg('Argument ''Running Length'' must be positive integer.'); | |
157 return; | |
158 end | |
159 if isempty(data.alpha) | data.alpha <= 0 | |
160 errordlg('Argument ''Initial Alpha Value'' must be a positive float.'); | |
161 return; | |
162 end | |
163 if isempty(data.radius) | data.radius <= 0 | |
164 errordlg('Argument ''Neighborhood Radius'' must be a positive float.'); | |
165 return; | |
166 end | |
167 if isempty(data.data) | |
168 errordlg('Argument ''Teaching Data'' must be a string.'); | |
169 return; | |
170 end | |
171 if isempty(data.input_file_type) | |
172 sData=evalin('base',data.data); | |
173 else | |
174 sData=data.data; | |
175 end | |
176 if isempty(data.out_file); | |
177 data.outfile = []; | |
178 end | |
179 if isempty(data.map) | |
180 errordlg('Argument ''Workspace Map'' must be a string.'); | |
181 return; | |
182 end | |
183 if isempty(data.map_type) | |
184 sMap=evalin('base',data.map); | |
185 else | |
186 sMap=data.map; | |
187 end | |
188 | |
189 answer=sompak_train(sMap,... | |
190 data.map_type,... | |
191 data.out_file,... | |
192 data.out_file_type,... | |
193 data.data,... | |
194 data.input_file_type,... | |
195 data.rlen,... | |
196 data.alpha,... | |
197 data.radius); | |
198 if any(strcmp(data.out_var,{'''ans''','ans'})) | isstr(answer) | |
199 varargout{1}=answer; | |
200 else | |
201 assignin('base',data.out_var,answer); | |
202 disp(sprintf('Map is set to workspace as ''%s''.',data.out_var)); | |
203 end | |
204 close(findobj(get(0,'Children'),'Tag','TrainGUI')); | |
205 return; | |
206 case 'sammon_ok' | |
207 if isempty(data.map) | |
208 errordlg('Argument ''Workspace Map'' must be a string.'); | |
209 return; | |
210 end | |
211 if isempty(data.map_type) | |
212 sMap=evalin('base',data.map); | |
213 else | |
214 sMap=data.map; | |
215 end | |
216 if isempty(data.out_file); | |
217 data.outfile = []; | |
218 end | |
219 answer=sompak_sammon(sMap,... | |
220 data.map_type,... | |
221 data.out_file,... | |
222 data.out_file_type,... | |
223 data.rlen); | |
224 if strcmp(data.out_var,'''ans''')|strcmp(data.out_var,'ans')|isstr(answer) | |
225 varargout{1}=answer; | |
226 else | |
227 assignin('base',data.out_var,answer); | |
228 disp(sprintf('Codebook is set to workspace as ''%s''.',data.out_var)); | |
229 end | |
230 close(findobj(get(0,'Children'),'Tag','SammonGUI')); | |
231 return; | |
232 end | |
233 | |
234 set(gcf,'UserData',data); | |
235 | |
236 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
237 | |
238 function bool = is_positive_integer(x) | |
239 | |
240 bool = ~isempty(x) & isreal(x) & all(size(x) == 1) & x > 0; | |
241 if ~isempty(bool) | |
242 if bool & x~=round(x) | |
243 bool = 0; | |
244 end | |
245 else | |
246 bool = 0; | |
247 end | |
248 | |
249 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
250 | |
251 | |
252 |