Box Spike Sorting
Common Use Cases
Real-time filtering, spike detection, and discrimination of neural signals using time-voltage windows. Use this gizmo to sort neuronal spikes on individual channels using time-voltage discrimination windows
Gizmo Help Slides
Reference
The Box Spike Sorting gizmo performs filtering, thresholding and online time- voltage spike sorting and storage on multi-channel neural signals at sampling rates up to 50 kHz.
Data Storage
This gizmo generates two types of data for storage: snippet data (includes timestamp, short waveform, and sort code) and plot decimated data streams. The stream data generated by this gizmo is a highly decimated version of the waveforms that keeps local maximum and minimum values of the filtered signals, which makes it ideal for visualizing high frequency spike activity on a computer monitor with a fixed number of pixels.
In plots and in the data tank, each type of data is designated with a prefix: 'e' for snippets and 'p' for streams. You can opt to save only snippets or to disable storage in the gizmo's configuration settings. The sort codes can be configured as an output to be used in other gizmos.
Threshold Detection
At runtime, candidate spikes are detected based on a calculation of the deviation of a waveform from its RMS. By default, the timestamp and position of the waveform in the snippet is dependent on the time of the threshold crossing for the signal. An alternative setting allows waveform timestamp and positioning to be determined by the waveform's highest peak, aligning snippets to their respective peaks. By default, detection is automated and you can make adjustments in the threshold control plot in the runtime window.
Spike Sorting
A runtime window tab offers manual sorting using time-voltage box pairs to classify potential units among candidate waveforms. When satisfied with the sorts for all channels, the user can choose to apply Hardware Sorts. The sorting parameters are sent to the hardware and sort codes will be applied to new data as it is acquired in real-time. This toolbar button must be 'pressed' for online sorting to take place on the hardware.
The Runtime Interface
Runtime Plot
Streamed waveform and Snippet plots are added to the runtime window for visualization.
Box Spike Sorting Tab
Box Spike Sorting Window |
The runtime window includes:
Simple Zoom
You can zoom any plot to see more or less detail without affecting the actual data.
To change the zoom level, hold down the Shift key and click-and-drag the pointer up or down.
To reset the zoom level, hold down the Shift key and double-click within the display area.
Display Scale
To make it easier to see waveform shapes for channels with lower magnitude, you may scale individual channels manually or normalize all channels to fit to a similar scale, all without altering the data being stored.
To normalize all channels, click the Auto Scale button in the toolbar and choose to normalize the display. Each channel is scaled individually to fit around 80% of the signal's vertical size in each plot. An up or down arrow is displayed in the bottom left corner of the plot or subplot to indicate whether the display has been scaled up or down. This does not change the scale of the feature space.
To adjust the scale of a single channel, press and hold down the Ctrl key, and click-and-drag the mouse up or down in the multi-channel display. While adjusting the display scale, the numeric value in the lower right corner of the channel plot indicates the new scale value.
To reset the scale for all channels, click the Reset Base Scale button. This does not remove any zoom applied to a plot.
To return a single channel to its base scale, right-click the desired channel and select Reset Scaling from the menu.
Settings Sidebar
Threshold Control
Click the Auto Threshold button to initiate automatic threshold tracking on all unlocked channels. If Auto Thresholding is enabled in the designtime interface, real-time tracking will begin on all channels, otherwise the channels will remain in manual threshold mode and the threshold will be set based on a one-time calculation using the current window data and the Thresholding Level and Polarity settings.
Click the Manual Threshold button to enable manual thresholding on all unlocked channels. In manual threshold mode, the threshold bar may be adjusted by clicking and dragging the white bar in the threshold display window (shown below) or in the pile plot.
Threshold Display in Manual Mode |
You can also right-click the plot at the desired threshold location and choose Set Threshold Here from the menu to move the threshold to that location on one channel. You have the option to apply this new location to all channels in manual thresholding mode.
Right-click the pile plot or threshold display and use the auto/manual threshold options to change the threshold mode of an individual channel.
Box Sorting Using the Pile Plot
Pair of color-coded boxes (one solid and one dotted) are used to classify each unit. In order to be classified as a particular unit, the following is required:
-
Candidate waveforms must enter the solid box only one time.
-
Candidate waveforms must contain data points that pass through both boxes in the pair.
-
One digitized point of the candidate waveform must exist in each box.
Box Sort Waveform Space
To add a box pair:
- Press and hold the Ctrl key and double-click to add a new box pair to the pile plot.
A sort code is automatically assigned to the newly added box pair. Click and drag the vertices to adjust the boundaries of the boxes or to move it. To remove a pair of boxes, drag one of the boxes outside of the vertical boundaries of the plot and release.
Important
If a waveform passes through more than one box pair, sort code priority is assigned based on the sort code number. This means that the lower sort code will win in the event that a waveform passes through more than one box pair.
Applying Sorts to New Data
Sort codes are not saved to the data tank until you apply the sorting parameters. You can re-sort or make adjustments as needed to get the best results.
Click the Hardware Sort button to send the sorting parameters to the hardware and begin saving sort codes to the tank. Sort codes are applied as new data is acquired. While this button is down, changes in sorting parameters in the display will be applied automatically to new data.
Locking Channels
Click the Lock All button to lock the boxes for all channels, or right-click individual channels and choose Lock.
Click the Unlock button to unlock all channels, or right-click individual channel plots and choose Unlock.
The Unit Display
Unit Display |
In the unit display, candidate waveforms from the currently selected channel are grouped by sort code. Unsorted (sort code 0) and outlier (sort code 31) waveforms are displayed to the left with the label NS.
The maximum number of sort codes (up to five) that can be sorted on the hardware is determined by the Max Sorts configuration setting. Assigned sort codes larger than this value are displayed in red to indicate they are only visible in the software interface. These waveforms will be given a sort code of 31 (outlier) in the data tank.
The unit display can be used to reassign units to different sort codes by clicking-and-dragging the units.
Box Spike Sorting Configuration Options
Sorting Tab
Sorting Options Tab |
Snippet Width
Drag slider to select the desired width (displayed in milliseconds and samples) of recorded snippets.
Max Sorts
Events that contain similar shapes are grouped into sorts and given the same sort code. The maximum number of sorts supported in hardware sorting is five. Allowing a larger number of sorts increases processing overhead, but accommodates greater variability in the data set.
Auto Thresholding
In automatic thresholding, the threshold used to record snippets is adjusted in real-time to changes in each channel waveform's RMS. The previous five seconds of data are used in the RMS calculation.
Artifact Rejection
When artifact rejection is enabled, snippets that contain at least one sample greater than the artifact rejection level set on the runtime interface are ignored.
Real-time Sort Code Output
Make the multi-channel integer stream of compressed sort codes available to other gizmos, such as Sort Binner or UDP output.
Note: The sort code output is delayed by (window width + 2) samples from when the threshold is crossed. When artifact rejection is enabled, the sort code output is delayed by an additional window width, so (2 * window width + 2) total samples.
Filtering Tab
The gizmo applies a highpass and lowpass filter to all channels before spike detection. The runtime interface includes controls for dynamic adjustments to the filter settings. You also set default values in the Filtering tab.
Filtering Options Tab |
Storage Tab
Storage Tab Options |
Save Options
Select whether to save only snippet waveforms or to include the plot decimated waveforms used by the sorting gizmo, or to save nothing at all. The waveforms will still be displayed in the runtime interface and data plots but will not be saved to disk.
Misc Tab
Misc Options Tab |
Monitor DAC Channel
Select an output channel to send the monitor signal to, or set to Disable to turn monitoring off.