function event_rate_estimator(L)
%description: takes a vector of ascend-sorted latencies, removes all with values from 1 to 499 (leaving background events only),...
    %takes the difference vector for an estimate of instantaneous rate, plots these, with a bar marking the transition from prestimulation background to postevent background
    %the first post-stim value is the latency of the first event with latency > 500 minus the latency of the last event with latency < 500
%calls: [no custom functions]
%called by:
%notes:
%code confirmed date: mar 2, 2013
close all, hold on

L
d=find(L>0)
e=find(L<500)

y=min(L(L>0))
i=find(L==y)
i=i(1)

LD=diff(L)

LD(d(1)-1:e(end)-1)=[]

LD=LD./10000 %converting from samples to seconds

a=1./LD  %converting from seconds to hertz

plot(a,'-kd','markersize',5)
plot([i-1.5 i-1.5],[0 1000],'k','linewidth',2)
%aa=movingwindowsmooth(a,3)
%plot(aa,'r')