Skip to main content

Python wrapper for the DCCCcore PET biomarker command-line tool

Project description

dcccpy

dcccpy is a Python wrapper for the DCCCcore command-line tool from DCCCSlicer. It keeps the native C++ core as the execution engine and provides a small Python API for running common PET biomarker workflows.

Install

The default package is slim:

pip install dcccpy

The first call downloads the matching DCCCcore release package into the local user cache if no native runtime is otherwise available. The slim package also installs nibabel for image loading and nibabel-style image inputs.

For Linux users who prefer pip install to include the native runtime and avoid first-run download:

pip install "dcccpy[linux-runtime]"

Python API

import dcccpy

result = dcccpy.centiloid("amyloid_pet.nii", skip_normalization=True)
print(result.metrics)
print(result.output)

The output argument is optional for single-image Python calls. When omitted, dcccpy creates a temporary output NIfTI path and returns it in the result. Relative input and output paths are resolved from the current Python working directory before DCCCcore is invoked.

result = dcccpy.centiloid("amyloid_pet.nii")
print(result.output)           # temporary output path
print(result.metrics.get("fbp"))

The wrapper accepts nibabel-style image objects with to_filename():

import nibabel as nib
import dcccpy

image = nib.load("amyloid_pet.nii.gz")
result = dcccpy.centiloid(image, skip_normalization=True)
output_image = result.load_output()

Common helpers mirror DCCCcore subcommands:

dcccpy.centiloid("amyloid.nii", suvr=True)
dcccpy.centaurz("tau.nii", report_detailed_regions=True)
dcccpy.fillstates("fdg.nii", tracer="fdg")
dcccpy.normalize("pet.nii", iterative=True)
dcccpy.run(["centiloid", "--input", "a.nii", "--output", "b.nii"])

Each helper returns DCCCResult with:

  • returncode
  • stdout / stderr
  • output
  • metrics, parsed from numeric lines in stdout
  • load_output(), which loads the output with nibabel

Command Line

dcccpy also forwards raw arguments to DCCCcore:

dcccpy --help
dcccpy centiloid --input amyloid_pet.nii --output result.nii

Runtime lookup

At runtime, dcccpy looks for DCCCcore in this order:

  1. DCCCPY_DCCCCORE environment variable.
  2. A vendored binary inside the installed dcccpy wheel.
  3. A binary from dcccpy-linux-runtime, installed by dcccpy[linux-runtime].
  4. The local dcccpy cache populated by automatic download.
  5. DCCCcore on PATH.
  6. Automatic download from GitHub releases, unless disabled.

Useful environment variables:

  • DCCCPY_DCCCCORE: exact path to a DCCCcore executable.
  • DCCCPY_AUTO_DOWNLOAD=0: disable first-run automatic download.
  • DCCCPY_CACHE_DIR: override the runtime cache directory.
  • DCCCPY_RELEASE_REPO: override the GitHub release repository.
  • DCCCPY_DCCCCORE_URL: override the release asset URL.

Runtime Packaging

Release wheels should vendor the matching DCCCcore runtime tree before build:

python scripts/vendor_dccccore.py --version 4.2.3 --release-platform ubuntu-latest-x64
python -m build --wheel

The source tree intentionally does not commit the vendored runtime because it contains large ONNX model and NIfTI runtime assets.

The preferred distribution layout is:

  • dcccpy: slim Python package with nibabel; downloads runtime on first use.
  • dcccpy-linux-runtime: optional Linux runtime wheel.
  • dcccpy[linux-runtime]: installs both packages.

Packaging note

The Linux DCCCcore-4.2.3-ubuntu-latest-x64.zip release asset contains the native executable, libtbb, ONNX registration/decoupling models, configuration files, and NIfTI template/mask assets. That full runtime is the correct unit to vendor for a wheel that works immediately after pip install dcccpy.

The full Linux runtime wheel is about 167 MB for version 4.2.3, so a public PyPI upload may require a file size limit increase unless a future release splits a smaller runtime profile from the full DCCCcore package.

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

dcccpy-0.1.2.tar.gz (13.7 kB view details)

Uploaded Source

Built Distribution

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

dcccpy-0.1.2-py3-none-any.whl (9.4 kB view details)

Uploaded Python 3

File details

Details for the file dcccpy-0.1.2.tar.gz.

File metadata

  • Download URL: dcccpy-0.1.2.tar.gz
  • Upload date:
  • Size: 13.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.19

File hashes

Hashes for dcccpy-0.1.2.tar.gz
Algorithm Hash digest
SHA256 ff7644743232e75b9553d7cff10ebb9713c95dc5c5f46e406d97bbb033cfa2cb
MD5 f41170f3b3abf829f780b918590ae66f
BLAKE2b-256 1150c29a5a0c07b9d4da51b246ab799344d5dac578ca3e82df83e9a6b501e2f2

See more details on using hashes here.

File details

Details for the file dcccpy-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: dcccpy-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 9.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.19

File hashes

Hashes for dcccpy-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 22e5cf2bbbea8fae7cc5958259420069755b10db2d229ddc55bd2dc63c810c9a
MD5 3f8435a76b07f03e40be0cfd4eb7c51b
BLAKE2b-256 a9b4b135f07826d72b345b110f97d9397dbbdc125317baa6fbfd755e58f04ef4

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