Skip to main content

Python package and CLI for L-Measure-based morphometric extraction

Project description

CI License: MIT Python Versions PyPI version

MorphoMeasure banner

MorphoMeasure

A Python package and command-line tool for automated extraction and summarization of morphometric features from neuron morphology files (SWC format) using L-Measure. It supports batch processing, flexible feature selection, tag-based extraction, and outputs results in convenient CSV formats for downstream analysis. This package also supports the extraction of ABEL, a recently discovered morphometric feature.


Quick Install

From PyPI (recommended):

pip install morphomeasure

Or for development:

git clone https://github.com/Masood-Akram/MorphoMeasure.git
cd MorphoMeasure
pip install -e .

Features

  • Python package & CLI for automated neuronal morphometric extraction using L-Measure
  • Batch processing of many SWC files
  • Outputs both branch-by-branch and summary morphometrics
  • Handles dendritic (3.0, 4.0) and glial (7.0) tags
  • Requires no Java or L-Measure installation - Lm.exe is bundled

Requirements

  • Python 3.8+
  • L-Measure (Lm.exe) is bundled with the package
  • pandas (auto-installed)

Usage

Python API

from morphomeasure import LMeasureWrapper

lm = LMeasureWrapper()
lm.run_batch(
    swc_dir='/path/to/swc-directory',
    output_dir='/path/to/output-directory',
    tags=['3.0'], # can be ['3.0', '4.0'] for apical & basal, and ['7.0'] for glia
    features_mode=['all']   # can be ['all', 'branch'], or ['all', 'branch', 'combined']
)

As a CLI Tool

morphomeasure --tag 3.0 4.0 --features all --swc_dir /path/to/swc_files --output_dir /path/to/output

All options:

morphomeasure --help

Arguments:

Argument Description Example
--tag Tags to process (e.g., 3.0 for basal, 4.0 for apical, 7.0 for glia) --tag 3.0 4.0
--features Output type: all, branch, or combined --features all
--swc_dir Directory containing input SWC files --swc_dir ./swc_files
--output_dir Directory to save output CSVs --output_dir ./Measurements
--tmp_dir Temporary directory for intermediate files (default: ./tmp) --tmp_dir ./tmp
--lm_exe_path Path to L-Measure executable (default: bundled with package) --lm_exe_path ./Lm/Lm.exe

Output

  • Complete structure CSVs:
    Measurements/<tag_label>/All_Morphemetrics.csv

  • Apical & Basal CSVs:
    Measurements/<tag_label>/All_Morphemetrics_apical.csv Measurements/<tag_label>/All_Morphemetrics_basal.csv

  • Branch-by-branch CSVs:
    Measurements/<tag_label>/Branch_Morphometrics_<neuron>.csv

  • Summary CSVs:

    • All_Morphometrics.csv (overall structure)
    • All_Morphometrics_basal.csv (basal dendrites)
    • All_Morphometrics_apical.csv (apical dendrites)
    • All_Morphometrics_glia.csv (glial processes)
  • Temporary files:
    Cleaned up automatically from the tmp directory.


Customization

  • Features:
    Edit morphomeasure/features.py to add or remove L-Measure features.
  • Summary Logic:
    Update the summary_logic dictionary in features.py.
  • Tag Labels:
    Edit TAG_LABELS in features.py.

Notes

  • Temporary CSVs are cleaned up from tmp/ after processing.
  • Make sure Lm.exe is compatible with your OS (bundled version is for Windows).
  • For L-Measure feature details, see the L-Measure documentation.

Roadmap

  • Extract features with tag 3 (basal) and tag 4 (apical) together and separately.
  • Extract features with tag 7 (glia).
  • PCA on Height, Width, and Depth.
  • Pure Python feature extraction (no L-Measure dependency).
  • Separate measures for apical & basal trees.

License

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


Citation

If you use this repository in your research, please cite the associated papers:

@article{https://doi.org/10.1038/nprot.2008.51,
  author = {Scorcioni, R., Polavaram, S., & Ascoli, G. A.},
  doi = {https://doi.org/10.1038/nprot.2008.51},
  journal = {Nature protocols},
  number = {5},
  pages = {866–-876},
  title = {{L-Measure: a web-accessible tool for the analysis, comparison and search of digital reconstructions of neuronal morphologies}},
  volume = {3},
  year = {2008}
}

@article{https://doi.org/10.1002/jnr.25131,
  author = {Akram, M. A., Wei, Q., & Ascoli, G. A.},
  doi = {https://doi.org/10.1002/jnr.25131},
  journal = {Journal of Neuroscience Research},
  number = {1},
  pages = {112--129},
  title = {{Machine learning classification reveals robust morphometric biomarker of glial and neuronal arbors}},
  volume = {101},
  year = {2023}
}

Acknowledgments

  • L-Measure: Center for Neural Informatics, Neural Structures, & Neural Plasticity, George Mason University

For questions or contributions, please open an issue or pull request!

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

morphomeasure-0.1.3.tar.gz (1.6 MB view details)

Uploaded Source

Built Distribution

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

morphomeasure-0.1.3-py3-none-any.whl (1.6 MB view details)

Uploaded Python 3

File details

Details for the file morphomeasure-0.1.3.tar.gz.

File metadata

  • Download URL: morphomeasure-0.1.3.tar.gz
  • Upload date:
  • Size: 1.6 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.7

File hashes

Hashes for morphomeasure-0.1.3.tar.gz
Algorithm Hash digest
SHA256 a34da4288fc88fa6679d57537645100e7b8e9d142c034f283d910d0a34ff3463
MD5 09d80a4d2984e8f9e3d8987521200db6
BLAKE2b-256 5cdef8673e6ae0984d1186b7fa49872265641a83685e4f3397c27b8793ae9dc7

See more details on using hashes here.

File details

Details for the file morphomeasure-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: morphomeasure-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 1.6 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.7

File hashes

Hashes for morphomeasure-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 d87ca0bb174303aca99e57f3cbf150eb8cb851c3d42d4904b7f842bac084268a
MD5 670035e81c31e6637ccd77100d3b9007
BLAKE2b-256 252599f647bef3ebaff5331d08542dc450e321a149dd72ac12f4bf0de46ec13d

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