π Please cite the Peer Community Journal if you use the pipeline π β And star this repository! β
The Power Pixels pipeline combines several packages and workflows into one end-to-end pipeline. It supports Neuropixel 1.0 and 2.0 probes recorded on a National Instruments system using SpikeGLX or OpenEphys.
This pipeline is all about combining existing modules and pipelines into one, which is especially useful for people who are just starting out doing Neuropixel recordings and maybe have heard of all these tools but need some help getting them all integrated. Power Pixels relies on these amazing open-source projects:
The pipeline contains the following elements:
It is recommended to install Power Pixels in an Anaconda or Miniforge environment.
conda create -n powerpixels python=3.10 git (use mamba instead of conda when using Miniforge)conda activate powerpixels (or mamba)git clone https://github.com/NeuroNetMem/PowerPixelsPipelinecd PowerPixelPipeline) and install PowerPixels with the command pip install -e .iblapps by cloning the repository git clone https://github.com/int-brain-lab/iblapps and installing it with the command pip install -e iblappsTo install a spike sorter there are two options: (1) directly install Kilosort4 in the python environment, or (2) use Docker to run the spike sorter in a container. Note: if you want to use a MATLAB-based spike sorter (like Kilosort 2.5) you will have to pick option 2.
Option 1: local installation of Kilosort4
Kilosort4 is already installed with PowerPixels, what you'll have to do now is make sure it uses the GPU.
powerpixels environmentpip uninstall torchpip3 install torch --index-url https://download.pytorch.org/whl/cu118.ipython and typing import torch; torch.cuda.is_available(). If the result is True you are good to go. If it's False you need to make sure PyTorch can use CUDA, good luck! (ask AI to help you out)Option 2: run spike sorter in Docker
wsl --installThe tracing of fluorescent probe trajectories in 2D histological brian slices can be done with AP_Histology or [Universal Probe Finder]((https://github.com/JorritMontijn/UniversalProbeFinder). Both of these are MATLAB packages so unfortunatly you will need a MATLAB license for this. As far as I know there are no python-based packages for the tracing of probe trajectories in 2D brain slices.
After installing all the necessary components you can set up your pipeline for use.
conda activate powerpixels (or mamba)powerpixels-setupThe pipeline is in principle agnostic to how your data is organized at a high level. The session folder can have any name and can be located anywhere in your top level data directory. However, each session folder does need to abide by some formatting requirements. Inside each session folder there needs to be a raw_ephys_data folder in which should be the output folder of SpikeGLX or OpenEphys. For the pipeline to find which session folder to process you need to create a process_me.flag file and put it in the session folder.
βββ session_folder
| βββ raw_ephys_data
βββ process_me.flag
To facilitate the process you can run the helper function python scripts\prepare_sessions.py which creates the folders and flags for you (optional).
The data that comes out of the Power Pixels pipeline is (1) raw spike sorter output files (e.g. Kilosort files), (2) data files in ALF filenaming convention, and (3) an NWB file. A helper function is included to load in your neural data from powerpixels import load_neural_data.
Before starting a recording prepare the folder structure, either manually or by running python scripts\prepare_sessions.py.
Perform your Neuropixel recording and make sure the output folder of SpikeGLX or the OpenEphys GUI is the "raw_ephys_data" folder.
Start the pipeline by running the command python scripts\run_pipeline_spikeglx.py or python scripts\run_pipeline_openephys.py, this will search your top-level data folder for any sessions that have the process_me.flag. The pipeline will take a long time to run so best to do it overnight. After the pipeline has run there will be new probe folders for each of the probes in the top-level of the session folder which contain the spike sorted data and other quality metrics.
After you've done your histology, launch AP_Histology or Universal Probe Finder in MATLAB and trace the fluorescent probe tracts.
To transform the tracks to something the alignment GUI can read run the scripts\convert_AP_Histology_probes.m or scripts\convert_UniversalProbeFinder_probes.m script in MATLAB. This will save .json files for all the probe tracks in a format the alignment GUI can read.
Match these tracks to the recorded probes and move the .json files to the corresponsing probe folders that were created by the pipeline. Once it's in the correct probe folder, rename the .json file to xyz_picks.json.
Launch the alignment gui by typing python iblapps\atlaselectrophysiology\ephys_atlas_gui.py -o True, see instructions on how to use the GUI here.
After the alignment is done click Upload and the final channel locations and brain regions will be saved in the channel_locations.json file.
You can do manual curation of the spike sorting output by running in a python terminal:
from powerpixels import manual_curation
manual_curation("path\to\sorting\results")
The SpikeInterface manual curation GUI will launch which will include the automatic classification output from Bombcell, UnitRefine and the IBL. You can use the GUI to manually annote units as good, or you can use it to see which one of the automated classification metrics you like and use one of those. They are loaded in together with the neural data so you can easily use them to filter units to use.
You can load in the neural data of your recording with a supplied helper function like this:
from powerpixels import load_neural_data
spikes, clusters, channels = load_neural_data(session_path, probe)
For extensive documentation as to what each dataset type in spikes, clusters, and channels means see the documentation here.
You can filter your neurons using one of the automatic curation criteria by adding the flag keep_units with the options 'bombcell', 'unitrefine', 'ibl' and kilosort. Alternativly you can do it yourself by using the following dataset types:
clusters['bombcell_label']: 0 = noise, 1 = good single neuron, 2 = multi-unit activity, 3 = non-somatic
clusters['unitrefine_label']: 0 = multi-unit activity or noise, 1 = good single neuron
clusters['ibl_label']: 0 = noise, 0.33-0.66 = multi-unit activity, 1 = good single neuron
clusters['kilosort_label']: 0 = multi-unit activity or noise, 1 = good single neuron
That's it, enjoy your beautiful data!
If you like this pipeline, you can star this repository and/or give me a shoutout on Bluesky (@guidomeijer.bsky.social) or X (@guido_meijer).
π Please cite the Peer Community Journal if you use the pipeline π β And star this repository! β
The Power Pixels pipeline combines several packages and workflows into one end-to-end pipeline. It supports Neuropixel 1.0 and 2.0 probes recorded on a National Instruments system using SpikeGLX or OpenEphys.
This pipeline is all about combining existing modules and pipelines into one, which is especially useful for people who are just starting out doing Neuropixel recordings and maybe have heard of all these tools but need some help getting them all integrated. Power Pixels relies on these amazing open-source projects:
The pipeline contains the following elements:
It is recommended to install Power Pixels in an Anaconda or Miniforge environment.
conda create -n powerpixels python=3.10 git (use mamba instead of conda when using Miniforge)conda activate powerpixels (or mamba)git clone https://github.com/NeuroNetMem/PowerPixelsPipelinecd PowerPixelPipeline) and install PowerPixels with the command pip install -e .iblapps by cloning the repository git clone https://github.com/int-brain-lab/iblapps and installing it with the command pip install -e iblappsTo install a spike sorter there are two options: (1) directly install Kilosort4 in the python environment, or (2) use Docker to run the spike sorter in a container. Note: if you want to use a MATLAB-based spike sorter (like Kilosort 2.5) you will have to pick option 2.
Option 1: local installation of Kilosort4
Kilosort4 is already installed with PowerPixels, what you'll have to do now is make sure it uses the GPU.
powerpixels environmentpip uninstall torchpip3 install torch --index-url https://download.pytorch.org/whl/cu118.ipython and typing import torch; torch.cuda.is_available(). If the result is True you are good to go. If it's False you need to make sure PyTorch can use CUDA, good luck! (ask AI to help you out)Option 2: run spike sorter in Docker
wsl --installThe tracing of fluorescent probe trajectories in 2D histological brian slices can be done with AP_Histology or [Universal Probe Finder]((https://github.com/JorritMontijn/UniversalProbeFinder). Both of these are MATLAB packages so unfortunatly you will need a MATLAB license for this. As far as I know there are no python-based packages for the tracing of probe trajectories in 2D brain slices.
After installing all the necessary components you can set up your pipeline for use.
conda activate powerpixels (or mamba)powerpixels-setupThe pipeline is in principle agnostic to how your data is organized at a high level. The session folder can have any name and can be located anywhere in your top level data directory. However, each session folder does need to abide by some formatting requirements. Inside each session folder there needs to be a raw_ephys_data folder in which should be the output folder of SpikeGLX or OpenEphys. For the pipeline to find which session folder to process you need to create a process_me.flag file and put it in the session folder.
βββ session_folder
| βββ raw_ephys_data
βββ process_me.flag
To facilitate the process you can run the helper function python scripts\prepare_sessions.py which creates the folders and flags for you (optional).
The data that comes out of the Power Pixels pipeline is (1) raw spike sorter output files (e.g. Kilosort files), (2) data files in ALF filenaming convention, and (3) an NWB file. A helper function is included to load in your neural data from powerpixels import load_neural_data.
Before starting a recording prepare the folder structure, either manually or by running python scripts\prepare_sessions.py.
Perform your Neuropixel recording and make sure the output folder of SpikeGLX or the OpenEphys GUI is the "raw_ephys_data" folder.
Start the pipeline by running the command python scripts\run_pipeline_spikeglx.py or python scripts\run_pipeline_openephys.py, this will search your top-level data folder for any sessions that have the process_me.flag. The pipeline will take a long time to run so best to do it overnight. After the pipeline has run there will be new probe folders for each of the probes in the top-level of the session folder which contain the spike sorted data and other quality metrics.
After you've done your histology, launch AP_Histology or Universal Probe Finder in MATLAB and trace the fluorescent probe tracts.
To transform the tracks to something the alignment GUI can read run the scripts\convert_AP_Histology_probes.m or scripts\convert_UniversalProbeFinder_probes.m script in MATLAB. This will save .json files for all the probe tracks in a format the alignment GUI can read.
Match these tracks to the recorded probes and move the .json files to the corresponsing probe folders that were created by the pipeline. Once it's in the correct probe folder, rename the .json file to xyz_picks.json.
Launch the alignment gui by typing python iblapps\atlaselectrophysiology\ephys_atlas_gui.py -o True, see instructions on how to use the GUI here.
After the alignment is done click Upload and the final channel locations and brain regions will be saved in the channel_locations.json file.
You can do manual curation of the spike sorting output by running in a python terminal:
from powerpixels import manual_curation
manual_curation("path\to\sorting\results")
The SpikeInterface manual curation GUI will launch which will include the automatic classification output from Bombcell, UnitRefine and the IBL. You can use the GUI to manually annote units as good, or you can use it to see which one of the automated classification metrics you like and use one of those. They are loaded in together with the neural data so you can easily use them to filter units to use.
You can load in the neural data of your recording with a supplied helper function like this:
from powerpixels import load_neural_data
spikes, clusters, channels = load_neural_data(session_path, probe)
For extensive documentation as to what each dataset type in spikes, clusters, and channels means see the documentation here.
You can filter your neurons using one of the automatic curation criteria by adding the flag keep_units with the options 'bombcell', 'unitrefine', 'ibl' and kilosort. Alternativly you can do it yourself by using the following dataset types:
clusters['bombcell_label']: 0 = noise, 1 = good single neuron, 2 = multi-unit activity, 3 = non-somatic
clusters['unitrefine_label']: 0 = multi-unit activity or noise, 1 = good single neuron
clusters['ibl_label']: 0 = noise, 0.33-0.66 = multi-unit activity, 1 = good single neuron
clusters['kilosort_label']: 0 = multi-unit activity or noise, 1 = good single neuron
That's it, enjoy your beautiful data!
If you like this pipeline, you can star this repository and/or give me a shoutout on Bluesky (@guidomeijer.bsky.social) or X (@guido_meijer).