Repository navigation
Conversation
Copied byte-for-byte from the standalone script. A .gitattributes rule keeps LF line endings so file hashes stay the same on Windows checkouts.
Reads the 24 per-level masks, validates them, runs the engine in memory, writes 24 masks, a combined map with ids 26-49 and a JSON report.
Import, choices entry and dispatch only. Default engine is unchanged. Adds the vertebrae_driftfix_relabel config key (default false).
Includes known limits and a placeholder for the benchmark table.
The held-out numbers in the docs describe the full pipeline, so the default now matches them. vertebrae_driftfix_relabel: false keeps the safer mask-preserving mode for data with L6/T13 spines.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds an optional case engine,
shapekit_driftfix, for the 24 vertebra masks (L5 ... C1).It removes specks and far debris, decides what to do with detached fragments, repairs label drift at the
discs, restores a lost level when the CT supports it, and flags inverted or oversized level steps. Every
change and flag is in a JSON report.
Files: the algorithm as a vendored script (
utils/vertebrae_driftfix_engine.py, unchanged from thestandalone version), a thin adapter (
utils/vertebrae_driftfix.py), tests,docs/VERTEBRAE_DRIFTFIX.md,a README section, a comment and one key in
config.yaml, and three small edits inmain.py(import,choices, dispatch).Why opt-in
It is selected only with
--vertebrae_engine shapekit_driftfix --vertebrae_only. The default engine, otherengines and shared code are untouched. All five stages run by default, which is the configuration scored on held-out scans. Setting
vertebrae_driftfix_relabel: falseskips the two stages that can change a vertebra's level; use it wherespines with an L6 or T13 are likely and nobody reviews the flags (see the L6 result below). The CT is optional; without it the
engine runs mask-only and the report says
ct_used: false(this differs from hao and ct_refinement, whichraise an error).
Validation actually done
voxel, on a synthetic phantom and on the cropped demo case BDMAP_00000006 (relabel off and on); missing
CT; existing output refused; grid mismatch, overlap and non-binary masks rejected. 15 tests pass.
CRLF checkout, not related to this change.
main.py: exit 0, 794 voxels changed, 1 review flag, about 28 s.main.pyon KaggleCPU (table in
docs/VERTEBRAE_DRIFTFIX.md): raw 0.8805 mean Dice; ct_refinement 0.8905 (+0.0100); this engine 0.8892(+0.0087, 95% interval +0.0017 to +0.0176), order violations 964 to 287, 59 scans better and 9 worse; hao 0.8809;
default shapekit 0.8769; songlin 0.8460. ct_refinement is ahead on Dice and makes only 1 scan worse.
shapekit_procrashed on 6 of the first 10 scans:IndexErroratutils/vertebrae_pro_engine.py:815(index equal tothe array length when a band reaches the top of the cropped spine). Happy to send a separate small fix.
Known limits
From the author's held-out test of 100 CTs with ground truth (frozen script, scored once):
moved 14 vertebrae one level the wrong way).
AI assistance
The design, the evaluation protocol and the benchmark are mine; much of the code, tests and docs were written with Claude Code under my direction and reviewed by me.