9
9
10
10
import numpy as np
11
11
12
+ have_dicom = True
12
13
try :
13
- import dicom
14
+ import dicom as pydicom
15
+ read_file = pydicom .read_file
14
16
except 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
18
23
dicom_test = np .testing .dec .skipif (not have_dicom ,
19
24
'could not import pydicom' )
20
25
32
37
DATA_FILE = pjoin (IO_DATA_PATH , 'siemens_dwi_1000.dcm.gz' )
33
38
DATA_FILE_PHILIPS = pjoin (IO_DATA_PATH , 'philips_mprage.dcm.gz' )
34
39
if 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 ))
37
42
else :
38
43
DATA = None
39
44
DATA_PHILIPS = None
@@ -166,7 +171,7 @@ def test_wrapper_from_data():
166
171
167
172
@dicom_test
168
173
def 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
170
175
dcm = didw .wrapper_from_file (DATA_FILE )
171
176
data = dcm .get_data ()
172
177
# Passing in non-default arg for defer_size
@@ -177,7 +182,7 @@ def test_wrapper_args_kwds():
177
182
assert_array_equal (data , dcm2 .get_data ())
178
183
# Trying to read non-dicom file raises pydicom error, usually
179
184
csa_fname = pjoin (IO_DATA_PATH , 'csa2_b0.bin' )
180
- assert_raises (dicom .filereader .InvalidDicomError ,
185
+ assert_raises (pydicom .filereader .InvalidDicomError ,
181
186
didw .wrapper_from_file ,
182
187
csa_fname )
183
188
# We can force the read, in which case rubbish returns
0 commit comments