Skip to content

Instantly share code, notes, and snippets.

@shaybensasson
Created March 7, 2015 16:24
Show Gist options
  • Select an option

  • Save shaybensasson/8ee85462b88388e196ac to your computer and use it in GitHub Desktop.

Select an option

Save shaybensasson/8ee85462b88388e196ac to your computer and use it in GitHub Desktop.
create firing rate from spike train using Gaussian kernel
%https://www.mathworks.com/matlabcentral/newsreader/view_thread/243177
clear all
clc
figure(1);clf
%y=[ 0 1 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 1]; % spike train
SPIKE_TRAIN_LENGTH = 100;
y=double(logical(rand(SPIKE_TRAIN_LENGTH,1)<0.5));
plot(y)
hold on
sigma=1;
x=[-100:sigma:100];
%k = exp(-(x/sigma).^2/2)/(sigma*sqrt(2*pi)); % Gaussian kernel.
k = gausswin(3);
z=conv(y,k);
z=z(ceil(length(k)/2):end-floor(length(k)/2))
h=plot(z, '-r');
h.Color(4) = 0.5; % 50% transparent
legend('Spike Train', 'Rate');
@elladulko
Copy link
Copy Markdown

Can the same be applied to data where I have spike times (time when they happened) instead of the binary format? Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment