fid = 'smellyI2643 (spontaneous, pre-stim)';
spktimes = x.time(x.time>600)-600;
channel = x.channel(x.time>600);

dt = 0.1;
burst_threshold = 800;
bins = 0:dt:max(spktimes); % bins for ASDR, cover a range of time in record
asdr = histc(spktimes,bins)/dt; % calculate ASDR

figure;

subplot(2,1,1);
plot(spktimes,channel,'.k','MarkerSize',2);
set(gca,'FontSize',12);
xlim([min(spktimes) max(spktimes)]); ylim([0 65]);
ylabel('channel');
title(fid,'Interpreter','none','FontSize',14);

subplot(2,1,2);
plot(bins,asdr,'-k');
hold on;
plot([0 dt*length(asdr)], [burst_threshold,burst_threshold],'r','LineWidth',2);
set(gca,'FontSize',12);
xlim([min(spktimes) max(spktimes)]);
xlabel('time (sec)'); ylabel('ASDR (sec^{-1})');



t_bursts = [];

for i = 1:length(asdr)-1 % detect rising edge in asdr that crosses thresh
    if (asdr(i) > burst_threshold) && (asdr(i+1) < burst_threshold)
        n_tmp = bins(i);
        t_bursts = [t_bursts,n_tmp];
    end
end

n_bursts = length(t_bursts);
disp([num2str(n_bursts),' bursts occurred in ',num2str(max(spktimes)-min(spktimes)),' seconds.  The average burst rate is ',num2str(n_bursts/(max(spktimes)-min(spktimes))),'Hz.'])