1515
1616from ... import logging
1717from ...utils .filemanip import split_filename
18- from ...utils .misc import package_check
1918from ...workflows .misc .utils import get_data_dims , get_vox_dims
20- from ..base import TraitedSpec , BaseInterface , File , isdefined
21-
22- import warnings
23- have_dipy = True
24- try :
25- package_check ('dipy' )
26- except Exception as e :
27- have_dipy = False
28- else :
29- from dipy .tracking .utils import move_streamlines , affine_from_fsl_mat_file
19+ from ..base import TraitedSpec , File , isdefined
20+ from ..dipy .base import DipyBaseInterface , HAVE_DIPY as have_dipy
3021
3122iflogger = logging .getLogger ('interface' )
3223
3324
3425def transform_to_affine (streams , header , affine ):
26+ from dipy .tracking .utils import move_streamlines
3527 rotation , scale = np .linalg .qr (affine )
3628 streams = move_streamlines (streams , rotation )
3729 scale [0 :3 , 0 :3 ] = np .dot (scale [0 :3 , 0 :3 ],
@@ -168,7 +160,7 @@ class MRTrix2TrackVisOutputSpec(TraitedSpec):
168160 out_file = File (exists = True )
169161
170162
171- class MRTrix2TrackVis (BaseInterface ):
163+ class MRTrix2TrackVis (DipyBaseInterface ):
172164 """
173165 Converts MRtrix (.tck) tract files into TrackVis (.trk) format
174166 using functions from dipy
@@ -184,6 +176,8 @@ class MRTrix2TrackVis(BaseInterface):
184176 output_spec = MRTrix2TrackVisOutputSpec
185177
186178 def _run_interface (self , runtime ):
179+ from dipy .tracking .utils import move_streamlines , \
180+ affine_from_fsl_mat_file
187181 dx , dy , dz = get_data_dims (self .inputs .image_file )
188182 vx , vy , vz = get_vox_dims (self .inputs .image_file )
189183 image_file = nb .load (self .inputs .image_file )
0 commit comments