% clear all;
% 
% x1 = loadspk('trouble22478_12DIV_nodrug_01.spk');
% x1.time = x1.time(~ismember(x1.channel,[52 55 60])==1);
% x1.unit = x1.unit(~ismember(x1.channel,[52 55 60])==1);
% x1.threshold = x1.threshold(~ismember(x1.channel,[52 55 60])==1);
% x1.waveform = x1.waveform(:,~ismember(x1.channel,[52 55 60])==1);
% x1.channel = x1.channel(~ismember(x1.channel,[52 55 60])==1);
% x2 = loadspk('trouble22468_13DIV_40uM-CNQX-ChR2-stim-CL_02.spk');
% %x3 = loadspk('usain22493_14DIV_wash4.spk');
% 
% time = [x1.time; max(x1.time)+x2.time];
% channel = [x1.channel; x2.channel];
% waveform = [x1.waveform x2.waveform];
% threshold = [x1.threshold; x2.threshold];
% unit = [x1.unit; x2.unit];
% 
% timestamps = [max(x1.time) max(x1.time)+max(x2.time)];
% 
% save trouble22468_12-14DIV_spkwaveforms time channel unit waveform timestamps;
% 
% 
% %% No manipulation of spikes
% clear all;
% spkdat = load('trouble22468_12-14DIV_spkwaveforms.mat');
% SS = SqueakySpk('trouble22468_12-14DIV_DoublePeakSortNR',2500,1/1200,spkdat);
% SS.Save;


%% Wavelet Approach
clear all;
spkdat = load('trouble22468_12-14DIV_spkwaveforms.mat');
SS = SqueakySpk('trouble22468_12-14DIV_WaveletSort',2500,1/1200,spkdat);
SS.WaveClus(3,50,[],0,1)
SS.Save;


%% PCA Approach
clear all;
spkdat = load('trouble22468_12-14DIV_spkwaveforms.mat');
SS = SqueakySpk('trouble22468_12-14DIV_PCASort',2500,1/1200,spkdat);
SS.WaveClus(3,50,'pca',0,1)
SS.Save;