This repository has been archived on 2021-05-17. You can view files and clone it, but cannot push or open issues or pull requests.
scientificComputing/pointprocesses/code/spikeraster.m

27 lines
597 B
Matlab

function spikeraster(spikes, tmax)
% Display a spike raster of the spike times given in spikes.
% spikes: a cell array of vectors of spike times
% tmax: plot spike raster upto tmax seconds
ntrials = length(spikes);
for k = 1:ntrials
times = spikes{k};
times = times(times<tmax);
if tmax < 1.5
times = 1000.0*times; % conversion to ms
end
for i = 1:length( times )
line([times(i) times(i)],[k-0.4 k+0.4], 'Color', 'k' );
end
end
if tmax < 1.5
xlabel( 'Time [ms]' );
else
xlabel( 'Time [s]' );
end
ylabel( 'Trials');
ylim( [ 0.3 ntrials+0.7 ] )
end