Daniel@0: function demnlab(action); Daniel@0: %DEMNLAB A front-end Graphical User Interface to the demos Daniel@0: % Daniel@0: % Description Daniel@0: % This function will start a user interface allowing the user to select Daniel@0: % different demonstration functions to view. The demos are divided into Daniel@0: % 4 groups, with the demo being executed by selecting the desired Daniel@0: % option from a pop-up menu. Daniel@0: % Daniel@0: % See also Daniel@0: % Daniel@0: Daniel@0: % Copyright (c) Ian T Nabney (1996-2001) Daniel@0: Daniel@0: % If run without parameters, initialise gui. Daniel@0: if nargin<1, Daniel@0: action='initialise'; Daniel@0: end; Daniel@0: Daniel@0: if strcmp(action,'initialise'), Daniel@0: Daniel@0: % Create figure Daniel@0: fig = figure( ... Daniel@0: 'Name', 'Netlab Demos', ... Daniel@0: 'NumberTitle', 'off', ... Daniel@0: 'Color', [0.7529 0.7529 0.7529], ... Daniel@0: 'Visible', 'on'); Daniel@0: Daniel@0: % Create GROUPS Daniel@0: % Bottom of demo buttons Daniel@0: group1_bot = 0.20; Daniel@0: group1_top = 0.75; Daniel@0: uicontrol(fig, ... Daniel@0: 'Style', 'frame', ... Daniel@0: 'Units', 'normalized', ... Daniel@0: 'Position', [0.03 group1_bot 0.94 group1_top - group1_bot], ... Daniel@0: 'BackgroundColor', [0.5 0.5 0.5]); Daniel@0: Daniel@0: % Bottom of help and close buttons Daniel@0: group2_bot = 0.04; Daniel@0: uicontrol(fig, ... Daniel@0: 'Style', 'frame', ... Daniel@0: 'Units', 'normalized', ... Daniel@0: 'Position', [0.03 group2_bot 0.94 0.12], ... Daniel@0: 'BackgroundColor', [0.5 0.5 0.5]); Daniel@0: Daniel@0: % Draw title Daniel@0: hLogoAxis = axes( ... Daniel@0: 'Units', 'normalized', ... Daniel@0: 'Position', [0.05 0.82 0.90 0.14], ... Daniel@0: 'Box', 'off', ... Daniel@0: 'XColor', [0 0 0], ... Daniel@0: 'YColor', [0 0 0], ... Daniel@0: 'Visible', 'on'); Daniel@0: Daniel@0: load netlogo; % load image and colour map Daniel@0: colormap(netcmap(1:3,:)); % change colour map: don't need many entries Daniel@0: image(nlogo); % draw logo Daniel@0: axis('image'); % ensures pixels on axis are square Daniel@0: axis off; % turn axes off Daniel@0: Daniel@0: % Create static text Daniel@0: uicontrol(fig, ... Daniel@0: 'Style', 'text', ... Daniel@0: 'Units', 'normalized', ... Daniel@0: 'BackgroundColor', [0.5 0.5 0.5], ... Daniel@0: 'Position', [0.05 group1_top-0.1 0.90 0.08], ... Daniel@0: 'String', 'Select demo to run:'); Daniel@0: Daniel@0: % First row text offset Daniel@0: tRow1Offset = 0.14; Daniel@0: % Offset between text and button Daniel@0: TBoffset = 0.07; Daniel@0: % First row button offset Daniel@0: bRow1Offset = tRow1Offset+TBoffset; Daniel@0: % ONE text Daniel@0: uicontrol(fig, ... Daniel@0: 'Style', 'text', ... Daniel@0: 'Units', 'normalized', ... Daniel@0: 'BackgroundColor', [0.5 0.5 0.5], ... Daniel@0: 'Position', [0.08 group1_top-tRow1Offset 0.36 0.05], ... Daniel@0: 'String', 'Regression'); Daniel@0: Daniel@0: popup1str(1) = {'Select Option'}; Daniel@0: popup1str(2) = {'Multi-Layer Perceptron'}; Daniel@0: popup1str(3) = {'Radial Basis Function'}; Daniel@0: popup1str(4) = {'Mixture Density Network'}; Daniel@0: % ONE popup Daniel@0: hPop1 = uicontrol(fig, ... Daniel@0: 'Style','popup', ... Daniel@0: 'Units','normalized', ... Daniel@0: 'String', popup1str, ... Daniel@0: 'Position', [0.08 group1_top-bRow1Offset 0.36 0.08], ... Daniel@0: 'BackgroundColor', [0.7 0.7 0.7], ... Daniel@0: 'Callback', 'demnlab popup1'); Daniel@0: Daniel@0: % TWO text Daniel@0: uicontrol(fig, ... Daniel@0: 'Style', 'text', ... Daniel@0: 'Units', 'normalized', ... Daniel@0: 'BackgroundColor', [0.5 0.5 0.5], ... Daniel@0: 'Position', [0.56 group1_top-tRow1Offset 0.36 0.05], ... Daniel@0: 'String', 'Classification'); Daniel@0: Daniel@0: popup2str(1) = popup1str(1); Daniel@0: popup2str(2) = {'Generalised Linear Model (2 class)'}; Daniel@0: popup2str(3) = {'Generalised Linear Model (3 class)'}; Daniel@0: popup2str(4) = {'Multi-Layer Perceptron'}; Daniel@0: popup2str(5) = {'K nearest neighbour'}; Daniel@0: % TWO popup Daniel@0: hPop2 = uicontrol(fig, ... Daniel@0: 'Style','popup', ... Daniel@0: 'Units','normalized', ... Daniel@0: 'String', popup2str, ... Daniel@0: 'Position', [0.56 group1_top-bRow1Offset 0.36 0.08], ... Daniel@0: 'BackgroundColor', [0.7 0.7 0.7], ... Daniel@0: 'Callback', 'demnlab popup2'); Daniel@0: Daniel@0: tRow2Offset = 0.30; Daniel@0: bRow2Offset = tRow2Offset+TBoffset; Daniel@0: % THREE text Daniel@0: uicontrol(fig, ... Daniel@0: 'Style', 'text', ... Daniel@0: 'Units', 'normalized', ... Daniel@0: 'BackgroundColor', [0.5 0.5 0.5], ... Daniel@0: 'Position', [0.08 group1_top - tRow2Offset 0.36 0.05], ... Daniel@0: 'String', 'Density Modelling and Clustering'); Daniel@0: Daniel@0: popup3str(1) = popup1str(1); Daniel@0: popup3str(2) = {'Gaussian Mixture (EM training)'}; Daniel@0: popup3str(3) = {'Gaussian Mixture (spherical)'}; Daniel@0: popup3str(4) = {'Gaussian Mixture (diagonal)'}; Daniel@0: popup3str(5) = {'Gaussian Mixture (full)'}; Daniel@0: popup3str(6) = {'Neuroscale'}; Daniel@0: popup3str(7) = {'GTM (EM training)'}; Daniel@0: popup3str(8) = {'GTM (visualisation)'}; Daniel@0: popup3str(9) = {'K-means clustering'}; Daniel@0: popup3str(10) = {'Self-Organising Map'}; Daniel@0: % TWO popup Daniel@0: % THREE popup Daniel@0: hPop3 = uicontrol(fig, ... Daniel@0: 'Style','popup', ... Daniel@0: 'Units','normalized', ... Daniel@0: 'String', popup3str, ... Daniel@0: 'Position', [0.08 group1_top - bRow2Offset 0.36 0.08], ... Daniel@0: 'BackgroundColor', [0.7 0.7 0.7], ... Daniel@0: 'Callback', 'demnlab popup3'); Daniel@0: Daniel@0: % FOUR text Daniel@0: uicontrol(fig, ... Daniel@0: 'Style', 'text', ... Daniel@0: 'Units', 'normalized', ... Daniel@0: 'BackgroundColor', [0.5 0.5 0.5], ... Daniel@0: 'Position', [0.56 group1_top - tRow2Offset 0.36 0.05], ... Daniel@0: 'String', 'Bayesian Methods'); Daniel@0: Daniel@0: popup4str(1) = popup1str(1); Daniel@0: popup4str(2) = {'Sampling the MLP Prior'}; Daniel@0: popup4str(3) = {'Evidence Approximation for MLP'}; Daniel@0: popup4str(4) = {'Evidence Approximation for RBF'}; Daniel@0: popup4str(5) = {'Evidence Approximation in Classification'}; Daniel@0: popup4str(6) = {'ARD for MLP'}; Daniel@0: popup4str(7) = {'Sampling the GP Prior'}; Daniel@0: popup4str(8) = {'GPs for Regression'}; Daniel@0: popup4str(9) = {'ARD for GP'}; Daniel@0: % FOUR popup Daniel@0: hPop4 = uicontrol(fig, ... Daniel@0: 'Style','popup', ... Daniel@0: 'Units','normalized', ... Daniel@0: 'String', popup4str, ... Daniel@0: 'Position', [0.56 group1_top - bRow2Offset 0.36 0.08], ... Daniel@0: 'BackgroundColor', [0.7 0.7 0.7], ... Daniel@0: 'Callback', 'demnlab popup4'); Daniel@0: Daniel@0: Daniel@0: tRow3Offset = 0.45; Daniel@0: bRow3Offset = tRow3Offset+TBoffset; Daniel@0: % FIVE text Daniel@0: uicontrol(fig, ... Daniel@0: 'Style', 'text', ... Daniel@0: 'Units', 'normalized', ... Daniel@0: 'BackgroundColor', [0.5 0.5 0.5], ... Daniel@0: 'Position', [0.08 group1_top - tRow3Offset 0.36 0.05], ... Daniel@0: 'String', 'Optimisation and Visualisation'); Daniel@0: Daniel@0: popup5str(1) = popup1str(1); Daniel@0: popup5str(2) = {'Algorithm Comparison'}; Daniel@0: popup5str(3) = {'On-line Gradient Descent'}; Daniel@0: popup5str(4) = {'Hinton Diagrams'}; Daniel@0: % FIVE popup Daniel@0: hPop5 = uicontrol(fig, ... Daniel@0: 'Style','popup', ... Daniel@0: 'Units','normalized', ... Daniel@0: 'String',popup5str, ... Daniel@0: 'Position', [0.08 group1_top - bRow3Offset 0.36 0.08], ... Daniel@0: 'BackgroundColor', [0.7 0.7 0.7], ... Daniel@0: 'Callback', 'demnlab popup5'); Daniel@0: Daniel@0: % SIX text Daniel@0: uicontrol(fig, ... Daniel@0: 'Style', 'text', ... Daniel@0: 'Units', 'normalized', ... Daniel@0: 'BackgroundColor', [0.5 0.5 0.5], ... Daniel@0: 'Position', [0.56 group1_top - tRow3Offset 0.36 0.05], ... Daniel@0: 'String', 'Sampling'); Daniel@0: Daniel@0: popup6str(1) = popup1str(1); Daniel@0: popup6str(2) = {'Sampling a Gaussian'}; Daniel@0: popup6str(3) = {'MCMC sampling (Metropolis)'}; Daniel@0: popup6str(4) = {'Hybrid MC (Gaussian mixture)'}; Daniel@0: popup6str(5) = {'Hybrid MC for MLP I'}; Daniel@0: popup6str(6) = {'Hybrid MC for MLP II'}; Daniel@0: % SIX popup Daniel@0: hPop6 = uicontrol(fig, ... Daniel@0: 'Style','popup', ... Daniel@0: 'Units','normalized', ... Daniel@0: 'String', popup6str, ... Daniel@0: 'Position', [0.56 group1_top - bRow3Offset 0.36 0.08], ... Daniel@0: 'BackgroundColor', [0.7 0.7 0.7], ... Daniel@0: 'Callback', 'demnlab popup6'); Daniel@0: Daniel@0: Daniel@0: % Create HELP button Daniel@0: uicontrol(fig, ... Daniel@0: 'Units', 'normalized', ... Daniel@0: 'Position' , [0.05 group2_bot+0.02 0.40 0.08], ... Daniel@0: 'String', 'Help', ... Daniel@0: 'Callback', 'demnlab help'); Daniel@0: Daniel@0: % Create CLOSE button Daniel@0: uicontrol(fig, ... Daniel@0: 'Units', 'normalized', ... Daniel@0: 'Position' , [0.55 group2_bot+0.02 0.40 0.08], ... Daniel@0: 'String', 'Close', ... Daniel@0: 'Callback', 'close(gcf)'); Daniel@0: Daniel@0: hndlList=[fig hPop1 hPop2 hPop3 hPop4 hPop5 hPop6]; Daniel@0: set(fig, 'UserData', hndlList); Daniel@0: set(fig, 'HandleVisibility', 'callback'); Daniel@0: Daniel@0: elseif strcmp(action, 'popup1'), Daniel@0: Daniel@0: hndlList=get(gcf,'UserData'); Daniel@0: hPop = hndlList(2); Daniel@0: Daniel@0: selected = get(hPop, 'Val'); Daniel@0: set(hPop, 'Val', [1]); Daniel@0: Daniel@0: switch selected Daniel@0: case 2 Daniel@0: demmlp1; Daniel@0: case 3 Daniel@0: demrbf1; Daniel@0: case 4 Daniel@0: demmdn1; Daniel@0: end; Daniel@0: Daniel@0: elseif strcmp(action,'popup2'), Daniel@0: Daniel@0: hndlList=get(gcf,'UserData'); Daniel@0: hPop = hndlList(3); Daniel@0: Daniel@0: selected = get(hPop, 'Val'); Daniel@0: set(hPop, 'Val', [1]); Daniel@0: Daniel@0: switch selected Daniel@0: case 2 Daniel@0: demglm1; Daniel@0: case 3 Daniel@0: demglm2; Daniel@0: case 4 Daniel@0: demmlp2; Daniel@0: case 5 Daniel@0: demknn1; Daniel@0: end Daniel@0: Daniel@0: elseif strcmp(action,'popup3'), Daniel@0: Daniel@0: hndlList=get(gcf,'UserData'); Daniel@0: hPop = hndlList(4); Daniel@0: Daniel@0: selected = get(hPop, 'Val'); Daniel@0: set(hPop, 'Val', [1]); Daniel@0: Daniel@0: switch selected Daniel@0: case 2 Daniel@0: demgmm1; Daniel@0: case 3 Daniel@0: demgmm2; Daniel@0: case 4 Daniel@0: demgmm3; Daniel@0: case 5 Daniel@0: demgmm4; Daniel@0: case 6 Daniel@0: demns1; Daniel@0: case 7 Daniel@0: demgtm1; Daniel@0: case 8 Daniel@0: demgtm2; Daniel@0: case 9 Daniel@0: demkmn1; Daniel@0: case 10 Daniel@0: demsom1; Daniel@0: end Daniel@0: Daniel@0: elseif strcmp(action,'popup4'), Daniel@0: Daniel@0: hndlList=get(gcf,'UserData'); Daniel@0: hPop = hndlList(5); Daniel@0: Daniel@0: selected = get(hPop, 'Val'); Daniel@0: set(hPop, 'Val', [1]); Daniel@0: Daniel@0: switch selected Daniel@0: case 2 Daniel@0: demprior; Daniel@0: case 3 Daniel@0: demev1; Daniel@0: case 4 Daniel@0: demev3; Daniel@0: case 5 Daniel@0: demev2; Daniel@0: case 6 Daniel@0: demard; Daniel@0: case 7 Daniel@0: demprgp; Daniel@0: case 8 Daniel@0: demgp; Daniel@0: case 9 Daniel@0: demgpard; Daniel@0: end Daniel@0: Daniel@0: elseif strcmp(action,'popup5'), Daniel@0: Daniel@0: hndlList=get(gcf,'UserData'); Daniel@0: hPop = hndlList(6); Daniel@0: Daniel@0: selected = get(hPop, 'Val'); Daniel@0: set(hPop, 'Val', [1]); Daniel@0: Daniel@0: switch selected Daniel@0: case 2 Daniel@0: demopt1; Daniel@0: case 3 Daniel@0: demolgd1; Daniel@0: case 4 Daniel@0: demhint; Daniel@0: end Daniel@0: Daniel@0: Daniel@0: elseif strcmp(action,'popup6'), Daniel@0: Daniel@0: hndlList=get(gcf,'UserData'); Daniel@0: hPop = hndlList(7); Daniel@0: Daniel@0: selected = get(hPop, 'Val'); Daniel@0: set(hPop, 'Val', [1]); Daniel@0: Daniel@0: switch selected Daniel@0: case 2 Daniel@0: demgauss; Daniel@0: case 3 Daniel@0: demmet1; Daniel@0: case 4 Daniel@0: demhmc1; Daniel@0: case 5 Daniel@0: demhmc2; Daniel@0: case 6 Daniel@0: demhmc3; Daniel@0: end Daniel@0: Daniel@0: elseif strcmp(action, 'help'), Daniel@0: Daniel@0: helpStr = {'To run a demo, press the appropriate button.'; ... Daniel@0: 'Instructions and information will appear in the Matlab';... Daniel@0: 'command window.'}; Daniel@0: Daniel@0: hHelpDlg = helpdlg(helpStr, 'Netlab Demo Help'); Daniel@0: Daniel@0: end;