gebaSpike: Python Spike Sorting Package (Tint/Axona Data) Draft

Posted by Geoff, Published: 5 years, 5 months ago (Updated: 5 years ago)

If you are recording electrophysiology data, you will at one point likely have to perform some spike sorting. Spike sorting is when the user distinguishes the activity of various neurons from the background activity (or from the spiking activity of other cells). There are many ways that spike sorting is performed, it can be entirely manual where the user is visualizing the spikes in feature space, the user selects their Regions of Interest (ROI), and assigns a cell ID to that ROI. Other methods boast about being entirely automated, where the data is brought into a, sometimes proprietary, algorithm that likely analyzes various features of the spike data in high dimensional space and classifies the spikes into discrete cell ID's based off of the variance (generally using Principal Component Analysis). Although these tools boast about being "fully automated", there still tends to be some manual cleaning of the cells. Some of these algorithms are bad at combining similar cells, and thus you will have to look at the data, and manually combine these cells. Other algorithms love to combine two discrete cells, and you have to go into the data and separate them.

If you are recording Axona1 data, you will likely be familiar with the Tint method for sorting, which involves a lot of time where the end-user is manually drawing ROI's onto this two-dimensional feature space and hoping that the pesky spikes that don't belong are discarded. As someone who was previously an Offline Sorter (Plexon)2 user, this Tint method doesn't feel satisfactory. Therefore, I have created gebaSpike, a Python Graphical User Interface for spike sorting Axona/Tint data. Instead of having to repeatedly use Tint's ROI + V(t) functionality to remove spikes, I have created a GUI where you can draw a line segment over the cell's waveform and remove any spikes that intersect with the drawn line segment. This is a direct, and I'd argue a more efficient way to remove noise masquerading as a spike within your data.

Keep note, this is a newly developed software that is very minimal in features that it provides. I didn't feel the need to replicate much of the functionality that Tint does well, so I use this program in concert with Tint. You can simply overwrite the .cut files using gebaSpike, and re-load the cut file in Tint to almost seamlessly visualize the effects. 

Requirements

  • Operating System (OS): gebaSpike does not have any OS requirements. Tint requires Windows, thus I will recommend using Windows. Especially since I developed the software using Windows so that is what it was tested with. Axona lists their compatible Windows versions3, however I do not believe this list is complete as I run Tint on Windows 10 perfectly.
  • Python: this code was written using Python 3.7, the compatibility is dependent on PyQt5, which is said to be compatible with Python 2.6+. As I mentioned, I wrote this using Python 3 so I suggest using the latest Python version4.

Python Dependencies

  • gebaSpike
  • Matplotlib
  • NumPy
  • PyOpenGl
  • PyQt5
  • PyQtGraph
  • Scikit-Learn
  • SciPy

Installation

  1. I have uploaded gebaSpike to PyPI, therefore you can simply use the pip module to install, for example:
    python -m pip install gebaSpike
  2. Once the installation has finished, you can simply use the following command to launch the GUI:
    python -m gebaSpike
  3. If launched properly, you should see the Main Window of gebaSpike shown below:
  4. Alternatively, the code lives in a gebaSpike GitHub repository5, feel free to download it locally by using the following git command:
    git clone "https://github.com/GeoffBarrett/gebaSpike.git"

Updates

Version 1.0.9 - 09/04/2019

  1. Alternate Cut Button: previously the cutting was only executed with the middle mouse button, I have now added an alternative button for the user to press in case they are getting tired of using their right hand (this button is the tilde(~)/back-quote(`) button). If you wanted to change this button, feel free to do so, it is set as the alt_action_button variable within the core/default_parameters.py file.
  2. Cut Function Refactoring: the cut functions were localized within the mouse_click_event, and mouse_click_eventPopUp functions for cuts made on the Main Window and the Pop Up Windows respectively. This made it slightly annoying as I would have to manage two functions in order to add/modify the way that gebaSpike executes cuts. I have since refactored the code to one dedicated function (cut_cell), this should make it easier if the code needs to be optimized. Note: the old functions were saved in the core/legacyCut.py file. I will likely remove this file in the next commit since the old functions are versioned in GitHub anyways.
  3. Multi-Session Compatibility: Added the ability for you to analyze .cut files that were created from combined sessions. You will have to manually choose your .cut file when using multiple sessions as there is no auto-generated filename, therefore I just made it manual. 
    1. Added some additional validation. The spike counts for the given tetrode number of all the chosen sessions will be summed and compared to the spike count within the .cut file. If they match, it is assumed that you chose the correct .set files + .cut file combination (also works with .clu files).
  4. Properly Closes Pop-ups: when you change sessions it would clear the plots, however you might notice that the pop-ups would remain. I have changed the reset_parameters functionality so that it would properly close all the Pop-Ups.
  5. Added Version to GUI: at the bottom of the main window you will see the current version number. 

Version 1.0.10 - 09/04/2019

  1. "Are You Sure?" Pop-up: There was a pop-up querying if you are sure that you want to re-plot the data (essentially erasing any work you have done). However, it shouldn't pop-up in the event that the user has changed tetrodes and wants to work on that new tetrode. Therefore I added some code that will compare the value in the Tetrode drop-down menu to tetrode that was plotted, and raise the pop-up accordingly.

References

  1. Axona's Company Website: http://www.axona.com
  2. Plexon's Offline Sorter: https://plexon.com/products/offline-sorter/
  3. Axona's Operating System Compatibility: http://axona.com/support/faq#S1
  4. Python's Downloads: https://www.python.org/downloads/
  5. gebaSpike GitHub Repository: https://github.com/GeoffBarrett/gebaSpike

Project Contents

gebaSpike: User Guide Draft

Now that you have installed gebaSpike, I will show you how you can go about using it. If you have not installed it, please see the installation instructions1. If you have any suggestions on features to add to gebaSpike, or bugs that you encounter, feel free to let me know. Keep in mind that this tool does not replace Tint. It simply was a quicker way for me to sort my cells, and thus it is missing some functionality that you get with Tint. I suggest using this in tandem with Tint. You can make …

Read More →

Comments

Post Comment