This Streamlit application generates ready-to-execute "Run Bundles" for the pi2/NRStitcher pipeline. It simplifies the complex process of creating configuration files and execution scripts for both local workstations and Slurm-managed clusters (like Misha).
- Interactive Configuration: Easily input dataset parameters (dimensions, overlap, voxel size) via a GUI.
- Auto-Detection: Automatically detects your dataset dimensions from file metadata.
- Smart Script Generation: Creates
run_local.bat(Windows),run_local.sh(Linux/Mac), andrun_nrstitcher.sbatch(Slurm) with intelligent backend detection. - Tiles View: (Optional) Creates a
tiles/folder with symlinks, renaming your files to a structured format (tile_{t}_z_{z}_c_{c}.tif) expected by some viewers, without duplicating data. - Preview: Visually inspect your tiles and verify coordinate mapping before generating.
- Slurm Resource Recommendation: Estimates required Partition, CPU, Memory, and Time based on your dataset size.
You'll need this UI application and the core stitcher (pi2).
A. The Run Bundle App (This UI) Clone this repository to your machine:
git clone https://github.com/allison714/nrstitcher-preprocessing.git
cd nrstitcher-preprocessingB. The Core Stitcher (pi2)
- Windows (Recommended): Download the pre-compiled binary distribution (
pi2-v4.5-win-no-opencl). The app automatically supports it if placed atD:\pi2-v4.5-win-no-opencl(or you can link it manually). You do NOT need to clone the pi2 repo. - Source Building: If you must build from source, clone the
pi2repo (git clone https://github.com/arttumiettinen/pi2.git).
Ensure you have Python 3.9+ and conda installed.
# Create environment
conda create -n stitch_app python=3.9 -y
conda activate stitch_app
# Install dependencies
pip install streamlit tifffile pandasNavigate to the project directory and run:
streamlit run app.pyThe application will open in your default web browser.
- Select Data: detailed instruction in the UI.
- Verify: Use the "Preview Tiles" section to check if your files are being read correctly.
- Configure Execution:
- Target Environment: Choose "Local Workstation" or "Misha Cluster (Slurm)".
- Backend config: The app attempts to auto-detect
pi2ornrstitcher. You can override this if needed.
- Generate: Click "Generate Run Bundle".
The app creates a new folder (e.g., MyDataset_local or MyDataset_slurm) containing:
stitch_settings.txt: The coordinate configuration for the stitcher.dataset_manifest.json: A record of your settings for reproducibility.run_local.bat/run_local.sh/run_nrstitcher.sbatch: The specific script to run the actual stitching.tiles/: (Optional) The symlinked view of your data.
For local stitching, you need the pi2 software. Since this is not a public PyPI package, you have two options:
-
Portable Bundle (Recommended):
- Download the pi2 source code.
- In the App, under Local Config, paste the path to your
pi2folder in "Path to 'pi2' Package Source". - The App will embed a copy of
pi2into the run bundle (tools/pi2). - The generated script will automatically use this embedded copy, meaning you don't need to install it in your environment!
-
Auto-Download from GitHub:
- If you leave the "Path to 'pi2'" blank, the generated script will attempt to:
- Create a fresh Conda environment (
stitch_app) if it doesn't exist. - Install dependencies (
numpy,tifffile,scikit-image). - Run
pip install git+https://github.com/arttumiettinen/pi2.
- Create a fresh Conda environment (
- Requires:
gitmust be installed and available in your command prompt.
- If you leave the "Path to 'pi2'" blank, the generated script will attempt to:
- Navigate to the generated bundle folder.
- Double-click
run_local.bat(Windows) or run./run_local.sh(Linux/Mac). - The script will:
- Activate the
stitch_appenvironment. - Run the stitch command.
- (Optional) Convert the output to Neuroglancer Precomputed format if selected.
- Activate the
If you selected Neuroglancer Precomputed output, you can instantly view your 3D stitched volume in your browser:
- Open Anaconda Prompt.
- Navigate to your stitched output folder (e.g.,
cd D:\StitchScratch\260224_local...). - Run the included server script:
python serve.py
- Open Chrome and go to neuroglancer-demo.appspot.com.
- Click the
+icon in the top left and add your local Source:precomputed://http://localhost:8000/precomputed.
The app creates a new folder containing:
stitch_settings.txt: Configuration file.dataset_manifest.json: JSON record of settings.run_local.bat/run_local.sh: Intelligent execution scripts.serve.py: Local web server for Neuroglancer visualization.tools/: (If using Portable Bundle) Contains the embeddedpi2package.
- Error:
pip install git+... failed - Cause: You likely don't have
gitinstalled, or you are behind a firewall. - Fix: Download
pi2manually from GitHub, extract it, and use the "Path to 'pi2' Package Source" field in the App to create a Portable Bundle instead.
- The script tries to find
condaautomatically. If it fails, open the App and check "Local Config > Conda Init Script". Ensure it points to your actualconda.bat(usuallyC:\Users\Username\anaconda3\condabin\conda.bat).