spikesorting
Automatic and manual spike sorting based on SpikeInterface
Science Score: 26.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
○CITATION.cff file
-
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
○DOI references
-
○Academic publication links
-
○Academic email domains
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (13.6%) to scientific vocabulary
Keywords
Repository
Automatic and manual spike sorting based on SpikeInterface
Basic Info
Statistics
- Stars: 2
- Watchers: 1
- Forks: 1
- Open Issues: 12
- Releases: 0
Topics
Metadata Files
README.md
SpikeSorting: Object Space Task Pipeline
Automatic and manual spike sorting for tetrode recordings based on SpikeInterface.
Dependencies
Same as SpikeInterface
Important: This pipeline uses the SpikeInterface version from 2020. Compatibility has not been tested with newer versions.
Please install each sorter as described here:
SpikeInterface Sorter Installation Guide
If the method above causes issues, try these detailed installation instructions (PDF).
When using Matlab-based sorters, save them in:
~/Documents/SpikeSorting/
To be used on Linux . Add this folder to your path temporarily:
bash
export PYTHONPATH=$PYTHONPATH:/path/to/this/folder
To make it permanent, paste it into your bashrc:
bash
gedit ~/.bashrc
Spike Sorting Pipeline
1. Activate your conda environment
bash
conda activate <Name of environment>
2. Check for corrupt or uneven length files
bash
python -m check_length /full/path/to/folder_with_Study_day_subfolders
Ensure trial folders dont have duplicate channel files like
100_CH1.continuousand100_CH1_2.continuous.
3. Select trials or merge trials (Trial1 + PostTrial1 or full-day)
Use merge_channels_revised_T1_PT1.m or merge_channels_revised.m in MATLAB.
Ensure correct sampling rate (fs):
- Rats 19 used 20kHz, not 30kHz.
Check folders variable in the MATLAB script and make sure it lists the correct trial folders in the right order.
Refer to the file:
RAT_OS_EPHYS_Channel_Normalization_Across_Animals.xlsx (Dropbox)
Run merging twice:
1. Trial1 + PostTrial1
2. Presleep + T1 + PT1 + + T5 + PT5 (+ Novelty trial if applicable)
Refer to this Google Planning Sheet
Generate hpc.xlsx and cortex.xlsx with tetrode IDs and channel info.
Skip tetrodes with only 1 channel or reference tetrodes.
4. Fix file names if needed
bash
python -m fix_channel_name /path/to/continuous_files
Copy the following files from the same study day (any trial or post-trial folder):
all_channels.eventsContinuous_Data.openephysmessages.eventssettings.xmltetrode.prb(same for all rats)hpc.xlsxandcortex.xlsx(omithpc.xlsxif not sorting HPC)
Work locally! Copy the merged folder to your computer's data hard drive.
5. Rearrange data by tetrode
bash
python -m rearrange_folders /path/to/merged_data
If only sorting cortical tetrodes, ensure rearrange_folders.py uses:
python
folders = ['cortex']
Instead of:
python
folders = ['hpc', 'cortex']
6. Run automatic spike sorting
bash
python -m run_tetrodes /path/to/brain_region_folder_with_tetrodes
Prefer using Spyder (prevents crashes):
bash
conda activate spiketutorial
spyder
In Spyder:
- Load run_tetrodes.py
- Set the correct path in the folder variable
- Press Ctrl+A then F9 to run the script
7. Create JSON for consensus
bash
python -m create_json /path/to/brain_region_folder
Copy JSON files to the respective brain area folders of the full-day merged folder.
To run manual curation:
bash
python -m run_tetrodes_manual /path/to/brain_region_folder_with_tetrodes
8. Manual curation with Phy
During manual curation:
- Alt+N = Noise
- Alt+M = MUA
- Alt+G = Pyramidal unit
- Leave unlabeled = Interneuron
Always save first, then close. If you close first and then save, your curation won't be saved.
9. Activation matrix & consensus post-curation
Both scripts (run_tetrodes.py or run_tetrodes_manual.py) create a phy folder with:
spike_times.npyspike_clusters.npy
You can generate activation matrices (25 ms bins) as actmat_auto_tetrode#.
To concatenate and detect assemblies:
bash
python -m phy2assembly
To view previous detections:
bash
os.system('phy template-gui phy_AGR/params.py')
Post-curation consensus:
bash
python -m consensus_post_curation /path/to/tetrode_folder
10. Quality Metrics
bash
python -m quality_metrics
Requires:
bash
conda env create -f environment_qm.yml
conda activate spiketutorial_qm
Running in Spyder
- Open
run_tetrodes.py - Press
Ctrl+A, thenF9
Running in Linux Terminal (Adrian's PC only)
bash
./loop
This calls run_tetrodes_brain_areas.py in a loop.
Download loop.sh rename to loop.
Add loop to your PATH in ~/.bashrc.
Modify sorter.py: add exit() to the end of ms4() and auto() functions.
Reading corrupted Open Ephys files
Navigate to:
/home/Username/anaconda3/envs/spiketutorial/lib/python3.6/site-packages/pyopenephys
Modify:
Newest scripts (yet to be described)
run_tetrodes_brain_areas.pyrun_tetrodes_json.pyrun_tetrodes_loop.pytruncate2.py
Owner
- Name: Adrián Alemán-Zapata
- Login: Aleman-Z
- Kind: user
- Location: Nijmegen, The Netherlands.
- Company: @Donders-Institute
- Website: http://www.linkedin.com/in/adrián-alemán-zapata-b1b727b2
- Repositories: 2
- Profile: https://github.com/Aleman-Z
PhD Candidate @ Donders Institute for Brain Cognition and Behaviour.
GitHub Events
Total
- Watch event: 1
- Push event: 4
Last Year
- Watch event: 1
- Push event: 4
Dependencies
- _libgcc_mutex 0.1
- alabaster 0.7.12
- argh 0.26.2
- astroid 2.4.2
- async_generator 1.10
- atomicwrites 1.4.0
- attrs 20.2.0
- autopep8 1.5.4
- babel 2.8.0
- backcall 0.2.0
- brotlipy 0.7.0
- ca-certificates 2020.10.14
- certifi 2020.6.20
- chardet 3.0.4
- cloudpickle 1.6.0
- cryptography 3.1.1
- cudatoolkit 11.0.221
- dbus 1.13.16
- decorator 4.4.2
- diff-match-patch 20200713
- docutils 0.16
- expat 2.2.9
- flake8 3.8.3
- fontconfig 2.13.0
- freetype 2.10.2
- future 0.18.2
- glib 2.65.0
- gst-plugins-base 1.14.0
- gstreamer 1.14.0
- icu 58.2
- idna 2.10
- imagesize 1.2.0
- importlib-metadata 1.7.0
- importlib_metadata 1.7.0
- intervaltree 3.1.0
- ipykernel 5.3.4
- ipython 7.16.1
- ipython_genutils 0.2.0
- isort 5.5.3
- jeepney 0.4.3
- jinja2 2.11.2
- jpeg 9b
- jsonschema 3.2.0
- jupyter_client 6.1.7
- jupyter_core 4.6.3
- jupyterlab_pygments 0.1.1
- keyring 21.4.0
- lazy-object-proxy 1.4.3
- ld_impl_linux-64 2.33.1
- libedit 3.1.20191231
- libffi 3.3
- libgcc-ng 9.1.0
- libpng 1.6.37
- libsodium 1.0.18
- libspatialindex 1.9.3
- libstdcxx-ng 9.1.0
- libuuid 1.0.3
- libxcb 1.14
- libxml2 2.9.10
- markupsafe 1.1.1
- mccabe 0.6.1
- mistune 0.8.4
- nbclient 0.5.0
- nbformat 5.0.7
- ncurses 6.2
- nest-asyncio 1.4.0
- numpydoc 1.1.0
- openssl 1.1.1h
- packaging 20.4
- pandoc 2.10.1
- pandocfilters 1.4.2
- pathtools 0.1.2
- pcre 8.44
- pexpect 4.8.0
- pip 20.2.2
- pluggy 0.13.1
- prompt-toolkit 3.0.7
- psutil 5.7.2
- pycodestyle 2.6.0
- pycparser 2.20
- pydocstyle 5.1.1
- pyflakes 2.2.0
- pygments 2.7.1
- pylint 2.6.0
- pyopenssl 19.1.0
- pyparsing 2.4.7
- pyqt 5.9.2
- pyrsistent 0.17.3
- pysocks 1.7.1
- python 3.6.12
- python-dateutil 2.8.1
- python-jsonrpc-server 0.4.0
- python-language-server 0.35.1
- pytz 2020.1
- pyxdg 0.26
- qdarkstyle 2.8.1
- qt 5.9.7
- qtawesome 0.7.2
- qtconsole 4.7.7
- qtpy 1.9.0
- readline 8.0
- requests 2.24.0
- rope 0.17.0
- rtree 0.9.4
- secretstorage 3.1.2
- setuptools 49.6.0
- sip 4.19.8
- six 1.15.0
- snowballstemmer 2.0.0
- sortedcontainers 2.2.2
- sphinx 3.2.1
- sphinxcontrib-applehelp 1.0.2
- sphinxcontrib-devhelp 1.0.2
- sphinxcontrib-htmlhelp 1.0.3
- sphinxcontrib-jsmath 1.0.1
- sphinxcontrib-qthelp 1.0.3
- sphinxcontrib-serializinghtml 1.1.4
- spyder 4.1.5
- spyder-kernels 1.9.4
- sqlite 3.33.0
- testpath 0.4.4
- tk 8.6.10
- toml 0.10.1
- tornado 6.0.4
- traitlets 4.3.3
- typed-ast 1.4.1
- ujson 3.2.0
- urllib3 1.25.10
- watchdog 0.10.3
- wcwidth 0.2.5
- wheel 0.35.1
- wrapt 1.11.2
- wurlitzer 2.0.1
- xlrd 1.2.0
- xz 5.2.5
- yaml 0.2.5
- yapf 0.30.0
- zeromq 4.3.2
- zipp 3.1.0
- zlib 1.2.11