DEMIS is a tool for stitching grids of electron microscopy (EM) images using deep learning-based feature matching and optical flow refinement.
DEMIS normalizes image tiles, detects feature matches using LoFTR, estimates pairwise transformations between tiles, and optimizes them globally to stitch the final grid.
Key features:
- Deep feature matching: Uses LoFTR for robust matching of EM images with low-quality or highly repetitive texture.
- Optical flow refinement: Refines alignments using RAFT-based optical flow.
- Flexible configuration: Support for multiple feature matching, grid construction and image compositing methods.
- ImageJ integration: Includes a plugin for easy use within ImageJ2 and Fiji.
The following setup guide was tested on Ubuntu 22.04 and Windows 11. Running on Windows might have a negative performance impact.
- Python 3.9
- uv: DEMIS uses uv for dependency management.
- CUDA: A CUDA-enabled GPU is required to use deep learning-based features. Running on CPU would be too slow.
- Clone the repository:
git clone https://github.com/PSilling/demis.git
cd demis- Install dependencies using
uv:
uv sync- Set
PYTHONPATHto the root of the repository.
- Linux:
export PYTHONPATH=$PWD - Windows:
$env:PYTHONPATH = $PWD(PowerShell)
- Download weights for LoFTR:
-
Place LoFTR weights in
LoFTR/weights/. Recommended options:- demis_ds.ckpt – weights fine-tuned on the EM424 dataset (synthetic EM image grids).
- outdoor_ds.ckpt – original outdoor dual-softmax weights of LoFTR. Trained on conventional photography only.
Scripts from scripts/ directory can be run using uv run. Ensure PYTHONPATH is set to project root.
To stitch a dataset using a configuration file:
uv run scripts/stitch.py --config configs/em424-fine-tuned.yamlTo evaluate performance on the EM424 dataset:
uv run scripts/evaluate_demis.py --config configs/em424-fine-tuned.yamlDetailed documentation is available in the docs/ directory:
- Configuration Guide: Detailed explanation of all YAML options.
- Datasets: Information on the EM424 dataset and expected dataset format.
- Training: Instructions for fine-tuning LoFTR on EM424 dataset.
- ImageJ Plugin: Guide for building and using the ImageJ plugin.
DEMIS is supported by TESCAN GROUP and the Faculty of Information Technology, Brno University of Technology.
If you use our tool, please cite our paper published in BIOIMAGING 2025:
ŠILLING, P.; ŠPANĚL, M. DEMIS: Electron Microscopy Image Stitching using Deep Learning Features and Global Optimisation. Proceedings of the 18th International Joint Conference on Biomedical Engineering Systems and Technologies - BIOIMAGING. Porto: Institute for Systems and Technologies of Information, Control and Communication, 2025. p. 255-256. ISBN: 978-989-758-731-3.