Skip to content

Commit

Permalink
Add print value when failing to read pixel array:
Browse files Browse the repository at this point in the history
  • Loading branch information
gacou54 committed Apr 12, 2024
1 parent be6e89c commit 58f8a6a
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions rt_utils/image_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,13 @@ def load_dcm_images_from_path(dicom_series_path: str) -> List[Dataset]:
for root, _, files in os.walk(dicom_series_path):
for file in files:
try:
ds = dcmread(os.path.join(root, file))
filepath = os.path.join(root, file)
ds = dcmread(filepath)
if hasattr(ds, "pixel_array"):
series_data.append(ds)

except Exception:
# Not a valid DICOM file
except Exception as e:
print(f'Failed to load pixel_array from {filepath}, error: {e}')
continue

return series_data
Expand Down

0 comments on commit 58f8a6a

Please sign in to comment.