Skip to main content

bone-microarchitecture icon

Bone Microarchitecture

Lightweight microarchitecture measurements from binary masks and optional calibrated grayscale arrays.

Author: Matthias Walle.

The array measurement API has no Slicer dependency and expects calibrated arrays on a common grid. File-based batch workflows use SimpleITK (and aimio-py for AIM) to load inputs and place cropped masks on the grayscale grid with nearest-neighbor resampling using origin, spacing, and direction. This is grid reconciliation, not registration; geometry-free arrays must already have the grayscale dimensions. The grid policy participates in batch cache compatibility so older incompatible maps are recomputed.

Batch discovery accepts canonical segmentation, periosteal, trabecular, and cortical roles from shared contour derivatives and their sidecars. See CHANGELOG.md for release notes.

GPU Backends

Exact Hildebrand sphere fitting supports three diameter-accumulation backends:

  • cpu: NumPy/SciPy fallback.
  • mps: native Apple Metal backend for macOS.
  • opencl: OpenCL backend for Windows/Linux systems with pyopencl and a working GPU OpenCL runtime.

Use thickness_backend="auto" to select Metal on macOS when available, OpenCL on Windows/Linux when available, and CPU otherwise.

Automatic OpenCL selection requires an actual GPU and a successfully compiled kernel; a CPU OpenCL runtime is not considered GPU acceleration. Batch logs identify the device and any CPU fallback reason before computation. CSV JSON sidecars and map manifests record thickness_backend, thickness_device, thickness_gpu, and thickness_backend_reason. Reused maps retain their original backend provenance; reusing maps does not run the GPU again.

Only sphere-diameter accumulation is GPU-accelerated. Distance transforms, ridge selection, statistics and image I/O remain on CPU. Installing bone-microarchitecture[gpu] installs platform-specific Python bindings, not the GPU manufacturer's driver/OpenCL runtime. Explicit GPU requests raise an error when unavailable; auto keeps CPU-only systems usable.

Optional installs:

pip install "bone-microarchitecture[mps]"
pip install "bone-microarchitecture[opencl]"
pip install "bone-microarchitecture[gpu]"

Parameter Definitions

  • Tb.BMD: mean calibrated grayscale value inside the trabecular compartment.
  • Tb.BV/TV: trabecular bone volume divided by trabecular total volume.
  • Tb.Th: maximal-sphere local thickness of trabecular bone.
  • Tb.Sp: maximal-sphere local thickness of non-bone space in the trabecular compartment.
  • Tb.N: reciprocal of mean ridge-to-ridge spacing in the trabecular compartment (not mean reciprocal spacing).
  • Tb.1/N.SD: standard deviation of ridge-to-ridge spacing.
  • Tb.BV: trabecular bone volume.
  • Tb.TV: trabecular compartment volume.
  • Ct.BMD: mean calibrated grayscale value inside the cortical compartment.
  • Ct.Th: maximal-sphere local thickness of the cortical compartment, including internal pores.
  • Ct.Po: cortical pore volume divided by cortical total volume.
  • Ct.Po.V: selected intracortical pore volume after connectivity and size cleanup.
  • Ct.Po.Dm: maximal-sphere local diameter of the selected intracortical pores.
  • Ct.BV: cortical bone volume.
  • Ct.TV: cortical compartment volume.

IPL-aligned measurement definitions

The standard method is ipl-aligned-region-v3, replacing the previous definitions. It follows the supplied IPL_UPAT_CALGARY_EVAL_XT2_NOREG.COM evaluation recipe:

  • Pore selection uses enclosed XY seeds, Z-only hysteresis growth, a second XY pass and removal of components smaller than five voxels. It does not classify every non-bone cortical voxel as a pore or close longitudinal canals at scan ends. The stages are described by Burghardt et al., Bone 2010.
  • Ct.Th uses the supplied cortical compartment, not only its mineralized phase. Ct.Po = selected pore volume / cortical compartment volume, matching the supplied script's denominator. Ct.Po is therefore not necessarily 1 - Ct.BV/Ct.TV.
  • Tb.Sp and ridge spacing retain the full bone-phase context before restricting reporting to the trabecular compartment. Tb.N is inverse mean spacing.
  • Hildebrand fitting follows the documented IPL suppress_boundary=2 policy: distances and ridges use the full input phase, then sphere centres are restricted to the reporting region. Spheres may extend beyond that region or reach an acquired image face; output is clipped to the image and reporting phase. No fixed slice strip is blanked. CPU, Metal and OpenCL share this policy. The optional edt preview remains a distance-transform approximation.

Pass analysis_mask to constrain sphere centres and reporting to a common or Functional Bone region. Distances and ridge extraction retain full native phase context: the ROI is not a new bone/marrow wall. Native cortical pore selection is preserved before intersection; Ct.Po.Mask records it independently of diameter.

Each analysis owns its final maps. Native batch maps remain in xct/maps/; common-region maps are in xct/registered_measurements/maps/. The file-level bone_microarchitecture.case.run_microarchitecture_case helper saves Functional Bone maps in output_dir/maps/. Unchanged inputs, geometry, region and settings reuse that analysis's complete final outputs. Changed input contents or missing/ rewritten maps invalidate reuse. Distance fields are recomputed, not cached. restrict_measurements remains a post-hoc reporting helper; it cannot change sphere eligibility and is not used for common/functional-region calculations.

Results and CSV JSON sidecars record ipl-aligned-region-v3 separately from the package version. Batch hashes invalidate pre-alignment maps and measurements; legacy results must be recalculated, not mixed into a new comparison. Ratios remain fractions, not percentages. For Tb.N, the CSV Mean is inverse mean spacing; its other distribution columns describe the local inverse-spacing map.

Exact IPL parity is not validated. The pore implementation explicitly uses 8-connectivity in XY, 26-connectivity in 3D, a 5%-of-background-area XY cutoff, and a compact XY crop with one-voxel margin. Native IPL percentage/rank and GOBJ boundary conventions may differ. Ridge dominance and the existing half-voxel radius correction remain approximations, not verified translations of IPL's assign_epsilon. Validation requires identical input AIM masks and native IPL pore/ridge/diameter maps, not comparison of final scalar tables alone.

Metadata

Release files for bone-microarchitecture 0.3.2

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

Source distribution (sdist)

Source distribution for bone-microarchitecture 0.3.2
File Size Uploaded Provenance Actions
bone_microarchitecture-0.3.2.tar.gz 57.1 kB With provenance Details for bone_microarchitecture-0.3.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for bone-microarchitecture 0.3.2
File Interpreter ABI Platform Actions
bone_microarchitecture-0.3.2-py3-none-any.whl Python 3 none any Details for bone_microarchitecture-0.3.2-py3-none-any.whl

Total release size: 98.3 kB

Release files / bone_microarchitecture-0.3.2.tar.gz

Download URL bone_microarchitecture-0.3.2.tar.gz
Size 57.1 kB
Tags Source
SHA-256 checksum
How to use checksums
c5e0a9576c4583421b6e4aa262b27f8e1ab92388a7c5d0a07fcea57689261408
BLAKE2b-256 checksum
How to use checksums
14f8a1920bc0be2637a99e336603e9874c1a931dfd16fc2cf8060b85c0fb1efb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 25, 2026.

Transparency log

Release files / bone_microarchitecture-0.3.2-py3-none-any.whl

Download URL bone_microarchitecture-0.3.2-py3-none-any.whl
Size 41.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1af6a9ec3abc29a173e0d98de80a40c0197cef805c6e8db45f51e62418280436
BLAKE2b-256 checksum
How to use checksums
04efd73e61f59abddd1ebc753bbbf7ba4731d02a2678d3043305e1d4d7ad2f0a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 25, 2026.

Transparency log

Security for bone-microarchitecture 0.3.2

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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for bone_microarchitecture-0.3.2.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 25, 2026.

Transparency log

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.

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