This is a work-in-progress literal Python port of the original MATLAB version of Kilosort 2, written by Marius Pachitariu. The code is still being debugged and is not ready for use.
Preprocessing functions and standardization of outputs
Kush Banga, Cyrille Rossant, Olivier Winter
The code makes extensive use of the GPU via the CUDA framework. A high-end NVIDIA GPU with at least 8GB of memory is required.
A good CPU and a large amount of RAM (minimum 32GB or 64GB) is also required.
See the Wiki on the Matlab version for more information.
You will need NVIDIA drivers and cuda-toolkit installed on your computer too. This can be the hardest part of the installation. To test if your is working OK you should be able to run the following:
nvidia-smi # Should show how much your GPU is being used right now
nvcc # This is the CUDA compiler
Only on Linux, first install fftw by running the following
sudo apt-get install -y libfftw3-dev
Navigate to the desired location for the repository and clone it
git clone -b drift_test_stable https://github.com/kushbanga/pykilosort.git
cd pykilosort
Create a conda environment
conda env create -f pyks2.yml
conda activate pyks2
conda develop .
Errors with the CUDA installation can sometimes be fixed by downgrading the version of cudatoolkit installed. Currently tested versions are 9.2, 10.0, 10.2, 11.0 and 11.5
To check the current version run the following:
conda activate pyks2
conda list cudatoolkit
To install version 10.0 for example run the following
conda activate pyks2
conda remove cupy, cudatoolkit
conda install -c conda-forge cupy cudatoolkit=10.0
This is how to run for general users
from pathlib import Path
from pykilosort import run, add_default_handler, np1_probe, np2_probe
# Run standard ks2.5 algorithm for a np1 probe
data_path = Path('path/to/data/data.bin')
dir_path = Path('path/to/output/folder') # by default uses the same folder as the dataset
add_default_handler(level='INFO') # print output as the algorithm runs
run(data_path, dir_path=dir_path, probe=np1_probe())
# Run chronic recordings for a np2 probe
# For now this still uses ks2.5 clustering, chronic clustering algorithm coming soon!
data_paths = [
Path('path/to/first/dataset/dataset.bin'),
Path('path/to/second/dataset/dataset.bin'),
Path('path/to/third/dataset/dataset.bin'),
]
dir_path = Path('path/to/output/folder') # by default uses the same folder as the first dataset
add_default_handler(level='INFO')
run(data_paths, dir_path=dir_path, probe=np2_probe(), low_memory=True)
This is how to run for NP1.0 probe (for IBL)
import shutil
from pathlib import Path