Read DICOM RT structure - contours with holes are filled in

4 次查看(过去 30 天)
When I try to make a binary mask from a DICOM-RT file, I encounter an issue. For most structures, this works well, but when there is a 'hole' in the structure, it is filled in. Weirdly, this only happens when the hole is from top to bottom, not when it is present from left to right or front to back.
With the figures below, I will try to show the problem. In the first figure, the output of the plotContour function is shown. Here you can see that the structure is cylindrical (the hole goes from top to bottom).
When I then use code to create a binary mask from this volume, I get the image in the second figure (cross-section in 'z-plane' in the first figure).
The code that I used was as shown below. I added the dicomInfo.mat file to the question.
clear all, close all, clc
info = load("dicomInfo.mat");
info = info.info;
contour = dicomContours(info);
figure(1), plotContour(contour)
ax = gca;
referenceInfo = imref3d([512 512 163],ax.XLim, ax.YLim, ax.ZLim);
contourIndex = 1;
rtMask = createMask(contour,contourIndex,referenceInfo);
figure(2), volshow(rtMask)
figure(3), imshow(rtMask[:,:,76])
Has anyone else encountered this issue as well? And does anyone know how to load the data in such a way that the hole is still visible in the mask? If more information is needed, I will gladly provide it!
Thank you in advance for your help!

回答(1 个)

Piyush Dubey
Piyush Dubey 2023-8-30
Hi Suzanne,
I understand that you are facing issue while trying to apply volume masks to a DICOM-RT structure.
Please know that issues like these arise when the ROI contour of the structure is incorrectly determined. Once an incorrect ROI is generated then the following operations too result in an unintended output.
The ROI of the hole in the DICOM structure can be obtained and excluded from the ROI before masking. Masking the structure after having a consolidated ROI will cause proper analysis of the DICOM structure and subsequent masking.
Another workaround can be to orthogonally rotate the DICOM structure such that the hole can be detected similarly as it was getting detected in other orientation of the figure where hollow figure’s volume was correctly determined.
You can check the following sample code snippet for reference:
% Extract the contour for the hole
holeContour = contour{contourIndex};
% Create a binary mask with the hole
rtMask = false(size(referenceInfo.XWorldLimits, 2), size(referenceInfo.YWorldLimits, 2), size(referenceInfo.ZWorldLimits, 2));
for i = 1:size(holeContour, 1)
x = holeContour(i, :, 1);
y = holeContour(i, :, 2);
z = holeContour(i, :, 3);
maskSlice = poly2mask(x, y, size(rtMask, 1), size(rtMask, 2));
rtMask(:, :, z) = rtMask(:, :, z) | maskSlice;
end
figure(2), volshow(rtMask)
figure(3), imshow(rtMask(:, :, 76))
I hope this helps.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by