Developed by: Luka Zivkovic, and Srdjan Sumarac
Translational Neurophysiology and Brain Stimulation Lab
University of Toronto
University Health Network
Spooky Spikes is a Python-based analysis tool for extracting features from electrophysiological data obtained through microelectrode recordings. The following documentation outlines important points of instruction pertaining to the tool's installation and functionality.
For the installation and launch of the Spooky Spikes analysis tool, please follow the steps enumerated below.
You may create a shortcut targeting this final executable file to be displayed on your Desktop. The entire program folder may also be moved to any location. However, please ensure all files installed remain within the program folder. Otherwise, the application will not run.
Electrophysiological signals can be imported in the “Source Data” section of the main panel (Figure 1). Spooky Spikes supports importing data from Spike2 datafiles (*.smr, *.smrx), comma-separated values format (CSV; *.csv), and MAT-Files (*.mat). For file requirements pertaining to each file extension, please refer to Table 1.
Filetype | Requirements |
---|---|
Spike2 (*.smr, *.smrx) |
|
MATLAB (*.mat) |
|
Comma Separated Values (*.csv) |
|
After importing one of the supported filetypes, you will be able to select the signal contained within the file using the dropdown menu in the “Source Channel” section of the main panel on the left side of the dashboard (Figure 1). This menu will appear differently depending on the filetype selected. However, upon importing a file, the first signal found will be selected by default and displayed in the main tab.
This section will introduce various preparatory steps available on the “Main” tab and left panel, which are to be taken before all signal features can be computed and displayed. These include filtering, peak threshold selection, threshold inversion, and signal visualization.
By default, the filtering feature is disabled. To enable it, select the “Filtering” checkbox on the left panel in the “Parameters” section (Figure 1). This will allow the user to enter high-pass and low-pass frequency cutoffs for a fourth-order Butterworth filter that is applied to the imported signal. To utilize the frequency cutoffs for the filter, enter them into the corresponding widgets and press the “Set” button on the “Main” tab within the “Signal filtering” section. The signal will be updated on the main plot immediately upon setting cutoff frequencies. Please see Figure 2 for an example of setting frequency cutoffs in the correct dashboard sections.
If the user enters both high-pass and low-pass cutoffs, a bandpass filter design is applied. If only one of either a high-pass or low-pass cutoff is set, then a high-pass or low-pass filter design is applied, respectively. To disapply filtering and retain the raw data, users can either uncheck the “Filtering” checkbox, or clear the frequency cutoff entries, and press the “Set” button alongside empty widget boxes.
In order for various spike-dependent features to be computed, a threshold-crossing method is first applied to detect peaks of action potentials within the electrophysiological data. Within the “Threshold” section of the “Main” tab, the user can enter a scaling factor that is applied to the median absolute deviation (MAD) of the data. Press “Set” within the same section to apply the factor and calculate the threshold (Figure 2). Spike peaks will be computed immediately and will be available for visualization. If no threshold is set, features requiring a spike-train will not be computed and displayed on the “Features” tab.
It must also be noted that setting a threshold to detect spiking is a necessary prerequisite for analysis methods such as spike sorting (see Section 2.3).
For some electrophysiological data, depending on the system one uses, spiking can occur in either the anodic (upward—positive) or cathodic (downward—negative) direction. Users can adjust the threshold detection direction such that it matches their data. By default, the threshold and detection of peaks is applied in the cathodic direction. However, click the “Invert Threshold” checkbox on the left panel in the “Parameters” section to apply this feature in the anodic direction.
On the “Main” tab, the signal the user has selected will appear in time-series format on the graph. The “Plot Display” section of the “Main” tab includes three checkboxes, all of which provide additional flexibility for visualizing spiking within the signal. The “Spike Train” checkbox will show the locations of the spikes as an event-plot above the main signal. “Event Peaks” will display the spike peaks overlayed on top of the main signal within the main plot. Finally, “Threshold Bar” will present a fixed dotted line at the amplitude corresponding to the threshold for peak detection. It must be noted that all three of the available display features enumerated in this paragraph only become available after a threshold has been set, since a threshold is the necessary condition for peak detection. Additionally, users can zoom in and out, move the signal, and save the figure using the toolbar at the bottom of the tab, directly below the plot. Please see Figure 2 for an example of the utilization of all three visualization methods.
Spooky Spikes includes spike sorting capabilities. Users can select between various clusters of noise and spikes to isolate the activity of interest and refine their analyses. This spike sorting method consists of a principal component analysis followed by k-Means clustering. The first two principal components are displayed on the “Spike Sorting” tab. Additionally, users may refine their spike sorting results by manually selecting the fixed number of clusters used to fit the data on the same tab under the “Number of Clusters” heading (Figure 3). Otherwise, the number of clusters is automatically determined based on optimal clustering performance using a silhouette score as a quality metric. The silhouette score for the selected cluster is displayed on the “Features” tab.
Following spike sorting, features are re-calculated based on the selected cluster. The selected cluster is then displayed on the dropdown menu in the “Select Cluster” section of the “Main” tab. By default, the cluster with spike peaks possessing the highest average amplitude is selected. Within the same tab, the spike waveforms corresponding to the selected cluster are displayed on the main plot as distinctly coloured compared to the rest of the signal (Figure 4). As users select different clusters, signal features are re-calculated according to the cluster that has been chosen. This processing method offers an efficient means of isolating different activity and dynamically computing signal characteristics.
Following the fulfillment of the necessary preparatory requirements, features are calculated dynamically and presented in the form of numerical displays as well as figures. Additionally, as previously noted in various places, features are dynamically calculated depending on the method used for detecting spike peaks. As users switch between methods (threshold-crossing versus spike sorting), or even alter clustering parameters (number of clusters and selected cluster), the features will be re-computed accordingly. This must be considered, since small alterations in user-selected parameters can drastically change the results obtained from Spooky Spikes.
Those signal features which are numerically formatted are displayed on the “Features” tab, and correspond to the following categories: patterned, quality metrics, spike-train oscillations, and local field potential (LFP) power (Figure 5). It must be noted that if a simple threshold-crossing method is used to calculate spikes and thus, features, then the silhouette score will not be available, since this is a quality metric pertaining to the clustering algorithm used in spike sorting. Furthermore, all characteristics within the LFP category do not require the detection of spiking peaks to be computed, but are calculated and displayed immediately upon importation of the source datafile, and/or selection of the source channel.
The final component of signal feature display involves four different figures, all of which are available on the “Features” tab under their corresponding sections (Figure 5). The first figure (“ISI Plot”) displays a histogram of log-inter-spike-interval durations. A Gaussian mixture model is fitted to the data and displayed, along with the component Gaussian curves (Figure 6A). Next, the “Oscillations Plot” presents spike-train oscillations at four different frequency bands with highlighted bursting regions (Figure 6B). The “LFP Plot” shows the signal’s power spectral density on the leftmost graph of the pop-up window, followed by LFP oscillations over time at four different frequency bands with highlighted bursting regions (Figure 6C). Finally, "Autocorrelation Plot" reveals the signal's autocorrelation up to a 0.5-second lag. Additionally, the power spectrum at four different frequency bands is displayed (Figure 6D).
Spooky Spikes allows users to save the results of their analysis. All save options can be found on the main left panel of the application under the “Export” heading (Figure 7). First, users can save the numerical features extracted from the electrophysiological signal to a spreadsheet. Each feature corresponds to a distinct column while the first row is populated by the resultant features. Furthermore, the signal segment can be saved along with the timestamps of individual spikes found either by threshold-crossing or spike sorting. The “Save Segment (All Spikes)” option will save the imported signal and all spiking timestamps as events in separate channels, or columns depending on the filetype used at the save. Additionally, “Save Segment (Selected Cluster)” will save the imported signal and only the timestamps of spikes belonging to the selected cluster following spike sorting.