Headless, backend-pluggable EM image segmentation library for HyperSpy
Project description
SegSpy
Headless, backend-pluggable EM image segmentation library for HyperSpy.
SegSpy turns a HyperSpy Signal2D into a list of particle objects. It is
microscope-generic (TEM/SEM) and particle-type-agnostic, shipping multiple
interchangeable segmentation backends behind a uniform registry:
traditional_cv— CLAHE → black-hat → threshold → morphology → GrabCut refinementsam— Meta SAM Auto-Mask Generator with a 5-stage post-filter
Installation
pip install SegSpy
For the SAM backend, install the optional extra:
pip install "SegSpy[sam]" # adds segment-anything + torch
For development:
git clone https://github.com/VANvonZHANG/SegSpy.git
cd SegSpy
pip install -e ".[dev]"
pre-commit install
Quick start
import hyperspy.api as hs
from SegSpy import SegConfig, SegmentationRegistry, measure_morphology
signal = hs.load("image.dm4")
backend = SegmentationRegistry.get("traditional_cv")
mask = backend.segment(signal, SegConfig())
objects = backend.extract_objects(signal, mask, SegConfig())
for obj in objects:
measure_morphology(obj, scale_nm=1.0)
CLI
SegSpy run image.dm4 --backend traditional_cv --output ./out
Writes <stem>_particles.csv (per-particle morphology metrics) and
<stem>_labeled.png (a labelled mask) to the output directory.
Status
v0.1 — pure library + CLI, no GUI (deferred to a later release). See the CHANGELOG for details. Contributions welcome — see CONTRIBUTING.md.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file segspy-0.1.0.tar.gz.
File metadata
- Download URL: segspy-0.1.0.tar.gz
- Upload date:
- Size: 23.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.20
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7cfacdc25415ff1a3585fc75dbb1114ffd7693058dc797607041f50d47fb3b60
|
|
| MD5 |
93fcdab4f4479aa27361e154f29146b1
|
|
| BLAKE2b-256 |
b0d0f0170862187d7f6a9eac9461ff44b0b12b564a89f41de9faf1ff82b539ec
|
File details
Details for the file segspy-0.1.0-py3-none-any.whl.
File metadata
- Download URL: segspy-0.1.0-py3-none-any.whl
- Upload date:
- Size: 18.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.20
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5bb46816e2317e87e1d03d651f9314396c3918bc598a1a02b72cc02bdebc9dd0
|
|
| MD5 |
f07e5bc9dc9515595a9f185de8c8e2cf
|
|
| BLAKE2b-256 |
d4cd94905d8fd94812297a481b0d8764c8cb08bbb16e22bcbbe0587b76665df4
|