badchan = [2 11 19];
fpath = 'C:\Users\USER\Documents\mingfaifong_tmp\2011.02.28 Chronic AMPAR Blockade & Recovery (Hamburger)\hamburger360 (NR)\';
fid = 'hamburger360_2011_02_28_cnqx-20uM-2011-03-03-08-03-42.spk';

inc = 10; %in seconds
t_inc = 0:inc:0.5*3600;

channel = [];
time = [];
threshold = [];
waveform = [];

T0 = clock;
for i = 1:length(t_inc)-1
    x = loadspike([fpath fid],[t_inc(i) t_inc(i+1)]);
    ind_goodchan = find(x.channel~=badchan(1) & x.channel~=badchan(2) & x.channel~=badchan(3));
    x.time = x.time(ind_goodchan);
    x.channel = x.channel(ind_goodchan);
    x.waveform = x.waveform(:,ind_goodchan);
    x.threshold = x.threshold(ind_goodchan);
    time = [time; x.time];
    channel = [channel; x.channel];
    waveform = [waveform, x.waveform];
    threshold = [threshold; x.threshold];
    %keyboard;
    clear x;
end
T1 = clock;
etime(T1,T0)

save([fid(1:length(fid)-4) '.mat'],'time','channel','waveform','threshold');