function varargout = gen_ensemble(varargin)
% GEN_ENSEMBLE Application M-file for gen_ensemble.fig
% FIG = GEN_ENSEMBLE launch gen_ensemble GUI.
% GEN_ENSEMBLE('callback_name', ...) invoke the named callback.
%% Copyright (C) by Charles. H. Anderson and Chris Eliasmith (All Rights Reserved)
%% Dept. Anatomy and Neurobiology
%% Washington Univ. School of Medicine
%% St. Louis, MO
%% cha@wustl.edu
%% eliasmith@uwaterloo.ca)
%% Modified Dec. 5, 2003 CHA
% Last Modified by GUIDE v2.5 14-Jan-2004 15:02:34
%
% Modified on 10/29/01 by John Harwell
%
% Removed unused commented out code
% Modified 9/27/02 by CHA to fix saving data.
% Cleaned up 10/13/03 by CHA
if nargin == 0 % LAUNCH GUI
fig = openfig(mfilename,'reuse');
% Generate a structure of handles to pass to callbacks, and store it.
handles = guihandles(fig);
handles.fig = fig;
guidata(fig, handles);
set(fig, 'Name', 'NESIM: Create Neuronal Ensembles');
if nargout > 0
varargout{1} = fig;
end
elseif ischar(varargin{1}) % INVOKE NAMED SUBFUNCTION OR CALLBACK
try
[varargout{1:nargout}] = feval(varargin{:}); % FEVAL switchyard
catch
disp(lasterr);
end
end
%| ABOUT CALLBACKS:
%| GUIDE automatically appends subfunction prototypes to this file, and
%| sets objects' callback properties to call them through the FEVAL
%| switchyard above. This comment describes that mechanism.
%|
%| Each callback subfunction declaration has the following form:
%| <SUBFUNCTION_NAME>(H, EVENTDATA, HANDLES, VARARGIN)
%|
%| The subfunction name is composed using the object's Tag and the
%| callback type separated by '_', e.g. 'slider2_Callback',
%| 'figure1_CloseRequestFcn', 'axis1_ButtondownFcn'.
%|
%| H is the callback object's handle (obtained using GCBO).
%|
%| EVENTDATA is empty, but reserved for future use.
%|
%| HANDLES is a structure containing handles of components in GUI using
%| tags as fieldnames, e.g. handles.figure1, handles.slider2. This
%| structure is created at GUI startup using GUIHANDLES and stored in
%| the figure's application data using GUIDATA. A copy of the structure
%| is passed to each callback. You can store additional information in
%| this structure at GUI startup, and you can change the structure
%| during callbacks. Call guidata(h, handles) after changing your
%| copy to replace the stored original so that subsequent callbacks see
%| the updates. Type "help guihandles" and "help guidata" for more
%| information.
%|
%| VARARGIN contains any extra arguments you have passed to the
%| callback. Specify the extra arguments by editing the callback
%| property in the inspector. By default, GUIDE sets the property to:
%| <MFILENAME>('<SUBFUNCTION_NAME>', gcbo, [], guidata(gcbo))
%| Add any extra arguments after the last argument, before the final
%| closing parenthesis.
% --------------------------------------------------------------------
function varargout = doApply(handles, doApply)
p.outputDirectory = get(handles.outputDirectoryText, 'String');
p.population = get(handles.populationText, 'String');
p.dimension = str2num(get(handles.dimensionText, 'String'));
p.numberNeurons = str2num(get(handles.numNeuronsText, 'String'));
p.randomSeed = str2num(get(handles.randomSeedText, 'String'));
p.radius = str2num(get(handles.radiusText, 'String'));
p.dRadius = p.radius*str2num(get(handles.dRadiusText, 'String'));
p.threshRangeMin = p.radius*str2num(get(handles.threshRangeMinText, 'String'));
p.threshRangeMax = p.radius*str2num(get(handles.threshRangeMaxText, 'String'));
p.satRangeMin = str2num(get(handles.satRangeMinText, 'String'));
p.satRangeMax = str2num(get(handles.satRangeMaxText, 'String'));
p.noise = str2num(get(handles.noiseText, 'String'));
p.weight = str2num(get(handles.weightText, 'String'));
% p.numSingularValues = str2num(get(handles.numSingularValuesText, 'String'));
p.tauRefractory = str2num(get(handles.tauRefractoryText, 'String'));
p.tauRC = str2num(get(handles.tauRCText, 'String'));
p.modelType = get(handles.modelTypePopupMenu, 'Value');
p.onsOnly = get(handles.onsOnlyCheckbox, 'Value');
p.plotPopulation = get(handles.populationCheckbox, 'Value');
p.plotLinearity = get(handles.linearityCheckbox, 'Value');
p.plotDecodingVectors = get(handles.decodingVectorsCheckbox, 'Value');
% p.saveData = doApply;
p.saveData = 1; % Always save the data
set(handles.fig,'Pointer','watch');
genEnsemble_main(p);
set(handles.fig,'Pointer','arrow');
% beep;
% --------------------------------------------------------------------
% "Ons Only" checkbox is only enabled if the dimension is one
function varargout = enableOnsOnly(handles)
dim = str2num(get(handles.dimensionText, 'String'));
if (dim > 1)
set(handles.onsOnlyCheckbox, 'Enable', 'off');
else
set(handles.onsOnlyCheckbox, 'Enable', 'on');
end
% --------------------------------------------------------------------
function varargout = runButton_Callback(h, eventdata, handles, varargin)
doApply(handles, 1);
% --------------------------------------------------------------------
function varargout = closeButton_Callback(h, eventdata, handles, varargin)
close all;
delete(gcbf);
% --------------------------------------------------------------------
function varargout = populationText_Callback(h, eventdata, handles, varargin)
% Stub for Callback of the uicontrol handles..
set(handles.ensFileName,'String',strcat(get(handles.populationText,'String'),'_N',...
get(handles.numNeuronsText,'String'),'D', ...
get(handles.dimensionText,'String'),'.mat'));
% --------------------------------------------------------------------
function varargout = dimensionText_Callback(h, eventdata, handles, varargin)
% Stub for Callback of the dimension handls..
enableOnsOnly(handles);
set(handles.ensFileName,'String',strcat(get(handles.populationText,'String'),'_N',...
get(handles.numNeuronsText,'String'),'D', ...
get(handles.dimensionText,'String'),'.mat'));
% --------------------------------------------------------------------
function varargout = numNeuronsText_Callback(h, eventdata, handles, varargin)
% Stub for Callback of the uicontrol handles..
set(handles.ensFileName,'String',strcat(get(handles.populationText,'String'),'_N',...
get(handles.numNeuronsText,'String'),'D', ...
get(handles.dimensionText,'String'),'.mat'));
% --------------------------------------------------------------------
function varargout = randomSeedText_Callback(h, eventdata, handles, varargin)
% Stub for Callback of the uicontrol handles..
% --------------------------------------------------------------------
function varargout = radiusText_Callback(h, eventdata, handles, varargin)
% Stub for Callback of the uicontrol handles..
% --------------------------------------------------------------------
function varargout = dRadiusText_Callback(h, eventdata, handles, varargin)
% Stub for Callback of the uicontrol handles..
% --------------------------------------------------------------------
function varargout = threshRangeMinText_Callback(h, eventdata, handles, varargin)
% Stub for Callback of the uicontrol handles..
% --------------------------------------------------------------------
function varargout = threshRangeMaxText_Callback(h, eventdata, handles, varargin)
% Stub for Callback of the uicontrol handles..
% --------------------------------------------------------------------
function varargout = satRangeMinText_Callback(h, eventdata, handles, varargin)
% Stub for Callback of the uicontrol handles..
% --------------------------------------------------------------------
function varargout = satRangeMaxText_Callback(h, eventdata, handles, varargin)
% Stub for Callback of the uicontrol handles..
% --------------------------------------------------------------------
function varargout = noiseText_Callback(h, eventdata, handles, varargin)
% Stub for Callback of the uicontrol handles..
% --------------------------------------------------------------------
function varargout = weightText_Callback(h, eventdata, handles, varargin)
% Stub for Callback of the uicontrol handles..
% --------------------------------------------------------------------
% function varargout = numSingularValuesText_Callback(h, eventdata, handles, varargin)
% Stub for Callback of the uicontrol handles..
% --------------------------------------------------------------------
function varargout = tauRefractoryText_Callback(h, eventdata, handles, varargin)
% Stub for Callback of the uicontrol handles..
% --------------------------------------------------------------------
function varargout = tauRCText_Callback(h, eventdata, handles, varargin)
% Stub for Callback of the uicontrol handles..
% --------------------------------------------------------------------
function varargout = modelTypePopupMenu_Callback(h, eventdata, handles, varargin)
% Stub for Callback of the uicontrol handles..
% --------------------------------------------------------------------
function varargout = populationCheckbox_Callback(h, eventdata, handles, varargin)
% Stub for Callback of the uicontrol handles.populationCheckbox.
% --------------------------------------------------------------------
function varargout = linearityCheckbox_Callback(h, eventdata, handles, varargin)
% Stub for Callback of the uicontrol handles.linearityCheckbox.
% --------------------------------------------------------------------
function varargout = decodingVectorsCheckbox_Callback(h, eventdata, handles, varargin)
% Stub for Callback of the uicontrol handles.decodingVectorsCheckbox.
% --------------------------------------------------------------------
function varargout = plotButton_Callback(h, eventdata, handles, varargin)
% Stub for Callback of the uicontrol handles.plotButton.
doApply(handles, 0);
% --------------------------------------------------------------------
function varargout = outputDirectoryText_Callback(h, eventdata, handles, varargin)
% Stub for Callback of the uicontrol handles.outputDirectoryText.
% --------------------------------------------------------------------
function varargout = onsOnlyCheckbox_Callback(h, eventdata, handles, varargin)
% Stub for Callback of the uicontrol handles.onsOnlyCheckbox.