elduvelle / SpikeinterfaceMS4_GenzelLab

MIT License
0 stars 0 forks source link

How-to: spike-sort Trodes data with Mountainsort4 and Phy

Disclaimer: code is not guaranteed to work! Use it at your own risk

UPDATE: more recent installation attempts fail at the pip install mountainsort4 phase. There might be a problem caused by Visual studio compiling (??). I have listed a few of the errors and solution attempts in this other page. PLEASE let me know if you find a solution to make this work on Windows (10 or 11).

Note: these instructions work on Linux (Ubuntu 18.04). Note: these instructions also work on Windows Subsystem for Linux (WSL). See further down for instructions on how to install that.

Installation

Installation of Spikeinterface, Mountainsort and Phy on Windows 10

Create a new environment, Python needs to be >=3.7

conda create --name name_of_your_environment

Activate your environment

conda activate name_of_your_environment

install your IDE (I use idlex)

pip install idle
pip install idlex

for spikeinterface installation

pip install spikeinterface[full]==0.93

for phy (as indicated on this page

pip install phy --pre --upgrade 

For Mountainsort4 in spikeinterface

pip install mountainsort4

if this step fails, it means you need to do the following and then run pip install mountainsort4 again:

Option 1:

pip install git+https://github.com/magland/isosplit5_python.git`

(you might have to do pip install git separately first, if git is not already installed; OR conda install -c anaconda git if pip install git doesn't work)

Option 2: Clone the isosplit5 repo, cd to it, install it with the setup.py file using the command (note, it might throw some deprecation warnings; see this issue):

python setup.py install

All necessary modules should now be installed!

Installation of Spikeinterface, Mountainsort and Phy on Windows 10 using Windows Subsystem for Linux (WSL)

If the instructions above didn't work... all hope is not lost! You can try to install the pipeline using the WSL which mimics a Linux environment without having to actually install Linux. How-to:

  1. Install WSL following the instructions here - in more details, in a console run as administrator run:
wsl --install
  1. Create the account & password
  2. Install miniconda as explained here:

3.1. Make sure you move to a folder that you have writing access to, like /home/your_user_name/ by doing cd path_to_that_folder

3.2 Download the miniconda installer

wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh

3.3. Run the installation, follow the instructions

bash Miniconda3-latest-Linux-x86_64.sh

3.3. Close and reopen

  1. Install 'C++ tools':
    sudo apt install build-essential

And then you should be able to go back at the top of this readme and follow the general installation instructions.

Usage

To export the data from Trodes: navigate to the Trodes folder and then type

`trodesexport -mountainsort -rec <full path to rec file ending in .rec> -sortingmode 1`

Note, if using Linux, do instead:

`./trodesexport -mountainsort -rec <full path to rec file ending in .rec> -sortingmode 1`

(this will create 1 '.mda' file per tetrode, which is what Mountainsort expects)

2 options to run the code:

Note 1: you'll have to be in the right conda environment!

Note 2: this will create 1 subfolder (output_Tx) per tetrode where X is the tetrode number. It will use the inbuilt function of spikeinterface to run mountainsort and export to phy the result.

Once the main code has run: 3 options for the manual refinement with Phy:

Note for linux: I had an error related to numpy ('np.bool is deprecated'). I fixed it by downgrading numpy in that environment:

python -m pip uninstall numpy
python -m pip install numpy==1.23.1

Additional resources:

Credits: Adrian Aleman & Kayvan Combadiere from the Genzel lab

Disclaimer: code is not guaranteed to work! Use it at your own risk