%% load data

dirID = 'C:\Users\USER\Documents\mingfaifong\goon_tmp\';
fid = 'goon21367_14-17DIV';
load([dirID fid '.mat']);

w(1,:) = [3 4 5 12 13 20 21 28 29];
w(2,:) = [7 14 15 16 22 23 24 30 31];
w(3,:) = [38 39 40 46 47 48 55 56 63];
w(4,:) = [36 37 44 45 52 53 60 61 62];
w(5,:) = [34 35 41 42 43 49 50 51 58];
w(6,:) = [2 9 10 17 18 19 25 26 27];

%% generate asdr
clear t asdr
dt = 3600;
bins = ceil(min(time)/dt)*dt:dt:floor(max(time)/dt)*dt;
asdr = zeros(6,length(bins));

for i = 1:6
    t{i} = time(ismember(channel,w(i,:))==1);
    asdr(i,:) = hist(t{i},bins)/dt;
end

%% plot stuff
close all;

for i = 1:6
    figure;
    stairs(bins/3600,asdr(i,:),'-k','LineWidth',2);
    
    %1sec bins
%     set(gca,'TickLength',[0.0025 0.025],'TickDir','out','XTick',[-6:2:54],'ytick',[0:500:2500]);
%     axis([-6 54 0 2500]);
    
    %10sec bins
%     set(gca,'TickLength',[0.0025 0.025],'TickDir','out','XTick',[-6:2:54],'ytick',[0:100:400]);
%     axis([-6 54 0 400]);

%     %60sec bins
%     set(gca,'TickLength',[0.0025 0.025],'TickDir','out','XTick',[-6:2:54],'ytick',[0:30:150]);
%      axis([-6 54 0 150]);

%      %5sec bins
%     set(gca,'TickLength',[0.0025 0.025],'TickDir','out','XTick',[-6:2:54],'ytick',[0:100:600]);
%       axis([-6 54 0 600]);

     %3600sec bins
    set(gca,'TickLength',[0.0025 0.025],'TickDir','out','XTick',[-6:2:54],'ytick',[0:10:70]);
      axis([-6 54 0 70]);

      box off;
       axis off;
    fig(gcf,'units','inches','width',23.17,'height',1.25);
    export_fig([dirID fid '_w' num2str(i) '_ASDR_bin' num2str(dt),'sec'],'-pdf','-transparent','-m2','-CMYK');
    export_fig([dirID fid '_w' num2str(i) '_ASDR_bin' num2str(dt),'sec'],'-png','-transparent','-m2','-CMYK');
end

%%
figure;
plot([0 1],[10000 10000]);
    %1sec bins
%     set(gca,'TickLength',[0.0025 0.025],'TickDir','out','XTick',[-6:2:54],'ytick',[0:500:2500]); %goon21367, 1sec bins
%     axis([-6 54 0 2500]);
    
    %10sec bins
%     set(gca,'TickLength',[0.0025 0.025],'TickDir','out','XTick',[-6:2:54],'ytick',[0:100:400]); %goon21367, 10sec bins
%     axis([-6 54 0 400]);

    %60sec bins
%     set(gca,'TickLength',[0.0025 0.025],'TickDir','out','XTick',[-6:2:54],'ytick',[0:30:150]);
%      axis([-6 54 0 150]);

%5sec bins
%     set(gca,'TickLength',[0.0025 0.025],'TickDir','out','XTick',[-6:2:54],'ytick',[0:100:600]);
%       axis([-6 54 0 600]);

%3600sec bins
    set(gca,'TickLength',[0.0025 0.025],'TickDir','out','XTick',[-6:2:54],'ytick',[0:10:70]);
      axis([-6 54 0 70]);

box off;
fig(gcf,'units','inches','width',23.17,'height',1.25);
export_fig([dirID fid '_axes_ASDR_bin' num2str(dt),'sec'],'-pdf','-transparent','-m2','-CMYK');
export_fig([dirID fid '_axes_ASDR_bin' num2str(dt),'sec'],'-png','-transparent','-m2','-CMYK');
