dicom-contour
dicom-contour copied to clipboard
Robustness of coords2pixel
Hello. Nice scripts. I found this repo through your blog post.
When trying this out, I noticed that it is based on two unstated assumptions:
- The .dcm files are named exactly as %SOPInstanceUID%.dcm
- The RTStruct .dcm file is located at the same directory level as the CT Slice .dcm files.
As DICOM standards are very loose, those two assumptions aren't always correct. (I noticed this problem because it failed on my data sets...)
For example, in coords2pixel:
# extract the image id corresponding to given countour
# read that dicom file
img_ID = contour_dataset.ContourImageSequence[0].ReferencedSOPInstanceUID
img = dicom.read_file(path + img_ID + '.dcm')
img_arr = img.pixel_array
Ditto... Any chance you could provide a way to get around having filenames that are not of the %SOPInstanceUID%.dcm format (e.g. 00000.dcm) and RTStruct is not in the same directory as slices?
Thanks for pointing this out! Please feel free to do PRs :)