File tree 2 files changed +14
-3
lines changed
2 files changed +14
-3
lines changed Original file line number Diff line number Diff line change @@ -506,9 +506,16 @@ def load_dicom(filename):
506
506
507
507
name = osp .splitext (osp .basename (filename ))[0 ]
508
508
try :
509
- data = dicomio .read_file (filename , force = True )
509
+ # For Pydicom 3/Python 3.10+
510
+ data = dicomio .dcmread (filename , force = True )
510
511
except TypeError :
511
- data = dicomio .read_file (filename )
512
+ data = dicomio .dcmread (filename )
513
+ except AttributeError :
514
+ # For Pydicom 2/Python 3.9-
515
+ try :
516
+ data = dicomio .read_file (filename , force = True )
517
+ except TypeError :
518
+ data = dicomio .read_file (filename )
512
519
arr = data .pixel_array
513
520
return {name : arr }, None
514
521
except Exception as error :
Original file line number Diff line number Diff line change 11
11
"""
12
12
13
13
# Standard library imports
14
+ import copy
14
15
import io
15
16
import os
16
- import copy
17
17
18
18
# Third party imports
19
19
from PIL import ImageFile
@@ -350,6 +350,10 @@ def test_save_load_hdf5_files(tmp_path):
350
350
assert repr (iofuncs .load_hdf5 (h5_file )) == repr (expected )
351
351
352
352
353
+ @pytest .mark .skipif (
354
+ os .environ .get ("USE_CONDA" ) == "true" ,
355
+ reason = "Pydicom is not installed correctly in Conda envs"
356
+ )
353
357
def test_load_dicom_files ():
354
358
"""Check that we can load DICOM files."""
355
359
# This test pass locally but we need to set the variable below for it to
You can’t perform that action at this time.
0 commit comments