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

[Bug] Segmentation is rendered in reverse order #4421

Open
TuanDTr opened this issue Oct 15, 2024 · 8 comments
Open

[Bug] Segmentation is rendered in reverse order #4421

TuanDTr opened this issue Oct 15, 2024 · 8 comments
Labels
Awaiting Reproduction Can we reproduce the reported bug?

Comments

@TuanDTr
Copy link

TuanDTr commented Oct 15, 2024

Describe the Bug

We generate the SEG file using highdicom and load in OHIF and Slicer. On OHIF the segmentation is loaded in the reverse order, e.g., the mask on slice 70/121 is rendered on slice 50/121. On Slicer it is rendered correctly

Steps to Reproduce

Our image is a multiframe OCT image and we use highdicom to create the corresponding SEG file. The script to create SEG file is adapted from this one.

The current behavior

The segmentation is rendered in the reversed order.

The expected behavior

Segmentation is mapped correctly to slice order of the image. For privacy issue, I am not able to provide the image and seg file.

OS

Windows10

Node version

I'm not able to find it

Browser

Chrome 129.0.0

@TuanDTr TuanDTr added the Awaiting Reproduction Can we reproduce the reported bug? label Oct 15, 2024
@TuanDTr
Copy link
Author

TuanDTr commented Oct 15, 2024

It's likely related to this issue #2833 and #3754

@igorsimko
Copy link

igorsimko commented Oct 30, 2024

Same thing happening to me. Order is reversed and middle frames are even overlapping - Seems like 2 frames are on top each other with some opacity + one frame is missing segmentations completely? Also some frames towards the end have weird noise in them. It really seems like rendering is not working properly for OCTs.

I tried playing with Image Position Patient and Image Orientation Patient. You can reverse order by changing Image Position Patient, but mentioned issues above still persist.

Does someone have any workaround/fix I can try?

EDIT:
I narrowed problem down to this commit 3dd0666. Seems like caching 3dd0666#diff-6b143612508a642eb2f3c52a3227be7f8d9cdd7784df1d48922fe46531ca6bf3R469 broke it.

Maybe @igoroctaviano can help solving this.

Workaround for now seems to be use commit before d5bcf54 or remove caching part.

@igoroctaviano
Copy link
Contributor

Same thing happening to me. Order is reversed and middle frames are even overlapping - Seems like 2 frames are on top each other with some opacity + one frame is missing segmentations completely? Also some frames towards the end have weird noise in them. It really seems like rendering is not working properly for OCTs.

I tried playing with Image Position Patient and Image Orientation Patient. You can reverse order by changing Image Position Patient, but mentioned issues above still persist.

Does someone have any workaround/fix I can try?

EDIT: I narrowed problem down to this commit 3dd0666. Seems like caching 3dd0666#diff-6b143612508a642eb2f3c52a3227be7f8d9cdd7784df1d48922fe46531ca6bf3R469 broke it.

Maybe @igoroctaviano can help solving this.

Workaround for now seems to be use commit before d5bcf54 or remove caching part.

Screenshot 2024-10-31 at 07 22 07

@igorsimko I can't replicate the issue on my end. Could you share the dataset and test steps? I'd like to confirm your data source and exact steps. Adding one line to enable caching causing the order to break seems unusual.

@igorsimko
Copy link

@igoroctaviano Unfortunately I can't share original files, but I'll create some testing sample based on https://github.com/dcmjs-org/dcmjs/pull/402/files#diff-8e614511788d9ed68fe64dd9c9c1fd1c8f91c00798b6c6edac9a306ec78f1b06R14 and share them here.

@igorsimko
Copy link

@igoroctaviano I'm attaching segmentations and oct.

You can quickly see reversed order of images (I burned indexes starting from 0 into images):
Without segmentation
image

With segmentation
image

You should be able to see same weird artifacts happening which I described in my first comment.

@igorsimko
Copy link

Hey @igoroctaviano do you have maybe some hints what can be an issue so I can try to debug it myself? I can see that Image Orientation Patient and specially Image Patient Position tags have impact on order but I don't understand why potentially wrong tag values can cause overlapping of frame images/ not displayed segmentations on some frames.

I know there's lot's of going on with OHIF and I really value any feedback you guys provide.

@igoroctaviano
Copy link
Contributor

Hey @igoroctaviano do you have maybe some hints what can be an issue so I can try to debug it myself? I can see that Image Orientation Patient and specially Image Patient Position tags have impact on order but I don't understand why potentially wrong tag values can cause overlapping of frame images/ not displayed segmentations on some frames.

I know there's lot's of going on with OHIF and I really value any feedback you guys provide.

Hi @igorsimko. I plan to look into it as soon as I have time. Many changes are being merged into OHIF following the integration of Cornerstone3D 2.0, so it makes sense to wait a bit.

@igorsimko
Copy link

igorsimko commented Nov 18, 2024

I did few more tests and I discovered few points which might help to debug it:

  • SliceThickness is very small - 0.06
  • Image Patient Position(s) are not evenly spread, distances (SliceThickness) between slices diverge a bit

When I changed SliceThickness to be >= 1 and spread slices evenly I no longer see these weird artifacts (overlaying of images). I also swapped order if Image Patient Position to match Reference Coordinates order so slices are not in reversed order.

I still don't fully understand why small slice thickness is causing issue with rendering since all values are coming from real OCT device.

EDIT: I just realized that all slices match except of 3 in the middle, 48, 49, 50, there seems to be shift by one

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Awaiting Reproduction Can we reproduce the reported bug?
Projects
None yet
Development

No branches or pull requests

3 participants