Clear Filters
Clear Filters

createMask is not creating a correct Contour

8 views (last 30 days)
NFC on 30 Apr 2021
Answered: Prabhan Purwar on 7 May 2021
I have a fairly straightforward code with which I am trying to create a mask from a dicom Contour, my code is largely based on the example to the createMask function with some small alterations:
path='RT-STRUCT.dcm' %path to dicom file
%extract dicominfo of Rt struct
%extract contours and ROIs
%find gtv index
gtv_index=ROIs.Number(strcmp(ROIs.Name, 'GTV'));
%plot contours (don't show plot)
plotContour(contours,gtv_index); %this creates xlim, ylim, zlim, which extracts the limits for plotting
%extract the dimension limits
%determine the sizes in all directions
points_per_mm=2; %this is the number of points per mm in the created mask
referenceInfo = imref3d([round(x_size*points_per_mm),round(y_size...
rtMask = createMask(contours, gtv_index, referenceInfo);
I have attached the result of plotContour (as a .fig) and volshow (as both .fig and png as the .fig had some issues loading) to the post, and as you can see the two are quite different.
I offer previews below, here is the contour plot
which as you can see has no flat or straight edges.
However, the volshow rendering has one completely flat side, which the contour plot does not.
Why is this happening and is there any way to change the creation of the mask in volshow to be more accurate? It seems like MATLAB is either doing some autofilling outside the contours or that my xlim, ylim, zlim arguments are causing the mask to be abruply cut off, however I can't see why it would be the latter as my xlim, ylim, zlim comes directly from the boundaries of the contourplot
EDIT: I got some clarity, if instead of
referenceInfo = imref3d([round(x_size*points_per_mm),round(y_size...
I just write
referenceInfo = imref3d([128,128,50],xlim,ylim,zlim);
then the resulting figure is much more reasonable
But I still don't quite understand why. I was led to believe that the first argument of imref3d only corresponds to the size of the output matrix, which presumably should not deform the actual shape that gets rendered when createMask is called, so why are the shapes different if all I have changed is the image size but kept world limits the same?
Thank you in advance for any responses

Answers (1)

Prabhan Purwar
Prabhan Purwar on 7 May 2021
Currently, createMask doesn't allow different pixel resolution along a single Xaxis or Yaxis, thus needs to maintain a ratio while giving Image size for creating a mask. Our team is aware of the cropping behavior and is working towards the same. I would recommend changing both to 128 (as you have shown that it works for your workflow).
Hope it helps!!
Thanks for your time and really appreciate your efforts.

Community Treasure Hunt

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

Start Hunting!