Skip to main content

Software for isolating and analyzing microglial morphology.

Project description

Pycroglia Banner

Pycroglia

PyPI version Python License

A Python-based toolkit for quantitative 3D morphology analysis of cells from fluorescence microscopy images.

Originally based on the MATLAB tool CellSelect-3DMorph, Pycroglia reconstructs individual cells voxel-by-voxel and extracts quantitative morphological descriptors. It is built with a robust, extensible Python architecture and supports both a PyQt6 graphical interface and a library mode for automated/scripted workflows.


Features

Morphological Analysis

  • Cell volume – Voxel-accurate 3D cell volume computation
  • Territorial volume – Convex-hull based territorial volume and coverage statistics
  • Ramification index – Complexity ratio comparing cell volume to territorial volume
  • Branch analysis – Branch length (with linear, PCHIP, and spline interpolation), branch count, branch order classification (primary to quaternary), end point detection
  • Centroid analysis – 3D centroid coordinates and mean pairwise distances in physical units
  • Convex hull metrics – Hull volume, surface area, solidity, and compactness ratios

Image Processing Pipeline

  • Multi-channel reader – TIFF and LSM file format support with automatic channel extraction
  • Otsu thresholding – Per-slice MATLAB-compatible Otsu thresholding with interactive adjustment
  • Small object removal – Minimum-size filtering to eliminate noise artifacts
  • Morphological erosion – Configurable 2D/3D structuring elements (disk, diamond, ball, octahedron, rectangle)
  • GMM clustering – Gaussian Mixture Model-based nucleus separation for splitting merged cells
  • Interactive segmentation – Per-cell segmentation with undo/rollback support

3D Skeletonization

  • Lee-Kashyap-Chu algorithm – Full implementation of the 3D thinning algorithm with based Skeleton3D method used by CellSelect-3DMorph.
  • Scikit-image fallback – Alternative skeletonization backend via skimage.morphology.skeletonize
  • Skeleton-to-graph conversion – Convert binary skeletons to graph representations to prune short branches and back.

Visualization & Export

  • 3D rendering – PyVista-powered visualizations: original cell surfaces, skeleton branch order coloring, end points, branch points, convex hulls
  • Geometry export – Export skeleton surfaces, cell mask surfaces, and boolean mask volumes in OBJ, PLY, VTP, VTK, VTI formats
  • Results export – Structured output to Excel (XLSX) and JSON
  • Branch lengths export – Specialized branch-lengths XLSX output for downstream analysis

Workflow & Performance

  • Wizard-based GUI – Step-by-step workflow: file selection → filtering → segmentation → cell selection → analysis dashboard
  • Library mode – Import pycroglia.core directly for automated batch processing
  • Parallel computation – Qt thread pool and multiprocessing backends via a unified Pool facade; metrics computed concurrently via a DAG-based orchestrator
  • Interactive dashboards – Per-file tabs throughout the pipeline, summary tables, per-cell viewers, and graph preview before export

Installation

Option 1

Download executable files already packages.

Option 2 — Run using uvx

Prerequisites

Install/Update and Run

uvx pycroglia

Option 3 — Install with pip

  • Python 3.11 or later
  • pip
pip install pycroglia
pycroglia

Option 4 — From source

git clone https://github.com/CGK-Laboratory/pycroglia.git
cd pycroglia
uv run python -m pycroglia

Run the test suite:

uv run pytest

Jupyter Notebook

Launch a notebook server connected to the project environment:

uv run --with jupyter jupyter lab

Usage

GUI Mode

Launch the application and follow the wizard:

  1. File Selection – Select TIFF or LSM image files
  2. Filter Editor – Adjust Otsu threshold per slice, remove small objects, configure erosion
  3. Segmentation Editor – View labeled cells by size, split merged cells via GMM
  4. Cell Selection – Filter cells by size, remove border cells, preview selections
  5. Results Dashboard – Set physical scale, compute all metrics, preview 3D visualizations, export results

Documentation

Full documentation is available at CGK-Laboratory.github.io/pycroglia (or locally via docs/).


Contributing

We welcome contributions! Please see CONTRIBUTING.md for guidelines.


License

This project is licensed under the MIT License — see the LICENSE file for details.

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

pycroglia-1.0.0.tar.gz (128.5 kB view details)

Uploaded Source

Built Distribution

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

pycroglia-1.0.0-py3-none-any.whl (183.1 kB view details)

Uploaded Python 3

File details

Details for the file pycroglia-1.0.0.tar.gz.

File metadata

  • Download URL: pycroglia-1.0.0.tar.gz
  • Upload date:
  • Size: 128.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.16 {"installer":{"name":"uv","version":"0.11.16","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for pycroglia-1.0.0.tar.gz
Algorithm Hash digest
SHA256 8b723dd0beb3f006c65268a012497360797612e672cf740f50aad5ef057d14bc
MD5 be247843c9458bbafb9517cc9f344fd3
BLAKE2b-256 cde84949128c11e72c29575e8c6f4782ba9c01120c02e214f4bcb88d46379e47

See more details on using hashes here.

File details

Details for the file pycroglia-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: pycroglia-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 183.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.16 {"installer":{"name":"uv","version":"0.11.16","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for pycroglia-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 251c7772f43a6744bcbe830b418c1c74801545e35066612890108d2e4111cdad
MD5 83e7946584704a5ea436d527cae7bb31
BLAKE2b-256 5606ce0e217ba469fe00a2a6c9fef44e0d00ff2557127e094c8b7821c7209468

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