Annotation-driven targeted microscopy acquisition from within QuPath
QPSC bridges QuPath's digital pathology environment with automated microscope control via Micro-Manager and Pycro-Manager. Users define regions of interest in QuPath and automatically acquire high-resolution microscopy data at those locations.
Note: QPSC requires a microscope with motorized stage, digital camera, and other automated hardware controllable through Micro-Manager device adapters. It does not add automation to manual microscopes.
→ Installation Instructions | → Set Up Your Microscope | → Quick Start (Brightfield)
Click any component to navigate to its repository or documentation.
flowchart TB
subgraph QuPath["QuPath Application"]
direction LR
QP["QuPath + QPSC Extension"]
T2P["Tiles-to-Pyramid Extension"]
end
subgraph Python["Python Microscope Control"]
direction LR
SRV["Command Server"]
CTRL["Hardware Control"]
PPM["PPM Library"]
end
subgraph Bridge["Hardware Bridge"]
direction LR
PM["Pycro-Manager"]
MM["Micro-Manager"]
end
subgraph Hardware["Microscope"]
HW[("Microscope Hardware")]
end
QP ==>|"Socket Commands"| SRV
SRV --> CTRL
SRV --> PPM
CTRL -->|"Python API"| PM
PM -->|"Java Bridge"| MM
MM -->|"Device Control"| HW
HW -.->|"Images"| CTRL
CTRL -.->|"Processing"| PPM
PPM -.->|"Processed images"| SRV
SRV -.->|"Raw tiles"| T2P
T2P -.->|"Stitched OME-ZARR"| QP
style QP fill:#4A90D9,color:#fff
style T2P fill:#4A90D9,color:#fff
style SRV fill:#306998,color:#fff
style CTRL fill:#4A7DB8,color:#fff
style PPM fill:#4A7DB8,color:#fff
style PM fill:#E67E22,color:#fff
style MM fill:#D35400,color:#fff
style HW fill:#C0392B,color:#fff
click QP "https://github.com/uw-loci/qupath-extension-qpsc" "QPSC Extension Repository"
click T2P "https://github.com/uw-loci/qupath-extension-tiles-to-pyramid" "Tiles-to-Pyramid Extension Repository"
click SRV "https://github.com/uw-loci/microscope_command_server" "Command Server Repository"
click CTRL "https://github.com/uw-loci/microscope_control" "Hardware Control Repository"
click PPM "https://github.com/uw-loci/ppm_library" "PPM Library Repository"
click PM "https://pycro-manager.readthedocs.io/" "Pycro-Manager Documentation"
click MM "https://micro-manager.org/" "Micro-Manager Website"
flowchart LR
subgraph Start["Define Region"]
direction TB
Img["Load overview<br/>image & annotate"]
Acq0["Acquire bounding<br/>box region"]
end
Start --> Xform["Coordinate<br/>transform"] --> Acq["Acquire<br/>tiles"] --> Stitch["Stitch &<br/>import"]
Stitch -.->|"Re-acquire"| Img
Stitch ~~~ PAD[ ]
style Img fill:#4A90D9,color:#fff
style Acq0 fill:#4A90D9,color:#fff
style Xform fill:#306998,color:#fff
style Acq fill:#306998,color:#fff
style Stitch fill:#27AE60,color:#fff
style PAD fill:none,stroke:none,color:none
- Setup Coordinates - Use known/estimated stage coordinates, or load an image from a slide scanner to enable mapping of stage coordinates to locations on the slide
- Define Regions - Draw annotations on areas of interest
- Configure Acquisition - Select imaging modality, objectives, and parameters
- Acquire - The QPSC extension sends a workflow to the microscope command server to capture high-resolution tiles
- Stitch & Import - Tiles are stitched into pyramidal images and imported into the QuPath project with metadata for sorting
Acquired images can serve as the basis for subsequent targeted acquisitions at higher resolution or with different modalities.
| Repository | Description | Language |
|---|---|---|
| qupath-extension-qpsc | Main QPSC QuPath extension - UI, workflows, coordinate transforms | Java |
| qupath-extension-ppm | PPM (Polarized light Microscopy) modality plugin - calibration and analysis workflows for birefringent samples | Java |
| qupath-extension-tiles-to-pyramid | Stitches acquired tiles into pyramidal OME-ZARR images | Java |
| Repository | Description | Language |
|---|---|---|
| microscope_command_server | Socket server for QuPath-to-microscope communication and acquisition workflows | Python |
| microscope_control | Hardware abstraction layer via Pycromanager/Micro-Manager | Python |
| ppm_library | Image processing library for PPM and general microscopy imaging | Python |
| microscope_configurations | YAML configuration templates for microscope systems | YAML |
| Repository | Description |
|---|---|
| qupath-extension-dl-pixel-classifier | Deep learning pixel classification with embedded Python (UNet, MuViT, ONNX) |
| qupath-extension-cluster-analysis-tools | Python-powered clustering and phenotyping for multiplexed imaging |
| qupath-extension-ocr4labels | OCR for slide label text extraction |
| qupath-extension-dialog-manager | Automatic dialog window position tracking and persistence across sessions |
QPSC uses a modular architecture with separate Python packages for different concerns:
- QuPath Extensions (Java) - User interface, workflows, coordinate transforms
- Python Microscope Control - Socket server, hardware abstraction, image processing
- Micro-Manager Stack - Hardware device control
For detailed architecture documentation including:
- Component structure and responsibilities
- Communication protocols
- Coordinate system transformations
- Modality system design
- Configuration hierarchy
- Threading and concurrency
See: docs/architecture.md
QPSC supports multiple imaging modalities through a pluggable architecture:
| Modality | Description | Status |
|---|---|---|
| PPM (Polarized Light) | Multi-angle polarization microscopy for birefringent samples (via qupath-extension-ppm) | Active |
| Brightfield | Standard transmitted light imaging | Active |
| Widefield Fluorescence | Multi-channel widefield fluorescence imaging | Planned |
| Point Scanning | Laser scanning modalities including two-photon, SHG, and single-photon confocal (via LaserScanningModalityHandler) | Beta |
QPSC requires several components that work together. This section guides you through installing everything needed for annotation-driven microscopy acquisition.
Microscope Hardware Requirements:
| Component | Status | Purpose |
|---|---|---|
| Motorized XY stage | Required | Tile-based acquisition -- stage moves between positions |
| Motorized Z stage | Required | Autofocus (sweep drift check + standard Z-sweep) |
| Image detector | Required | Camera or laser scanning detector (Micro-Manager compatible) |
| Rotation stage (PSG) | Recommended (PPM) | Polarizer rotation for multi-angle PPM imaging |
| Motorized objective turret | Optional | Automated objective switching (not yet software-controlled -- manual switch required) |
| Motorized filter wheel | Optional | Filter changes for fluorescence (future modality support) |
| Slide scanner with macro camera | Optional | Overview image for alignment workflow and Stage Map overlay |
All motorized components must be controllable through Micro-Manager device adapters.
Install these foundational software components in this order before QPSC installation:
- Version: 2.0+ (latest 2.0 gamma release recommended)
- Purpose: Controls microscope hardware via device adapters
- Installation: Micro-Manager Download
- Configuration: Configure device adapters for your specific hardware before proceeding. You should be able to move the XY and Z stages and capture images before continuing.
- Note: Must be installed and tested before Python packages
- Version: 0.6.0+
- Purpose: Annotation interface and image analysis environment
- Installation: QuPath Download
- Note: Install before QPSC extensions
- Version: Python 3.10 or later (3.12 recommended)
- Purpose: Runtime for microscope control server
- Installation: Python Download
- Windows Note: Check "Add Python to PATH" during installation
Most users can skip this. Standard Windows editions (Home, Pro, Education) already include these components. Only install if you encounter
ImportError: DLL load failed while importing cv2.
- Required for: Windows N or KN editions (Education N, Pro N, etc.)
- Purpose: Provides media codecs required by OpenCV (autofocus functionality)
- Check if you need this: Open Settings -> System -> About. If "Edition" ends with "N", you need it.
- Installation: Media Feature Pack Download
Most users can skip this. Only needed if you want to build QuPath extensions from source code.
- Version: Java 21+
- Purpose: Building QuPath extensions from source
- Installation: Adoptium Temurin
Best for most users - Automated PowerShell script handles all Python package installation, QuPath extensions, and configuration templates.
For users who want to use QPSC without modifying code:
1. Open PowerShell (Run as Administrator recommended)
PowerShell version: The script requires PowerShell 5.1+, which is included with Windows 10 and later. You should not need to install anything extra. If you get errors about unrecognized commands, check your version with
$PSVersionTable.PSVersion.Execution policy: If you get a "cannot be loaded because running scripts is disabled" error, run:
Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy RemoteSignedand try again.
2. Navigate to your home directory (avoid System32!):
cd $env:USERPROFILE3. Download the setup script:
Invoke-WebRequest -Uri "https://raw.githubusercontent.com/uw-loci/QPSC/main/PPM-QuPath.ps1" -OutFile "PPM-QuPath.ps1"4. Run the setup script:
.\PPM-QuPath.ps1What this does:
- Creates a Python virtual environment
- Installs Python packages from GitHub (latest versions, including prereleases)
- Installs OpenCV (required for autofocus)
- Downloads QPSC, PPM, and Tiles-to-Pyramid extension JARs (shadow JARs with bundled dependencies)
- Stores extensions in local
QPSC\extensions\folder for easy access - Automatically copies extensions to QuPath user data directory
- Downloads configuration templates
- Creates a launcher script that opens server in visible window showing status
Default installation location: C:\Users\YourUsername\QPSC\
Custom installation location:
.\PPM-QuPath.ps1 -InstallDir "D:\MyProjects\QPSC"Custom QuPath location (if not auto-detected):
.\PPM-QuPath.ps1 -QuPathDir "C:\path\to\QuPath-0.6.0"Note: The script automatically searches for QuPath in:
%LOCALAPPDATA%\QuPath-*(MSI installation default)%USERPROFILE%\QuPath(portable installation)%ProgramFiles%\QuPathIf QuPath is in a different location, use the
-QuPathDirparameter.
The setup script creates a detailed installation summary file:
%USERPROFILE%\QPSC\INSTALLATION_SUMMARY.txt
This file contains:
- Python environment location and activation commands
- Exact paths where packages were installed
- Verification commands to test your installation
- Troubleshooting tips for common issues
Quick verification commands:
All installations use a virtual environment located at C:\Users\YourUsername\QPSC\venv_qpsc\
# Activate the virtual environment
C:\Users\YourUsername\QPSC\venv_qpsc\Scripts\Activate.ps1
# Check installed packages
pip list | Select-String "microscope|ppm"
# Test import
python -c "import microscope_command_server; print('Import OK')"Or use the venv Python directly without activation:
C:\Users\YourUsername\QPSC\venv_qpsc\Scripts\python.exe -c "import microscope_command_server; print('Import OK')"Open the INSTALLATION_SUMMARY.txt file to see all available verification commands and troubleshooting steps!
Development Mode
For developers who want to modify QPSC code:
Navigate to your home directory (if you followed Quick Start above, you're already there):
cd $env:USERPROFILEDownload and run in development mode:
.\PPM-QuPath.ps1 -DevelopmentWhat this does:
- Clones all 6 QPSC repositories
- Creates Python virtual environment
- Installs packages in editable mode (
pip install -e .) - Downloads QuPath extensions
- Sets up development environment
Detailed setup script documentation: SETUP_SCRIPTS_README.md
When to use manual installation:
- macOS or Linux systems
- Prefer manual control over installation process
- Need to customize installation steps
- Automated script fails or is unavailable
Before starting, verify you have the required tools installed:
Check Python version (should show 3.10 or higher):
python --versionCheck pip is available:
pip --versionCheck git is available (for development mode):
git --versionUsing a virtual environment isolates QPSC dependencies from system Python:
Windows:
Navigate to an appropriate directory (e.g., your home directory):
cd $env:USERPROFILECreate virtual environment:
python -m venv qpsc-envActivate virtual environment:
.\qpsc-env\Scripts\activateVerify activation (should show path to venv):
where pythonmacOS/Linux:
Navigate to an appropriate directory (e.g., your home directory):
cd ~Create virtual environment:
python3 -m venv qpsc-envActivate virtual environment:
source qpsc-env/bin/activateVerify activation:
which pythonNote: You must activate the virtual environment each time you want to run the microscope server.
Critical: Installation Order Matters
These packages have dependencies on each other and must be installed in this exact order:
Option A: Install from GitHub (Users)
Installs the latest released versions from GitHub.
1. Install PPM Library (no QPSC dependencies):
pip install git+https://github.com/uw-loci/ppm_library.git2. Install Microscope Control (depends on ppm_library):
pip install git+https://github.com/uw-loci/microscope_control.git3. Install Microscope Command Server (depends on both above):
pip install git+https://github.com/uw-loci/microscope_command_server.gitOption B: Clone and Install Editable (Developers)
For development and code modification.
Navigate to a parent directory for repositories:
cd /path/to/your/projects/Clone and install ppm_library:
git clone https://github.com/uw-loci/ppm_library.git
cd ppm_library
pip install -e .
cd ..Clone and install microscope_control:
git clone https://github.com/uw-loci/microscope_control.git
cd microscope_control
pip install -e .
cd ..Clone and install microscope_command_server:
git clone https://github.com/uw-loci/microscope_command_server.git
cd microscope_command_server
pip install -e .
cd ..Verify installation:
pip list | grep -E "(ppm-library|microscope-control|microscope-command-server)"Expected output:
microscope-command-server 1.0.0 /path/to/microscope_command_server
microscope-control 1.0.0 /path/to/microscope_control
ppm-library 1.0.0 /path/to/ppm_library
Troubleshooting: See the Python Package Installation section of the troubleshooting guide.
Download the latest JAR files from GitHub releases:
-
QPSC Extension (main functionality)
- Navigate to: qupath-extension-qpsc/releases
- Download:
qupath-extension-qpsc-[version].jar
-
PPM Extension (polarized light microscopy modality)
- Navigate to: qupath-extension-ppm/releases
- Download:
qupath-extension-ppm-[version].jar
-
Tiles-to-Pyramid Extension (stitching)
- Navigate to: qupath-extension-tiles-to-pyramid/releases
- Download:
qupath-extension-tiles-to-pyramid-[version].jar
Install extensions:
Copy all JAR files to QuPath's extensions folder:
- Windows (MSI install):
C:\Users\[YourUsername]\AppData\Local\QuPath-0.6.0\extensions\ - Windows (portable):
C:\Users\[YourUsername]\QuPath\extensions\ - macOS:
~/Library/Application Support/QuPath/extensions/or~/QuPath/extensions/ - Linux:
~/.local/share/QuPath/extensions/or~/QuPath/extensions/
Tip: In QuPath, go to
Edit > Preferencesand look at the "Extension directory" setting to find the exact path on your system.
Verify installation:
- Launch QuPath
- Go to
Extensionsmenu - Look for
QPSCmenu entry
If you don't see QPSC in the Extensions menu, check:
- JAR files are in the correct extensions folder
- QuPath was restarted after copying JARs
- Check QuPath's log for any loading errors
Configuration files tell the server about your microscope hardware.
Download from GitHub:
Navigate to microscope_configurations and download:
templates/config_template.yml- Main microscope configurationtemplates/autofocus_template.yml- Autofocus parameterstemplates/imageprocessing_template.yml- Camera/exposure settingsresources/resources_LOCI.yml- Hardware component lookup tables
Save location:
Create a configurations folder in your project directory, e.g.:
- Windows:
C:\QPSC\configurations\ - macOS/Linux:
~/QPSC/configurations/
Edit for your hardware:
- Copy
config_template.ymlto a new file (e.g.,config_mymicroscope.yml) - Edit device names, stage limits, objectives, etc. to match your hardware
- See Configuration Documentation for details
Ensure Micro-Manager is running before starting the server.
From command line:
# Activate virtual environment (if using)
# Windows:
.\qpsc-env\Scripts\activate
# macOS/Linux:
source qpsc-env/bin/activate
# Start server
microscope-command-serverExpected output:
INFO - Loading generic startup configuration...
INFO - Initializing Micro-Manager connection...
INFO - Server listening on 0.0.0.0:5000
INFO - Ready for connections...
Server is now ready! You can connect from QuPath's QPSC extension.
To stop the server: Press Ctrl+C
For step-by-step instructions with screenshots and troubleshooting, see individual repository READMEs:
| Component | Repository | Installation Guide |
|---|---|---|
| PPM Library | ppm_library | Installation |
| Microscope Control | microscope_control | Installation |
| Command Server | microscope_command_server | Installation |
| Configuration Templates | microscope_configurations | Configuration Guide |
| QPSC Extension | qupath-extension-qpsc | Extension Docs |
| PPM Extension | qupath-extension-ppm | Extension Docs |
| Stitching Extension | qupath-extension-tiles-to-pyramid | Extension Docs |
For installation issues, see the Troubleshooting Guide:
- QuPath installation issues -- QuPath not found, extensions directory, QPSC not appearing
- Python package issues -- ModuleNotFoundError, OpenCV errors, circular imports
- Server and network issues -- port conflicts
- Setup script issues -- PowerShell execution policy
After installation, verify everything works:
python -c "import ppm_library, microscope_control, microscope_command_server; print('All packages imported successfully')"# Start Micro-Manager first
# Then start server
microscope-command-serverExpected: Server should start and show "Server listening on 0.0.0.0:5000"
- Launch QuPath
- Go to
Extensions > QPSC - You should see menu options for workflows
See the Brightfield Quick Start or Laser Scanning Quick Start for workflow walkthroughs
Software is installed -- now configure QPSC for your specific microscope hardware.
| Step | Guide | What it does |
|---|---|---|
| 1. Create config files | Setup Wizard | The Setup Wizard (Extensions > QP Scope > Setup Wizard) walks you through creating YAML configuration files that describe your objectives, cameras, stage limits, and imaging modalities. |
| 2. Connect & align | Microscope Alignment | Calibrate the coordinate mapping between QuPath images and your microscope stage. Required once per microscope/scanner combination. |
| 3. First acquisition | Brightfield Quick Start | Step-by-step guide to your first tile acquisition. |
For the complete setup walkthrough: Full Installation & Setup Guide
To remove QPSC components for a clean reinstallation or complete uninstall, see the Uninstallation Guide.
QPSC uses YAML configuration files for microscope-specific settings:
# Example: config_ppm.yml
microscope:
name: "PPM Microscope"
stage:
type: "ASI"
limits:
x: [-50000, 50000]
y: [-50000, 50000]
modalities:
ppm_20x:
objective: "20x"
angles: [0, 45, 90, 135]
exposure_ms: 50See Configuration Documentation for full details.
# Clone the main extension
git clone https://github.com/uw-loci/qupath-extension-qpsc.git
cd qupath-extension-qpsc
# Build (requires Java 21+)
./gradlew build
# Run tests
./gradlew testFor detailed package structure and component documentation, see the Architecture Guide.
QPSC uses a socket-based protocol for communication between QuPath and the Python server:
sequenceDiagram
participant QP as QuPath/QPSC
participant Srv as Python Server
participant MM as Micro-Manager
QP->>Srv: Connect (TCP)
QP->>Srv: ACQUIRE command + params
Srv->>MM: Initialize acquisition
loop For each tile position
Srv->>MM: Move stage
Srv->>MM: Capture image(s)
Srv-->>QP: Progress update
end
Srv-->>QP: Acquisition complete
QP->>QP: Stitch tiles (tiles-to-pyramid)
QP->>QP: Import result to project
We welcome contributions! Please see individual repository guidelines:
QuPath Extensions:
Python Microscope Control:
- Microscope Command Server Issues
- Microscope Control Issues
- PPM Library Issues
- Configuration Templates
If you use QPSC in your research, please cite:
[Citation information to be added]
Components are licensed individually - see each repository for details.
QPSC is developed at the Laboratory for Optical and Computational Instrumentation (LOCI) at the University of Wisconsin-Madison.
- QuPath - Open source software for bioimage analysis
- Micro-Manager - Open source microscopy software
- Pycro-Manager - Python interface for Micro-Manager
Questions? Open an issue in the relevant repository or contact the LOCI team.