⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 if_gui.m

📁 ifnn
💻 M
📖 第 1 页 / 共 4 页
字号:
% --------------------------------------------------------------------
function varargout = modelparam4_Callback(h, eventdata, handles, varargin)




% --------------------------------------------------------------------
function varargout = modelparam5_Callback(h, eventdata, handles, varargin)




% --------------------------------------------------------------------
function varargout = simparam1_Callback(h, eventdata, handles, varargin)

%%% This function generates a graph of the power spectrum for various
%%% values of the noise
%%% It can be called externally via
function noiseramp(duration)
NREPEAT = 10;
fig = openfig(mfilename,'reuse');

	% Generate a structure of handles to pass to callbacks, and store it. 
	handles = guihandles(fig);
	guidata(fig, handles);
    set(handles.hideplots,'value',1);
    set(handles.modelparam1,'string','1.0');
    set(handles.modelparam2,'string','10.0');
    set(handles.simparam2,'string',num2str(duration));
set(handles.noiseparam3_check,'value',1);
set(handles.draw_power,'checked','off'); set(handles.draw_SNR,'checked','on'); set(handles.draw_ISI,'checked','off'); set(handles.draw_phase,'checked','off'); set(handles.cumulative,'checked','on');
for i = 1:NREPEAT
for sigma = [0.5,1,1.5,2,2.5,3,3.5,4,4.5,5,6,7,8,10,15]
    set(handles.noiseparam3,'string',num2str(sigma));
    i
    apply_Callback(handles.apply, [], handles);
end;
end;
beep;

function onerun_powerspectrum(duration,trefr)
    fig = openfig(mfilename,'reuse');
    % Generate a structure of handles to pass to callbacks, and store it. 
	handles = guihandles(fig);
	guidata(fig, handles);
set(handles.hideplots,'value',1);
set(handles.simparam2,'string',num2str(duration));
    set(handles.modelparam1,'string','20.0');
    set(handles.modelparam2,'string',num2str(trefr));
    set(handles.popup_model,'value',4);
    set(handles.noiseparam3_check,'value',0);
    set(handles.draw_power,'checked','on'); set(handles.draw_SNR,'checked','off'); set(handles.draw_ISI,'checked','off'); set(handles.draw_phase,'checked','off'); set(handles.cumulative,'checked','on');
    apply_Callback(handles.apply, [], handles);
beep;

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%              Functions for spike detection                 %%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function is_spike = hazard(v,vth,myrate,dt) %%The hazard function
    is_spike = exp((v - vth)*myrate)*dt > rand(1);
    %is_spike = (dt*0.1 > rand(1));
function is_spike = hardthreshold(v,vth)    
    is_spike = v > vth;


% --------------------------------------------------------------------
function varargout = defaultparams_Callback(h, eventdata, handles, varargin)
model = get(handles.popup_model,'value');
switch(model)
case 1%IF model
    [C,R,vth,trefr,vr] = IF_baseparams;
    set(handles.modelparam1,'string',num2str(C));
    set(handles.modelparam2,'string',num2str(R));
    set(handles.modelparam3,'string',num2str(vth));
    set(handles.modelparam4,'string',num2str(trefr));
    set(handles.modelparam5,'string',num2str(vr));
case 2%Poisson model
    [myrate,trefr] = poisson_baseparams;
    set(handles.modelparam1,'string',num2str(myrate));
    set(handles.modelparam2,'string',num2str(trefr));
end;


% --- Executes on button press in checkbox4.
function checkbox4_Callback(hObject, eventdata, handles)

function noiseparam4_Callback(hObject, eventdata, handles)

function noiseparam4_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end

% --------------------------------------------------------------------
function draw_survivor_Callback(hObject, eventdata, handles)
swap_check(hObject);
% --------------------------------------------------------------------

%%%%%%%Menu functions %%%%%%%%%
function swap_check(hObject)
state = get(hObject,'checked');
if(strcmp(state,'on')) check = 'off'; else check = 'on'; end;
set(hObject,'checked',check);

function swap_enable(hparent,hObject)
state = get(hparent,'checked');
if(strcmp(state,'on')) enable= 'on'; else enable = 'off'; end;
set(hObject,'enable',enable);



% --------------------------------------------------------------------
function ISI_on_Callback(hObject, eventdata, handles)
swap_check(hObject);
swap_enable(hObject,handles.set_ISI_bin);

% --------------------------------------------------------------------
function set_ISI_bin_Callback(hObject, eventdata, handles)
global ISI_BIN_WIDTH; ISI_BIN_WIDTH = setbinwidth(ISI_BIN_WIDTH);

% --------------------------------------------------------------------
function phase_on_Callback(hObject, eventdata, handles)
swap_check(hObject);
swap_enable(hObject,handles.set_phase_bin);

% --------------------------------------------------------------------
function set_phase_bin_Callback(hObject, eventdata, handles)
global PHASE_BIN_WIDTH; PHASE_BIN_WIDTH = setbinwidth(PHASE_BIN_WIDTH);

function newwidth = setbinwidth(oldwidth)
answer = inputdlg('Enter new bin width in milliseconds','Set bin width',1,{num2str(oldwidth)});
if(~isempty(answer)) 
    newwidth = str2num(answer{1}); 
else
    newwidth = oldwidth; 
end;


%% -------------------------------------------------------------------- %%
%%      the base parameters for each model are defined here             %%
%% -------------------------------------------------------------------- %%
function varargout = IF_baseparams
C = 1;
R = 10;
vth = 10;
trefr = 0;
vr  = 0;
varargout = {{C,R,vth,trefr,vr}};

function varargout = poisson_baseparams
myrate = 20;
trefr = 0;
varargout = {{myrate,trefr}};

function MP = get_basemodelparams;
MP = {IF_baseparams; poisson_baseparams};

%% -------------------------------------------------------------------- %%
%%      the base parameters for each stimulus are defined here          %%
%% -------------------------------------------------------------------- %%

function varargout = steppulse_baseparams
amplitude = 0.1;
duration = 50;
onset_time = 50;
varargout = {{amplitude,duration,onset_time}};

function varargout = sinewave_baseparams
amplitude = 0.1;
frequency = 20;
DC_offset = 0.0;
varargout = {{amplitude,frequency,DC_offset}};

function varargout = pulsetrain_baseparams
excitatory_amplitude = 0.025;
excitatory_rate = 100;
inhibitory_amplitude = 0.1;
inhibitory_rate = 25;
varargout = {{excitatory_amplitude, excitatory_rate, inhibitory_amplitude, inhibitory_rate}};

function SP = get_basestimparams;
SP = {steppulse_baseparams; sinewave_baseparams; pulsetrain_baseparams};


%% -------------------------------------------------------------------- %%
%%              this set objects' position on the figure                %%
%% -------------------------------------------------------------------- %%

function pos = setpositions(handles)
global FIGSIZE; 
height = FIGSIZE(4); width = FIGSIZE(3);

han = [handles.apply,...
    handles.simparams_titletext,handles.simparam1_text,handles.simparam1,handles.simparam1_units,...
    handles.simparam2_text,handles.simparam2,handles.simparam2_units,...
    handles.clear,handles.noiseparams_titletext,handles.noiseparam1_text,handles.noiseparam1,handles.noiseparam1_check,...
    handles.noiseparam2_text,handles.noiseparam2,handles.noiseparam2_check,...
    handles.noiseparam3_text,handles.noiseparam3,handles.noiseparam3_check,...
    handles.noiseparam4_text,handles.noiseparam4,handles.noiseparam4_check,...
    handles.stimulusparams_titletext,handles.popup_stimulus,...
    handles.param1_text,handles.param1,handles.param1_units1,handles.param1_units2,...
    handles.param2_text,handles.param2,handles.param2_units,...
    handles.param3_text,handles.param3,handles.param3_units1,handles.param3_units2,...
    handles.param4_text,handles.param4,handles.param4_units,...
    handles.modelparams_titletext,handles.popup_model,...
    handles.modelparam1_text,handles.modelparam1,handles.modelparam1_units1,handles.modelparam1_units2,handles.modelparam1_unitssuperscript,...
    handles.modelparam2_text,handles.modelparam2,handles.modelparam2_units1,handles.modelparam2_units2,handles.modelparam2_unitssuperscript,...
    handles.modelparam3_text,handles.modelparam3,handles.modelparam3_units,...
    handles.modelparam4_text,handles.modelparam4,handles.modelparam4_units,...
    handles.modelparam5_text,handles.modelparam5,handles.modelparam5_units,...
    handles.hideplots];
pos = 1e5;
posr = 0;
post = 0;
for h = han
    p = get(h,'position');
    pos = min(pos,p(1));
    posr = max(posr,p(1) + p(3));
    post = max(post,p(2) + p(4));
end;
panewidth = posr-pos;
if(post > height) 
    for h = han; set(h,'position',get(h,'position').*[1,0.95*(height/post),1,1]); end;
end;
for h = han
    set(h,'position',get(h,'position') - [pos,0,0,0] + [0.99*width - panewidth,0,0,0]);
end;
pos = 0.99*width - panewidth;

%%% Sets the colors
bkcolor = get(0,'defaultUicontrolBackgroundColor');
set(handles.figure1,'color',bkcolor);
for h = han
    switch(get(h,'style'))
        case {'edit'}
        case {'popupmenu'} 
            set(h,'backgroundcolor','w');
            set(h,'foregroundcolor',[0.0,0.0,0.5]);
        case {'text','checkbox','pushbutton'} 
            set(h,'backgroundcolor',bkcolor);
            set(h,'foregroundcolor','k');
        otherwise
            set(h,'backgroundcolor',bkcolor);
            set(h,'foregroundcolor','k');
    end;
end;
for h = [handles.simparams_titletext,handles.noiseparams_titletext,handles.stimulusparams_titletext,handles.modelparams_titletext]
    set(h,'foregroundcolor',[0.0,0.66,0.0]); end;

%% -------------------------------------------------------------------- %%
%%              these are unused callback functions                     %%
%% -------------------------------------------------------------------- %%


% --------------------------------------------------------------------
function varargout = edit5_Callback(h, eventdata, handles, varargin)

% --------------------------------------------------------------------
function varargout = text15_Callback(h, eventdata, handles, varargin)

% --------------------------------------------------------------------
function varargout = text16_Callback(h, eventdata, handles, varargin)

% --------------------------------------------------------------------
function varargout = edit6_Callback(h, eventdata, handles, varargin)

% --------------------------------------------------------------------
function varargout = text17_Callback(h, eventdata, handles, varargin)

% --------------------------------------------------------------------
function varargout = edit7_Callback(h, eventdata, handles, varargin)

% --------------------------------------------------------------------
function varargout = edit8_Callback(h, eventdata, handles, varargin)

% --------------------------------------------------------------------
function varargout = pushbutton1_ButtonDownFcn(h, eventdata, handles, varargin)

% --------------------------------------------------------------------
function varargout = edit11_Callback(h, eventdata, handles, varargin)

% --------------------------------------------------------------------
function varargout = edit12_Callback(h, eventdata, handles, varargin)

% --------------------------------------------------------------------
function varargout = edit13_Callback(h, eventdata, handles, varargin)

% --------------------------------------------------------------------
function varargout = edit14_Callback(h, eventdata, handles, varargin)

% --------------------------------------------------------------------
function varargout = edit1_Callback(h, eventdata, handles, varargin)

% --------------------------------------------------------------------
function varargout = edit2_Callback(h, eventdata, handles, varargin)

% --------------------------------------------------------------------
function varargout = pushbutton1_Callback(h, eventdata, handles, varargin)
% --------------------------------------------------------------------
function varargout = edit15_Callback(h, eventdata, handles, varargin)

% --------------------------------------------------------------------
function varargout = vaxes_ButtonDownFcn(h, eventdata, handles, varargin)

% --------------------------------------------------------------------
function varargout = Iaxes_ButtonDownFcn(h, eventdata, handles, varargin)

% --------------------------------------------------------------------
function param4_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -