razorx89 / pydicom-seg

Python package for DICOM-SEG medical segmentation file reading and writing
MIT License
76 stars 14 forks source link

Add support for more use-cases (2D, 3D, temporal) #10

Open razorx89 opened 4 years ago

razorx89 commented 4 years ago

Currently, only the 3D reading and writing is implemented (e.g. MRI, CT), similiar to the dmcqi project. In my opinion, this covers the most common use case for e.g. image analysis. Nevertheless, more imaging modalities and dimension setups should be supported.

apint0-media commented 2 years ago

Hi @razorx89

First of, nice work on raising this repo! 😃 Wanted to ask you if there are any plans to support the temporal 2D Imaging. I've been using pydicom-seg for cardiac cine images (which are 2D + t) and noticed that the final output is a 3D vol instead of a sequence of frames, but I do not have the expertise on how to change the dicom seg.

razorx89 commented 2 years ago

Thank you! In theory I would like to support all mentioned use-cases. However, the DICOM standard is so flexible that it is not feasible to implement a solution on my own which cannot be opened by other frameworks or viewers. So if you could provide me example DICOM-SEGs generated by other tools or even clinically used software, I could have a look at how it is solved, especially regarding the dimensional indexing.

If you load your series in ITK, how is it actually stored? 3D volume or does ITK/SimpleITK correctly handle this as a temporal 2D volume?

apint0-media commented 2 years ago

Unfortunately, I do not have any reference example of DICOM-SEG files generated for 2D + t data, generated by other tools or clinical software, which hardens the problem.

The example I am trying to build, concerns a case with 25 frames, were an algo delineated 3 different classes. With that in mind, after loading the DICOM-SEG generated with pydicom-seg, the shape of the output data (with ITK) is (156,192,75,1). The 3rd dimension seems to concern the #_frames x #_classes. When loading the source input data with ITK the shape output is (156, 192, 25).

razorx89 commented 2 years ago

I don't have a 2D+t series at hand, but I would imagine that SimpleITK loads the series with GetSize()==(156,192,25) and GetDepth()==25? That would be already a problem for me, because the spatial extent would be invalid and when encoding the DICOM-SEG I would have no clue about the temporal dimension. Former workarounds (just from a quick look at some search results) separated the series DICOMs by manual header interpretation and loaded several ITK images. Maybe that got easier with SimpleITK >=2.0. Would you be able to share the DICOM data (anonymized of course) and example segmentation?

The encoding/decoding would still be somewhat problematic, because I cannot find a reference implementation in other frameworks. dcmjs seems to also only support normal 3D volumes.

apint0-media commented 2 years ago

Yes, you are correct, GetSize() and GetDepth() gave those values. Thanks for the explanation, also have some thoughts that the constrains might be on how to deal with the temporal info. Regarding sharing an example case, I'm checking if internally we can share it.