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

📄 if_gui.m

📁 ifnn
💻 M
📖 第 1 页 / 共 4 页
字号:
if(strcmp(state,'on')) check = 'off'; else check = 'on'; end;
set(handles.draw_phase,'checked',check);




% --------------------------------------------------------------------
function varargout = draw_SNR_Callback(h, eventdata, handles, varargin)
state = get(handles.draw_SNR,'checked');
if(strcmp(state,'on')) check = 'off'; else check = 'on'; end;
set(handles.draw_SNR,'checked',check);

% --------------------------------------------------------------------
function varargout = draw_power_Callback(h, eventdata, handles, varargin)
state = get(handles.draw_power,'checked');
if(strcmp(state,'on')) check = 'off'; else check = 'on'; end;
set(handles.draw_power,'checked',check);


function draw_survivor_function(tf,dt,cumulative)
h = findobj('type','figure','tag','survivor_function_figure');
if(isempty(h)) 
    h = figure('tag','survivor_function_figure','name','survivor function','NumberTitle','off');
    a = axes;
    set(a,'parent',h);
    %set(a,'tag','0');    
end;
a = findobj('type','axes','parent',h);
if(isempty(a))
    a = axes;
    set(a,'parent',h);
    %set(a,'tag','0');
end;
ISI = diffs(tf);
M = max(ISI);
l = findobj('parent',a,'type','line'); if(length(l) > 1) l = l(1); end;
if((cumulative) & (~isempty(l)))
    bins = get(l,'xdata');
else
    bins = [0:dt:1.25*M];
end;
survivors = zeros(1,length(bins));
for i = 1:length(bins)
    survivors(i) = sum(ISI > bins(i)); %Finds the survivors
end;
if((isempty(l)) | (~cumulative))
    I = length(ISI);
else
    I = str2num(get(l,'tag')); %The total number of survivors that are already in the graph
    survivors = (survivors+I*get(l,'ydata'));
    I = I + length(ISI);
   
end;
survivors = survivors/I;
col = 'b';
figure(h);
l = plot(bins,survivors,'marker','s','parent',a,'color',col,'markerfacecolor',col,'linestyle',':');
set(l,'tag',num2str(I));
set(get(a,'xlabel'),'string','time after last spike');
set(get(a,'ylabel'),'string','survival probability');
xlim([0 max(bins)]);
ylim([0 1.1]);

function draw_phase_histogram(tf,frequency,cumulative)
global PHASE_BIN_WIDTH;
h = findobj('type','figure','tag','phase_histogram_figure');
if(isempty(h)) 
    h = figure('tag','phase_histogram_figure','name','phase histogram','NumberTitle','off');
    a = axes;
    set(a,'parent',h);
    %set(a,'tag','0');    
end;
a = findobj('type','axes','parent',h);
if(isempty(a))
    a = axes;
    set(a,'parent',h);
    %set(a,'tag','0');
end;
nspikes = length(tf);
tf = tf(2:nspikes);
phases = 2*pi*(frequency*tf/1000 - floor(frequency*tf/1000)); %Calculates the phases    
l = findobj('parent',a,'type','line'); if(length(l) > 1) l = l(1); end;
if((cumulative) & (~isempty(l)))
    bins = get(l,'xdata');
else
    bins = [0:PHASE_BIN_WIDTH:2*pi];
end;
histo = hist(phases,bins);
if((isempty(l)) | (~cumulative))
    n = 0;
else
    I = str2num(get(l,'tag'));
    histo = (histo+I*get(l,'ydata'));
end;
[histo,I] = normhist(histo,bins);
col = 'b';
figure(h);
l = plot(bins,histo,'marker','s','parent',a,'color',col,'markerfacecolor',col,'linestyle',':');
set(l,'tag',num2str(I));
set(get(a,'xlabel'),'string','phase (radians)');
set(get(a,'ylabel'),'string','probability density');
xlim([0 2*pi]);
ylim([0 1.1*max(histo)]);

%%%%%%%%%%%%%%%%%%%%%%%55
function draw_ISI_histogram(tf,cumulative)
global ISI_BIN_WIDTH;
%Searches for an exisitng figure
h = findobj('type','figure','tag','ISI_histogram_figure');
if(isempty(h)) 
    h = figure('tag','ISI_histogram_figure','name','ISI histogram','NumberTitle','off');
    a = axes;
    set(a,'parent',h);
    %set(a,'tag','0');    
end;
a = findobj('type','axes','parent',h);
if(isempty(a))
    a = axes;
    set(a,'parent',h);
    %set(a,'tag','0');
end;

%plots the histogram
ISI = diffs(tf);
M = max(ISI);
l = findobj('parent',a,'type','line'); if(length(l) > 1) l = l(1); end;
if((cumulative) & (~isempty(l)))
    bins = get(l,'xdata');
else
    bins = [0:ISI_BIN_WIDTH:2*M];
end;
histo = hist(ISI,bins);
if((cumulative) & (~isempty(l)))
    I = str2num(get(l,'tag'));
    histo = (histo + I*get(l,'ydata'));
end;
[histo,I] = normhist(histo,bins);
col = 'r';
figure(h);
l = plot(bins,histo,'marker','s','parent',a,'color',col,'markerfacecolor',col,'linestyle',':');
set(l,'tag',num2str(I));
set(get(a,'xlabel'),'string','interspike interval (ms)');
set(get(a,'ylabel'),'string','probability density');
xlim([0 max(bins)]);


function varargout = normhist(myh,myx)
len = length(myx);
I = myh(1)*(myx(2)-myx(1));
for i = 2:len-1
    I = I + myh(i)*(myx(i+1)-myx(i-1))/2;
end;
I = I + myh(len)*(myx(len)-myx(len-1));
myh = myh/I;
varargout = {myh,I};

function y = diffs(myx)
for i = 1:length(myx) - 1;
    y(i) = myx(i+1) - myx(i);
end;

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


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function draw_SNR(tf,T,omega,sigma,cumulative)
%Searches for an existing figure
h = findobj('type','figure','tag','SNR_figure');
if(isempty(h)) 
    h = figure('tag','SNR_figure','name','signal-to-noise ratio','NumberTitle','off');
    a = axes;
    set(a,'parent',h);
    %set(a,'tag','0');    
end;
a = findobj('type','axes','parent',h);
if(isempty(a))
    a = axes;
    set(a,'parent',h);
    %set(a,'tag','0');
end;

%Plots the histogram
P = power_spectrum(tf,T,omega)/T;
myrate = length(tf)/T
SNR = P/myrate
col = 'k';
figure(h);
l = findobj('parent',a,'type','line');
if((~cumulative) | isempty(l))
    l = plot(sigma,SNR,'parent',a,'color',col,'marker','s','markersize',6,'markerfacecolor',col,'linestyle','none');
else
    set(l,'xdata',cat(2,get(l,'xdata'),sigma),'ydata',cat(2,get(l,'ydata'),SNR));
end;

set(get(a,'xlabel'),'string','noise level (mV^2)');
set(get(a,'ylabel'),'string','signal-to-noise ratio');
lim = get(l,'ydata'); set(a,'ylim',[0 max(1,max(lim)+1)]);
lim = get(l,'xdata'); set(a,'xlim',[0,max(1,max(lim)+1)]);

function draw_power(tf,T,omega,cumulative)
global POWER_SPECTRUM_NBINS;
    h = findobj('type','figure','tag','fft'); if(isempty(h)); h = figure('tag','fft','numbertitle','off','name','power spectrum'); end;
    a = findobj('type','axes','parent',h); if(isempty(a)); a = axes; set(a,'parent',h); end; set(get(a,'xlabel'),'string','frequency [Hz]'); set(get(a,'ylabel'),'string','power spectrum');
    figure(h); if(cumulative) hold on;  else hold off; end;
    lom = 0*omega;
    Lom = 3*omega;
    om = [lom:(Lom-lom)/POWER_SPECTRUM_NBINS:Lom]; 
    P = power_spectrum(tf,T,om);
    myrate = length(tf)/T
    plot(om,P/myrate,'marker','.','color',rand(1,3));
    ylim([0,2*mean(P)]);
    set(get(a,'xlabel'),'string','frequency (Hz)');
    set(get(a,'ylabel'),'string','power spectrum');    

function pp(lom,Lom,tf,T,omega,cumulative)
global POWER_SPECTRUM_NBINS;
    om = [lom:(Lom-lom)/POWER_SPECTRUM_NBINS:Lom]; 
    P = power_spectrum(tf,T,om);
    myrate = length(tf)/T
    plot(om,P/myrate,'marker','.','color',rand(1,3));
    ylim([0,2*mean(P)]);
        
function P = power_spectrum(tf,T,omega)
%Calculates the power spectrum of the spike train tf, on a time interval T, at the frequency omega
N = length(tf);
P = 0;
for j  = 1:N
    for k = j:N       
        P = P + cos(2*pi*omega*(tf(j)-tf(k)));% - i*sin(2*pi*omega*(tf(j)-tf(k))); %The imaginary part cancels outs
   end;
end;
P = 2*P/T;



% --------------------------------------------------------------------
function varargout = cumulative_Callback(h, eventdata, handles, varargin)
state = get(handles.cumulative,'checked');
if(strcmp(state,'on')) check = 'off'; else check = 'on'; end;
set(handles.cumulative,'checked',check);


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




% --------------------------------------------------------------------
function varargout = popup_model_Callback(h, eventdata, handles, varargin)
global MODEL_PARAMS;
modeltype = get(handles.popup_model,'value');
switch(modeltype)
case 1
    set(handles.modelparam1_text,'visible','on','string','Membrane capacitance =');
    set(handles.modelparam1_units1,'visible','on','string','m','fontname','symbol');
    set(handles.modelparam1_units2,'visible','on');
    set(handles.modelparam1_unitssuperscript,'visible','on');
    set(handles.modelparam1,'string',num2str(MODEL_PARAMS{modeltype}{1}));
    set(handles.modelparam2_text,'visible','on','string','Membrane resistivity');
    set(handles.modelparam2_unitssuperscript,'visible','on');
    set(handles.modelparam2_units1,'visible','on','string','M     cm');
    set(handles.modelparam2_units2,'visible','on');
    set(handles.modelparam2,'visible','on','string',num2str(MODEL_PARAMS{modeltype}{2}));
    set(handles.modelparam3_text,'visible','on','string','Firing threshold');
    set(handles.modelparam3,'visible','on','string',num2str(MODEL_PARAMS{modeltype}{3}));
    set(handles.modelparam3_units,'visible','on','string','mV');
    set(handles.modelparam4_text,'visible','on','string','Refractory period');
    set(handles.modelparam4,'visible','on','string',num2str(MODEL_PARAMS{modeltype}{4}));
    set(handles.modelparam4_units,'visible','on','string','ms');
    set(handles.modelparam5_text,'visible','on','string','Reset potential');
    set(handles.modelparam5,'visible','on','string',num2str(MODEL_PARAMS{modeltype}{5}));
    set(handles.modelparam5_units,'visible','on','string','mV');
case 2
    set(handles.modelparam1_text,'visible','on','string','Rate =');
    set(handles.modelparam1_units1,'visible','on','string','Hz','fontname','helvetica');
    set(handles.modelparam1_units2,'visible','off');
    set(handles.modelparam1_unitssuperscript,'visible','off');
    set(handles.modelparam2_text,'visible','on','string','Reftractory period =');
    set(handles.modelparam2_unitssuperscript,'visible','off');
    set(handles.modelparam2_units1,'visible','on','string','ms');
    set(handles.modelparam2_units2,'visible','off');
    set(handles.modelparam3_text,'visible','off');
    set(handles.modelparam4_text,'visible','off');
    set(handles.modelparam5_text,'visible','off');
    set(handles.modelparam3_units,'visible','off');
    set(handles.modelparam5_units,'visible','off');
    set(handles.modelparam4_units,'visible','off');
    set(handles.modelparam1,'visible','on','string',num2str(MODEL_PARAMS{modeltype}{1}));
    set(handles.modelparam2,'visible','on','string',num2str(MODEL_PARAMS{modeltype}{2}));
    set(handles.modelparam3,'visible','off');
    set(handles.modelparam4,'visible','off');
    set(handles.modelparam5,'visible','off');
    
end;


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




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




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




⌨️ 快捷键说明

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