title: Sem Stitcher emoji: 🏢 colorFrom: blue colorTo: yellow sdk: gradio sdk_version: 6.4.0 app_file: app.py pinned: false license: mit short_description: Mosaic JEOL SEM or microprobe images and add analysis points
🔬 SEM Stitcher
Stitch scanning electron microscope (SEM) tile images using stage coordinates from metadata files.
Features
- Stitch SEM tiles using stage coordinates from metadata files
- Overlay analysis points from CSV files
- Web interface via Hugging Face Spaces (no coding required)
- Python library for integration into workflows
- 🖥Command-line tool for batch processing
Currently supports JEOL metadata format.
Quick Start
Web Interface (No Installation)
Visit the Hugging Face Space to use the web interface.
Python Library
pip install semstitcher
from semstitcher import stitch_tiles
# Basic stitching
mosaic, transform = stitch_tiles("path/to/tiles", output_path="mosaic.tif")
# With point overlay
mosaic, transform = stitch_tiles(
"path/to/tiles",
output_path="mosaic.tif",
csv_path="analysis_points.csv"
)
Command Line
# Basic stitching
semstitcher /path/to/tiles output.tif
# With point overlay
semstitcher /path/to/tiles output.tif --csv points.csv
File Format Requirements
Image and Metadata Files
- Images:
.tifor.tifffiles - Metadata:
.txtfiles with the same base name as the image- Example:
sample_001.tifandsample_001.txt
- Example:
JEOL Metadata Format
The metadata file must contain at minimum:
$CM_STAGE_POS -2.4153 10.1840 10.7170 0 0 0
$$SM_MICRON_BAR 170
$CM_FULL_SIZE 5120 3840
CSV Format for Analysis Points
Phase,Point,X-POS,Y-POS
Olivine,1,-2.5607,11.7652
Spinel,1,-3.1858,10.2133
Cpx,1,-3.2824,11.8894
Required columns: X-POS, Y-POS
Optional columns for labels: Phase, Point
API Reference
stitch_tiles()
High-level function to stitch tiles and optionally overlay points.
from semstitcher import stitch_tiles
mosaic, transform = stitch_tiles(
input_dir="path/to/tiles", # Directory with .tif and .txt files
output_path="output.tif", # Output file path (optional)
csv_path="points.csv", # CSV with analysis points (optional)
point_radius=25, # Radius of point markers
compression='lzw', # TIFF compression
)
create_mosaic()
Lower-level function for more control.
from semstitcher import create_mosaic
from semstitcher.stitcher import load_tiles_from_directory
tiles = load_tiles_from_directory("path/to/tiles")
mosaic, transform = create_mosaic(tiles)
overlay_points()
Add point markers to an existing mosaic.
from semstitcher import overlay_points
mosaic = overlay_points(
mosaic,
transform,
csv_path="points.csv",
point_radius=25,
point_color=(255, 105, 180), # Pink
text_color=(255, 255, 0), # Yellow
)
Coordinate System
This tool is designed for JEOL SEMs where:
- Stage X increases to the left in the image
- Stage Y increases downward in the image
The coordinate transformation is applied automatically.
Development
# Clone the repository
git clone https://github.com/yourusername/sem-stitcher.git
cd sem-stitcher
# Install in development mode
pip install -e ".[dev]"
# Run tests
pytest
# Run the Gradio app locally
python app.py
License
MIT License - see LICENSE for details.
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
Planned Features
- Support for FEI/Thermo Fisher metadata format
- Support for Zeiss metadata format
- Automatic tile alignment using image features
- Blend overlapping regions
- Export to pyramidal TIFF for large mosaics
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
Metadata
Release files for semstitcher 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| semstitcher-0.1.0.tar.gz | 11.8 kB | Without provenance | Details for semstitcher-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| semstitcher-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for semstitcher-0.1.0-py3-none-any.whl |
Total release size: 23.6 kB
Release files / semstitcher-0.1.0.tar.gz
| Download URL | semstitcher-0.1.0.tar.gz |
|---|---|
| Size | 11.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b49fab1ec55789172bb489fdf12fa64ff71d8d555510a65fa5a241854be52258
|
|
BLAKE2b-256 checksum How to use checksums |
6056b93f33d8dee5acf3b3dcaa22048dc34f70ab7fde73f18c871400db77e2c4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.5
|
Release files / semstitcher-0.1.0-py3-none-any.whl
| Download URL | semstitcher-0.1.0-py3-none-any.whl |
|---|---|
| Size | 11.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
706106db8df394026e3c5a8cad5ef58f1695c4052f67077f7c3d99cdfb2c987a
|
|
BLAKE2b-256 checksum How to use checksums |
bcbb3075c58d6a865397a1ef2e53c3c823b455044579a94b1b991f486a8a1cfe
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.5
|
Security for semstitcher 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.