%
%	rasterplot(stimes,r)
%       plots the wth rastergram of stimes
%		r: rastergram index;
%       
%
%   Author: Jean-Marc fellous
%   fellous@salk.edu



function rasterplot(stimes,r)
ntrials=size(stimes,1);
cla;
hold on;
if r>0 & r<31       % hardcoded limit: here all 'spiketimes' arrays have exactly 30 rastergrams
        I=1;
		for i=1:ntrials
			s=1;
			while(stimes(i,r,s) ~=0 & s<size(stimes,3))
				%plot([stimes(i,r,s)],[i],'.','MarkerSize',3)    % use for very heavy rasterplots
				line([stimes(i,r,s) stimes(i,r,s)],[I I+0.9],'LineWidth',2)
				s=s+1;
			end
            I=I+1;
		end
end
%ylabel(sprintf('%d ',r),'FontSize',8,'Rotation',0);
set(gca,'XLim',[0 1]);
set(gca,'YLim',[1 ntrials+1]);
xlabel('Time (s)');
ylabel('Trials');
%set(gca,'YTick',[])

