bastula / dicompyler

Extensible radiation therapy research platform and viewer for DICOM and DICOM RT
http://www.dicompyler.com
263 stars 99 forks source link

Update dicomgui.py #111

Open gertsikkema opened 6 years ago

gertsikkema commented 6 years ago

6 missing 'break' statements added. This repairs some strange features importing data. In my case it would never find the structured data (RTSS), while I knew it was there. These 6 bug fixes assume that there is always exactly one and one match.When this one match is found it applies a 'break' statement to the 'for' loop. However, I am not sure if there could be more than one match in the DICOM header data (more entries in a sequence?)

So please check if this does not jeopardize how the code should work... for my particular data cases it is an improvement.

bastula commented 6 years ago

I will look into this shortly. I know there are some conditions that it doesn't work with, but are you able to provide some example (anonymized) data to test with?

I eventually wanted to refactor the logic behind dicomgui.py into a new module inside dicompyler-core to isolate the study / series linkages.

gertsikkema commented 6 years ago

hi Aditya,

thanks for your reply.

I can send you a dataset, anonymized using CTP. Please send me your email-adress, so that I can give you permission to download. It consists of 1 CT session of 246 images, 7 RTDOSE, 5 RTPLAN, 7 RTSTRUCT and 13 RTIMAGE (the latter are never used by dicompyler)

To find the data dependencies I wrote a simple python program that solely uses DICOM UID references to find the data dependencies. It starts by first finding the RTDOSE files, then finds the dependent RTPLANs that in turn depend on RTSTRUCT which subsequently refer to a image-series/CT-SESSION.

In this example it turns out that the 7 RTDOSE refer to 3 different RTPLANs that each link to 1 RTSTRUCT. The remaining (5-3=2) 2 RTPLAN refer each to an other RTSTRUCT The final remainng (7-3-2=2) 2 RTSTRUCT are not used by any RTPLAN.

From the 7 RTSTRUCT, 6 refer to the CT session that is present in the dataset. 1 RTSTRUCT refers to a CT session that is not available in the dataset. However, this last RTSTRUCT does have a RTPLAN and a RTDOSE.

After loading the data in dicompyler, it should not show any red font with the messages 'RT Plan Not Found', 'RT Structure Set Not found'. However it shows many of these statements. It also show a few double entries.

The changes I proposed in your code (adding the 'break' statements) solves all these problems and shows all the dependencies correctly as explained above.

Rationale for changes: NOTE: Without the 'break' statements, you never break out of a for loop when a variable (for instance 'foundstructure') has been set to 'True'. The 6 break statement involving the 'for' loops break the for loop when a foundstructure, foundseries, foundplan had been set to 'True'.

cheers, Gert Sikkema

Aditya Panchal schreef op 01-05-2018 19:39:

I will look into this shortly. I know there are some conditions that it doesn't work with, but are you able to provide some example (anonymized) data to test with?

I eventually wanted to refactor the logic behind dicomgui.py into a new module inside dicompyler-core to isolate the study / series linkages.

-- You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub [1], or mute the thread [2].

*

Links:

[1] https://github.com/bastula/dicompyler/pull/111#issuecomment-385735569 [2] https://github.com/notifications/unsubscribe-auth/ANUKG-3XufLIGxdOkFuVK-9ej3RQX6nTks5tuJ3UgaJpZM4TsbnI