Skip to main content

Headless, backend-pluggable EM image segmentation library for HyperSpy

Project description

SegSpy

CI Lint Docs License: MIT

📖 Read the documentation

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 refinement
  • sam — 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

segspy-0.1.0.tar.gz (23.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

segspy-0.1.0-py3-none-any.whl (18.4 kB view details)

Uploaded Python 3

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

Hashes for segspy-0.1.0.tar.gz
Algorithm Hash digest
SHA256 7cfacdc25415ff1a3585fc75dbb1114ffd7693058dc797607041f50d47fb3b60
MD5 93fcdab4f4479aa27361e154f29146b1
BLAKE2b-256 b0d0f0170862187d7f6a9eac9461ff44b0b12b564a89f41de9faf1ff82b539ec

See more details on using hashes here.

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

Hashes for segspy-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5bb46816e2317e87e1d03d651f9314396c3918bc598a1a02b72cc02bdebc9dd0
MD5 f07e5bc9dc9515595a9f185de8c8e2cf
BLAKE2b-256 d4cd94905d8fd94812297a481b0d8764c8cb08bbb16e22bcbbe0587b76665df4

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page