annotate toolboxes/FullBNT-1.0.7/netlab3.3/demnlab.m @ 0:e9a9cd732c1e tip

first hg version after svn
author wolffd
date Tue, 10 Feb 2015 15:05:51 +0000
parents
children
rev   line source
wolffd@0 1 function demnlab(action);
wolffd@0 2 %DEMNLAB A front-end Graphical User Interface to the demos
wolffd@0 3 %
wolffd@0 4 % Description
wolffd@0 5 % This function will start a user interface allowing the user to select
wolffd@0 6 % different demonstration functions to view. The demos are divided into
wolffd@0 7 % 4 groups, with the demo being executed by selecting the desired
wolffd@0 8 % option from a pop-up menu.
wolffd@0 9 %
wolffd@0 10 % See also
wolffd@0 11 %
wolffd@0 12
wolffd@0 13 % Copyright (c) Ian T Nabney (1996-2001)
wolffd@0 14
wolffd@0 15 % If run without parameters, initialise gui.
wolffd@0 16 if nargin<1,
wolffd@0 17 action='initialise';
wolffd@0 18 end;
wolffd@0 19
wolffd@0 20 if strcmp(action,'initialise'),
wolffd@0 21
wolffd@0 22 % Create figure
wolffd@0 23 fig = figure( ...
wolffd@0 24 'Name', 'Netlab Demos', ...
wolffd@0 25 'NumberTitle', 'off', ...
wolffd@0 26 'Color', [0.7529 0.7529 0.7529], ...
wolffd@0 27 'Visible', 'on');
wolffd@0 28
wolffd@0 29 % Create GROUPS
wolffd@0 30 % Bottom of demo buttons
wolffd@0 31 group1_bot = 0.20;
wolffd@0 32 group1_top = 0.75;
wolffd@0 33 uicontrol(fig, ...
wolffd@0 34 'Style', 'frame', ...
wolffd@0 35 'Units', 'normalized', ...
wolffd@0 36 'Position', [0.03 group1_bot 0.94 group1_top - group1_bot], ...
wolffd@0 37 'BackgroundColor', [0.5 0.5 0.5]);
wolffd@0 38
wolffd@0 39 % Bottom of help and close buttons
wolffd@0 40 group2_bot = 0.04;
wolffd@0 41 uicontrol(fig, ...
wolffd@0 42 'Style', 'frame', ...
wolffd@0 43 'Units', 'normalized', ...
wolffd@0 44 'Position', [0.03 group2_bot 0.94 0.12], ...
wolffd@0 45 'BackgroundColor', [0.5 0.5 0.5]);
wolffd@0 46
wolffd@0 47 % Draw title
wolffd@0 48 hLogoAxis = axes( ...
wolffd@0 49 'Units', 'normalized', ...
wolffd@0 50 'Position', [0.05 0.82 0.90 0.14], ...
wolffd@0 51 'Box', 'off', ...
wolffd@0 52 'XColor', [0 0 0], ...
wolffd@0 53 'YColor', [0 0 0], ...
wolffd@0 54 'Visible', 'on');
wolffd@0 55
wolffd@0 56 load netlogo; % load image and colour map
wolffd@0 57 colormap(netcmap(1:3,:)); % change colour map: don't need many entries
wolffd@0 58 image(nlogo); % draw logo
wolffd@0 59 axis('image'); % ensures pixels on axis are square
wolffd@0 60 axis off; % turn axes off
wolffd@0 61
wolffd@0 62 % Create static text
wolffd@0 63 uicontrol(fig, ...
wolffd@0 64 'Style', 'text', ...
wolffd@0 65 'Units', 'normalized', ...
wolffd@0 66 'BackgroundColor', [0.5 0.5 0.5], ...
wolffd@0 67 'Position', [0.05 group1_top-0.1 0.90 0.08], ...
wolffd@0 68 'String', 'Select demo to run:');
wolffd@0 69
wolffd@0 70 % First row text offset
wolffd@0 71 tRow1Offset = 0.14;
wolffd@0 72 % Offset between text and button
wolffd@0 73 TBoffset = 0.07;
wolffd@0 74 % First row button offset
wolffd@0 75 bRow1Offset = tRow1Offset+TBoffset;
wolffd@0 76 % ONE text
wolffd@0 77 uicontrol(fig, ...
wolffd@0 78 'Style', 'text', ...
wolffd@0 79 'Units', 'normalized', ...
wolffd@0 80 'BackgroundColor', [0.5 0.5 0.5], ...
wolffd@0 81 'Position', [0.08 group1_top-tRow1Offset 0.36 0.05], ...
wolffd@0 82 'String', 'Regression');
wolffd@0 83
wolffd@0 84 popup1str(1) = {'Select Option'};
wolffd@0 85 popup1str(2) = {'Multi-Layer Perceptron'};
wolffd@0 86 popup1str(3) = {'Radial Basis Function'};
wolffd@0 87 popup1str(4) = {'Mixture Density Network'};
wolffd@0 88 % ONE popup
wolffd@0 89 hPop1 = uicontrol(fig, ...
wolffd@0 90 'Style','popup', ...
wolffd@0 91 'Units','normalized', ...
wolffd@0 92 'String', popup1str, ...
wolffd@0 93 'Position', [0.08 group1_top-bRow1Offset 0.36 0.08], ...
wolffd@0 94 'BackgroundColor', [0.7 0.7 0.7], ...
wolffd@0 95 'Callback', 'demnlab popup1');
wolffd@0 96
wolffd@0 97 % TWO text
wolffd@0 98 uicontrol(fig, ...
wolffd@0 99 'Style', 'text', ...
wolffd@0 100 'Units', 'normalized', ...
wolffd@0 101 'BackgroundColor', [0.5 0.5 0.5], ...
wolffd@0 102 'Position', [0.56 group1_top-tRow1Offset 0.36 0.05], ...
wolffd@0 103 'String', 'Classification');
wolffd@0 104
wolffd@0 105 popup2str(1) = popup1str(1);
wolffd@0 106 popup2str(2) = {'Generalised Linear Model (2 class)'};
wolffd@0 107 popup2str(3) = {'Generalised Linear Model (3 class)'};
wolffd@0 108 popup2str(4) = {'Multi-Layer Perceptron'};
wolffd@0 109 popup2str(5) = {'K nearest neighbour'};
wolffd@0 110 % TWO popup
wolffd@0 111 hPop2 = uicontrol(fig, ...
wolffd@0 112 'Style','popup', ...
wolffd@0 113 'Units','normalized', ...
wolffd@0 114 'String', popup2str, ...
wolffd@0 115 'Position', [0.56 group1_top-bRow1Offset 0.36 0.08], ...
wolffd@0 116 'BackgroundColor', [0.7 0.7 0.7], ...
wolffd@0 117 'Callback', 'demnlab popup2');
wolffd@0 118
wolffd@0 119 tRow2Offset = 0.30;
wolffd@0 120 bRow2Offset = tRow2Offset+TBoffset;
wolffd@0 121 % THREE text
wolffd@0 122 uicontrol(fig, ...
wolffd@0 123 'Style', 'text', ...
wolffd@0 124 'Units', 'normalized', ...
wolffd@0 125 'BackgroundColor', [0.5 0.5 0.5], ...
wolffd@0 126 'Position', [0.08 group1_top - tRow2Offset 0.36 0.05], ...
wolffd@0 127 'String', 'Density Modelling and Clustering');
wolffd@0 128
wolffd@0 129 popup3str(1) = popup1str(1);
wolffd@0 130 popup3str(2) = {'Gaussian Mixture (EM training)'};
wolffd@0 131 popup3str(3) = {'Gaussian Mixture (spherical)'};
wolffd@0 132 popup3str(4) = {'Gaussian Mixture (diagonal)'};
wolffd@0 133 popup3str(5) = {'Gaussian Mixture (full)'};
wolffd@0 134 popup3str(6) = {'Neuroscale'};
wolffd@0 135 popup3str(7) = {'GTM (EM training)'};
wolffd@0 136 popup3str(8) = {'GTM (visualisation)'};
wolffd@0 137 popup3str(9) = {'K-means clustering'};
wolffd@0 138 popup3str(10) = {'Self-Organising Map'};
wolffd@0 139 % TWO popup
wolffd@0 140 % THREE popup
wolffd@0 141 hPop3 = uicontrol(fig, ...
wolffd@0 142 'Style','popup', ...
wolffd@0 143 'Units','normalized', ...
wolffd@0 144 'String', popup3str, ...
wolffd@0 145 'Position', [0.08 group1_top - bRow2Offset 0.36 0.08], ...
wolffd@0 146 'BackgroundColor', [0.7 0.7 0.7], ...
wolffd@0 147 'Callback', 'demnlab popup3');
wolffd@0 148
wolffd@0 149 % FOUR text
wolffd@0 150 uicontrol(fig, ...
wolffd@0 151 'Style', 'text', ...
wolffd@0 152 'Units', 'normalized', ...
wolffd@0 153 'BackgroundColor', [0.5 0.5 0.5], ...
wolffd@0 154 'Position', [0.56 group1_top - tRow2Offset 0.36 0.05], ...
wolffd@0 155 'String', 'Bayesian Methods');
wolffd@0 156
wolffd@0 157 popup4str(1) = popup1str(1);
wolffd@0 158 popup4str(2) = {'Sampling the MLP Prior'};
wolffd@0 159 popup4str(3) = {'Evidence Approximation for MLP'};
wolffd@0 160 popup4str(4) = {'Evidence Approximation for RBF'};
wolffd@0 161 popup4str(5) = {'Evidence Approximation in Classification'};
wolffd@0 162 popup4str(6) = {'ARD for MLP'};
wolffd@0 163 popup4str(7) = {'Sampling the GP Prior'};
wolffd@0 164 popup4str(8) = {'GPs for Regression'};
wolffd@0 165 popup4str(9) = {'ARD for GP'};
wolffd@0 166 % FOUR popup
wolffd@0 167 hPop4 = uicontrol(fig, ...
wolffd@0 168 'Style','popup', ...
wolffd@0 169 'Units','normalized', ...
wolffd@0 170 'String', popup4str, ...
wolffd@0 171 'Position', [0.56 group1_top - bRow2Offset 0.36 0.08], ...
wolffd@0 172 'BackgroundColor', [0.7 0.7 0.7], ...
wolffd@0 173 'Callback', 'demnlab popup4');
wolffd@0 174
wolffd@0 175
wolffd@0 176 tRow3Offset = 0.45;
wolffd@0 177 bRow3Offset = tRow3Offset+TBoffset;
wolffd@0 178 % FIVE text
wolffd@0 179 uicontrol(fig, ...
wolffd@0 180 'Style', 'text', ...
wolffd@0 181 'Units', 'normalized', ...
wolffd@0 182 'BackgroundColor', [0.5 0.5 0.5], ...
wolffd@0 183 'Position', [0.08 group1_top - tRow3Offset 0.36 0.05], ...
wolffd@0 184 'String', 'Optimisation and Visualisation');
wolffd@0 185
wolffd@0 186 popup5str(1) = popup1str(1);
wolffd@0 187 popup5str(2) = {'Algorithm Comparison'};
wolffd@0 188 popup5str(3) = {'On-line Gradient Descent'};
wolffd@0 189 popup5str(4) = {'Hinton Diagrams'};
wolffd@0 190 % FIVE popup
wolffd@0 191 hPop5 = uicontrol(fig, ...
wolffd@0 192 'Style','popup', ...
wolffd@0 193 'Units','normalized', ...
wolffd@0 194 'String',popup5str, ...
wolffd@0 195 'Position', [0.08 group1_top - bRow3Offset 0.36 0.08], ...
wolffd@0 196 'BackgroundColor', [0.7 0.7 0.7], ...
wolffd@0 197 'Callback', 'demnlab popup5');
wolffd@0 198
wolffd@0 199 % SIX text
wolffd@0 200 uicontrol(fig, ...
wolffd@0 201 'Style', 'text', ...
wolffd@0 202 'Units', 'normalized', ...
wolffd@0 203 'BackgroundColor', [0.5 0.5 0.5], ...
wolffd@0 204 'Position', [0.56 group1_top - tRow3Offset 0.36 0.05], ...
wolffd@0 205 'String', 'Sampling');
wolffd@0 206
wolffd@0 207 popup6str(1) = popup1str(1);
wolffd@0 208 popup6str(2) = {'Sampling a Gaussian'};
wolffd@0 209 popup6str(3) = {'MCMC sampling (Metropolis)'};
wolffd@0 210 popup6str(4) = {'Hybrid MC (Gaussian mixture)'};
wolffd@0 211 popup6str(5) = {'Hybrid MC for MLP I'};
wolffd@0 212 popup6str(6) = {'Hybrid MC for MLP II'};
wolffd@0 213 % SIX popup
wolffd@0 214 hPop6 = uicontrol(fig, ...
wolffd@0 215 'Style','popup', ...
wolffd@0 216 'Units','normalized', ...
wolffd@0 217 'String', popup6str, ...
wolffd@0 218 'Position', [0.56 group1_top - bRow3Offset 0.36 0.08], ...
wolffd@0 219 'BackgroundColor', [0.7 0.7 0.7], ...
wolffd@0 220 'Callback', 'demnlab popup6');
wolffd@0 221
wolffd@0 222
wolffd@0 223 % Create HELP button
wolffd@0 224 uicontrol(fig, ...
wolffd@0 225 'Units', 'normalized', ...
wolffd@0 226 'Position' , [0.05 group2_bot+0.02 0.40 0.08], ...
wolffd@0 227 'String', 'Help', ...
wolffd@0 228 'Callback', 'demnlab help');
wolffd@0 229
wolffd@0 230 % Create CLOSE button
wolffd@0 231 uicontrol(fig, ...
wolffd@0 232 'Units', 'normalized', ...
wolffd@0 233 'Position' , [0.55 group2_bot+0.02 0.40 0.08], ...
wolffd@0 234 'String', 'Close', ...
wolffd@0 235 'Callback', 'close(gcf)');
wolffd@0 236
wolffd@0 237 hndlList=[fig hPop1 hPop2 hPop3 hPop4 hPop5 hPop6];
wolffd@0 238 set(fig, 'UserData', hndlList);
wolffd@0 239 set(fig, 'HandleVisibility', 'callback');
wolffd@0 240
wolffd@0 241 elseif strcmp(action, 'popup1'),
wolffd@0 242
wolffd@0 243 hndlList=get(gcf,'UserData');
wolffd@0 244 hPop = hndlList(2);
wolffd@0 245
wolffd@0 246 selected = get(hPop, 'Val');
wolffd@0 247 set(hPop, 'Val', [1]);
wolffd@0 248
wolffd@0 249 switch selected
wolffd@0 250 case 2
wolffd@0 251 demmlp1;
wolffd@0 252 case 3
wolffd@0 253 demrbf1;
wolffd@0 254 case 4
wolffd@0 255 demmdn1;
wolffd@0 256 end;
wolffd@0 257
wolffd@0 258 elseif strcmp(action,'popup2'),
wolffd@0 259
wolffd@0 260 hndlList=get(gcf,'UserData');
wolffd@0 261 hPop = hndlList(3);
wolffd@0 262
wolffd@0 263 selected = get(hPop, 'Val');
wolffd@0 264 set(hPop, 'Val', [1]);
wolffd@0 265
wolffd@0 266 switch selected
wolffd@0 267 case 2
wolffd@0 268 demglm1;
wolffd@0 269 case 3
wolffd@0 270 demglm2;
wolffd@0 271 case 4
wolffd@0 272 demmlp2;
wolffd@0 273 case 5
wolffd@0 274 demknn1;
wolffd@0 275 end
wolffd@0 276
wolffd@0 277 elseif strcmp(action,'popup3'),
wolffd@0 278
wolffd@0 279 hndlList=get(gcf,'UserData');
wolffd@0 280 hPop = hndlList(4);
wolffd@0 281
wolffd@0 282 selected = get(hPop, 'Val');
wolffd@0 283 set(hPop, 'Val', [1]);
wolffd@0 284
wolffd@0 285 switch selected
wolffd@0 286 case 2
wolffd@0 287 demgmm1;
wolffd@0 288 case 3
wolffd@0 289 demgmm2;
wolffd@0 290 case 4
wolffd@0 291 demgmm3;
wolffd@0 292 case 5
wolffd@0 293 demgmm4;
wolffd@0 294 case 6
wolffd@0 295 demns1;
wolffd@0 296 case 7
wolffd@0 297 demgtm1;
wolffd@0 298 case 8
wolffd@0 299 demgtm2;
wolffd@0 300 case 9
wolffd@0 301 demkmn1;
wolffd@0 302 case 10
wolffd@0 303 demsom1;
wolffd@0 304 end
wolffd@0 305
wolffd@0 306 elseif strcmp(action,'popup4'),
wolffd@0 307
wolffd@0 308 hndlList=get(gcf,'UserData');
wolffd@0 309 hPop = hndlList(5);
wolffd@0 310
wolffd@0 311 selected = get(hPop, 'Val');
wolffd@0 312 set(hPop, 'Val', [1]);
wolffd@0 313
wolffd@0 314 switch selected
wolffd@0 315 case 2
wolffd@0 316 demprior;
wolffd@0 317 case 3
wolffd@0 318 demev1;
wolffd@0 319 case 4
wolffd@0 320 demev3;
wolffd@0 321 case 5
wolffd@0 322 demev2;
wolffd@0 323 case 6
wolffd@0 324 demard;
wolffd@0 325 case 7
wolffd@0 326 demprgp;
wolffd@0 327 case 8
wolffd@0 328 demgp;
wolffd@0 329 case 9
wolffd@0 330 demgpard;
wolffd@0 331 end
wolffd@0 332
wolffd@0 333 elseif strcmp(action,'popup5'),
wolffd@0 334
wolffd@0 335 hndlList=get(gcf,'UserData');
wolffd@0 336 hPop = hndlList(6);
wolffd@0 337
wolffd@0 338 selected = get(hPop, 'Val');
wolffd@0 339 set(hPop, 'Val', [1]);
wolffd@0 340
wolffd@0 341 switch selected
wolffd@0 342 case 2
wolffd@0 343 demopt1;
wolffd@0 344 case 3
wolffd@0 345 demolgd1;
wolffd@0 346 case 4
wolffd@0 347 demhint;
wolffd@0 348 end
wolffd@0 349
wolffd@0 350
wolffd@0 351 elseif strcmp(action,'popup6'),
wolffd@0 352
wolffd@0 353 hndlList=get(gcf,'UserData');
wolffd@0 354 hPop = hndlList(7);
wolffd@0 355
wolffd@0 356 selected = get(hPop, 'Val');
wolffd@0 357 set(hPop, 'Val', [1]);
wolffd@0 358
wolffd@0 359 switch selected
wolffd@0 360 case 2
wolffd@0 361 demgauss;
wolffd@0 362 case 3
wolffd@0 363 demmet1;
wolffd@0 364 case 4
wolffd@0 365 demhmc1;
wolffd@0 366 case 5
wolffd@0 367 demhmc2;
wolffd@0 368 case 6
wolffd@0 369 demhmc3;
wolffd@0 370 end
wolffd@0 371
wolffd@0 372 elseif strcmp(action, 'help'),
wolffd@0 373
wolffd@0 374 helpStr = {'To run a demo, press the appropriate button.'; ...
wolffd@0 375 'Instructions and information will appear in the Matlab';...
wolffd@0 376 'command window.'};
wolffd@0 377
wolffd@0 378 hHelpDlg = helpdlg(helpStr, 'Netlab Demo Help');
wolffd@0 379
wolffd@0 380 end;