No BSD License  

Highlights from
NESim

image thumbnail
from NESim by Chris Eliasmith
General package for large-scale biologically plausible simulations (with GUI).

gui_plot_3(varargin)
function varargout = gui_plot_3(varargin)
% GUI_PLOT_3 Application M-file for gui_plot_3.fig
%    FIG = GUI_PLOT_3 launch gui_plot_3 GUI.
%    GUI_PLOT_3('callback_name', ...) invoke the named callback.

%% Many Changes  3/5/03 by CHA
%% More Changes  8/26/03 by CHA

% Last Modified by GUIDE v2.5 07-Jan-2002 22:17:50

if nargin == 0  % LAUNCH GUI

	fig = openfig(mfilename,'reuse');
    
	% Generate a structure of handles to pass to callbacks, and store it. 
	handles = guihandles(fig);
	guidata(fig, handles);
    set(fig, 'Name', 'NESIM: Select Plots');
    
	if nargout > 0
		varargout{1} = fig;
	end

    loadPlotPopupMenu(handles);
    loadPlotData(handles, 1);
    
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 = loadPlotPopupMenu(handles)
global PlotInfo NumPlotInfo

% disp(['NumPlotInfo: ' num2str(NumPlotInfo)]);

if NumPlotInfo == 0
    return;
end

for i = 1:NumPlotInfo
    plotLabels{i} = PlotInfo(i).label;
end
set(handles.plotPopupMenu, 'String', plotLabels);
set(handles.plotPopupMenu, 'Value', 1);

% --------------------------------------------------------------------
function varargout = loadPlotData(handles, selNum)
global PlotInfo NumPlotInfo

set(handles.plotOutputValues, 'Value', PlotInfo(selNum).outputValues);
set(handles.plotInputValues, 'Value', PlotInfo(selNum).inputValues);
set(handles.directSolutionCheckbox, 'Value', PlotInfo(selNum).directSolution);
set(handles.rastersCheckbox, 'Value', PlotInfo(selNum).rasters);
set(handles.somaCurrentCheckbox, 'Value', PlotInfo(selNum).somaCurrents);
set(handles.somaVoltagesCheckbox, 'Value', PlotInfo(selNum).somaVoltages);
set(handles.Activities_Checkbox, 'Value', PlotInfo(selNum).act);
set(handles.numberOfNeuronsTextbox, 'String', num2str(PlotInfo(selNum).numNeurons));
selNum = get(handles.plotPopupMenu, 'Value');
set(handles.Sel_Components, 'String', PlotInfo(selNum).sel_components);
set(handles.Sel_Components,'Enable','on');
set(handles.rastersCheckbox,           'Enable', 'off');
set(handles.somaCurrentCheckbox,       'Enable', 'off');
set(handles.somaVoltagesCheckbox,      'Enable', 'off');
set(handles.Activities_Checkbox,              'Enable', 'off');
set(handles.numberOfNeuronsTextbox,    'Enable', 'off');
set(handles.numberOfNeuronsStaticText, 'Enable', 'off');
set(handles.plotOutputValues,              'Enable', 'off');
set(handles.plotInputValues, 'Enable', 'off');
set(handles.AllDirect, 'Enable','on');
set(handles.directSolutionCheckbox,    'Enable', 'on');
set(handles.AllInput,'Enable','off');
set(handles.AllOutput,'Enable','off');
set(handles.OutFilTC,  'Enable', 'off');
set(handles.TCText,  'Enable', 'off');
if (PlotInfo(selNum).type == 0)
   allDirectFlag=1;
   for(i=1:NumPlotInfo)
       if(~PlotInfo(i).type)
           if(~PlotInfo(i).directSolution)
               allDirectFlag=0;
           end
       end
   end
   set(handles.AllDirect,'Value',allDirectFlag);
elseif ((PlotInfo(selNum).type == 1))
   set(handles.Sel_Components,'Enable','on');
   set(handles.plotInputValues, 'Enable', 'on');
   set(handles.plotOutputValues,  'Enable', 'on');
   set(handles.AllOutput, 'Enable', 'on');
   set(handles.AllDirect, 'Enable','on');
   set(handles.AllInput,'Enable','on');
   if (get(handles.plotOutputValues,'Value') | ...
       get(handles.AllOutput,'Value'))
       set(handles.OutFilTC,  'Enable', 'on');
       set(handles.TCText,  'Enable', 'on');
   else
       set(handles.OutFilTC,  'Enable', 'off');
       set(handles.TCText,  'Enable', 'off');
   end
          
   %% Set all direct on if all the directSolutions are set
   allDirectFlag=1;
   allInputFlag=1;
   allOutputFlag=1;
   for(i=1:NumPlotInfo)
       if(PlotInfo(i).type)
           if(~PlotInfo(i).directSolution)
               allDirectFlag=0;
           end
           if(~PlotInfo(i).inputValues)
               allInputFlag=0;
           end
           if(~PlotInfo(i).outputValues)
               allOutputFlag=0;
           end
       end
   end
   set(handles.AllDirect,'Value',allDirectFlag);
   set(handles.AllInput,'Value',allInputFlag);
   set(handles.AllOutput,'Value',allOutputFlag);
   if (PlotInfo(selNum).can_outputRasters ~= 0)
       set(handles.rastersCheckbox,           'Enable', 'on');
       set(handles.numberOfNeuronsTextbox,    'Enable', 'on');
       set(handles.numberOfNeuronsStaticText, 'Enable', 'on');
   end
   if (PlotInfo(selNum).can_outputCurrents ~= 0)
       set(handles.somaCurrentCheckbox,       'Enable', 'on');
       set(handles.numberOfNeuronsTextbox,    'Enable', 'on');
       set(handles.numberOfNeuronsStaticText, 'Enable', 'on');
   end
   if (PlotInfo(selNum).can_outputVoltages ~= 0)
       set(handles.somaVoltagesCheckbox,      'Enable', 'on');
       set(handles.numberOfNeuronsTextbox,    'Enable', 'on');
       set(handles.numberOfNeuronsStaticText, 'Enable', 'on');
   end
   if (PlotInfo(selNum).can_outputAct ~= 0)
       set(handles.Activities_Checkbox,              'Enable', 'on');
       set(handles.numberOfNeuronsTextbox,    'Enable', 'on');
       set(handles.numberOfNeuronsStaticText, 'Enable', 'on');
   end
   set(handles.OutFilTC,'String',num2str(PlotInfo(selNum).Filter_tc));
end
% --------------------------------------------------------------------
function varargout = plotPopupMenu_Callback(h, eventdata, handles, varargin)
% Stub for Callback of the uicontrol handles.plotPopupMenu.
global PlotInfo NumPlotInfo
selNum = get(handles.plotPopupMenu, 'Value');
loadPlotData(handles, selNum);

% --------------------------------------------------------------------
function varargout = plotOutputValues_Callback(h, eventdata, handles, varargin)
% Stub for Callback of the uicontrol handles.plotOutputValues.
global PlotInfo NumPlotInfo
selNum = get(handles.plotPopupMenu, 'Value');
PlotInfo(selNum).outputValues = get(handles.plotOutputValues, 'Value');
if (get(handles.plotOutputValues,'Value'))
    set(handles.OutFilTC,  'Enable', 'on');
    set(handles.TCText,  'Enable', 'on');
end
if(get(handles.AllOutput,'Value'))
    set(handles.AllOutput, 'Value',0);
end

% --------------------------------------------------------------------
function varargout = plotInputValues_Callback(h, eventdata, handles, varargin)
global PlotInfo NumPlotInfo
% Stub for Callback of the uicontrol handles.plotInputValues.
selNum = get(handles.plotPopupMenu, 'Value');
PlotInfo(selNum).inputValues = get(handles.plotInputValues, 'Value');
if(get(handles.AllInput,'Value'))
    set(handles.AllInput, 'Value',0);
end

% --------------------------------------------------------------------
function varargout = directSolutionCheckbox_Callback(h, eventdata, handles, varargin)
global PlotInfo NumPlotInfo
% Stub for Callback of the uicontrol handles.directSolutionCheckbox.
selNum = get(handles.plotPopupMenu, 'Value');
PlotInfo(selNum).directSolution = get(handles.directSolutionCheckbox, 'Value');
if(get(handles.AllDirect,'Value'))
    set(handles.AllDirect, 'Value',0);
end
% --------------------------------------------------------------------
function varargout = rastersCheckbox_Callback(h, eventdata, handles, varargin)
global PlotInfo NumPlotInfo
% Stub for Callback of the uicontrol handles.rastersCheckbox.
selNum = get(handles.plotPopupMenu, 'Value');
PlotInfo(selNum).rasters = get(handles.rastersCheckbox, 'Value');

% --------------------------------------------------------------------
function varargout = somaCurrentCheckbox_Callback(h, eventdata, handles, varargin)
global PlotInfo NumPlotInfo
% Stub for Callback of the uicontrol handles.somaCurrentCheckbox.
selNum = get(handles.plotPopupMenu, 'Value');
PlotInfo(selNum).somaCurrents = get(handles.somaCurrentCheckbox, 'Value');

% --------------------------------------------------------------------
function varargout = numberOfNeuronsTextbox_Callback(h, eventdata, handles, varargin)
global PlotInfo NumPlotInfo
% Stub for Callback of the uicontrol handles.numberOfNeuronsTextbox.
selNum = get(handles.plotPopupMenu, 'Value');
PlotInfo(selNum).numNeurons = str2double(get(handles.numberOfNeuronsTextbox, 'String'));

% --------------------------------------------------------------------
function varargout = closeButton_Callback(h, eventdata, handles, varargin)
% Stub for Callback of the uicontrol handles.closeButton.
delete(gcbf);


% --- Executes on button press in somaVoltagesCheckbox.
function somaVoltagesCheckbox_Callback(hObject, eventdata, handles)
global PlotInfo NumPlotInfo
% Stub for Callback of the uicontrol handles.somaCurrentCheckbox.
selNum = get(handles.plotPopupMenu, 'Value');
PlotInfo(selNum).somaVoltages = get(handles.somaVoltagesCheckbox, 'Value');

% hObject    handle to somaVoltagesCheckbox (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 somaVoltagesCheckbox


% --- Executes on button press in Activities_Checkbox.
function Activities_Checkbox_Callback(hObject, eventdata, handles)
global PlotInfo NumPlotInfo
% Stub for Callback of the uicontrol handles.somaCurrentCheckbox.
selNum = get(handles.plotPopupMenu, 'Value');
PlotInfo(selNum).act = get(handles.Activities_Checkbox, 'Value');

% hObject    handle to Activities_Checkbox (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 Activities_Checkbox


% --- Executes on button press in AllDirect.
function AllDirect_Callback(hObject, eventdata, handles)
global PlotInfo NumPlotInfo 

selNum = get(handles.plotPopupMenu, 'Value');
TypeValue = PlotInfo(selNum).type;

if(get(handles.AllDirect,'Value'))
    for i = 1:NumPlotInfo
        if(PlotInfo(i).type==TypeValue)
            PlotInfo(i).directSolution=1;
        end
    end
    if(~get(handles.directSolutionCheckbox, 'Value'));
        set(handles.directSolutionCheckbox, 'Value',1);
    end
    set(handles.AllDirect,'Value',1);
else
    for i = 1:NumPlotInfo
        if(PlotInfo(i).type==TypeValue)
            PlotInfo(i).directSolution=0;
        end
    end
    if(get(handles.directSolutionCheckbox, 'Value'));
        set(handles.directSolutionCheckbox, 'Value',0);
    end   
    set(handles.AllDirect,'Value',0);
end



% --- Executes on button press in AllInput.
function AllInput_Callback(hObject, eventdata, handles)
global PlotInfo NumPlotInfo 

if(get(handles.AllInput,'Value'))
    for i = 1:NumPlotInfo
        if(PlotInfo(i).type)
            PlotInfo(i).inputValues=1;
        end
    end
    if(~get(handles.plotInputValues, 'Value'));
        set(handles.plotInputValues, 'Value',1);
    end
    set(handles.AllInput,'Value',1);
else
    for i = 1:NumPlotInfo
        if(PlotInfo(i).type)
            PlotInfo(i).inputValues=0;
        end
    end
    if(get(handles.plotInputValues, 'Value'));
        set(handles.plotInputValues, 'Value',0);
    end   
    set(handles.AllInput,'Value',0);
end


% --- Executes on button press in AllOutput.
function AllOutput_Callback(hObject, eventdata, handles)
global PlotInfo NumPlotInfo 

selNum = get(handles.plotPopupMenu, 'Value');

if(get(handles.AllOutput,'Value'))
    for i = 1:NumPlotInfo
        if(PlotInfo(i).type)
            PlotInfo(i).outputValues=1;
        end
    end
    if(~get(handles.plotOutputValues, 'Value'));
        set(handles.plotOutputValues, 'Value',1);
    end
    set(handles.AllOutput,'Value',1);
    set(handles.OutFilTC,  'Enable', 'on');
    set(handles.TCText,  'Enable', 'on');
else
    for i = 1:NumPlotInfo
        if(PlotInfo(i).type)
            PlotInfo(i).outputValues=0;
        end
    end
    if(get(handles.plotOutputValues, 'Value'));
        set(handles.plotOutputValues, 'Value',0);
    end   
    set(handles.AllOutput,'Value',0);
    set(handles.OutFilTC,  'Enable', 'off');
    set(handles.TCText,  'Enable', 'off');
end

function Sel_Components_Callback(hObject, eventdata, handles)
global PlotInfo NumPlotInfo 

selNum = get(handles.plotPopupMenu, 'Value');
strComponents =  get(handles.Sel_Components, 'String');
[components,ok] = str2num(strComponents);
D_Str = num2str([1:PlotInfo(selNum).D]);
if(~ok)
    set(handles.Sel_Components,'String',D_Str);
    beep;
elseif(max(components)>PlotInfo(selNum).D)
    set(handles.Sel_Components,'String',D_Str);
    beep;
elseif(min(components)<1)
    set(handles.Sel_Components,'String',D_Str);
    beep;
else
    PlotInfo(selNum).sel_components = strComponents;
end

function OutFilTC_Callback(hObject, eventdata, handles)
global PlotInfo NumPlotInfo 

selNum = get(handles.plotPopupMenu, 'Value');
tcstr = get(handles.OutFilTC,'String');
[tc,ok] = str2num(tcstr);
if(ok)
    set(handles.OutFilTC,'String',tcstr);
    PlotInfo(selNum).Filter_tc = tc;
else
    beep;
    set(handles.OutFilTC,'String','???');
end

Contact us at files@mathworks.com