Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Team Run ID: 📒 Files selected for processing (1)
Included review availability: Your plan provides up to 2 included reviews per hour; 1 remains after this review. WalkthroughThe DICOM series-to-volume operator updates its copyright year, removes unused setup code, and calculates depth pixel spacing from the first two slice-normal projections. ChangesDICOM spacing update
Estimated code review effort: 2 (Simple) | ~10 minutes Merge Risk: ⚪ Minimal · up to Depth spacing is now calculated from consecutive slice projection distances, correcting oblique-series spacing without unresolved merge-readiness risk. Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Signed-off-by: bluna301 <luna.bryanr@gmail.com>
dae4f92 to
187bf52
Compare
Signed-off-by: bluna301 <luna.bryanr@gmail.com>
|



Bug
A discrepancy was identified between DICOM SR volume values written by one of our internal MAP pipelines and calculated volumes extracted from DICOM SEG metadata (produced by the same pipeline). This is despite DICE being >
0.999for MONAI Bundle NIfTI vs. MAP DICOM SEG.Further investigation showed a discrepancy in the depth pixel spacing (DPS) produced by the
DICOMSeriesToVolumeOperatorvs. DPS extracted from the DICOM SEG:DPS seemed to be underestimated specifically for oblique acquisitions.
Investigation
Our MAP pipeline pulls
depth_pixel_spacing(calculated in DSTVO) frommetadata(DSTVO's create_metadata method)After analysis of DSTVO's current approach, DPS is systematically underestimated for oblique acquisitions.
Currently, DPS is derived by taking the Euclidean norm of the difference between the
first_pixel_on_slice_normalvectors of the first two SOP instances. That vector is not a point in space, so the norm is not a distance. The resulting spacing is correct only whenImageOrientationPatientis not oblique. For any oblique orientation, DPS is always too small.Inside
prepare_series, each slice stores an element-wise product:and later consumes it as if it were a coordinate:
sqrt(a² + b² + c²)is only a length whena,b,care displacements along three mutually orthogonal axes. Herea,b, andcare the three component differencesp1[i] - p2[i], which are three addends of a single sum, not displacements along three orthogonal axes. Combining them under Pythagoras rather than adding them is a category error. The real DPS is|a + b + c|.Fix
The signed position along the normal for each slice has already been calculated as
distance.series._sop_instanceshave already been sorted bydistance, so taking the difference between two consecutive slice's signed positions should give the depth pixel spacing:Examples
Non-oblique.
IOP = [1, 0, 0, 0, 1, 0]givesn = (0, 0, 1). Two slices 4 mm apart:first_pixel_on_slice_normaldistance(-150, -150, 10.0)(0, 0, 10.0)10.0(-150, -150, 14.0)(0, 0, 14.0)14.0Norm of the difference:
sqrt(0² + 0² + 4²) = 4.0. Difference of distances:abs(14.0 - 10.0) = 4.0. The two agree, becausenzeroes two of the three components andsqrt(x²) = |x|for a single surviving term. Every non-oblique axial, coronal and sagittal series would produce the correct DPS, and thus the failure in calculation logic would be silent.Oblique.
IOP = [1, 0, 0, 0, 0.8, -0.6]givesn = (0, 0.6, 0.8). Same 4 mm spacing, so the second slice is offset by4n = (0, 2.4, 3.2):first_pixel_on_slice_normaldistance(-150, -150.0, 10.0)(0, -90.00, 8.00)-82.0(-150, -147.6, 13.2)(0, -88.56, 10.56)-78.0Norm of the difference:
sqrt(0² + 1.44² + 2.56²) = 2.937. Difference of distances:abs(-78.0 - -82.0) = 4.0.Two components are now live instead of one, so the norm splits the 4 mm across them and takes the hypotenuse instead of the sum. This results in a constant underestimating of the DPS in oblique cases.
Post-Fix Comparison
After the fix, the DPS is now correct for the oblique cases; DPS Error % and Volume RVE % are now consistently minuscule as expected. All cases have DPS =
4 mm, which aligns with theSpacingBetweenSlicesmetadata on each DICOM series.Summary by CodeRabbit
Bug Fixes
Chores