Add opt-in read-only vertebral instance analysis - #7
Draft
ShirongZuo-ai wants to merge 3 commits into
Draft
Conversation
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.
Summary
Add a disabled-by-default anatomical-consistency audit that produces deterministic per-case JSON reports without modifying segmentation outputs.
This is a diagnostic, read-only contribution. It does not implement automatic vertebral correction, re-identification, or relabeling.
What changed
Add
analyze_vertebral_instances(...), a standalone analyzer that:Add an opt-in batch adapter that runs immediately after segmentation loading and before mask combination or organ postprocessing.
Write one canonical JSON audit to:
Add strict configuration validation, lazy analyzer import, failure isolation, atomic writes, same-patient concurrency protection, path containment, and control-character rejection.
Configuration
The audit is disabled by default:
CT data are accessed only when
use_reference_as_ct: true. The configured reference must be a known voxel-aligned CT image. Invalid requested CT input falls back to geometry-only evidence with a warning.Safety and compatibility
main.main()regression tests verify identical segmentation-output SHA-256 maps for absent, disabled, geometry-only, CT-authorized, and analyzer-failure modes.mkstemp.Validation
Result:
Coverage includes physical spacing and affine behavior, anisotropy, supported mild obliquity, unsupported shear/obliquity, missing and duplicate identities, partial FOV, ambiguity, overlaps, rejected off-trajectory candidates, CT-optional behavior, deterministic serialization, input non-mutation, multiprocessing consistency, actual batch loading/saving, failure handling, concurrent same-patient writes, and symlink containment.
Boundaries and limitations
Reviewer focus