Skip to content

Commit

Permalink
Support pydicom 3.0
Browse files Browse the repository at this point in the history
Address deprecation warnings.

Fix up for pydicom 3
  • Loading branch information
blowekamp committed Oct 2, 2024
1 parent bf470a0 commit a804e92
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion rap_sitkcore/read_dcm.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,11 @@ def _read_dcm_pydicom(filename: Path) -> sitk.Image:
img = sitk.GetImageFromArray(~arr, isVector=False)
elif ds.PhotometricInterpretation in ["YBR_FULL_422", "YBR_FULL", "RGB"]:
if ds.PhotometricInterpretation != "RGB":
from pydicom.pixel_data_handlers.util import convert_color_space
try:
# requires pydicom 3.0
from pydicom.pixels import convert_color_space
except ImportError:
from pydicom.pixel_data_handlers.util import convert_color_space

arr = convert_color_space(ds.pixel_array, ds.PhotometricInterpretation, "RGB")

Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
SimpleITK >=2.1.0, <2.5.0

numpy
pydicom
pydicom>=2.1.0
requests>=2.31.0

# additional packages for pydicom to expand supported files
Expand Down

0 comments on commit a804e92

Please sign in to comment.