%% data bounds

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

%% files
fileloc = {
    'G:\ming\runOvernight_2014-04-11\yam22669B_10-12DIV_WaveletSort.SS';
    'G:\ming\runOvernight_2014-04-11\yam21367B_10-13DIV_WaveletSort.SS';
    'G:\ming\runOvernight_2014-04-11\yam21367E_10-13DIV_WaveletSort.SS';
    'G:\ming\runOvernight_2014-04-11\vivy21367A_10-12DIV_WaveletSort.SS';
    'G:\ming\runOvernight_2014-04-11\vivy21369C_10-12DIV_WaveletSort.SS';
%     'G:\ming\runOvernight_2014-04-11\haruki17898A_13-16DIV_WaveletSort.SS';
%     'G:\ming\runOvernight_2014-04-11\haruki17898D_13-16DIV_WaveletSort.SS';
    'G:\ming\runOvernight_2014-04-11\milkdud19309_13-16DIV_WaveletSort.SS'
    };

badchannels = {
    [1 6 8 11 32 33 54 57 59 64 47]; %yam22669B, possibly [10 24 31 34 35 41 47 49 55 58 61]
    [1 6 8 11 32 33 54 57 59 64]; %yam21367B
    [1 6 8 11 32 33 54 57 59 64 55]; %yam21367E
    [1 6 8 11 32 33 54 57 59 64 46]; %vivy21367A
    [1 6 8 11 32 33 54 57 59 64]; %vivy21369C
%     [1 6 8 11 32 33 54 57 59 64]; %haruki17898A
%     [1 6 8 11 32 33 54 57 59 64]; %haruki17898D
    [1 8 33 57 64] %milkdud19309
    };

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

for i = 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-2);
    USDR{i} = SS.usdr.usdr(2:end-2,:);
    clear SS;
end

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