Skip to main content

Isolate soma‑specific arbors & export SWC.

Project description

napari-isolate-cell

License BSD-3 Python Version tests codecov npe2

A napari plugin to isolate single cell morphologies (e.g., neurons) from label volumes based on a user click, automatically read image scale, and export the isolated structure as TIFF and correctly scaled SWC files.

Demo of napari-cell-isolate plugin


Overview

This plugin helps streamline the process of extracting individual cell structures from dense segmentations, such as those produced by deep learning models like nnUNet.

Key Features:

  • Click-Based Isolation: Simply click on the soma (or any part) of the cell you want to isolate in a Napari Labels layer.
  • Automatic Scale Detection: Reads ZYX scale information directly from TIFF metadata (standard tags or ImageJ metadata) and applies it to the loaded Napari layer.
  • Anisotropy Awareness: Automatically populates the widget's Anisotropy fields based on the detected image scale.
  • Outputs:
    • Adds the isolated cell as a new Labels layer in Napari, preserving the original scale.
    • Saves the isolated label volume as a TIFF file.
    • Saves the skeletonized structure as an SWC file with coordinates reflecting the original image's physical scale (micrometers).
  • Configurable Parameters: Adjust morphological closing radius (defaults to 0 for dense segmentations) and skeleton dust threshold.

Workflow

Workflow diagram

Installation

For Users (Recommended)

pip install napari-isolate-cell

Or using uv (faster):

uv pip install napari-isolate-cell

For Developers

git clone https://github.com/serg-bg/napari-isolate-cell.git
cd napari-isolate-cell
pip install -e .[testing]

Usage

  1. Launch napari and open your 3D segmentation (.tif file)
  2. Open plugin: Pluginsnapari-isolate-cellIsolate Cell Arbor
  3. Select your labels layer from the dropdown
  4. Click "Activate Click Isolation"
  5. Click any cell in the viewer to isolate it

Outputs:

  • New labels layer with isolated cell
  • isolated_outputs/ folder containing:
    • .tif - Isolated cell volume
    • .swc - Skeleton with physical coordinates (µm)

Parameters:

  • Morphological Closing: Default 0 (increase to bridge small gaps)
  • Dust Threshold: Default 100 (minimum skeleton branch size in voxels)
  • Anisotropy: Auto-detected from TIFF metadata

Requirements

  • Python >= 3.10
  • napari
  • NumPy
  • scikit-image
  • SciPy
  • tifffile
  • magicgui
  • qtpy

(See pyproject.toml for specific version constraints)

Contributing

Contributions are very welcome. Please file an issue to discuss potential changes or features first. Tests can be run with pytest (pip install -e .[testing] then pytest). Please ensure the coverage at least stays the same before you submit a pull request.

License

Distributed under the terms of the BSD-3 license, "napari-isolate-cell" is free and open source software

Issues

If you encounter any problems, please file an issue along with a detailed description.

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

napari_isolate_cell-0.1.1.tar.gz (21.6 kB view details)

Uploaded Source

Built Distribution

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

napari_isolate_cell-0.1.1-py3-none-any.whl (20.8 kB view details)

Uploaded Python 3

File details

Details for the file napari_isolate_cell-0.1.1.tar.gz.

File metadata

  • Download URL: napari_isolate_cell-0.1.1.tar.gz
  • Upload date:
  • Size: 21.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.11

File hashes

Hashes for napari_isolate_cell-0.1.1.tar.gz
Algorithm Hash digest
SHA256 8b1f5c68de11404859498d0aac51fc0797a5be2297bca9b9f94e5a8bceb93255
MD5 4fb6959bda5a900396ca70869de56a37
BLAKE2b-256 395b80cf507be1f17ef417042196874e59060504e85acb9314fb80694ac46159

See more details on using hashes here.

File details

Details for the file napari_isolate_cell-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for napari_isolate_cell-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 eec239ea7fc9b6d227dd95adbdd2dfa50954737373ea748848af0612d26031b7
MD5 5744a4f2a7b6991b3387dab9865c9f35
BLAKE2b-256 4cd7b170dfa71a02ce18cd26433fdf0251a50097665bc6fc1887ef6d5cd19d89

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