function batch_ASDR(fid_prefix,hpr,starthour)

%hpr = 33; %hours per row
%starthour = 0;

fpath = 'C:\Users\USER\Documents\mingfaifong\';
load([fpath fid_prefix '_nowaveform.mat']);

load('empty.SS','-mat');
SS.name = [fid_prefix '_nowaveform'];
SS.clean = cleanspk;
SS.time = spktimes;
SS.channel = channels;
SS.badchannel = [1 8 33 57 64];
SS.badunit = 0;
SS.Save(fpath);
clear channels cleanspk spktimes

binsize_options_secs = [1,2,5,10,30,1*60,2*60,5*60,10*60,30*60,1*3600];
binsize_options = [1,2,5,10,30,1,2,5,10,30,1];
binsize_units = {'sec','sec','sec','sec','sec','min','min','min','min','min','hr'};

[evt_times evt_text] = get_events(fid_prefix);

for i_bin = 1:length(binsize_options)

    close all;
    figure('units','normalized','outerposition',[0 0 1 1])
    binsize = binsize_options_secs(i_bin);
    binsize_label = [num2str(binsize_options(i_bin)) binsize_units{i_bin}];
    
    for i_subplot = 1:5
        subplot(5,1,i_subplot);
        SS.ASDR(binsize,1,0);
        hold on;
        
        asdr_sorted = sortrows(SS.asdr(:,2));
        y_upperlim = asdr_sorted(round(length(asdr_sorted)*.9995));
       
        for m = 1:length(evt_times)
            plot([evt_times(m) evt_times(m)],[0 y_upperlim],'--r');
            text(evt_times(m)+(hpr*.005)*3600,y_upperlim*.9,evt_text{m},'Color','r','FontSize',8);
        end
        
        axis([((i_subplot-1)*hpr+starthour)*3600 ((i_subplot*hpr)+starthour)*3600 0 y_upperlim]);
        set(gca,'TickDir','out',...
            'XTick',[((i_subplot-1)*hpr+starthour)*3600:3600:((i_subplot*hpr)+starthour)*3600],...
            'XTickLabel',[(i_subplot-1)*hpr+starthour:1:(i_subplot*hpr)+starthour]);
       
        switch i_subplot
            case 1
                xlabel(''); ylabel('');
                text((hpr*.82+starthour)*3600,y_upperlim*.9,['bin size = ' binsize_label]);
            case 2
                xlabel(''); ylabel('');
            case 3
                xlabel(''); ylabel('Array-Wide Spike Rate (Hz)','FontSize',14);
            case 4
                xlabel(''); ylabel('');
            case 5
                xlabel([10,'Time (hours)'],'FontSize',14); ylabel('');
        end
    
    end

    print('-depsc',[fid_prefix '_ASDR_bin',binsize_label,'.eps']);
    print('-dpng',[fid_prefix '_ASDR_bin',binsize_label,'.png']);
    saveas(gcf,[fid_prefix '_ASDR_bin',binsize_label,'.fig'],'fig');
    
end