%% data bounds

dt = 3*3600;
suffix = '3hr';
bounds = [-6 24]*3600;

%% files
fileloc = {
    'G:\ming\2013-03-19_dojo22493_11-13DIV_MEA_CNQX\dojo22493_11-13DIV_WaveletSortNR.SS';
    'G:\ming\2013-03-01_atlas22493_10-12DIV_MEA_CNQX\atlas22493_10-12DIV_WaveletSort.SS';
    'G:\ming\2013-02-08_xinhai22493_11-13DIV_MEA_CNQX\xinhai22493_11-13DIV_WaveletSort.SS';
    'G:\ming\2013-02-03_wingnut22468_10-12DIV_MEA_CNQX\wingnut22468_10-12DIV_12-14DIV_WaveletSort.SS';
    'G:\ming\2013-01-21_trouble22467_12-14DIV_MEA_CNQX\trouble22467_12-14DIV_WaveletSort.SS';
    'G:\ming\2013-01-24_usain22493_12-14DIV_MEA_CNQX\usain22493_12-14DIV_WaveletSort.SS';
    'G:\ming\runOvernight_2014-04-11\yam21367D_10-13DIV_WaveletSort.SS';
    'G:\ming\runOvernight_2014-04-11\yam21367F_10-13DIV_WaveletSort.SS';
    'G:\ming\runOvernight_2014-04-11\yam22669C_10-13DIV_WaveletSort.SS';
    'G:\ming\runOvernight_2014-04-11\vivy21367F_10-12DIV_WaveletSort.SS';
    'G:\ming\runOvernight_2014-04-11\vivy21369F_10-12DIV_WaveletSort.SS';
    'G:\ming\runOvernight_2014-04-11\haruki17898C_13-16DIV_WaveletSort.SS';
    'G:\ming\runOvernight_2014-04-11\haruki17898E_13-16DIV_WaveletSort.SS'
    };

badchannels = {
    [1 8 33 57 64]; %dojo22493
    [1 8 33 57 64]; %atlas22493
    [1 8 33 57 64]; %xinhai22493
    [1 8 33 57 64]; %wingnut22468
    [1 8 33 57 64]; %trouble22467
    [1 8 33 57 64]; %usain22493
    [1 6 8 11 32 33 54 57 59 64]; %yam21367D
    [1 6 8 11 32 33 54 57 59 64 55]; %yam21367F
    [1 6 8 11 32 33 54 57 59 64 47]; %yam22669C, possibly [10 24 31 34 35 41 47 49 55 58 61]
    [1 6 8 11 32 33 54 57 59 64 46]; %vivy21367F
    [1 6 8 11 32 33 54 57 59 64]; %vivy21369F
    [1 6 8 11 32 33 54 57 59 64]; %haruki17898C
    [1 6 8 11 32 33 54 57 59 64]; %haruki17898E
    };

fids = cell(length(fileloc),1);
ASDR = cell(length(fileloc),1);
USDR = cell(length(fileloc),1);

for i = length(fileloc)-1:length(fileloc)
    load(fileloc{i},'-mat');
    SS.RemoveChannel(badchannels{i});
    SS.RemoveUnit([0]);
    
    fids{i} = SS.name;
    SS.ASDR(dt,[bounds(1)-dt bounds(2)+dt],[],[],[],0); %calculate ASDR from -6 to 24 hours, with flanking bins to cut out excess
    ASDR{i} = SS.asdr.asdr(2:end-1);
    USDR{i} = SS.usdr.usdr(2:end-1,:);
    clear SS;
end

save(['UnitFR_CNQX-cultures_' suffix],'fids','ASDR','USDR','dt','bounds');