how to convert dicom RT structure to binary mask

21 visualizzazioni (ultimi 30 giorni)
I am using the MATLAB documentation for converting ROIs stored in my DICOM-RT structure into binary masks. I am using [536,536,25] as the image size for the imref3d function. However, when I run the code it gives me this warning and the binary masks are empty. Can some please tell me what is going wrong?
"Warning: [20] contours have been found to be of incorrect Geometric type and have been omitted from
mask creation
> In images.internal.dicom.createMaskHelp (line 135)
In dicomContours/createMask (line 361) "
Here is my code:
info = dicominfo('p001_Pre_RT.dcm');
contour = dicomContours(info);
stat = contour.ROIs;
plotContour(contour);
referenceInfo = imref3d([352,352,25],xlim,ylim,zlim);
contourIndex = 3; %non-enhancing mask
neMask_pt01 = createMask(contour, contourIndex, referenceInfo);
  2 Commenti
Image Analyst
Image Analyst il 20 Gen 2022
Put the .dcm file into a zip file and attach it with the paperclip icon.

Accedi per commentare.

Risposte (1)

Simon Chan
Simon Chan il 17 Gen 2022
It uses world coordinates in x,y & z axis which is shown in your attached png file. So you need to capture the axis information to create the referenceInfo.
info = dicominfo('p001_Pre_RT.dcm');
rtContours = dicomContours(info);
figure(1)
plotContour(rtContours); % Your attached figure here
ax = gca; % Get the axis information here
referenceInfo = imref3d([536,536,25],ax.XLim,ax.YLim,ax.ZLim);
contourIndex = 3;
rtMask = createMask(rtContours, contourIndex, referenceInfo);
figure(2)
volshow(rtMask); % Just check you are able to obtain the masks
  3 Commenti
Raheema Al Karim Damani
Raheema Al Karim Damani il 19 Gen 2022
Modificato: Raheema Al Karim Damani il 19 Gen 2022
Okay so the only thing that got rid of that warning for me was to go into the CreateMask function and then edit this code on the line if numel(geoTypes) == numel(contours) && false
to if numel(geoTypes) == numel(contours)
this way I am actually able to get the binary masks but they do not look correct. I'm not sure what do.
Simon Chan
Simon Chan il 20 Gen 2022
I think the masks created by MATLAB are correct since they matches what you see in plotContour command.
When you rotate the contours in plotContour, you are able to see the contours only appears in some of the slices, and there exist a large gap between them. So a lot of masks created are blank.
So the main concern is that whether the RT Structure file is created correctly.
May be this file was created via a in-house software, or a third party software or both? or I may be wrong.
Anyway, I spend some time on your attached zip file and found the followings:
(1) Review ROIContourSequence and found that
For ROI#1,
ReferencedSOPClassUID: '1.2.840.10008.5.1.4.1.1.4'
ReferencedSOPInstanceUID: '2.16.840.1.114362.1.11940992.24221775583.597460774.939.450'
However, for ROI#2 to ROI#5
ReferencedSOPClassUID: '1.2.840.10008.5.1.4.1.1.2'
ReferencedSOPInstanceUID: '1.2.840.113619.2.55.3.503998593.11335.1281663748.908.120.202'
(2) Review ContourImageSequence in RTReferencedSeriesSequence found that
ReferencedSOPClassUID: '1.2.840.10008.5.1.4.1.1.4'
ReferencedSOPInstanceUID: '2.16.840.1.114362.1.11940992.24221775583.597460774.939.450'
It seems ROI#2 to ROI#5 were created separately from ROI#1 where the reference images are different.
(3) I checked All contours are CLOSED_PLANAR and hence createMask should be able to create the mask for you. The warning message may suggests that there are some inconsistency in the RT Structure file that the program is declined to do it and that is the reason why you need to edit the code to make it work.
I would suggest to create the RT Structure file from the beginning one more time and try again.

Accedi per commentare.

Categorie

Scopri di più su DICOM Format in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by