dt = 3600;
%bins = 0:dt:max(time);
bins = 0:dt:max(3600*93);
asdr = zeros(6,length(bins));

fid_prefix = 'haruki17898b';

fpath = ['C:\Users\USER\Documents\mingfaifong\' fid_prefix '\FullRecNoWaveformNoClean\'];
spath = ['C:\Users\USER\Documents\mingfaifong\' fid_prefix '\FullRecNoWaveformNoClean\figures\'];

fpath_info = dir(fpath);      %get info about contents of directory
isfile = ~[fpath_info.isdir]; %get index for files only
fidlist = {fpath_info(isfile).name}; %create list of files

for i = 1:length(fidlist)
    fid = fidlist{i}
    load([fpath fid],'-mat');
    max(time)/3600;
    t{i} = time;
%     subplot(6,1,i)
%     n_channel = unique(channel);
%     for j = 1:length(n_channel)
%         ind_channel = find(channel==n_channel(j));
%         plot(time(ind_channel),...
%             j*ones(size(time(ind_channel)))+0.25*rand(size(time(ind_channel))),...
%             'k.','MarkerSize',1);
%         hold on;
%     end
    %t{i} = time(clean==1 & ismember(channel,w(i,:))==1);
    %c{i} = channel(clean==1 & ismember(channel,w(i,:))==1);
    asdr(i,:) = hist(t{i},bins)/dt;
    clear time channel
end

%% plot stuff

for i = 1:6
    subplot(6,1,i)
    plot(bins(1:end-1)/3600+.5,asdr(i,1:end-1),'-ok','LineWidth',2,'MarkerSize',5);
    xlim([0 93]);
    ylim([0 250]);
    set(gca,'XTick',0:4:93);
    ylabel('ASDR (Hz)');
end

xlabel('Time (hours)');