Skip to main content

An automated deep learning pipeline for segmentation of the scapula, humerus, and their respective subregions in CT scans.

Project description

armcortnet

PyPI Latest Release Code style: black

Armcortnet provides automatic segmentation of the humerus and scapula from CT scans. The deep learning model is trained to also segment out the cortical and trabecular subregions from each bone as well.

The deep learning pipeple consists of using armcrop to crop to an oriented bounding box around each humerus or scapula in the image and then a neural network based traine from the nnUNet framework segments that cropped volume. The segmetnation is then transformed back to the original coordinate system, post-processed and finally saved as a .seg.nrrd file.

Installation

Please install pytorch first before installing armcortnet. You can learn about installing pytorch from the official website here.

Then install armcortnet using pip:

pip install armcortnet

For faster oriented bounding box cropping you can replace onnxruntime with onnxruntime-gpu.

Usage

To generate a segmentation of the humerus or scapula from a CT volume, use the following:

import armcortnet
import SimpleITK as sitk

# initialize the segmentation model
model = armcortnet.Net(bone_type="scapula")  # or "humerus"

# perform segmentation prediction on a CT volume
pred_segmentations = model.predict(
    vol_path="path/to/input/ct.nrrd"
)
# output is a list of SimpleITK images, one for each bone_type detected in the CT
for i, pred_seg in enumerate(pred_segmentations):
    # write each of the segmentations to the disk
    sitk.WriteImage(pred_seg, f"scapula-{i}.seg.nrrd")

A mesh of the predicted bone can be generated using the following:

# perform mesh prediction on a CT volume, returns list of vtkPolyData objects
pred_meshes = model.predict_poly(
    vol_path="path/to/input/ct.nrrd"
)

# iterate over each detected object
for i, cort_trab_polys in enumerate(pred_meshes):
    # iterate over the cortical and trabecular meshes
    for j, poly in enumerate(cort_trab_polys):
        armcortnet.write_polydata(p, f"scapula_{i}_{j}.ply")

Output Labels

The segmentation output contains the following labels:

  • 0: Background
  • 1: Other adjacent bones ("i.e clavicle, radius, ulna, etc.")
  • 2: Cortical region of bone of interest
  • 3: Trabecular region of bone of interest

Note: label 1 is removed when post-processing is used

Models

Trained models are automatically downloaded from HuggingFace Hub (gregspangenberg/armcortnet) on first use.

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

armcortnet-0.7.1.tar.gz (17.4 kB view details)

Uploaded Source

Built Distribution

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

armcortnet-0.7.1-py3-none-any.whl (17.8 kB view details)

Uploaded Python 3

File details

Details for the file armcortnet-0.7.1.tar.gz.

File metadata

  • Download URL: armcortnet-0.7.1.tar.gz
  • Upload date:
  • Size: 17.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.8 {"installer":{"name":"uv","version":"0.10.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Fedora Linux","version":"43","id":"","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for armcortnet-0.7.1.tar.gz
Algorithm Hash digest
SHA256 abe4929edc5e4e6f0578dde68945f3050e166fb3550bf5e7a28b1f9ef93a44e4
MD5 83333b3cced43184d4578fa8e6133221
BLAKE2b-256 615db93ec238fc87584c71eab70193e577e4c5b1ec5c61f33ecae2f3a2d7017b

See more details on using hashes here.

File details

Details for the file armcortnet-0.7.1-py3-none-any.whl.

File metadata

  • Download URL: armcortnet-0.7.1-py3-none-any.whl
  • Upload date:
  • Size: 17.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.8 {"installer":{"name":"uv","version":"0.10.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Fedora Linux","version":"43","id":"","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for armcortnet-0.7.1-py3-none-any.whl
Algorithm Hash digest
SHA256 0c8858f2a1f160d32d0a192a925dfdcb341a1e6e8a0434780e71b27743ac81fa
MD5 160ebc83de9751c28a763af76849cc96
BLAKE2b-256 57d6b60eae7395e723945596127b39dff720b4d9916f08b0b9489f7eb7233386

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