From 450593de1dbb33a357a549d26374aea40f777854 Mon Sep 17 00:00:00 2001 From: koenhelwegen Date: Mon, 22 Nov 2021 23:17:03 +0100 Subject: [PATCH 1/3] rename dipy move_streamlines to transform_tracking_output --- nipype/interfaces/mrtrix/convert.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/nipype/interfaces/mrtrix/convert.py b/nipype/interfaces/mrtrix/convert.py index 41b593d9a6..b2a78f2994 100644 --- a/nipype/interfaces/mrtrix/convert.py +++ b/nipype/interfaces/mrtrix/convert.py @@ -40,13 +40,13 @@ def get_data_dims(volume): def transform_to_affine(streams, header, affine): - from dipy.tracking.utils import move_streamlines + from dipy.tracking.utils import transform_tracking_output rotation, scale = np.linalg.qr(affine) - streams = move_streamlines(streams, rotation) + streams = transform_tracking_output(streams, rotation) scale[0:3, 0:3] = np.dot(scale[0:3, 0:3], np.diag(1.0 / header["voxel_size"])) scale[0:3, 3] = abs(scale[0:3, 3]) - streams = move_streamlines(streams, scale) + streams = transform_tracking_output(streams, scale) return streams @@ -193,7 +193,10 @@ class MRTrix2TrackVis(DipyBaseInterface): output_spec = MRTrix2TrackVisOutputSpec def _run_interface(self, runtime): - from dipy.tracking.utils import move_streamlines, affine_from_fsl_mat_file + from dipy.tracking.utils import ( + affine_from_fsl_mat_file, + transform_tracking_output, + ) dx, dy, dz = get_data_dims(self.inputs.image_file) vx, vy, vz = get_vox_dims(self.inputs.image_file) @@ -243,7 +246,7 @@ def _run_interface(self, runtime): axcode = aff2axcodes(reg_affine) trk_header["voxel_order"] = axcode[0] + axcode[1] + axcode[2] - final_streamlines = move_streamlines(transformed_streamlines, aff) + final_streamlines = transform_tracking_output(transformed_streamlines, aff) trk_tracks = ((ii, None, None) for ii in final_streamlines) trk.write(out_filename, trk_tracks, trk_header) iflogger.info("Saving transformed Trackvis file as %s", out_filename) From 0bfabab1a0a149b0c0890e75b79ccd6bda784f82 Mon Sep 17 00:00:00 2001 From: Koen Helwegen Date: Mon, 21 Mar 2022 12:50:43 +0100 Subject: [PATCH 2/3] Apply suggestions from code review Co-authored-by: Chris Markiewicz --- nipype/interfaces/mrtrix/convert.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/nipype/interfaces/mrtrix/convert.py b/nipype/interfaces/mrtrix/convert.py index b2a78f2994..1d42bfc3f7 100644 --- a/nipype/interfaces/mrtrix/convert.py +++ b/nipype/interfaces/mrtrix/convert.py @@ -40,7 +40,10 @@ def get_data_dims(volume): def transform_to_affine(streams, header, affine): - from dipy.tracking.utils import transform_tracking_output + try: + from dipy.tracking.utils import transform_tracking_output + except ImportError: + from dipy.tracking.utils import move_streamlines as transform_tracking_output rotation, scale = np.linalg.qr(affine) streams = transform_tracking_output(streams, rotation) @@ -193,10 +196,11 @@ class MRTrix2TrackVis(DipyBaseInterface): output_spec = MRTrix2TrackVisOutputSpec def _run_interface(self, runtime): - from dipy.tracking.utils import ( - affine_from_fsl_mat_file, - transform_tracking_output, - ) + from dipy.tracking.utils import affine_from_fsl_mat_file + try: + from dipy.tracking.utils import transform_tracking_output + except ImportError: + from dipy.tracking.utils import move_streamlines as transform_tracking_output dx, dy, dz = get_data_dims(self.inputs.image_file) vx, vy, vz = get_vox_dims(self.inputs.image_file) From 537457b047e6825c10418cd00974340e1c07695b Mon Sep 17 00:00:00 2001 From: koenhelwegen Date: Mon, 21 Mar 2022 13:34:44 +0100 Subject: [PATCH 3/3] black --- nipype/interfaces/mrtrix/convert.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/nipype/interfaces/mrtrix/convert.py b/nipype/interfaces/mrtrix/convert.py index 1d42bfc3f7..d09a388c33 100644 --- a/nipype/interfaces/mrtrix/convert.py +++ b/nipype/interfaces/mrtrix/convert.py @@ -197,10 +197,13 @@ class MRTrix2TrackVis(DipyBaseInterface): def _run_interface(self, runtime): from dipy.tracking.utils import affine_from_fsl_mat_file + try: from dipy.tracking.utils import transform_tracking_output except ImportError: - from dipy.tracking.utils import move_streamlines as transform_tracking_output + from dipy.tracking.utils import ( + move_streamlines as transform_tracking_output, + ) dx, dy, dz = get_data_dims(self.inputs.image_file) vx, vy, vz = get_vox_dims(self.inputs.image_file)