Mismatch between DICOM segmentation volume and original image #7060
Replies: 7 comments 1 reply
-
Loading DICOM seg object is not supported.. @ericspod @vikashg would be great to understand the current best practice, any recommendations for offline preprocessing? |
Beta Was this translation helpful? Give feedback.
-
one possibility is to use then use monai transforms to convert the seg.nii into the same space as the corresponding image: import monai.transforms as mt
img = mt.LoadImage(ensure_channel_first=True)('image.nii.gz')
seg = mt.LoadImage(ensure_channel_first=True)('seg-1.nii.gz')
out_seg = mt.ResampleToMatch(mode="nearest", padding_mode="zeros")(seg, img)
saved = mt.SaveImage("/Users/Documents/temp")(out_seg) |
Beta Was this translation helpful? Give feedback.
-
Thanks @wyli for the investigation. This is close to what I have been doing now with the workaround script. From what I have read from the segmentation object meta, it doesn't contain info of the original image. So it needs to info image (w, h, d) plus the affine to correctly align the label and the image. |
Beta Was this translation helpful? Give feedback.
-
I'm afraid for now this conversion is probably the best idea. We have been discussing the need for DICOM seg support with MONAI Deploy but haven't implementing support in core. @vikashg perhaps would have a better idea of seg software support. |
Beta Was this translation helpful? Give feedback.
-
An alternative way using pydicom_seg.
|
Beta Was this translation helpful? Give feedback.
-
Hello @wyli and @ericspod I will post some code tonight and link it here. Sorry I was tied up with few things so I wasn't able to respond earlier |
Beta Was this translation helpful? Give feedback.
-
Hello all, https://github.com/Project-MONAI/monai-dicom-utils/tree/vikash/dicomseg/app |
Beta Was this translation helpful? Give feedback.
-
Describe the bug
Could be related to #6928
Background:
This issue appears when I am working with DICOM segmentations generated by OHIF viewer.
There are dicom images and segmentations (labels) in OHIF.
I can read the dicom images succesfully with MONAI, but the labels in DICOM segmentation "SE00000.dcm" are organized by invidual slices. So if I read it directly with
LoadImaged
, the volume sizes of image and label will be mismatch.In my example below, the s0004 (total segmentator) has a image size of
[255, 177, 440]
, but the "label" generated by the DICOM segmentation is(7987, 177, 255)
I have a script to fix this:
To Reproduce
Steps to reproduce the behavior:
Below is the data and script to reproduce:
data_and_script.zip
Expected behavior
A clear and concise description of what you expected to happen.
Screenshots
If applicable, add screenshots to help explain your problem.
Environment
Ensuring you use the relevant python executable, please paste the output of:
Additional context
Add any other context about the problem here.
Beta Was this translation helpful? Give feedback.
All reactions