ENH: add volume_geometry_index for 3D volume geometry validation#126
ENH: add volume_geometry_index for 3D volume geometry validation#126
Conversation
Add a new series-level index that checks geometric consistency of single-frame CT, MR, and PT series. Each row contains boolean columns for orientation, spacing, dimensions, and slice position checks, plus a composite valid_3d_volume flag. Key decisions informed by sensitivity analysis against 303k series: - sliceIntervalTolerance set to 0.2mm (matches dcm2niix kSliceTolerance) - Removed minInstanceCount check (not a geometry property) - All derived columns use snake_case per project convention Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
b1807b9 to
623d8c6
Compare
| # This table contains one row per DICOM series from IDC | ||
| # for single-frame CT, MR, and PT SOP classes, with boolean | ||
| # columns indicating whether each geometric consistency check | ||
| # passes. The checks validate that the series represents a |
There was a problem hiding this comment.
"Validate" may not be the best term here, rephrase.
| # TRUE if all individual checks pass, indicating the series forms a valid 3D volume | ||
| single_orientation AND orthogonal_orientation AND unique_slice_positions | ||
| AND consistent_in_plane_row AND consistent_in_plane_col AND consistent_pixel_spacing | ||
| AND consistent_image_dimensions AND uniform_slice_spacing AS valid_3d_volume |
There was a problem hiding this comment.
regularly_spaced_3d_volume?
|
From @pieper
|
Compute expected slice spacing as (max_position - min_position) / (N - 1) and compare each adjacent interval against it, rather than comparing MAX(interval) - MIN(interval). This is more numerically robust per the approach used in 3D Slicer. Recovers 19 additional series at 0.2mm tolerance with no regressions. Reference: Slicer/Slicer@3328b8121 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…scriptions - Rename composite column to regularly_spaced_3d_volume to better reflect what it tests (regular spacing, not general validity) - Rephrase table description to characterize geometric properties rather than "validate" — series that fail checks may still be usable with resampling or acquisition geometry correction - Add clarification that the composite flag means the series can be loaded directly into a 3D array without resampling Addresses review feedback from @fedorov and @pieper. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Add approach overview explaining the geometric projection strategy - Document key SQL patterns (WITH/CTE, LEAD, window functions, SAFE_CAST, SAFE_DIVIDE, COUNT DISTINCT, ANY_VALUE) - Add header comments for each CTE explaining its role in the pipeline - Expand inline comments to explain the geometric meaning of each computation (dot products, cross products, projections) - Reference DICOM tag numbers for key attributes Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Replace absolute sliceIntervalTolerance (0.2mm) with a relative relativeSliceTolerance (2% of expected spacing). The absolute threshold was inappropriate for preclinical/small-animal imaging in IDC (~1,400 mouse MR series with ~0.1mm spacing), where 0.2mm is 2x the actual spacing. Empirical analysis confirmed floating-point jitter is sub-micrometer, so no absolute floor is needed. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Tighten relativeSliceTolerance from 2% to 1% to match the default _DEFAULT_SPACING_RELATIVE_TOLERANCE in highdicom's get_volume_positions. Empirical analysis shows only 131 additional series (out of 296k) fail at 1% vs 2% — the distribution is bimodal with no meaningful population in between. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…cquisitions Add a numeric column reporting the angle (in degrees) between the slice normal and the nearest cardinal axis. 0° = pure axial/sagittal/coronal, higher values indicate oblique acquisition or gantry tilt. ~27k series (9%) in IDC have non-trivial obliquity. This information was previously invisible in the boolean checks since the projection-based approach correctly handles oblique geometry — a tilted series passes all regularity checks. The new column lets users identify tilted series that may need special handling (e.g., reformatting to true axial). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Analysis: comparison with highdicom and 3D Slicer geometry handlinghighdicom
|
| Our check | highdicom | Slicer |
|---|---|---|
single_orientation |
Caller checks before calling get_volume_positions |
Implicit (corner mismatch if IOPs differ) |
orthogonal_orientation |
Not explicit | Not explicit (assumes orthogonal) |
unique_slice_positions |
allow_duplicate_positions parameter |
Implicit (duplicate positions → zero displacement) |
consistent_in_plane_row/col |
Perpendicularity check (span direction) | Corner comparison detects lateral shifts |
consistent_pixel_spacing |
Not in this function | Corner comparison detects in-plane scale changes |
consistent_image_dimensions |
Not in this function | Not checked (assumes uniform) |
uniform_slice_spacing |
np.isclose(spacings, spacing, rtol=0.01) |
Corner comparison detects spacing irregularity |
obliquity_degrees |
Not computed | Not computed (handles tilt via correction transform) |
regularly_spaced_3d_volume |
Returns spacing, positions or None, None |
maxError ≤ cornerEpsilon |
OHIF Viewer geometry validationOHIF checks reconstructability in Tolerance constantsconst spacingTolerance = 0.2; // 20% relative tolerance
const iopTolerance = 0.01; // absolute tolerance per IOP componentNote: OHIF's Spacing checkOHIF computes
Key difference: OHIF uses Euclidean distance between IPP vectors ( Orientation check
Position shift check
Dimension/component checks
Comparison table
Notable observations
|
Add a new series-level index that checks geometric consistency of single-frame CT, MR, and PT series. Each row contains boolean columns for orientation, spacing, dimensions, and slice position checks, plus a composite valid_3d_volume flag.
Key decisions informed by sensitivity analysis against 303k series: