% Overnight, April 11-12, 2014: Spiking Sorting on Old Control, Re-sorting
% problematic files from earlier runs
% -------------------------------------------------------------------------
%% Usain, CNQX+stim

spkdat = load('C:\Users\USER\Documents\mingfaifong\2013-01-24_usain22471_12-14DIV_MEA_CNQX-ChR2-stim-CL\usain22471_waveforms.mat');
fid = 'usain22471_waveforms';
SS = SqueakySpk([fid '_DoublePeakSortNR'],25000,1,spkdat);
SS.Save;
clear SS;
SS = SqueakySpk([fid '_WaveletSort'],25000,1,spkdat);
SS.WaveClus(5,200,'wav',0,0);
SS.Save;
clear all;

%% Unicorn, Control

spkdat = load('C:\Users\USER\Documents\mingfaifong\pre-2012 (need to sort)\2011-07-09_unicorn364_9-12DIV_MEA_vehicle\unicorn364_9-12DIV_waveforms.mat');
fid = 'unicorn364_9-12DIV_waveforms';
bounds = [-24 48]*3600; %maximum time bounds for super long recordings
spkdat.channel = spkdat.channel(spkdat.time>bounds(1) & spkdat.time<bounds(2));
spkdat.threshold = spkdat.threshold(spkdat.time>bounds(1) & spkdat.time<bounds(2));
spkdat.waveform = spkdat.waveform(:,spkdat.time>bounds(1) & spkdat.time<bounds(2));
spkdat.time = spkdat.time(spkdat.time>bounds(1) & spkdat.time<bounds(2));
SS = SqueakySpk([fid '_DoublePeakSortNR'],25000,1,spkdat);
SS.Save;
clear SS;
SS = SqueakySpk([fid '_WaveletSort'],25000,1,spkdat);
SS.WaveClus(5,200,'wav',0,0);
SS.Save;
clear all;

%% Milton, Control

spkdat = load('C:\Users\USER\Documents\mingfaifong\pre-2012 (need to sort)\2011-05-04_milton360_13-17DIV_MEA_vehicle\milton360_13-17DIV_waveforms.mat');
fid = 'milton360_13-17DIV';
bounds = [-24 48]*3600; %maximum time bounds for super long recordings
spkdat.channel = spkdat.channel(spkdat.time>bounds(1) & spkdat.time<bounds(2));
spkdat.threshold = spkdat.threshold(spkdat.time>bounds(1) & spkdat.time<bounds(2));
spkdat.waveform = spkdat.waveform(:,spkdat.time>bounds(1) & spkdat.time<bounds(2));
spkdat.time = spkdat.time(spkdat.time>bounds(1) & spkdat.time<bounds(2));
SS = SqueakySpk([fid '_DoublePeakSortNR'],25000,1,spkdat);
SS.Save;
clear SS;
SS = SqueakySpk([fid '_WaveletSort'],25000,1,spkdat);
SS.WaveClus(5,200,'wav',0,0);
SS.Save;
clear all;

%% Gimli, Control

spkdat = load('C:\Users\USER\Documents\mingfaifong\pre-2012 (need to sort)\2011-10-21_gimli19306_8-11DIV_MEA_vehicle\gimli19306_8-11DIV_waveforms.mat');
fid = 'gimli19306_8-11DIV';
bounds = [-24 48]*3600; %maximum time bounds for super long recordings
spkdat.channel = spkdat.channel(spkdat.time>bounds(1) & spkdat.time<bounds(2));
spkdat.threshold = spkdat.threshold(spkdat.time>bounds(1) & spkdat.time<bounds(2));
spkdat.waveform = spkdat.waveform(:,spkdat.time>bounds(1) & spkdat.time<bounds(2));
spkdat.time = spkdat.time(spkdat.time>bounds(1) & spkdat.time<bounds(2));
SS = SqueakySpk([fid '_DoublePeakSortNR'],25000,1,spkdat);
SS.Save;
clear SS;
SS = SqueakySpk([fid '_WaveletSort'],25000,1,spkdat);
SS.WaveClus(5,200,'wav',0,0);
SS.Save;
clear all;

%% Yoda, Control

spkdat = load('C:\Users\USER\Documents\mingfaifong\pre-2012 (need to sort)\2011-07-30_yoda359_8-11DIV_MEA_vehicle\yoda359_8-11DIV_waveforms.mat');
fid = 'yoda359_8-11DIV';
bounds = [-24 48]*3600; %maximum time bounds for super long recordings
spkdat.channel = spkdat.channel(spkdat.time>bounds(1) & spkdat.time<bounds(2));
spkdat.threshold = spkdat.threshold(spkdat.time>bounds(1) & spkdat.time<bounds(2));
spkdat.waveform = spkdat.waveform(:,spkdat.time>bounds(1) & spkdat.time<bounds(2));
spkdat.time = spkdat.time(spkdat.time>bounds(1) & spkdat.time<bounds(2));
SS = SqueakySpk([fid '_DoublePeakSortNR'],25000,1,spkdat);
SS.Save;
clear SS;
SS = SqueakySpk([fid '_WaveletSort'],25000,1,spkdat);
SS.WaveClus(5,200,'wav',0,0);
SS.Save;
clear all;

