function asdr_medfilt(fid_prefix,hpr,starthour)

% fid_prefix = 'turbo361';
load([fid_prefix '_nowaveform.SS'],'-mat');
[evt_times evt_text] = get_events(fid_prefix);

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


binsize = 1; %asdr bin size for calculating median
% med_order = 60*5; %2.5 minute on either side to calc median
% med_binsize_label = [num2str(binsize) 'sec bins',10,num2str(med_order)];
% 

% ASDR
close all;
%figure('Position',[-1228 -277 1229 951]);
figure('units','normalized','outerposition',[0 0 1 1])


SS.ASDR(binsize,0,0);
asdr_times = SS.asdr(:,1);
asdr_1sec = SS.asdr(:,2);
asdr_med_1min = medfilt1(SS.asdr(:,2),60);
asdr_med_1hr = medfilt1(SS.asdr(:,2),3600,5000);
y_upperlim = max(asdr_med_1min);
save([fid_prefix '_asdr_medfilt.mat']);

h_tight = tight_subplot(5,1,[.03 .01],[.1 .1],[.1 .1]);

    for i_subplot = 1:5
        axes(h_tight(i_subplot));
        plot(asdr_times,asdr_1sec,'Color',[.8 .8 .8],'LineWidth',0.5);
        hold on;
        plot(asdr_times,asdr_med_1min,'Color',[.4 .4 .4],'LineWidth',1);
        plot(asdr_times,asdr_med_1hr,'Color',[0 0 0],'LineWidth',2.5);
       
        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
        
        grid on;
        axis([((i_subplot-1)*hpr+starthour)*3600 ((i_subplot*hpr)+starthour)*3600 0 y_upperlim]);
        set(gca,'XTick',[((i_subplot-1)*hpr+starthour)*3600:3600:((i_subplot*hpr)+starthour)*3600],...
            'XTickLabel',[(i_subplot-1)*hpr+starthour:1:(i_subplot*hpr)+starthour]);
        set(gca,'FontSize',8)
        
        switch i_subplot
            case 1
                xlabel(''); ylabel('');
                h_leg = legend('Spike Rate (1 sec bins)',...
                    'Median Spike Rate (avg over 1 min)',...
                    'Median Spike Rate (avg over 1 hr)',...
                    'Location','NorthEast');
                set(h_leg,'FontSize',6);
            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_medfilt','.eps']);
print('-dpng',[fid_prefix '_ASDR_medfilt','.png']);
saveas(gcf,[fid_prefix '_ASDR_medfilt','.fig'],'fig');