Setup Guide
This guide walks you through the setup and usage of the calcium imaging and stimulation data pipeline.
π¦ Prerequisites
Before you begin, make sure the following are installed:
- Git
- Anaconda (recommended for managing Python environments)
- MATLAB (recommended versions: 2021b to 2023a)
- Also install the Parallel Computing Toolbox for CellReg
- Python IDE (e.g., PyCharm)
π Repository Setup
Clone the Repository
Open Git Bash or your terminal and run:
git clone https://github.com/nszti/hstim_pipeline.git
cd hstim_pipeline
You should now see the hstim_pipeline
folder in your working directory.
π§± Project Structure
Here's a simplified layout of the project:
Hyperstim/pipeline_pending/
βββ pipeline_script.py
βββ mesc_loader.py
βββ general.py
βββ package_for_pipeline/
β βββ CoM.py
β βββ cellreg_analysis.py
β βββ cellreg_process.py
β βββ frequency_to_save.py
β βββ functions.py
β βββ mesc_data_handling.py
β βββ mesc_tiff_extract.py
β βββ suite2p_script.py
β βββ tiff_merge.py
βββ hdf5io/
βββ setup.py
π Python Environment Setup
The environment includes dependencies for Suite2p and the custom pipeline scripts.
Step-by-Step:
- Open your terminal / Anaconda Prompt
- Navigate to the repository directory containing:
bash environment.yml
- Create the Conda environment (this may take a few minutes):
- First, make sure there is no environment with the same name, then use the command:
bash conda env create -f environment.yml
- You'll probably get
FutureWarning
messages about theconda
command, but you can ignore them as it will create the environment anyway. - Activate it:
bash conda activate suite2p
- Verify Suite2p is installed:
bash suite2p --version python -m suite2p
- You can open the Suite2p GUI with the command:
bash python -m suite2p
π₯οΈ IDE Setup (PyCharm Recommended)
Connect Conda Environment
Please see here, the detailed instructions to connect the Conda environment to your IDE, but here's a quick summary for PyCharm:
- Open PyCharm
- Go to Project > Python Interpreter
- Click Add Interpreter
- Select Add Local Interpreter
- Choose Conda and select the
suite2p
environment - Click OK and wait for it to load the packages
Now your IDE should be able to run the Python-based parts of the pipeline.
𧬠MATLAB + CellReg Setup
Cellreg intorduction: CellReg is a package we use for the tracking of neurons between multiple sessions (recordings, tiffs) and find the overlap between sessions. It is mostly working, but has some bugs which weβre yet to understand. CellReg is matlab based, so the functions in the pipeline have the purpose of creating the .mat files needed for cellregβs input.
Namely: βmatrices of spatial footprints of cellular activity (ROIs) of the cells that were detected separately in the different sessionsβ
The dimensions of said matrices translated into Suite2p outputs: [nROIs, Ly, Lx]
. So the needed outputs of Suite2p for generating CellReg inputs are: ops.npy
for Ly
and Lx
dimensions, stat.npy
for pixel information, iscell.npy
for ROI information.
Run cellreg manually:
First make sure to add to path all the folders and subfolders of CellReg in Matlab.
Then, in the MATLAB GUI:
CellReg.m
run β in GUI load new data: select the .mat
files for sessions & give 1.07 micron for pixel size β run Non-rigid alignment β run probabilistc modeling with 12 microns β from here just run the next part of the pipeline
Since CellReg is MATLAB-based:
- Download and install CellReg
- Add all folders and subfolders of CellReg to the MATLAB path
- Use the MATLAB GUI to:
- Load sessions
- Run non-rigid alignment
- Run probabilistic modeling (12 microns pixel size)
Full instructions are available in the official CellReg documentation.
Once setup is complete, continue to the pipeline_script.py
to run the analysis.