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
|Snippets (optional)||Timestamped spike waveforms|
|Stream (optional)||Plot decimated waveforms|
|Main||Filtered, multi-channel floating point signal|
|Sort Codes||Multi-channel integer signal containing compressed sort codes|
Gizmo Help Slides
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.
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.
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.
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
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:
|Tool Buttons||Performs actions that are global to all channels.|
|Threshold Display||Displays the plot decimated waveform of the currently selected channel and the threshold marker. When automatic threshold tracking is active the threshold bar is locked.|
|Channel Selector||Selects the active channel and indicates channel status. Gray indicates the channel is locked and sorting parameters can't be changed.|
|Pile Plot||Displays candidate spikes for the active channel. Indicators in the bottom left corner denote scaling and threshold tracking states ('A' for automatic, 'M' for manual). Hold down the Ctrl key and double-click to add time-voltage windows.|
|Multi-Channel Display||Displays a pile plot for each channel. The channel number is shown in the bottom right corner of each subplot and new waveforms are highlighted as they are added to the plot. Clicking a subplot makes that channel the active channel for other plots on the tab. Indicators in the bottom left corner denote scaling and threshold tracking states.|
|Unit Display||Displays a single channel of candidate waveforms by unit - each plot displays all waveforms classified with a single sort code.|
|Settings Sidebar||Includes settings for display options, filtering, and threshold settings.|
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.
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.
|Show Channels||Select the number of channels to display in the Multi-Channel Display.|
|Pile Depth||Enter a number to set the maximum number of events displayed in pile plots. The oldest waveform traces are removed as new events are added.|
|Clear on fill||Select the check box to refresh plots, clearing all traces for a given channel whenever the pile depth is reached on that channel.|
|Mon Level||Slide the indicator to adjust the level of the audio monitor output, when enabled.|
|Bypass Gate||A noise gate on the audio monitor removes background noises so only the spikes are heard. Select this check box to turn off the noise gate.|
|HighPass/LowPass||Set the highpass and lowpass digital filter settings. The filter is applied to the data before threhsolding, sorting, or visualization|
|Level||Set the automatic threshold level for spike detection, in number of standard deviations from the baseline.|
|Polarity||Set automatic threshold search polarity, either positive or negative.|
|Peak Align||If enabled, aligns spikes according to their peak values, altering the timestamp of the snippet.|
|Art Reject||When artifact rejection is enabled in the configuration options, sets the artifact rejection level in microvolts. If any sample of the candidate waveform is above this level, the waveform is ignored.|
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.
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.
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
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 Options Tab|
Drag slider to select the desired width (displayed in milliseconds and samples) of recorded snippets.
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.
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.
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.
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 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 Options Tab|
Monitor DAC Channel
Select an output channel to send the monitor signal to, or set to Disable to turn monitoring off.