clear all;
x1 = loadspk('trouble22467_12DIV_nodrug_01.spk');
x2 = loadspk('trouble22467_13DIV_40uM-CNQX_01.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 trouble22467_12-14DIV_spkwaveforms time channel unit waveform timestamps;

%% No manipulation of spikes
clear all;
spkdat = load('trouble22467_12-14DIV_spkwaveforms.mat');
SS = SqueakySpk('trouble22467_12-14DIV_DoublePeakSortNR',2500,1/1200,spkdat);
SS.Save;


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


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