Home > src > gui_main.m

gui_main

PURPOSE ^

% Visual Clustering of Parallel Coordinates

SYNOPSIS ^

function varargout = gui_main(varargin)

DESCRIPTION ^

% Visual Clustering of Parallel Coordinates
 @author Mazurek/Bartalsky
% gui_main.m parameters
 * *Description:*
 * Gui of the parallel coordinates script. The script accepts .mat files
 * as input, these files should contain a matrix. The collums of this 
 * should be the dimensions of the parallel coordinates and the rows are
 * the observations.
 * *Input:*  
 * _hObject_ ... handle to figure
 * _eventdata_ ... reserved - to be defined in a future version of MATLAB
 * _handles_ ... structure with handles and user data (see GUIDATA)
 * _varargin_ ... command line arguments to myui (see VARARGIN)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 %% Visual Clustering of Parallel Coordinates
0002 % @author Mazurek/Bartalsky
0003 %% gui_main.m parameters
0004 % * *Description:*
0005 % * Gui of the parallel coordinates script. The script accepts .mat files
0006 % * as input, these files should contain a matrix. The collums of this
0007 % * should be the dimensions of the parallel coordinates and the rows are
0008 % * the observations.
0009 % * *Input:*
0010 % * _hObject_ ... handle to figure
0011 % * _eventdata_ ... reserved - to be defined in a future version of MATLAB
0012 % * _handles_ ... structure with handles and user data (see GUIDATA)
0013 % * _varargin_ ... command line arguments to myui (see VARARGIN)
0014 function varargout = gui_main(varargin)
0015     gui_Singleton = 1;
0016     gui_State = struct('gui_Name',       mfilename, ...
0017                        'gui_Singleton',  gui_Singleton, ...
0018                        'gui_OpeningFcn', @gui_main_OpeningFcn, ...
0019                        'gui_OutputFcn',  @gui_main_OutputFcn, ...
0020                        'gui_LayoutFcn',  [] , ...
0021                        'gui_Callback',   []);
0022     if nargin && ischar(varargin{1})
0023         gui_State.gui_Callback = str2func(varargin{1});
0024     end
0025 
0026     if nargout
0027         [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
0028     else
0029         gui_mainfcn(gui_State, varargin{:});
0030     end
0031 end
0032 
0033 %% OpeningFcn
0034 % * *Description:*
0035 % Function that gets executed on start
0036 function gui_main_OpeningFcn(hObject, eventdata, handles, varargin)
0037     handles.output = hObject;
0038     guidata(hObject, handles);
0039 
0040     %% Read Inputfile
0041     global UserSettings;
0042     UserSettings.dataset          = readInput('input/synthesized.mat');
0043     name=fieldnames(UserSettings.dataset);
0044     name=name{1};
0045     UserSettings.dataset = UserSettings.dataset.(name);
0046     % Normalize data
0047     for i = 1:size(UserSettings.dataset,2)
0048         UserSettings.dataset(:,i) = mat2gray(UserSettings.dataset(:,i));
0049     end
0050     
0051     %% define starting parameters
0052     UserSettings.subcoords= 4;
0053     UserSettings.angle      = 1;
0054     UserSettings.distance   = 1;
0055     UserSettings.alpha_c   = 0.99;
0056     
0057     %% set slider parameters
0058     set(handles.sliderAngle,    'Value', UserSettings.angle);
0059     UserSettings.numSteps = 11;
0060     set(handles.sliderAngle, 'Min', 1);
0061     set(handles.sliderAngle, 'Max', UserSettings.numSteps);
0062     set(handles.sliderAngle, 'SliderStep', [1/(UserSettings.numSteps-1) , 1/(UserSettings.numSteps-1) ]);
0063     set(handles.sliderDistance, 'Value', UserSettings.distance);
0064     set(handles.sliderDistance, 'Min', 1);
0065     set(handles.sliderDistance, 'Max', UserSettings.numSteps);
0066     set(handles.sliderDistance, 'SliderStep', [1/(UserSettings.numSteps-1) , 1/(UserSettings.numSteps-1) ]);
0067     set(handles.sliderStraight, 'Value', UserSettings.alpha_c);
0068     set(handles.sliderStraight, 'Min', 0);
0069     set(handles.sliderStraight, 'Max', 1);
0070     
0071     guidata(hObject, handles);
0072     
0073     updateOutput(hObject, handles);
0074 end
0075 
0076 %% updateOutput
0077 % * *Description:*
0078 % * function that updates the figures
0079 function updateOutput(hObject, handles)
0080     %% update parameters
0081     global UserSettings;    
0082     UserSettings.angle      =       get(handles.sliderAngle,      'Value');    
0083     UserSettings.distance   =       get(handles.sliderDistance,   'Value');    
0084     UserSettings.alpha_c   =       get(handles.sliderStraight,   'Value');
0085     
0086     %% compute new clustering for parallel coordinates
0087     try
0088     [subM, valM]=main(UserSettings.dataset, UserSettings.subcoords, UserSettings.angle, UserSettings.distance, UserSettings.alpha_c);
0089     catch err
0090         fprintf(2,[getReport(err) '\n']);
0091     end
0092     
0093     %% draw original parallel coordinates
0094     axes(handles.axesColor);
0095         cla;
0096         plotSubs(UserSettings.dataset, subM);
0097     
0098     %% draw clustered parallel coordinates
0099     axes(handles.axesResult);
0100         cla;
0101         plotBezier(UserSettings.dataset, valM);
0102     
0103     %% set texts in figure to match computations
0104     set(handles.txtAngle,   'String',           num2str(UserSettings.angle));
0105     set(handles.txtDistance,    'String',           num2str(UserSettings.distance));
0106     set(handles.txtStraight,    'String',           num2str(UserSettings.alpha_c));
0107     set(handles.sliderDistance, 'Min', 1);
0108     set(handles.sliderDistance, 'Max', UserSettings.numSteps);
0109     set(handles.sliderDistance, 'SliderStep', [1/(UserSettings.numSteps-1) , 1/(UserSettings.numSteps-1) ]);
0110     set(handles.sliderAngle, 'Min', 1);
0111     set(handles.sliderAngle, 'Max', UserSettings.numSteps);
0112     set(handles.sliderAngle, 'SliderStep', [1/(UserSettings.numSteps-1) , 1/(UserSettings.numSteps-1) ]);
0113     
0114     guidata(hObject, handles);
0115 end
0116 
0117 function sliderAngle_Callback(hObject, eventdata, handles) %#ok<DEFNU>
0118     val=round(hObject.Value);
0119     hObject.Value=val;
0120     updateOutput(hObject, handles);
0121 end
0122 
0123 function sliderDistance_Callback(hObject, eventdata, handles) %#ok<DEFNU>
0124     global UserSettings;
0125     prev=UserSettings.distance;
0126     val=round(hObject.Value);
0127     if (mod(val,2)==0)
0128     if(val>prev)
0129     hObject.Value=val+1;
0130     else
0131     hObject.Value=val-1;   
0132     end
0133     else    
0134     hObject.Value=val;   
0135     end
0136     updateOutput(hObject, handles);
0137 end
0138 
0139 function sliderStraight_Callback(hObject, eventdata, handles) %#ok<DEFNU>
0140     updateOutput(hObject, handles);
0141 end
0142 
0143 %% updateOutput
0144 % * *Description:*
0145 % * Callback of the Dataset Button. The script accepts .mat files
0146 % * as input, these files should contain a matrix. The collums of this
0147 % * should be the dimensions of the parallel coordinates and the rows are
0148 % * the observations.
0149 function btnDataset_Callback(hObject, eventdata, handles) %#ok<DEFNU>
0150     global UserSettings;
0151     cpy=UserSettings.dataset;
0152     %% Read Inputfile
0153     try
0154     data = uigetfile({'*.mat'},'Dataset auswählen');
0155     UserSettings.dataset=load(['input/' char(data)]);
0156     name=fieldnames(UserSettings.dataset);
0157     name=name{1};
0158     UserSettings.dataset = UserSettings.dataset.(name);
0159     % Normalize data
0160     for i = 1:size(UserSettings.dataset,2)
0161         UserSettings.dataset(:,i) = mat2gray(UserSettings.dataset(:,i));
0162     end
0163     catch err
0164         UserSettings.dataset=cpy;
0165         fprintf(2,[getReport(err) '\n']);
0166     end
0167     %% define starting parameters for new dataset
0168     UserSettings.angle=1;
0169     UserSettings.distance=1;
0170     UserSettings.alpha_c=0.75;
0171     
0172     %set sliders
0173     set(handles.sliderAngle,    'Value', UserSettings.angle);
0174     set(handles.sliderDistance, 'Value', UserSettings.distance);
0175     set(handles.sliderStraight, 'Value', UserSettings.alpha_c);
0176     
0177     updateOutput(hObject, handles);
0178 end
0179 
0180 function varargout = gui_main_OutputFcn(hObject, eventdata, handles) 
0181     varargout{1} = handles.output;
0182 end

Generated on Tue 31-May-2016 19:24:56 by m2html © 2005