Skip to content
Prev Previous commit
Next Next commit
RF: MRTrix2TrackVis is a DipyBaseInterface
  • Loading branch information
effigies committed Apr 12, 2018
commit 2c1e47b339d4027804291f55631f204f257c3eeb
18 changes: 6 additions & 12 deletions nipype/interfaces/mrtrix/convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,15 @@

from ... import logging
from ...utils.filemanip import split_filename
from ...utils.misc import package_check
from ...workflows.misc.utils import get_data_dims, get_vox_dims
from ..base import TraitedSpec, BaseInterface, File, isdefined

import warnings
have_dipy = True
try:
package_check('dipy')
except Exception as e:
have_dipy = False
else:
from dipy.tracking.utils import move_streamlines, affine_from_fsl_mat_file
from ..base import TraitedSpec, File, isdefined
from ..dipy.base import DipyBaseInterface, HAVE_DIPY as have_dipy

iflogger = logging.getLogger('interface')


def transform_to_affine(streams, header, affine):
from dipy.tracking.utils import move_streamlines
rotation, scale = np.linalg.qr(affine)
streams = move_streamlines(streams, rotation)
scale[0:3, 0:3] = np.dot(scale[0:3, 0:3],
Expand Down Expand Up @@ -168,7 +160,7 @@ class MRTrix2TrackVisOutputSpec(TraitedSpec):
out_file = File(exists=True)


class MRTrix2TrackVis(BaseInterface):
class MRTrix2TrackVis(DipyBaseInterface):
"""
Converts MRtrix (.tck) tract files into TrackVis (.trk) format
using functions from dipy
Expand All @@ -184,6 +176,8 @@ class MRTrix2TrackVis(BaseInterface):
output_spec = MRTrix2TrackVisOutputSpec

def _run_interface(self, runtime):
from dipy.tracking.utils import move_streamlines, \
affine_from_fsl_mat_file
dx, dy, dz = get_data_dims(self.inputs.image_file)
vx, vy, vz = get_vox_dims(self.inputs.image_file)
image_file = nb.load(self.inputs.image_file)
Expand Down