Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(sortImageIdsAndGetSpacing): sliceThickness and spacingBetweenSlices in case of nonstrict spacing #1752

Merged
merged 2 commits into from
Jan 15, 2025

Conversation

sedghi
Copy link
Member

@sedghi sedghi commented Jan 14, 2025

Not sure why the logic was like this, it didn't makes sense
zSpacing also should not be negative

… using Math.abs for sliceThickness and spacingBetweenSlices
Copy link

stackblitz bot commented Jan 14, 2025

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

Copy link

netlify bot commented Jan 14, 2025

Deploy Preview for cornerstone-3d-docs ready!

Name Link
🔨 Latest commit 527f665
🔍 Latest deploy log https://app.netlify.com/sites/cornerstone-3d-docs/deploys/678714fcd65346000741fd79
😎 Deploy Preview https://deploy-preview-1752--cornerstone-3d-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@sedghi
Copy link
Member Author

sedghi commented Jan 14, 2025

FYI @salimkanoun

@salimkanoun
Copy link
Contributor

salimkanoun commented Jan 14, 2025

It could be negative, see https://dicom.innolitics.com/ciods/ct-image/image-plane/00180088
"and a negative spacing indicates slices are stacked in front of the first slice. See Image Orientation (0020,0037) in the NM Detector Module."

If you use absolute value you will reintroduce flipped NM images issue

@@ -157,14 +157,14 @@ export default function sortImageIdsAndGetSpacing(
// If possible, we use the sliceThickness, but we warn about this dicom file
// weirdness. If sliceThickness is not available, we set to 1 just to render
if (zSpacing === 0 && !strictZSpacingForVolumeViewport) {
if (sliceThickness && spacingBetweenSlices) {
if (!sliceThickness && spacingBetweenSlices) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you care about slice thickness at all - just order it starting at the preferred item, then moving to the least preferred. So maybe
if( spacingBetweenSclies ) {
...
else if ( sliceThickness)

That is, ignore the sliceThickness in the first test, OR put the slice thickness version first.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Copy link
Collaborator

@wayfarer3130 wayfarer3130 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See my comment inline.

@pieper
Copy link
Contributor

pieper commented Jan 15, 2025

More discussion (much more) about issues with negative SpacingBetweenSlices that popped up in ITK and Slicer not so long ago:

Slicer/Slicer#7987

InsightSoftwareConsortium/ITK#4794

There are some nonstandard CT instances in the world (at least some in IDC that appear to have come from real modalities) where the spacing value is negative even though the standard says it should only happen for NM.

@sedghi
Copy link
Member Author

sedghi commented Jan 15, 2025

It could be negative, see dicom.innolitics.com/ciods/ct-image/image-plane/00180088 "and a negative spacing indicates slices are stacked in front of the first slice. See Image Orientation (0020,0037) in the NM Detector Module."

If you use absolute value you will reintroduce flipped NM images issue

It can be negative for spacing between slices, but our construct (zSpacing, vtk spacing) cannot be negative as far as i know

…ion to ensure correct usage of sliceThickness and spacingBetweenSlices
@sedghi
Copy link
Member Author

sedghi commented Jan 15, 2025

@salimkanoun Actually i reverted the Math.abs and still works so most likely vtk.js Math.abs internally

@sedghi sedghi changed the title fix(sortImageIdsAndGetSpacing): ensure zSpacing is always positive by using Math.abs for sliceThickness and spacingBetweenSlices fix(sortImageIdsAndGetSpacing): sliceThickness and spacingBetweenSlices in case of nonstrict spacing Jan 15, 2025
@salimkanoun
Copy link
Contributor

Sounds good!

@wayfarer3130 wayfarer3130 merged commit aede384 into main Jan 15, 2025
26 checks passed
@sedghi sedghi deleted the fix/multiframe-nm-spacing branch January 22, 2025 16:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants