-
Notifications
You must be signed in to change notification settings - Fork 72
Open
Description
While using the rt-Utils library for RTstruct conversion, I noticed that:
If slices are present multiple times in the dicom path, they will be loaded as many times , resulting in a size N times bigger in the z-axis than it should be.
N being the number of times a slice is repeated
I fixed this by ensuring unique SOPInstanceUID in the list of files inside the load_dcm_images_from_path function:
def load_dcm_images_from_path(dicom_series_path: str) -> List[Dataset]:
unique_sop_UIDs = [] # New
series_data = []
SOPInstanceUID_tag = Tag(0x00080018) # New
for root, _, files in os.walk(dicom_series_path):
for file in files:
try:
ds = dcmread(os.path.join(root, file))
if hasattr(ds, "pixel_array") and ds[SOPInstanceUID_tag] not in unique_sop_UIDs: # Partly new (second check)
series_data.append(ds)
unique_sop_UIDs.append(ds[SOPInstanceUID_tag]) # New
except Exception:
# Not a valid DICOM file
continue
return series_dataIf this is considered useful I can submit a pull request
Regards
Zhack
Metadata
Metadata
Assignees
Labels
No labels