99
1010import numpy as np
1111
12+ have_dicom = True
1213try :
13- import dicom
14+ import dicom as pydicom
15+ read_file = pydicom .read_file
1416except ImportError :
15- have_dicom = False
16- else :
17- have_dicom = True
17+ try :
18+ import pydicom
19+ except ImportError :
20+ have_dicom = False
21+ else :
22+ from pydicom .dicomio import read_file
1823dicom_test = np .testing .dec .skipif (not have_dicom ,
1924 'could not import pydicom' )
2025
3237DATA_FILE = pjoin (IO_DATA_PATH , 'siemens_dwi_1000.dcm.gz' )
3338DATA_FILE_PHILIPS = pjoin (IO_DATA_PATH , 'philips_mprage.dcm.gz' )
3439if have_dicom :
35- DATA = dicom . read_file (gzip .open (DATA_FILE ))
36- DATA_PHILIPS = dicom . read_file (gzip .open (DATA_FILE_PHILIPS ))
40+ DATA = read_file (gzip .open (DATA_FILE ))
41+ DATA_PHILIPS = read_file (gzip .open (DATA_FILE_PHILIPS ))
3742else :
3843 DATA = None
3944 DATA_PHILIPS = None
@@ -166,7 +171,7 @@ def test_wrapper_from_data():
166171
167172@dicom_test
168173def test_wrapper_args_kwds ():
169- # Test we can pass args, kwargs to dicom. read_file
174+ # Test we can pass args, kwargs to read_file
170175 dcm = didw .wrapper_from_file (DATA_FILE )
171176 data = dcm .get_data ()
172177 # Passing in non-default arg for defer_size
@@ -177,7 +182,7 @@ def test_wrapper_args_kwds():
177182 assert_array_equal (data , dcm2 .get_data ())
178183 # Trying to read non-dicom file raises pydicom error, usually
179184 csa_fname = pjoin (IO_DATA_PATH , 'csa2_b0.bin' )
180- assert_raises (dicom .filereader .InvalidDicomError ,
185+ assert_raises (pydicom .filereader .InvalidDicomError ,
181186 didw .wrapper_from_file ,
182187 csa_fname )
183188 # We can force the read, in which case rubbish returns
0 commit comments