pyplati / platipy

Processing Library and Analysis Toolkit for Medical Imaging in Python
https://pyplati.github.io/platipy/
Apache License 2.0
103 stars 24 forks source link

Read_dicom_image(path2folder) function returns 2D/4D image when path2folder contains combination of CT slices, and RT Dose or DRR (RT image)RT #211

Closed LeviMadden closed 1 year ago

LeviMadden commented 1 year ago

I've been working with Platipy to create 3DCT images from CT slices in a parent folder, and I've come across some unexpected behaviour. The function platipy.dicom.io.rtstruct_to_nifti.read_dicom_image() sometimes returns a Simple ITK image that has incorrect dimensionality, e.g., a 2D or 4D simple ITK image instead of a 3DCT. After some investigation, I've found that the image dimensionality is incorrect when the folder containing the CT slices also contains DRRs (RT images) or RT dose files. I believe this behaviour is inherited from Simple ITK's ImageSeriesReader_GetGDCMSeriesIDs(path2folder). Unfortunately, I can't provide a minimum working example as I am working with patient data.

pchlap commented 1 year ago

Hi @LeviMadden,

ah yes I see what you mean. That certainly is a problem. You basically need to make sure each folder contains only the DICOM files for that series, its a bit of a pain.

My approach to dealing with issues like this is to develop a new tool that sits alongside platipy. It takes care of sorting out all the DICOM files prior to converting them. It may be overkill for what you need but might help you along in the right direction. The tool is called PyDicer, still a work in progress but it is coming along: https://github.com/AustralianCancerDataNetwork/pydicer

LeviMadden commented 1 year ago

Hi @pchlap,

Thank you for your prompt response. I will look into PyDicer. My solution was to call os.list_dir() and filter out files without "CT" in their name, but that ended up being slow when working with 4DCTs.

Thank you, Levi