Skip to main content

DSM-tools

DSM-tools is a Python module that converts neuron morphology into sequences by binary tree traversals and implements deep learning models for encoding the sequences and predicting cell types.

This project was started by Feng Xiong (xiongfengNJ) in 2020, SEU-ALLEN, Nanjing.

The Python package was authorised to be developed by Zuo-Han Zhao (zzhmark) in 2022.

Installation

Depedencies

  • Python (>=3.9)
  • tensorflow (>=2.10.0)
  • scikit-learn (>=1.1.3)
  • SimpleITK (2.2.0)
  • gensim (>=4.2.0)
  • matplotlib (>=3.6.2)
  • pandas (>=1.5.1)
  • importlib_resources (>=5.10.0)

Install by PyPI

pip install DSM-tools

Install by GitHub

pip install git+https://github.com/xiongfengNJ/DSM-tools

User Guide

Here's some simple usage that get you a quick start.

Transform SWC files to sequence dataframes

from dsmtools.preprocessing import NeuronSequenceDataset

# dataset generation tool, with computation settings
ds = NeuronSequenceDataset(swc_file_paths, jobs=10)

# processing
ds.read_parallel()
ds.qc_parallel(qc_len_thr=10)
ds.make_sequence_parallel()

# save the result (OrderedDict) as pickle
ds.pickle_result('output.pickle')

By default, it gives you a set of features for each neuron by the order of preorder traversals.

Predict cell types with HAN model

from dsmtools.modeling import DSMDataConverter, DSMHierarchicalAttentionNetwork

# further convert the dataframes to dataset fed to tensorflow
converter = DSMDataConverter(ds)
han_x = converter.convert_for_han()

# models trained with our data ready for use
han = DSMHierarchicalAttentionNetwork.load_1282_seu()
le = DSMHierarchicalAttentionNetwork.label_encoder_1282_seu()

# decode the one-hot matrix back to labels
le.inverse_transform(np.argmax(han.predict(han_x), axis=1))

The prediction for autoencoder is similar.

Train an autoencoder

from dsmtools.modeling import DSMAutoencoder

ae_x = converter.convert_for_ae()

# build model
ae = DSMAutoencoder(result_dir='output')
ae.compile(feature_dim=6, seq_len=2000)

# training
ae.fit(train_x, test_x, model_save_path='ae_checkpoint.h5', epochs=300, batch_size=32)

ae.plot_learning_curve('ae_learning.png')

The training for HAN is similar.

Please see the examples directory for details.

Fine tune the data processing

You can inherit classes like NeuronSequenceDataset to change the data processing behaviours, which should be quite easy. The tree manipulating class NeuronTree offers you the freedom of exploring your own definition of subtree nodes to generate traversal sequences.

Contact & Support

Documentation

DSM-tools API Documentation: https://xiongfengnj.github.io/DSM-tools
powered by pdoc, served in GitHub Pages.

GitHub projects

Package source: https://github.com/xiongfengNJ/DSM-tools

Experiment code: https://github.com/xiongfengNJ/neuron2seq

Experiment data: http://101.43.104.173:8500

Online service: http://101.43.104.173:8501

Team

SEU-ALLEN Joint Center,
Institute for Brain and Intelligence,
Southeast University

Lab homepage: https://braintell.org

Citation

Our paper is still under review, please check the link for preprint. For now, you can cite it as:

Hanchuan Peng, Feng Xiong, Peng Xie et al. DSM: Deep Sequential Model for Complete Neuronal Morphology Representation and Feature Extraction, 29 June 2022, PREPRINT (Version 1) available at Research Square [https://doi.org/10.21203/rs.3.rs-1627621/v1]

Metadata

Release files for DSM-tools 1.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for DSM-tools 1.1.0
File Size Uploaded Provenance Actions
DSM-tools-1.1.0.tar.gz 10.1 MB Without provenance Details for DSM-tools-1.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for DSM-tools 1.1.0
File Interpreter ABI Platform Actions
DSM_tools-1.1.0-py3-none-any.whl Python 3 none any Details for DSM_tools-1.1.0-py3-none-any.whl

Total release size: 17.2 MB

Release files / DSM-tools-1.1.0.tar.gz

Download URL DSM-tools-1.1.0.tar.gz
Size 10.1 MB
Tags Source
SHA-256 checksum
How to use checksums
906ca08baa94e10df80c23dc92afea5ca69a7d6b0f7e2720d31d6471a691a3c6
BLAKE2b-256 checksum
How to use checksums
e607fe5e25a252a6312be995e859a93671233e93b145c816ada901c2dff9ae51
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.0

Release files / DSM_tools-1.1.0-py3-none-any.whl

Download URL DSM_tools-1.1.0-py3-none-any.whl
Size 7.1 MB
Tags Python 3
SHA-256 checksum
How to use checksums
29edbcb11425768d485d35885da79470f3a9631484e9c89b5d551bcf9daae1d6
BLAKE2b-256 checksum
How to use checksums
a0d3f1bba2d064a40f86c6db318b82b9a63fa246a8d5768bec8b1f2987131244
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.0

Security for DSM-tools 1.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page