







clearvars -except spktimes channels

% plot rasterplot for entire recording
dt = 18000;  %chunk each file into 5hr (18000sec) blocks
n = ceil((max(spktimes)-min(spktimes))/18000);

for i = 1:n
    clearvars -except spktimes dt n channels
    x1 = find(spktimes < dt*(i-1));
    x2 = find(spktimes < dt*i);
    ind = x2(length(x1)+1:length(x2));
    
    % plot CSDR (spikes/sec) for entire recording, by channel
    % plot ASDR (spikes/sec) for entire recording, by channel
    % plot average firing rate for entire recording
    %   - boxcar w/ 1hr width
    %   - gaussian w/ 1hr = 4sigma (captures 95%)
    
    channel = spkdat.channel(ind);
    time = spkdat.time(ind);
    threshold = spkdat.threshold(ind);
    waveform = spkdat.waveform(:,ind);
    fid = ['frodo364_20uM-CNQX_10uM-APV_',num2str((i-1)*dt/3600),'to',num2str(i*dt/3600),'hr'];
    save(fid,'channel','time','threshold','waveform');
end

% plot CSDR (spikes/sec) for entire recording, by channel
% plot ASDR (spikes/sec) for entire recording, by channel
% plot average firing rate for entire recording
%   - boxcar w/ 1hr width
%   - gaussian w/ 1hr = 4sigma (captures 95%)