brianmanderson/Dicom_RT_and_Images_to_Mask

Possible race condition in the `walk_through_folders`

Closed this issue · 1 comments

Hi Brian,

Thank you for implementing this useful package. I am reporting a possible race condition observed in the folder parsing method.
My use case is as follows:
I have directories of dicom files of the following structure:
|-patient_name|
|-original_ct_and_rtss
|-derived_ct_and_rtss1
|-derived_ct_and_rtss2
...
where I use your package to generate derived rtstruct files based on the original ct info. The derived ct images were transformed original ct images via ITK. I have found that repeating the folder parsing with the walk_through_folders does not give consistent results (i.e. different number of set of CT-RTss were found in different iterations). After digging deeper into the source code, I think the problem originates from this line, where the dicts (self.images_dictionary, self.rt_dictionary, self.rd_dictionary, self.rp_dictionary) were passed into multiple threads, and the modification on these dictionary were performed in-place.

Have you observed any similar phenomenon? Or My use case here is simply not well supported?
I will try to remove the multi-threading part in the walk_through_folders and give the feedback on the modification.
My Platform is a mac Ventura 13.4.1 with python 3.11.7.
Thank you for your time.

Update: Hi Brian, sorry about the raised issue, it turns out that the question was related to the ct image generation. As the creation time of the CT series was used for the series instance UID. It is possible to have two CT series sharing identical series instance UID. This is Unrelated to the Dicomrttool.

TLDR: This issue is not related to Dicomrttool and may be removed.

Hey, no worries! Thanks for reaching out with a perceived issue. I'm glad it ended up working out in the end, and that the problem was not related to the package =)

Best,
Brian