Skip to content

Commit 13a1c36

Browse files
committed
BF: Wrap imports of optional deps in try-except block
1 parent 54d1c3c commit 13a1c36

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

nipype/interfaces/dcmstack.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,16 @@
1010
traits,
1111
BaseInterface,
1212
)
13-
import dicom
14-
import dcmstack
15-
from dcmstack.dcmmeta import NiftiWrapper
1613
import nibabel as nb
1714

15+
have_dcmstack = True
16+
try:
17+
import dicom
18+
import dcmstack
19+
from dcmstack.dcmmeta import NiftiWrapper
20+
except ImportError:
21+
have_dcmstack = False
22+
1823
def sanitize_path_comp(path_comp):
1924
result = []
2025
for char in path_comp:

0 commit comments

Comments
 (0)