%This software package is dual licensed. You can use it according to the terms
%of either the GPLv3 or the BSD license.
%
%The Biodata toolbox for MATLAB: a spectral database system for storing and
%processing spectra
%C 2004-2008, Kris De Gussem, Raman Spectroscopy Research Group, Department
%of analytical chemistry, Ghent University
%C 2009 Kris De Gussem
%
%This file is part of Biodata.
%
%Biodata is free software: you can redistribute it and/or modify
%it under the terms of the GNU General Public License as published by
%the Free Software Foundation, either version 3 of the License, or
%(at your option) any later version.
%
%Biodata is distributed in the hope that it will be useful,
%but WITHOUT ANY WARRANTY; without even the implied warranty of
%MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
%GNU General Public License for more details.
%
%You should have received a copy of the GNU General Public License
%along with Biodata. If not, see <http://www.gnu.org/licenses/>.
%Copyright (c) 2004-2009, Kris De Gussem
%All rights reserved.
%
%Redistribution and use in source and binary forms, with or without
%modification, are permitted provided that the following conditions are
%met:
%
% * Redistributions of source code must retain the above copyright
% notice, this list of conditions and the following disclaimer.
% * Redistributions in binary form must reproduce the above copyright
% notice, this list of conditions and the following disclaimer in
% the documentation and/or other materials provided with the distribution
% * Neither the name of Raman Spectroscopy Research Group, Department of
% analytical chemistry, Ghent University nor the names
% of its contributors may be used to endorse or promote products derived
% from this software without specific prior written permission.
%
%THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
%AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
%IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
%ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
%LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
%CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
%SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
%INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
%CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
%ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
%POSSIBILITY OF SUCH DAMAGE.
function varargout = graphmap(varargin)
% GRAPHMAP M-file for graphmap.fig
% GRAPHMAP, by itself, creates a new GRAPHMAP or raises the existing
% singleton*.
%
% H = GRAPHMAP returns the handle to a new GRAPHMAP or the handle to
% the existing singleton*.
%
% GRAPHMAP('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in GRAPHMAP.M with the given input arguments.
%
% GRAPHMAP('Property','Value',...) creates a new GRAPHMAP or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before graphmap_OpeningFunction gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to graphmap_OpeningFcn via varargin.
%
% *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one
% instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES
% Edit the above text to modify the response to help graphmap
% Last Modified by GUIDE v2.5 14-Aug-2005 22:28:23
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @graphmap_OpeningFcn, ...
'gui_OutputFcn', @graphmap_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback', []);
if nargin && ischar(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
end
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT
% --- Executes just before graphmap is made visible.
function graphmap_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% 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 graphmap (see VARARGIN)
% Choose default command line output for graphmap
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
%just in case the user prefers to plot with a certain Biodata object, so he
%has entered it in the calling command ('graphmap (Biodata_name)')
switch length (varargin)
case 0
handles.standard_bd = [];
handles.standard_class = [];
case 1
handles.standard_bd = varargin {1};
handles.standard_class = [];
case 2
handles.standard_bd = varargin {1};
handles.standard_class = varargin {2};
otherwise
error ('Biodata:msg', 'Wrong number of input parameters...');
end
guidata (hObject, handles);
if strcmp(get(hObject,'Visible'),'off')
initialize_gui(hObject, handles);
end
setappdata (hObject, 'InitializeFunction', @initialize_gui);%(fig_handle, handles)
setappdata (hObject, 'VarListCallback', @VariableList_Callback);
setappdata (hObject, 'SampleNumberCallback', @EditSampleNr_Callback);
global GraphMapHandle
GraphMapHandle = hObject;
clear GraphMapHandle
global GraphMapHandle
% UIWAIT makes graphmap wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = graphmap_OutputFcn(hObject, eventdata, handles)
% varargout cell array for returning output args (see VARARGOUT);
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Get default command line output from handles structure
varargout{1} = handles.output;
function [selstruc, ind] = GenerateSelectionStructure (handles, varname);
RowContents = get(handles.RowLabel,'String');
RowClass = RowContents{get(handles.RowLabel,'Value')};
RowContents = get(handles.RowIndex,'String');
RowIndex = RowContents{get(handles.RowIndex,'Value')};
ColContents = get(handles.ColLabel,'String');
ColClass = ColContents{get(handles.ColLabel,'Value')};
ColContents = get(handles.ColIndex,'String');
ColIndex = ColContents{get(handles.ColIndex,'Value')};
selstruc{1}.classdescription = RowClass;
selstruc{1}.searchval = RowIndex;
selstruc{1}(2).classdescription = ColClass;
selstruc{1}(2).searchval = ColIndex;
if nargout == 2
bd = evalin ('base', varname);
ind = selectsamples (bd, selstruc); clear bd
end
% --- Executes on button press in PushPlot.
function PushPlot_Callback(hObject, eventdata, handles)
% hObject handle to PushPlot (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% data = getappdata(gcbf, 'metricdata');
%
if isfield (handles, 'fighandle') == false
fighandle = figure;
else
fighandle = handles.fighandle;
end
handles.fighandle = fighandle;
guidata(handles.output, handles);
varname = GetSelectedBd (handles);
if isempty(evalin('base', sprintf('who(''%s'')', varname)))
uiwait(warndlg ('This Biodata variable does not exist anyore. Will reload graphmap...'));
initialize_gui(gcbf, handles);
return;
end
[selstruc, xvar] = GenerateSelectionStructure (handles, varname);
% xvar = ControlSampleNr (Value);
if isempty (xvar)
xvar = [];
elseif length (xvar) > 1
error ('Biodata:msg', 'Only one spectrum allowed for one position...');
end
Value = get(handles.EditYvar, 'String');
yvar = ControlSampleNr (Value);
if isempty (yvar)
yvar = [];
end
cl = GetSelectedClass (handles);
%generate plot command
isnormal = get (handles.RadioNormal, 'Value');
tmpstr = sprintf ('plotn (%s, [%s], [%s], ''%s'')', varname, num2str (xvar), num2str (yvar), cl);
%execute plot command
figure (fighandle);
set (fighandle, 'visible', 'on');
evalin ('base', tmpstr);
usenrs = get (handles.CheckUseSampleNrs, 'Value');
% if usenrs && (isred == false) && isClassSameColor %isred: no extra legend in case of pca plots (= scatterplot)
% h = gca;
% Children = get (h, 'Children');
% for i = 1:length (Children)
% Tag(i) = str2num(get (Children(i), 'Tag'));
% end
% tmp = sortrows([Tag' Children]);
% legend (tmp(:,2), num2str(tmp(:,1)), GetLegendPos (handles));
% end
% --- Executes on button press in ResetBtn.
function ResetBtn_Callback(hObject, eventdata, handles)
% hObject handle to ResetBtn (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
initialize_gui(gcbf, handles);
function cl = GetSelectedClass (handles)
contents = get(handles.PopupClass,'String');
cl = contents{get(handles.PopupClass,'Value')};
clear contents;
% function legpos = GetLegendPos (handles);
% legpos = get (handles.PopupLegendPos, 'Value');
% legposarr = get (handles.PopupLegendPos, 'Userdata');
% legpos = legposarr(legpos);
function SetCheckboxesOK (handles)
bd=evalin ('base', varname);%for compatibility with earlier versions
if isfield (bd.PlotOptions, 'useSampleNumbers') == false
evalin ('base', sprintf ('%s.PlotOptions.useSampleNumbers = false;', varname));
end
if isfield (bd.PlotOptions, 'LegendPos') == false
evalin ('base', sprintf ('%s.PlotOptions.LegendPos = 0;', varname));
end
clear bd;
UseSampleNrs = evalin ('base', sprintf ('%s.PlotOptions.useSampleNumbers', varname));
set (handles.CheckUseSampleNrs, 'Value', UseSampleNrs);
LegendPos = evalin ('base', sprintf ('%s.PlotOptions.LegendPos', varname));
tmp = get (handles.PopupLegendPos, 'Userdata');
tmp = find (tmp == LegendPos);
set (handles.PopupLegendPos, 'Value', tmp);
set (handles.CheckUseSampleNrs, 'Enable', 'on');
function SetCheckboxesNOK (handles)
set (handles.CheckUseSampleNrs, 'Value', 0);
set (handles.CheckUseSampleNrs, 'Enable', 'off');
function SetAllNOK (handles)
SetCheckboxesNOK (handles);
set (handles.EditDescription, 'String', '');
set (handles.DetailedSampleInfo, 'String', '');
set (handles.EditYvar, 'String', '');
set (handles.PopupClass, 'String', ' ');
set (handles.PopupClass, 'Value', 1);
set (handles.EditDescription, 'Enable', 'off');
set (handles.DetailedSampleInfo, 'Enable', 'off');
set (handles.EditYvar, 'Enable', 'off');
set (handles.PopupClass, 'Enable', 'off');
set (handles.PushSampleInfo, 'Enable', 'off');
set (handles.PushPlot, 'Enable', 'off');
function SetAllOK (handles, varname, orgname)
SetCheckboxesOK (handles);
tmpstr = evalin ('base', sprintf ('%s.description', varname));
set (handles.EditDescription, 'String', tmpstr);
set (handles.DetailedSampleInfo, 'String', '');
set (handles.EditYvar, 'String', '');
ClassList = evalin ('base', sprintf ('GetClassList (%s)', varname));
set (handles.PopupClass, 'String', ClassList);
switch orgname
case ''
set (handles.PopupClass, 'Value', 1);
case 'Fungi'
set (handles.PopupClass, 'Value', 3); %om het gemakkelijk op de soortnaam te zetten
case 'Bacteria'
set (handles.PopupClass, 'Value', 1);
otherwise
set (handles.PopupClass, 'Value', 1);
end
set (handles.EditDescription, 'Enable', 'on');
set (handles.DetailedSampleInfo, 'Enable', 'on');
set (handles.EditYvar, 'Enable', 'on');
set (handles.PopupClass, 'Enable', 'on');
set (handles.PushSampleInfo, 'Enable', 'on');
set (handles.PushPlot, 'Enable', 'on');
function initialize_gui(fig_handle, handles)
%setappdata(fig_handle, 'metricdata', data);
bdvariables = GetBdVar;
set (handles.DetailedSampleInfo, 'String', '');
if isempty (bdvariables)
bdvariables {1} = ' ';
set (handles.VariableList, 'Enable', 'off');
set (handles.VariableList, 'String', bdvariables);
set (handles.VariableList, 'Value', 1); %zet automatische gelijk aan de eerste waarde
else
set (handles.VariableList, 'Enable', 'on');
set (handles.VariableList, 'String', bdvariables);
set (handles.VariableList, 'Value', 1); %zet automatische gelijk aan de eerste waarde
end
if isempty (handles.standard_bd) == false
for i = 1:length (bdvariables)
if strcmp (bdvariables{i}, handles.standard_bd)
set (handles.VariableList, 'Value', i);
end
end
handles.standard_bd = [];
guidata (fig_handle, handles);
end
VariableList_Callback(handles.VariableList, [], handles) %mogelijks problemen n toekomst: eventdata??
% --- Executes during object creation, after setting all properties.
function VariableList_CreateFcn(hObject, eventdata, handles)
% hObject handle to VariableList (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: popupmenu controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc
set(hObject,'BackgroundColor','white');
else
set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end
% --- Executes on selection change in VariableList.
function VariableList_Callback(hObject, eventdata, handles)
% hObject handle to VariableList (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: contents = get(hObject,'String') returns VariableList contents as cell array
% contents{get(hObject,'Value')} returns selected item from VariableList
set(handles.PushPointInfo, 'Enable', 'off');
varname = GetSelectedBd (handles);
if strcmp (varname, ' ') ~= 1
if isempty(evalin('base', sprintf('who(''%s'')', varname)))
uiwait(warndlg ('This Biodata variable does not exist anyore. Will reload graphmap...'));
initialize_gui(gcbf, handles);
return;
end
type = evalin ('base', sprintf ('class (%s)', varname));
else
type = '';
end
if strcmp (type, 'Biodata')
%varname kan ook nog spatie zijn: ten teke van dat er geen Biodata
%objecten zijn
set (handles.DetailedSampleInfo, 'String', ' ');
tmp = evalin ('base', sprintf ('%s.reduceddata', varname));
[n,m] = evalin ('base', sprintf ('size(%s.data)', varname));
if tmp == 1
set (handles.RedInfo, 'String', sprintf ('contains reduced data, %i samples and %i variables', n , m));
set (handles.EditLabels, 'Enable', 'on');
set (handles.CheckLegend, 'Enable', 'off');
set (handles.CheckPoints, 'Enable', 'on');
set(handles.PushPointInfo, 'Visible', 'on');
set(handles.PushNamePeak, 'Visible', 'off');
set (handles.PopupLegendPos, 'Enable', 'off');
else
set (handles.RedInfo, 'String', sprintf ('contains full spectra, %i samples and %i colums', n , m));
set (handles.EditLabels, 'Enable', 'off');
set (handles.CheckLegend, 'Enable', 'on');
set (handles.CheckPoints, 'Enable', 'off');
set(handles.PushPointInfo, 'Visible', 'off');
set(handles.PushNamePeak, 'Visible', 'on');
set (handles.PopupLegendPos, 'Enable', 'on');
end
c = evalin ('base', sprintf ('count (%s)', varname));
if c == 0
set (handles.RedInfo, 'String', 'contains no data');
SetAllNOK (handles);
else
try
tmp = evalin ('base', sprintf ('%s.options.TypeOfOrganism', varname));
catch
tmp = '';
end
SetAllOK (handles, varname, tmp);
end
if isempty (handles.standard_class) == false
classlist = get (handles.PopupClass, 'String');
for i = 1:length (classlist)
if strcmp (classlist{i}, handles.standard_class)
set (handles.PopupClass, 'Value', i);
end
end
clear classlist
handles.standard_class = [];
guidata (hObject, handles);
end
else
SetAllNOK (handles);
set (handles.RedInfo, 'String', ' ');
end
% --- Executes during object creation, after setting all properties.
function DetailedSampleInfo_CreateFcn(hObject, eventdata, handles)
% hObject handle to DetailedSampleInfo (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc
set(hObject,'BackgroundColor','white');
else
set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end
function DetailedSampleInfo_Callback(hObject, eventdata, handles)
% hObject handle to DetailedSampleInfo (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of DetailedSampleInfo as text
% str2double(get(hObject,'String')) returns contents of DetailedSampleInfo as a double
% --- Executes on button press in CheckSimpleLegend.
function CheckSimpleLegend_Callback(hObject, eventdata, handles)
% hObject handle to CheckSimpleLegend (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hint: get(hObject,'Value') returns toggle state of CheckSimpleLegend
varname = GetSelectedBd (handles);%krijg de naam van het te bewerken object
if isempty(evalin('base', sprintf('who(''%s'')', varname)))
uiwait(warndlg ('This Biodata variable does not exist anyore. Will reload graphmap...'));
initialize_gui(gcbf, handles);
return;
end
value = get(hObject,'Value');
tmpstr = sprintf ('%s.PlotOptions.nSimpleLegend = %i;', varname, value);
evalin ('base', tmpstr); % zet de inhoud
% --- Executes on button press in CheckClassSameColor.
function CheckClassSameColor_Callback(hObject, eventdata, handles)
% hObject handle to CheckClassSameColor (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hint: get(hObject,'Value') returns toggle state of CheckClassSameColor
varname = GetSelectedBd (handles);%krijg de naam van het te bewerken object
if isempty(evalin('base', sprintf('who(''%s'')', varname)))
uiwait(warndlg ('This Biodata variable does not exist anyore. Will reload graphmap...'));
initialize_gui(gcbf, handles);
return;
end
value = get(hObject,'Value');
tmpstr = sprintf ('%s.PlotOptions.PlotClassSameColor = %i;', varname, value);
evalin ('base', tmpstr); % zet de inhoud
% --- Executes on button press in CheckYTicks.
function CheckYTicks_Callback(hObject, eventdata, handles)
% hObject handle to CheckYTicks (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hint: get(hObject,'Value') returns toggle state of CheckYTicks
if isempty(evalin('base', sprintf('who(''%s'')', varname)))
uiwait(warndlg ('This Biodata variable does not exist anyore. Will reload graphmap...'));
initialize_gui(gcbf, handles);
return;
end
varname = GetSelectedBd (handles);%krijg de naam van het te bewerken object
if isempty(evalin('base', sprintf('who(''%s'')', varname)))
uiwait(warndlg ('This Biodata variable does not exist anyore. Will reload graphmap...'));
initialize_gui(gcbf, handles);
return;
end
value = get(hObject,'Value');
tmpstr = sprintf ('%s.PlotOptions.ShowYTicks = %i;', varname, value);
evalin ('base', tmpstr); % zet de inhoud
% --- Executes on button press in EditLabels.
function EditLabels_Callback(hObject, eventdata, handles)
% hObject handle to EditLabels (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hint: get(hObject,'Value') returns toggle state of EditLabels
varname = GetSelectedBd (handles);%krijg de naam van het te bewerken object
if isempty(evalin('base', sprintf('who(''%s'')', varname)))
uiwait(warndlg ('This Biodata variable does not exist anyore. Will reload graphmap...'));
initialize_gui(gcbf, handles);
return;
end
value = get(hObject,'String');
tmpstr = sprintf ('%s.PlotOptions.PlotLabels = ''%s'';', varname, value);
evalin ('base', tmpstr); % zet de inhoud
% --- Executes on button press in CheckLegend.
function CheckLegend_Callback(hObject, eventdata, handles)
% hObject handle to CheckLegend (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hint: get(hObject,'Value') returns toggle state of CheckLegend
varname = GetSelectedBd (handles);%krijg de naam van het te bewerken object
if isempty(evalin('base', sprintf('who(''%s'')', varname)))
uiwait(warndlg ('This Biodata variable does not exist anyore. Will reload graphmap...'));
initialize_gui(gcbf, handles);
return;
end
value = get(hObject,'Value');
tmpstr = sprintf ('%s.PlotOptions.PlotLegend = %i;', varname, value);
evalin ('base', tmpstr); % zet de inhoud
% --- Executes on button press in CheckPoints.
function CheckPoints_Callback(hObject, eventdata, handles)
% hObject handle to CheckPoints (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hint: get(hObject,'Value') returns toggle state of CheckPoints
varname = GetSelectedBd (handles);%krijg de naam van het te bewerken object
if isempty(evalin('base', sprintf('who(''%s'')', varname)))
uiwait(warndlg ('This Biodata variable does not exist anyore. Will reload graphmap...'));
initialize_gui(gcbf, handles);
return;
end
value = get(hObject,'Value');
tmpstr = sprintf ('%s.PlotOptions.PlotPoints = %i;', varname, value);
evalin ('base', tmpstr); % zet de inhoud
% --- Executes on button press in PushSampleInfo.
function PushSampleInfo_Callback(hObject, eventdata, handles)
% hObject handle to PushSampleInfo (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
%controleer invoer sample nr
Value = get(handles.EditSampleNr, 'String');
Result = ControlSampleNr (Value);
if isempty (Result)
Result = '';
end
%Result bevat nu de numerieke waarden van de sample numbers waar info
%gewenst
%creeer alle combinaties van beschrijvingen
varname = GetSelectedBd (handles);
if isempty(evalin('base', sprintf('who(''%s'')', varname)))
uiwait(warndlg ('This Biodata variable does not exist anyore. Will reload graphmap...'));
initialize_gui(gcbf, handles);
return;
end
options.AddDescriptionLine = true;
options.AddSampleNumberFirst = false;
options.Sorted = false;
assignin ('base', 'tmpoptions', options);
tmpstr = sprintf ('[tmparr, tmptree, %s] = GetClassComb(%s, [], [%s], tmpoptions);', varname, varname, num2str (Result));
evalin ('base', tmpstr);
des = evalin ('base', 'tmparr');
evalin ('base', 'clear tmparr tmptree tmpoptions');
set (handles.DetailedSampleInfo, 'String', des);
% --- Executes during object creation, after setting all properties.
function EditSampleNr_CreateFcn(hObject, eventdata, handles)
% hObject handle to EditSampleNr (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc
set(hObject,'BackgroundColor','white');
else
set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end
function EditSampleNr_Callback(hObject, eventdata, handles)
% hObject handle to EditSampleNr (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of EditSampleNr as text
% str2double(get(hObject,'String')) returns contents of EditSampleNr as a double
Value = get(hObject,'String');
Result = ControlSampleNr (Value);
if isempty (Result)
set (hObject, 'String', ' ');
else
set (hObject, 'String', Value);
end
% --- Executes during object creation, after setting all properties.
function EditDescription_CreateFcn(hObject, eventdata, handles)
% hObject handle to EditDescription (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc
set(hObject,'BackgroundColor','white');
else
set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end
function EditDescription_Callback(hObject, eventdata, handles)
% hObject handle to EditDescription (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of EditDescription as text
% str2double(get(hObject,'String')) returns contents of EditDescription as a double
des = get(hObject,'String');
varname = GetSelectedBd (handles);
if isempty(evalin('base', sprintf('who(''%s'')', varname)))
uiwait(warndlg ('This Biodata variable does not exist anyore. Will reload graphmap...'));
initialize_gui(gcbf, handles);
return;
end
tmpstr = sprintf ('%s.description = ''%s'';', varname, des);
evalin ('base', tmpstr);
% --- Executes during object creation, after setting all properties.
function EditYvar_CreateFcn(hObject, eventdata, handles)
% hObject handle to EditYvar (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc
set(hObject,'BackgroundColor','white');
else
set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end
function EditYvar_Callback(hObject, eventdata, handles)
% hObject handle to EditYvar (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of EditYvar as text
% str2double(get(hObject,'String')) returns contents of EditYvar as a double
Value = get(handles.EditYvar, 'String');
Result = ControlSampleNr (Value);
if isempty (Result)
Result = ' ';
set (handles.EditYvar, 'String', Result);
else
varname = GetSelectedBd (handles);
if isempty(evalin('base', sprintf('who(''%s'')', varname)))
uiwait(warndlg ('This Biodata variable does not exist anyore. Will reload graphmap...'));
initialize_gui(gcbf, handles);
return;
end
[m,n] = evalin('base', sprintf('size(%s.data)', varname));
if min(Result) < 1
Result = ' ';
end
if max(Result) > n
Result = ' ';
end
set (handles.EditYvar, 'String', Value);
end
% --- Executes during object creation, after setting all properties.
function PopupClass_CreateFcn(hObject, eventdata, handles)
% hObject handle to PopupClass (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: popupmenu controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc
set(hObject,'BackgroundColor','white');
else
set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end
% --- Executes on selection change in PopupClass.
function PopupClass_Callback(hObject, eventdata, handles)
% hObject handle to PopupClass (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: contents = get(hObject,'String') returns PopupClass contents as cell array
% contents{get(hObject,'Value')} returns selected item from PopupClass
% --- Executes on button press in RadioNormal.
function RadioNormal_Callback(hObject, eventdata, handles)
% hObject handle to RadioNormal (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hint: get(hObject,'Value') returns toggle state of RadioNormal
set(hObject,'Value', 1)
off = [handles.RadioStacked];
mutual_exclude(off);
% --- Executes on button press in RadioStacked.
function RadioStacked_Callback(hObject, eventdata, handles)
% hObject handle to RadioStacked (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hint: get(hObject,'Value') returns toggle state of RadioStacked
set(hObject,'Value', 1)
off = [handles.RadioNormal];
mutual_exclude(off);
function mutual_exclude(off)
set(off,'Value',0);
% --- Executes on button press in CheckUseSampleNrs.
function CheckUseSampleNrs_Callback(hObject, eventdata, handles)
% hObject handle to CheckUseSampleNrs (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hint: get(hObject,'Value') returns toggle state of CheckUseSampleNrs
varname = GetSelectedBd (handles);
if isempty(evalin('base', sprintf('who(''%s'')', varname)))
uiwait(warndlg ('This Biodata variable does not exist anyore. Will reload graphmap...'));
initialize_gui(gcbf, handles);
return;
end
tmpstr = sprintf ('%s.PlotOptions.useSampleNumbers = %i;', varname, get(hObject,'Value'));
evalin ('base', tmpstr);
% --- Executes on button press in PushNamePeak.
function PushNamePeak_Callback(hObject, eventdata, handles)
% hObject handle to PushNamePeak (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
val = inputdlg ('Give threshhold value for second derivative:', 'Graphplot Name Peak');
val = val{1};
figure (handles.fighandle);
set (handles.fighandle, 'visible', 'on');
ShowPeakName (str2num(val));
% --- Executes on button press in PushObjectInfo.
function PushObjectInfo_Callback(hObject, eventdata, handles)
% hObject handle to PushObjectInfo (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
varname = GetSelectedBd (handles);
if isempty(evalin('base', sprintf('who(''%s'')', varname)))
uiwait(warndlg ('This Biodata variable does not exist anyore. Will reload graphmap...'));
initialize_gui(gcbf, handles);
return;
end
tmpstr = sprintf ('GetBDinfo(%s, true, ''%s'')', varname, varname);
des = evalin ('base', tmpstr); % krijg de inhoud van de Biodata variabele
for i = 1:length (des)
des{i} = ReplaceTabBySpaces (des{i}, 5);
end
set (handles.DetailedSampleInfo, 'String', des);
% --- Executes on button press in PushSelect.
function PushSelect_Callback(hObject, eventdata, handles)
% hObject handle to PushSelect (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
varname = GetSelectedBd (handles);
if isempty(evalin('base', sprintf('who(''%s'')', varname)))
uiwait(warndlg ('This Biodata variable does not exist anyore. Will reload graphmap...'));
initialize_gui(gcbf, handles);
return;
end
Graphsel (varname);
% --- Executes on button press in PushCluster.
function PushCluster_Callback(hObject, eventdata, handles)
% hObject handle to PushCluster (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
varname = GetSelectedBd (handles);
if isempty(evalin('base', sprintf('who(''%s'')', varname)))
uiwait(warndlg ('This Biodata variable does not exist anyore. Will reload graphmap...'));
initialize_gui(gcbf, handles);
return;
end
Value = get(handles.EditSampleNr, 'String');
xvar = ControlSampleNr (Value);
if isempty (xvar)
xvar = ':';
else
%ask if the user wants to select samples for cluster
Btn = questdlg ('Do you want to select the samples before clustering? Answering ''No'' will use all samples to build te cluster.', 'Plot difference spectra', 'Yes', 'No', 'No');
if strcmp (Btn, 'Yes')
xvar = ['[' num2str(xvar) ']' ];
else
xvar = ':';
end
end
%doe de clustering
tmpstr = sprintf ('%s.data(%s,:)', varname, xvar);
X = evalin ('base', tmpstr);
Y = pdist(X,'euclidean');
Z = linkage(Y,'ward');
tmpstr = sprintf ('%s.classes(%i).classvalue', varname, get(handles.PopupClass,'Value'));
Labels = evalin ('base', tmpstr);
Info = GSDendrogram (Z, Labels);
fprintf (1, '\nCophenet value (1 = ideal cluster, 0 = no clustering): %f.\n', cophenet(Z,Y));
tmpstr = sprintf ('%s.description', varname);
tmpstr = evalin ('base', tmpstr);
tmpstr = sprintf ('Cluster: %s', tmpstr);
h = title (tmpstr);
%zorg dat de plot er schoontjes uitziet: pas parameters aan
weight = evalin ('base', sprintf ('%s.PlotOptions.TitleFontWeight', varname));
size = evalin ('base', sprintf ('%s.PlotOptions.TitleFontSize', varname));
set (h, 'FontWeight', weight);
set (h, 'FontSize', size);
% --- Executes on button press in PushEnd.
function PushEnd_Callback(hObject, eventdata, handles)
% hObject handle to PushEnd (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
delete (handles.figure1);
% --- Executes on button press in PushPlotMean.
function PushPlotMean_Callback(hObject, eventdata, handles)
% hObject handle to PushPlotMean (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
if isfield (handles, 'fighandle') == false
fighandle = figure;
else
fighandle = handles.fighandle;
end
handles.fighandle = fighandle;
% guidata(handles.output, handles);
guidata(hObject, handles);
varname = GetSelectedBd (handles);
if isempty(evalin('base', sprintf('who(''%s'')', varname)))
uiwait(warndlg ('This Biodata variable does not exist anyore. Will reload graphmap...'));
initialize_gui(gcbf, handles);
return;
end
isred = evalin ('base', sprintf ('%s.reduceddata', varname));
Value = get(handles.EditSampleNr, 'String');
xvar = ControlSampleNr (Value);
if isempty (xvar)
xvar = [];
end
Value = get(handles.EditYvar, 'String');
yvar = ControlSampleNr (Value);
if isempty (yvar)
yvar = [];
end
cl = GetSelectedClass (handles);
%get the spectra in the Biodata variable
tmpstr = sprintf ('getsamples (%s, [%s]);', varname, num2str (xvar));
bdtmp = evalin ('base', tmpstr);
m = mean (bdtmp);
s = std (bdtmp.data);
%genereer het te uit te voeren commando
figure (fighandle);
if isred % zijn het gereduceerde data?
error ('Biodata:msg', 'Cannot plot a mean spectrum of reduced data...');
end
plotn (m, [], yvar, cl, false);
hold on;
plot (bdtmp.xaxis, m.data+s, 'r');
plot (bdtmp.xaxis, m.data-s, 'r');
h = legend;
tmpleg = get (findobj (h, 'Type', 'Text'), 'String');
tmpleg = tmpleg (3:length (tmpleg)-1);
leg = strvcat (sprintf ('m(%s)', tmpleg), sprintf ('m+s(%s)', tmpleg), sprintf ('m-s(%s)', tmpleg));
legend (leg);
% --- Executes on button press in PushPointInfo.
function PushPointInfo_Callback(hObject, eventdata, handles)
% hObject handle to PushPointInfo (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
figure (handles.fighandle);
%zorg dat scherm bijna gemaximaliseerd is (vb 95% in beide richtingen
%anders rare effecten als scherm volledig gemax is
varname = GetSelectedBd (handles);
if isempty(evalin('base', sprintf('who(''%s'')', varname)))
uiwait(warndlg ('This Biodata variable does not exist anyore. Will reload graphmap...'));
initialize_gui(gcbf, handles);
return;
end
[x, y] = gselect ('nearest');
h = gca;
co = str2num(get(h, 'Tag'));
if length (co) == 2
%search for var with these coordinates
tmpstr = sprintf ('%s.data', varname);
data = evalin ('base', tmpstr);
xdata = find (data (:, co(1)) == x);
ydata = find (data (:, co(2)) == y);
pos = intersect (xdata, ydata);
tmpstr = sprintf ('GetClassComb(%s, [], [%s])', varname, num2str (pos));
des = evalin ('base', tmpstr); % krijg de inhoud van de Biodata variabele
text (x, y, des);
%get the info of these points
elseif length (co) == 3
error ('Biodata:msg', 'only supported for 2d plots');
else
error ('Biodata:msg', 'programming error...');
end
legend %this command is for lay-out purposes: if you click in the plot window, the scatter plot becomes in front of the legend and the legend is obscured
% --- Executes on button press in PushDiff.
function PushDiff_Callback(hObject, eventdata, handles)
% hObject handle to PushDiff (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
%check input
if isfield (handles, 'fighandle') == false
fighandle = figure;
else
fighandle = handles.fighandle;
end
handles.fighandle = fighandle;
guidata(handles.output, handles);
varname = GetSelectedBd (handles);
if isempty(evalin('base', sprintf('who(''%s'')', varname)))
uiwait(warndlg ('This Biodata variable does not exist anyore. Will reload graphmap...'));
initialize_gui(gcbf, handles);
return;
end
Value = get(handles.EditSampleNr, 'String');
xvar = ControlSampleNr (Value);
if isempty (xvar)
Btn = questdlg ('Do you want to plot difference spectra for all samples?', 'Plot difference spectra', 'Yes', 'No', 'No');
switch Btn
case 'Yes'
c = evalin ('base', sprintf ('count (%s)', varname));
xvar = 1:c;
case 'No'
xvar = [];
otherwise
error ('Biodata:msg', 'No option selected');
end
end
Value = get(handles.EditYvar, 'String');
yvar = ControlSampleNr (Value);
if isempty (yvar)
yvar = [];
end
cl = GetSelectedClass (handles);
%fighandle = plotDiff (bd, X, Y, Classindex, fighandle);
tmpstr = sprintf ('plotdiff (%s, [%s], [%s], ''%s'', [%s])', varname, num2str(xvar), num2str(yvar), cl, num2str(fighandle));
evalin ('base', tmpstr);
% --- Executes during object creation, after setting all properties.
function PopupLegendPos_CreateFcn(hObject, eventdata, handles)
% hObject handle to PopupLegendPos (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: popupmenu controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc
set(hObject,'BackgroundColor','white');
else
set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end
% --- Executes on selection change in PopupLegendPos.
function PopupLegendPos_Callback(hObject, eventdata, handles)
% hObject handle to PopupLegendPos (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: contents = get(hObject,'String') returns PopupLegendPos contents as cell array
% contents{get(hObject,'Value')} returns selected item from PopupLegendPos
varname = GetSelectedBd (handles);
legpos = get (handles.PopupLegendPos, 'Value');
legposarr = get (handles.PopupLegendPos, 'Userdata');
legpos = legposarr(legpos);
evalin ('base', sprintf ('%s.PlotOptions.LegendPos = %s;', varname, num2str(legpos)));
% --- Executes during object creation, after setting all properties.
function RowLabel_CreateFcn(hObject, eventdata, handles)
% hObject handle to RowLabel (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: popupmenu controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc
set(hObject,'BackgroundColor','white');
else
set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end
% --- Executes on selection change in RowLabel.
function RowLabel_Callback(hObject, eventdata, handles)
% hObject handle to RowLabel (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: contents = get(hObject,'String') returns RowLabel contents as cell array
% contents{get(hObject,'Value')} returns selected item from RowLabel
% --- Executes during object creation, after setting all properties.
function ColLabel_CreateFcn(hObject, eventdata, handles)
% hObject handle to ColLabel (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: popupmenu controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc
set(hObject,'BackgroundColor','white');
else
set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end
% --- Executes on selection change in ColLabel.
function ColLabel_Callback(hObject, eventdata, handles)
% hObject handle to ColLabel (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: contents = get(hObject,'String') returns ColLabel contents as cell array
% contents{get(hObject,'Value')} returns selected item from ColLabel
% --- Executes during object creation, after setting all properties.
function RowIndex_CreateFcn(hObject, eventdata, handles)
% hObject handle to RowIndex (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: popupmenu controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc
set(hObject,'BackgroundColor','white');
else
set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end
% --- Executes on selection change in RowIndex.
function RowIndex_Callback(hObject, eventdata, handles)
% hObject handle to RowIndex (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: contents = get(hObject,'String') returns RowIndex contents as cell array
% contents{get(hObject,'Value')} returns selected item from RowIndex
% --- Executes during object creation, after setting all properties.
function ColIndex_CreateFcn(hObject, eventdata, handles)
% hObject handle to ColIndex (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: popupmenu controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc
set(hObject,'BackgroundColor','white');
else
set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end
% --- Executes on selection change in ColIndex.
function ColIndex_Callback(hObject, eventdata, handles)
% hObject handle to ColIndex (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: contents = get(hObject,'String') returns ColIndex contents as cell array
% contents{get(hObject,'Value')} returns selected item from ColIndex