myoL3
Automated L3-level trunk-muscle analysis from CT. Give it a full-body CT; it localizes the L3 level and crops to it, segments the trunk muscles, strips interior fat, and quantifies per-muscle, per-side body composition.
Pipeline
full-body CT -> L3 localizer (presence-gated sliding window) -> z-crop
-> muscle segmentation (nnU-Net, in-Python) -> raw labels
-> strip interior fat (intramuscular adipose tissue) -> TOTAL muscle seg
-> per-muscle / per-side composition metrics -> JSON
Muscles: psoas, quadratus lumborum, erector spinae / multifidus. The muscle/low-attenuation split is a per-scan, per-muscle Gaussian Mixture Model (GMM) crossover; interior fat (< −30 Hounsfield units, HU) is removed to form the total-muscle segmentation.
GMM crossover — a muscle's HU values form two overlapping populations, denser normal muscle and lower-HU fatty muscle. The GMM fits one bell curve to each and puts the split where they cross, so the threshold adapts to each patient rather than using a fixed cutoff.
Models. The L3 localizer is a Residual Network (ResNet-18) slice encoder with a bidirectional Gated Recurrent Unit (GRU) over the superior–inferior axis, a soft-argmax boundary head, and a presence head. The muscle segmenter is a 3D UNet (no-new-UNet / nnU-Net, full-resolution configuration) run with sliding-window inference in Python.
Installation
Install PyTorch first (pytorch.org), then:
pip install myoL3
Download the model weights (localizer + segmenter, once only):
myol3-install /path/to/models/dir
On shared HPC clusters, point at existing files instead:
export MYOL3_LOCALIZER_CKPT=/shared/models/myol3/l3_localizer.pt
export MYOL3_SEGMENTER_CKPT=/shared/models/myol3/muscle_seg.pth
Usage
# full pipeline -> total muscle seg + composition map + metrics JSON
myol3 -i fullbody_ct.nii.gz -o total_muscle_seg.nii.gz \
--save-comp composition.nii.gz --save-metrics metrics.json
# already cropped to L3 yourself -> skip localization
myol3 -i my_l3_crop.nii.gz -o total_muscle_seg.nii.gz --cropped
# localize + crop only (no segmentation model needed)
myol3 -i fullbody_ct.nii.gz --save-crop l3_crop.nii.gz
| Flag | Description |
|---|---|
-i, --input |
full-body CT (.nii / .nii.gz) — required |
-o, --output |
total muscle segmentation (interior fat stripped); omit to only localize/crop |
--cropped |
input is already cropped to L3; skip the localizer |
--save-crop |
also write the L3-cropped CT |
--save-comp |
also write the 4-compartment map (muscle*10 + compartment) |
--save-metrics |
also write per-muscle / per-side metrics (.json) |
--localizer-ckpt / --segmenter-ckpt |
checkpoint overrides |
--pad |
extra slices each side of the L3 crop |
--device |
cpu | cuda (auto if unset) |
Python API:
import myol3
myol3.run("fullbody_ct.nii.gz", "total_muscle_seg.nii.gz",
save_comp="composition.nii.gz", save_metrics="metrics.json")
Metrics
Per muscle × side (L/R), in mm² (mean, median, std, n_slices):
muscle_csa— total-muscle cross-sectional area (edge-outlier trimmed)fat_pv_muscle_csa— low-attenuation ("fat partial-volume") muscleintramuscular_fat_csa— solidly-fat interior (intramuscular adipose tissue, IMAT)outer_edge_pv_fat_csa— partial-volume boundary rim
License
MIT
Release files for myoL3 0.1.6
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| myol3-0.1.6.tar.gz | 17.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| myol3-0.1.6-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 36.2 kB
Release files / myol3-0.1.6.tar.gz
| Download URL | myol3-0.1.6.tar.gz |
|---|---|
| Size | 17.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f2c09fef127f0671b1726328446288fe7838afa4ab4a45989d8020884e3e39a4
|
|
BLAKE2b-256 checksum How to use checksums |
526f695ec0f36c5978cc62a0aa96c4bfa279c5a1f268ade2e8d6a000273abe3a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.2
|
Release files / myol3-0.1.6-py3-none-any.whl
| Download URL | myol3-0.1.6-py3-none-any.whl |
|---|---|
| Size | 18.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
bbe590e456b61b4bc441c75a655657e197e37c83ccef2ac8b65ae7386c90e7e7
|
|
BLAKE2b-256 checksum How to use checksums |
e9c9d13fc5a8190cbbd3b6f2c2b8e1d1902d06b95cb7294fbe894b6785498d19
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.2
|