
for i = 0:3600*72
    t0 = i*5*60;
    t1 = (i+1)*5*60;
    x = loadspike('kalvin16549_20100806_pre.spk',[t0 t1]);
    if isempty(x.channel)
        break
    else
        ind_goodchan = find(x.channel~=1 & x.channel~=8 & x.channel~=33 & x.channel~=57 & x.channel~=64);
        time = x.time(ind_goodchan);
        channel = x.channel(ind_goodchan);
        waveform = x.waveform(:,ind_goodchan);
        threshold = x.threshold(ind_goodchan);
        save(['matfiles/kalvin16549_pre_' num2str(t0/60) 'to' num2str(t1/60) 'min'],'time','waveform','channel','threshold');
    end
    clear channel time threshold waveform x
end
i
clear;

for i = 0:3600*72
    t0 = i*5*60;
    t1 = (i+1)*5*60;
    x = loadspike('kalvin16549_20100806_48hrBIC_20uM.spk',[t0 t1]);
    if isempty(x.channel)
        break
    else
        ind_goodchan = find(x.channel~=1 & x.channel~=8 & x.channel~=33 & x.channel~=57 & x.channel~=64);
        time = x.time(ind_goodchan);
        channel = x.channel(ind_goodchan);
        waveform = x.waveform(:,ind_goodchan);
        threshold = x.threshold(ind_goodchan);
        save(['matfiles/kalvin16549_bic1_' num2str(t0/60) 'to' num2str(t1/60) 'min'],'time','waveform','channel','threshold');
    end
    clear channel time threshold waveform x
end
i
clear;

for i = 0:3600*72
    t0 = i*5*60;
    t1 = (i+1)*5*60;
    x = loadspike('kalvin16549_20100806_48hrBIC_20uM_restart.spk',[t0 t1]);
    if isempty(x.channel)
        break
    else
        ind_goodchan = find(x.channel~=1 & x.channel~=8 & x.channel~=33 & x.channel~=57 & x.channel~=64);
        time = x.time(ind_goodchan);
        channel = x.channel(ind_goodchan);
        waveform = x.waveform(:,ind_goodchan);
        threshold = x.threshold(ind_goodchan);
        save(['matfiles/kalvin16549_bic2_' num2str(t0/60) 'to' num2str(t1/60) 'min'],'time','waveform','channel','threshold');
    end
    clear channel time threshold waveform x
end
i
clear;

for i = 0:3600*72
    t0 = i*5*60;
    t1 = (i+1)*5*60;
    x = loadspike('kalvin16549_20100806_48hrBIC_20uM_restart2_1234pm.spk',[t0 t1]);
    if isempty(x.channel)
        break
    else
        ind_goodchan = find(x.channel~=1 & x.channel~=8 & x.channel~=33 & x.channel~=57 & x.channel~=64);
        time = x.time(ind_goodchan);
        channel = x.channel(ind_goodchan);
        waveform = x.waveform(:,ind_goodchan);
        threshold = x.threshold(ind_goodchan);
        save(['matfiles/kalvin16549_bic3_' num2str(t0/60) 'to' num2str(t1/60) 'min'],'time','waveform','channel','threshold');
    end
    clear channel time threshold waveform x
end
i
clear;


for i = 0:2
    t0 = i*5*60;
    t1 = (i+1)*5*60;
    x = loadspike('kalvin16549_20100806_48hrBIC_wash.spk',[t0 t1]);
    if isempty(x.channel)
        break
    else
        ind_goodchan = find(x.channel~=1 & x.channel~=8 & x.channel~=33 & x.channel~=57 & x.channel~=64);
        time = x.time(ind_goodchan);
        channel = x.channel(ind_goodchan);
        waveform = x.waveform(:,ind_goodchan);
        threshold = x.threshold(ind_goodchan);
        save(['matfiles/kalvin16549_wash_' num2str(t0/60) 'to' num2str(t1/60) 'min'],'time','waveform','channel','threshold');
    end
    clear channel time threshold waveform x
end
i
clear;

