jrkerns / pylinac

An image analysis library for medical physics
MIT License
145 stars 94 forks source link

Creation of ground truth .dcm for WinstonLutz #436

Closed caro314 closed 1 year ago

caro314 commented 1 year ago

Hi together, maybe someone can help me out, would really appreciate any help. If this is not the right context here, please be gentle, it is my first issue on github.

I am trying to build ground truth synthetic dicoms to test a STX QA tool in which I have built in pylinac WinstonLutz.

My idea was simple but turns out "just writing a dicom" is not as simple as I thought. My vision:´is the following

Describe alternatives you've considered

pylinac 3d spheres

Additional context

I am aware that there have been tests implemented recently. However, my co-physicist are not well trained with the concept of testing in software development ;) I therefore want to demonstrate the functionality of pylinac winstonlutz with my ground truth images. Really appreciate any help, here.

Best, Cati

jrkerns commented 1 year ago

Hello Cati, I can hopefully help. First though, this is more of a discussion vs an "issue" and is better suited for the google forum: https://groups.google.com/g/pylinac.

If I'm understanding correctly, I think we can shortcut your problem and use the image generator module in pylinac. You can see examples and code to create the DICOMs here: https://pylinac.readthedocs.io/en/latest/winston_lutz.html#benchmarking-the-algorithm. I also had issues trying to prove that the WL algorithm was correct. Real data always has some error it in, and identifying whether that error was accurate proved tricky, which is why I made the synthetic image generator. If that solves your problem then I think that's it.

To answer the question about creating dicoms from an array, it is very possible to do so. The excellent pydicom library can help you there: https://pydicom.github.io/pydicom/stable/tutorials/dataset_basics.html. For the image itself, you should write back to bytes and also adjust the Rows and Columns tags so when you read it again it all matches. Here's how pylinac does it: https://github.com/jrkerns/pylinac/blob/master/pylinac/core/image.py#L1040-L1055

caro314 commented 1 year ago

Hi, thank you for the fast answer - okay, next time I'll post it in the forum!

You got my request quite right, as you described the problem perfectly:

I also had issues trying to prove that the WL algorithm was correct. Real data always has some error it in, and identifying whether that error was accurate proved tricky, which is why I made the synthetic image generator. If that solves your problem then I think that's it.

I will check out all your suggestions and report the outcome :-)

mchamberland commented 1 year ago

@caro314 @jrkerns for the record, the synthetic image generator in Pylinqc helped convince me and my colleagues that we could safely switch to Pylinqc for Winston-Lutz and other tests. Highly recommend using it for testing and benchmarking.