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

Setting value of "Contour Geometric Type". #16

Open
mathiasgaede opened this issue Mar 26, 2021 · 4 comments
Open

Setting value of "Contour Geometric Type". #16

mathiasgaede opened this issue Mar 26, 2021 · 4 comments
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@mathiasgaede
Copy link

Very nice RT toolbox you are making! Due to a lack of resources such as this a year ago, i actually ended up writing some RT tools for my hospital department, for transforming mask outputs from DL models, which are also based on cv2 and pydicom. I never found the time to turn them into a well made toolbox for github, so i would love to help you guys expand your toolbox a little instead.

Contour Geometric Type
contour.ContourGeometricType = 'CLOSED_PLANAR' # TODO figure out how to get this value
contour.NumberOfContourPoints = len(contour_data) / 3 # Each point has an x, y, and z value

Setting the geometric value as CLOSED_PLANAR will nearly always work, but i recently had to expand this part myself, as it resulted in a few errors when loading some RTstructs into our image software.
If part of the mask has a lone voxel in a slice, the voxel will be deleted when importing the RTstruct unless the geometric type is set to "POINT".
If only two voxels are connected, they must be set to "OPEN_PLANAR", as the CLOSED_PLANAR value only works for 3+ connected contour points. OPEN_PLANAR is not always supported by image software, so i have had to define cases with two connected voxels as two separate POINT contours.

@awtkns
Copy link
Contributor

awtkns commented Mar 26, 2021

Hi @mathiasgaede, thanks for the feedback.

I would love to help you guys expand your toolbox a little instead.

That would be awesome, we always are happy help new contributors.

Regarding what your are saying with the contours, what would be an ideal fix? We can change between OPEN_PLANAR / CLOSED_PLANAR based on the number of points. We can also provided an interface so that users can enable POINT's instead of
OPEN_PLANAR,

@awtkns awtkns added the enhancement New feature or request label Mar 26, 2021
@mathiasgaede
Copy link
Author

mathiasgaede commented Mar 29, 2021

A quick and dirty fix would just be to use the NumberOfContourPoints value to set the geometric type:

1 = POINT
2 = OPEN_PLANAR
3 <= CLOSED_PLANAR

For this part, i don't think you need any user input, as you just need the model output to be successfully transferred to the image software without information loss. The trouble here is with the OPEN_PLANAR part not always being supported, which i will test a few methods for this week. I'm working with Syngo.via from Siemens and Mirada XD from Mirada Medical, but i can also check stuff in Slicer3D, if that is the program you are using.

For OPEN_NONPLANAR and CLOSEDPLANAR_XOR i do think you need some kind of user decision to implement them properly, but I'm not familiar enough with your toolbox to suggest a way to implement it yet.

To handle empty spaces inside contours, such as dead areas inside a tumour, i currently just inverse the binary mask, discard the largest connected component and give the other components the CLOSEDPLANAR_XOR type. This function has to be manually activated, as it is not a situation that can happen for most image series i work with. I'm sure that there are smarter ways to implement this.

I have no personal experience with usage of OPEN_NONPLANAR and i have not yet had a use case for this.

Link to Dicom standard for geometric types:
http:https://dicom.nema.org/medical/dicom/current/output/chtml/part03/sect_C.8.8.6.html#sect_C.8.8.6.1

@awtkns
Copy link
Contributor

awtkns commented Mar 31, 2021

@mathiasgaede thanks for the detailed response. We are hoping to publish the changes for this sometime over the next week.

@awtkns awtkns added this to the 1.2.0 milestone Mar 31, 2021
@mathiasgaede
Copy link
Author

A small update from my side:

I ended up converting all POINT and OPEN_PLANAR structures into CLOSED_PLANAR by expanding the number of triplets using the corresponding image serie dimensions to determine the new triplet positions, as this resultet in a better workflow for our physicians.
The reason for this, is that our delineation software has more tools available for CLOSED_PLANAR structures, whereas POINT structures had to be replaced by new delineations in order to adjust the size.

I'm not sure how common this is for other image software, but this approach will work when POINT and OPEN_PLANAR are not supported.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants