%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 = graphsel(varargin)
% GRAPHSEL M-file for graphsel.fig
% GRAPHSEL, by itself, creates a new GRAPHSEL or raises the existing
% singleton*.
%
% H = GRAPHSEL returns the handle to a new GRAPHSEL or the handle to
% the existing singleton*.
%
% GRAPHSEL('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in GRAPHSEL.M with the given input arguments.
%
% GRAPHSEL('Property','Value',...) creates a new GRAPHSEL or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before graphsel_OpeningFunction gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to graphsel_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 graphsel
% Last Modified by GUIDE v2.5 18-Apr-2005 13:26:12
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @graphsel_OpeningFcn, ...
'gui_OutputFcn', @graphsel_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
function initialize_gui(fig_handle, handles)
bdvariables = GetBdVar;
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
set (handles.PushSave, 'Enable', 'off');
set (handles.PushGetSampleNrs, 'Enable', 'off');
set (handles.PushPlot, 'Enable', 'off');
set (handles.PushClearRules, 'Enable' , 'off');
set (handles.PushDelete, 'Enable' , 'off');
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 just before graphsel is made visible.
function graphsel_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 graphsel (see VARARGIN)
% Choose default command line output for graphsel
handles.output = hObject;
%just in case the user prefers to select with a certain Biodata object, so he
%has entered it in the calling command ('graphsel (Biodata_name)')
if length (varargin) == 1
handles.standard_bd = varargin {1};
else
handles.standard_bd = [];
end
% Update handles structure
guidata (hObject, handles);
if strcmp(get(hObject,'Visible'),'off')
initialize_gui(hObject, handles);
end
handles.selstruc = [];
setappdata (hObject, 'InitializeFunction', @initialize_gui);%(fig_handle, handles)
guidata(hObject, handles);
global GraphSelHandle
GraphSelHandle = hObject;
clear GraphSelHandle
global GraphSelHandle
% --- Outputs from this function are returned to the command line.
function varargout = graphsel_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;
% --- 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
function [cl, nr] = GetSelectedClass (handles)
contents = get(handles.PopupSelectClass,'String');
nr = get(handles.PopupSelectClass,'Value');
cl = contents{nr};
clear contents;
function [cl, nr] = GetSelectedItem (handles)
contents = get(handles.PopupSelectItem,'String');
nr = get(handles.PopupSelectItem,'Value');
cl = contents{nr};
clear contents;
function [cl, nr] = GetRule (handles)
contents = get(handles.PopupRule,'String');
nr = get(handles.PopupRule,'Value');
cl = contents{nr};
clear contents;
function SetAllNOK (handles)
set (handles.PopupSelectClass, 'String', ' ');
set (handles.PopupSelectClass, 'Value', 1);
set (handles.PopupSelectItem, 'String', ' ');
set (handles.PopupSelectItem, 'Value', 1);
set (handles.PopupRule, 'String', ' ');
set (handles.PopupRule, 'Value', 1);
set (handles.RulesList, 'String', '');
set (handles.PopupSelectClass, 'Enable', 'off');
set (handles.PopupSelectItem, 'Enable', 'off');
set (handles.PopupRule, 'Enable', 'off');
set (handles.PushAdd, 'Enable', 'off');
set (handles.PushClearRules, 'Enable' , 'off');
set (handles.RulesList, 'Enable', 'off');
set (handles.PushSave, 'Enable', 'off');
set (handles.PushGetSampleNrs, 'Enable', 'off');
set (handles.PushPlot, 'Enable', 'off');
function ResetItem (handles, varname)
%Get selected class
[cl, clnr] = GetSelectedClass (handles); %#ok<ASGLU>
tmpstr = sprintf('[tmptree, %s] = BTree (%s, %i);', varname, varname, clnr);
evalin ('base', tmpstr);
tree = evalin ('base', 'tmptree'); evalin ('base', 'clear tmptree');
[Items, ItemList] = GetItems (tree); %#ok<ASGLU>
%make sure lists are OK
set (handles.PopupSelectItem, 'Value', 1);
set (handles.PopupSelectItem, 'String', ItemList);
function SetAllOK (handles, varname)
ClassList = evalin ('base', sprintf ('GetClassList (%s)', varname));
set (handles.PopupSelectClass, 'String', ClassList);
try
orgname = evalin ('base', sprintf ('%s.options.TypeOfOrganism', varname));
catch
orgname = '';
end
switch orgname
case ''
set (handles.PopupSelectClass, 'Value', 1);
case 'Fungi'
set (handles.PopupSelectClass, 'Value', 3); %om het gemakkelijk op de soortnaam te zetten
case 'Bacteria'
set (handles.PopupSelectClass, 'Value', 1);
otherwise
set (handles.PopupSelectClass, 'Value', 1);
end
set (handles.PopupSelectItem, 'String', ' '); % elders keuzelijst met items goed zetten
set (handles.PopupSelectItem, 'Value', 1);
set (handles.PopupRule, 'String', cellstr('1'));
set (handles.PopupRule, 'Value', 1);
set (handles.RulesList, 'String', '');
set (handles.PopupSelectClass, 'Enable', 'on');
set (handles.PopupSelectItem, 'Enable', 'on');
set (handles.PopupRule, 'Enable', 'on');
set (handles.PushAdd, 'Enable', 'on');
set (handles.RulesList, 'Enable', 'on');
set (handles.PushReset, 'Enable', 'on');
% --- 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
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 graphsel...'));
initialize_gui(gcbf, handles);
VariableList_Callback(hObject, eventdata, handles);
return
end
type = evalin ('base', sprintf ('class (%s)', varname));
else
type = '';
end
if strcmpi (type, 'Biodata')
%varname kan ook nog spatie zijn: ten teke van dat er geen Biodata
%objecten zijn
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));
else
set (handles.RedInfo, 'String', sprintf ('contains full spectra, %i samples and %i colums', n , m));
end
c = evalin ('base', sprintf ('Count (%s)', varname));
if c == 0
set (handles.RedInfo, 'String', 'contains no data');
SetAllNOK (handles);
else
SetAllOK (handles, varname);
ResetItem (handles, varname);
end
else
SetAllNOK (handles);
set (handles.RedInfo, 'String', ' ');
end
handles.selstruc = [];
guidata(hObject, handles);
% --- Executes during object creation, after setting all properties.
function PopupSelectClass_CreateFcn(hObject, eventdata, handles)
% hObject handle to PopupSelectClass (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 PopupSelectClass.
function PopupSelectClass_Callback(hObject, eventdata, handles)
% hObject handle to PopupSelectClass (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 PopupSelectClass contents as cell array
% contents{get(hObject,'Value')} returns selected item from PopupSelectClass
varname = GetSelectedBd (handles);
if isempty(evalin('base', sprintf('who(''%s'')', varname)))
uiwait(warndlg ('This Biodata variable does not exist anyore. Will reload graphsel...'));
initialize_gui(gcbf, handles);
return;
end
ResetItem (handles, varname);
% --- Executes during object creation, after setting all properties.
function PopupRule_CreateFcn(hObject, eventdata, handles)
% hObject handle to PopupRule (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 PopupRule.
function PopupRule_Callback(hObject, eventdata, handles)
% hObject handle to PopupRule (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 PopupRule contents as cell array
% contents{get(hObject,'Value')} returns selected item from PopupRule
% --- Executes on button press in PushAdd.
function PushAdd_Callback(hObject, eventdata, handles)
% hObject handle to PushAdd (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
selstruc = handles.selstruc;
varname = GetSelectedBd (handles);
if isempty(evalin('base', sprintf('who(''%s'')', varname)))
uiwait(warndlg ('This Biodata variable does not exist anyore. Will reload graphsel...'));
initialize_gui(gcbf, handles);
return;
end
[cl] = GetSelectedClass (handles);
[it] = GetSelectedItem (handles);
[ru, runr] = GetRule (handles); %#ok<ASGLU>
s.classdescription = cl; % search (s) for class cl
s.searchval = it; % search (s) in this class for it
if runr > length (selstruc)
selstruc{runr} = s;
isnewrule = true;
else
thisrule = selstruc{runr};
l = length (thisrule);
thisrule (l+1) = s; %achter de keten de nieuwe toevoegen
selstruc{runr} = thisrule;
isnewrule = false;
end
l = length (selstruc);
set (handles.PopupRule, 'String', cellstr (num2str([1:l+1]')));
if isnewrule
set (handles.PopupRule, 'Value', l+1); % zorg dat standaard een nieuwe rule begonnen wordt
else
set (handles.PopupRule, 'Value', runr);% voeg standaard toe aan dezelfde rule
end
Info = GenerateRuleInfo (selstruc);
set (handles.RulesList, 'String', Info);
handles.selstruc = selstruc;
guidata(hObject, handles);
%maak dat de knoppen gebruikt kunnen worden
set (handles.PushGetSampleNrs, 'Enable', 'on');
set (handles.PushPlot, 'Enable', 'on');
set (handles.PushSave, 'Enable', 'on');
set (handles.PushClearRules, 'Enable' , 'on');
set (handles.PushDelete, 'Enable' , 'on');
function Info = GenerateRuleInfo (selstruc)
Info = [];
Info {1} = sprintf ('%s\t%s\t%s', 'Rule', 'Class', 'Item');
%Info {1} = 'Rule \tClass \tItem';%zo aanvaard hij tabs blijkbaar niet
for i = 1:length (selstruc)
thisrule = selstruc{i};
for j = 1:length (thisrule)
str = sprintf ('%i\t%s\t%s', i, thisrule(j).classdescription, thisrule(j).searchval);
Info {length (Info)+1} = str;
end
end
% --- Executes during object creation, after setting all properties.
function RulesList_CreateFcn(hObject, eventdata, handles)
% hObject handle to RulesList (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 RulesList_Callback(hObject, eventdata, handles)
% hObject handle to RulesList (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 RulesList as text
% str2double(get(hObject,'String')) returns contents of RulesList as a double
function nrs = GetTheSampleNrs (handles,varname)
IsSelEmpty = true;
try
baseval = evalin ('base', 'who(''sel'')');
IsSelEmpty = isempty(baseval);
catch
end
assignin ('base', 'sel', handles.selstruc); % krijg de sample nummers
tmpstr = sprintf ('[tmppos, tmpbd2, %s] = selectsamples (%s, sel);', varname, varname);
evalin ('base', tmpstr);
nrs = evalin ('base', 'tmppos''');
evalin ('base', 'clear tmppos tmpbd2');
%als sel al bestond in "base": zet het terug, anders wis het
if IsSelEmpty
evalin ('base', 'clear sel;');
else
assignin ('base', 'sel', baseval);
end
if size(nrs, 2) > 1
nrs = nrs';
end
% --- Executes on button press in PushSave.
function PushSave_Callback(hObject, eventdata, handles)
% hObject handle to PushSave (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Name = get(handles.EditNewName,'String');
if isempty(handles.selstruc)
uiwait(errordlg ('Please add your selection rules to the list, before you can save the results to another Biodata object...'))
return;
end
bdname = GetSelectedBd (handles);
if isempty(evalin('base', sprintf('who(''%s'')', bdname)))
uiwait(warndlg ('This Biodata variable does not exist anyore. Will reload graphsel...'));
initialize_gui(gcbf, handles);
return;
end
nrs = GetTheSampleNrs (handles, bdname);
prompt = {'Give name for new variable:'};
dlg_title = 'Graphsel: give new variablename for saving';
num_lines= 1;
try %in case of the cancel button has been pushed on
Name = inputdlg(prompt,dlg_title,num_lines);
Name = Name{1};
tmpstr = sprintf ('GetSamples (%s, [%s]);', bdname, num2str (nrs'));
bdsel = evalin ('base', tmpstr);
info = handles.selstruc{1};
bdsel.description = sprintf ('%s, %s %s', bdsel.description, info(1).classdescription, info(1).searchval);
assignin ('base', Name, bdsel);
catch
end
%reinitialize all windows
InitializeGraphplot;
InitializeGraphtools;
[bdvariables, handles] = LoadBdVar (handles); %#ok<ASGLU>
SetAsSelectedBd(handles, bdname);
% --- 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 during object creation, after setting all properties.
function PopupSelectItem_CreateFcn(hObject, eventdata, handles)
% hObject handle to PopupSelectItem (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 PopupSelectItem.
function PopupSelectItem_Callback(hObject, eventdata, handles)
% hObject handle to PopupSelectItem (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 PopupSelectItem contents as cell array
% contents{get(hObject,'Value')} returns selected item from PopupSelectItem
% --- Executes on button press in PushReset.
function PushReset_Callback(hObject, eventdata, handles)
% hObject handle to PushReset (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 setGraphplotBDVar (h, varname)
Myhandle = findobj(h, 'Tag','VariableList');
contents = get(Myhandle,'String'); %get the list of Biodata variables
for i=1:length (contents) %search for that item in the list
if strcmp (contents{i}, varname) == 1
pos = i;
break;
end
end
set(Myhandle, 'Value', pos); %select the right Biodata variable
feval (getappdata (h, 'VarListCallback'), Myhandle, [], guidata(h));
function setGraphplotSampleNr (handles, h, varname)
nrs = GetTheSampleNrs (handles,varname);
Myhandle = findobj(h, 'Tag','EditSampleNr'); %search the right handle of the edit box for the sample nrs
set (Myhandle, 'String', num2str (nrs'));
feval (getappdata (h, 'SampleNumberCallback'), Myhandle, [], guidata(h));
% --- 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)
if isempty(handles.selstruc)
uiwait(errordlg ('Please add your selection rules to the list, before you can plot the samples spectra ...'))
return;
end
h = graphplot;
tmp = getappdata (h, 'InitializeFunction');
feval (tmp, h, guidata(h)); %do initialize;
varname = GetSelectedBd (handles);
if isempty(evalin('base', sprintf('who(''%s'')', varname)))
uiwait(warndlg ('This Biodata variable does not exist anyore. Will reload graphsel...'));
initialize_gui(gcbf, handles);
return;
end
setGraphplotBDVar (h, varname);
setGraphplotSampleNr (handles, h, varname);
% --- Executes on button press in PushGetSampleNrs.
function PushGetSampleNrs_Callback(hObject, eventdata, handles)
% hObject handle to PushGetSampleNrs (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
if isempty(handles.selstruc)
uiwait(errordlg ('Please add your selection rules to the list, before you can the samples'' numbers...'))
return;
end
varname = GetSelectedBd (handles);
if isempty(evalin('base', sprintf('who(''%s'')', varname)))
uiwait(warndlg ('This Biodata variable does not exist anyore. Will reload graphsel...'));
initialize_gui(gcbf, handles);
return;
end
nrs = GetTheSampleNrs (handles,varname);
prompt = {'Sample nrs are:','Give name for new variable:'};
dlg_title = 'Graphsel: copy sample nrs or give variablename for saving';
num_lines= 1;
def = num2str (nrs');
def = {def, ''};
try%in case of the cancel button has been pushed on
Name = inputdlg(prompt,dlg_title,num_lines,def);
Name = Name{2};
catch
Name = [];
end
if isempty (Name) == false
tmpstr = sprintf ('getsamples (%s, [%s]);', varname, num2str (nrs));
bdsel = evalin ('base', tmpstr);
info = handles.selstruc{1};
bdsel.description = sprintf ('%s, %s %s', bdsel.description, info(1).classdescription, info(1).searchval);
assignin ('base', Name, bdsel);
end
% --- Executes on button press in PushDelete.
function PushDelete_Callback(hObject, eventdata, handles)
% hObject handle to PushDelete (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
if isempty(handles.selstruc)
uiwait(errordlg ('Please add your selection rules to the list, before you can delete the samples from the Biodata object...'))
return;
end
varname = GetSelectedBd (handles);
if isempty(evalin('base', sprintf('who(''%s'')', varname)))
uiwait(warndlg ('This Biodata variable does not exist anyore. Will reload graphsel...'));
initialize_gui(gcbf, handles);
return;
end
retval = questdlg ('Are you sure you want to delete the selected spectra?', 'Biodata spectra select', 'Yes','No','No');
if strcmp (retval, 'Yes') == 1
nrs = GetTheSampleNrs (handles,varname);
prompt = {'Give name for new database if you want to keep the old data:'};
dlg_title = 'Graphsel: delete spectra from database';
num_lines= 1;
def = {varname};
try %in case of the cancel button has been pushed on
Name = inputdlg(prompt,dlg_title,num_lines, def);
Name = Name{1};
tmpstr = sprintf ('%s = delsample(%s, [%s]);', Name, varname, num2str (nrs'));
evalin ('base', tmpstr);
catch
end
end
% --- Executes on button press in PushClearRules.
function PushClearRules_Callback(hObject, eventdata, handles)
% hObject handle to PushClearRules (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
set (handles.RulesList, 'String', ' ');
handles.selstruc = [];
guidata(hObject, handles);
set (hObject, 'Enable' , 'off');
set (handles.PopupRule, 'String', cellstr('1'));
set (handles.PopupRule, 'Value', 1);
set (handles.RulesList, 'String', '');
set (handles.PushSave, 'Enable', 'off');
set (handles.PushGetSampleNrs, 'Enable', 'off');
set (handles.PushPlot, 'Enable', 'off');
set (handles.PushClearRules, 'Enable' , 'off');
set (handles.PushDelete, 'Enable' , 'off');