In [ ]:
using SpikeSorting
In [ ]:
detect=DetectPower();
cluster=ClusterOSort();
align=AlignMax();
feature=FeatureTime();
reduce=ReductionNone();
thres=ThresholdMean();
num_channels=20;
s1=create_multi(detect,cluster,align,feature,reduce,thres,num_channels);
The data structures that contain the detected spikes and input voltages are separate from the sorting structure to facilitate integration with other software. The output_buffer method will create the data structure that hold:
The idea is that these buffers will be wiped after each iteration of online sorting.
In [ ]:
(buf,nums)=output_buffer(num_channels);
Before sorting, there are several types of calibration that need to occur. First, the very first iteration will initialize all methods that need some kind of starting values. Then, the thresholds for detection need to be calculated. Then any candidate spikes that are detected may need to be used to calibrate dimensionality reduction or clustering steps.
The cal! method will perform the appropriate stage of calibration based on the value of its last input as follows:
So for online use, a timer or iteration counter could be used so that time is spent in each of the appropriate calibration phases.
In [ ]:
v=rand(1:1000, 1000, num_channels); #Dummy voltage matrix
#First run
cal!(s1,v,buf,nums,0)
#Threshold calibration
cal!(s1,v,buf,nums,1)
#Clustering / DM calibration
cal!(s1,v,buf,nums,2)
In [ ]:
onlinesort!(s1,v,buf,nums);
In [ ]: