Rasterizing planar contours

Skip to first unread message

Andrey Fedorov

Oct 2, 2020, 4:25:14 PM10/2/20
to Plastimatch

I have annotations that are defined as closed planar contours (ordered list of in-plane points) - similar to RTSTRUCT, but not in RTSTRUCT objects.

Is there any way I can use Plastimatch tools to fill and rasterize those planar contours to the image slice geometry?


Sharp, Gregory C.

Oct 2, 2020, 5:59:27 PM10/2/20
to plast...@googlegroups.com

Hi Andrey,


Probably yes.  Plastimatch has an ASCII format, but it does require that the point locations are sorted around the polygon. The ASCII format also requires 3D coordinates and a few other caveats.  Please let give a bit more detail and I can give cleaner suggestion of the difficulty of marshalling over.




From: plast...@googlegroups.com <plast...@googlegroups.com> On Behalf Of Andrey Fedorov
Sent: Friday, October 02, 2020 4:25 PM
To: Plastimatch <plast...@googlegroups.com>
Subject: [Plastimatch] Rasterizing planar contours


        External Email - Use Caution        

You received this message because you are subscribed to the Google Groups "Plastimatch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to plastimatch...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/plastimatch/2eec75be-0ce3-4927-b959-955ced4a233en%40googlegroups.com.

The information in this e-mail is intended only for the person to whom it is addressed. If you believe this e-mail was sent to you in error and the e-mail contains patient information, please contact the Mass General Brigham Compliance HelpLine at http://www.massgeneralbrigham.org/complianceline . If the e-mail was sent to you in error but does not contain patient information, please contact the sender and properly dispose of the e-mail.

Andrey Fedorov

Oct 2, 2020, 6:08:26 PM10/2/20
to Plastimatch

sounds promising!

What I am trying to do is to rasterize annotations created in md.ai (https://docs.md.ai/data/json/). I do NOT recommend you try to decipher their documentation - IMHO it is not complete and requires reverse-engineering, but I asked experts of md.ai to clarify few things, so hopefully will get it resolved. Currently, they may have multiple contours in the same plane, and it is not clear what set of "id"s is needed to separate groups of points corresponding to the individual in-plane contours.

In a nutshell, when I get the missing info, what I should be able to have is 1) in-plane list of points with 3d coordinates of a closed contour, with points listed in order of contour traversal; 2) DICOM instance corresponding to the plane of the contour.

At this point, I am rasterizing consecutive points with lines, and was going to next use some binary filling filter from ITK to fill the contour, but somehow I feel plastimatch might have something more robust than that (e.g., what I have in mind will fail if the outer edges of the contour touch).

Does this give all the details you need?


Sharp, Gregory C.

Oct 2, 2020, 6:26:26 PM10/2/20
to plast...@googlegroups.com

Hi AF,

Yes.  Perhaps plm might better than your script, it implements the standard line-scan polygon fill algorithm.  But there are always caveats as you know.


The plastimatch ASCII format has a specification, albeit bare-boned.  The easiest way to understand how to marshall data would be to create a segmentation and then convert it using plastimatch with the --output-cxt option.  The specification is below, but making an example will be easy and useful.  Happy to help any questions!



Andrey Fedorov

Oct 2, 2020, 9:59:45 PM10/2/20
to Plastimatch
Thanks a lot Greg, this is very helpful! I will follow up if I run into issues.

For the sake of completeness of this thread, below is an example CXT file I generated usinig an RTSTRUCT instance from this TCIA public dataset: https://doi.org/10.7937/K9/TCIA.2015.PF0M9REI (feel free to reuse it for the Plastimatch documentation - I think it will not hurt ;-) ).

CT_SERIES_UID 1.2.826.0.1.3680043.
CT_STUDY_UID 1.2.826.0.1.3680043.
CT_FRAME_OF_REFERENCE_UID 1.2.826.0.1.3680043.
PATIENT_ID PL428899027484971
OFFSET -149.79 -354.415 -612.5
DIMENSION 512 512 88
SPACING 0.613614 0.613614 3
2|0 255 120|GTV-1
6|255 192 96|Spinal-Cord
7|64 64 255|Lung-Left
8|64 64 255|Lung-Right

Reply all
Reply to author
0 new messages