Skip to content

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:

  1. Open your terminal / Anaconda Prompt
  2. Navigate to the repository directory containing: bash environment.yml
  3. Create the Conda environment (this may take a few minutes):
  4. First, make sure there is no environment with the same name, then use the command: bash conda env create -f environment.yml
  5. You'll probably get FutureWarning messages about the conda command, but you can ignore them as it will create the environment anyway.
  6. Activate it: bash conda activate suite2p
  7. Verify Suite2p is installed: bash suite2p --version python -m suite2p
  8. You can open the Suite2p GUI with the command: bash python -m suite2p

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:

  1. Open PyCharm
  2. Go to Project > Python Interpreter
  3. Click Add Interpreter
  4. Select Add Local Interpreter
  5. Choose Conda and select the suite2p environment
  6. 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.