Created
March 7, 2015 16:24
-
-
Save shaybensasson/8ee85462b88388e196ac to your computer and use it in GitHub Desktop.
create firing rate from spike train using Gaussian kernel
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| %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'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Can the same be applied to data where I have spike times (time when they happened) instead of the binary format? Thanks!