Skip to content

FIX: Delay access of nibabel.trackvis until actually needed #3488

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 12, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions nipype/interfaces/mrtrix/convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@
# vi: set ft=python sts=4 ts=4 sw=4 et:
import os.path as op
import nibabel as nb
import nibabel.trackvis as trk
import numpy as np
from nibabel.trackvis import HeaderError
from nibabel.volumeutils import native_code
from nibabel.orientations import aff2axcodes

Expand Down Expand Up @@ -120,7 +118,7 @@ def track_gen(track_points):
nan_str = fileobj.read(bytesize)
if len(pts_str) < (n_pts * bytesize):
if not n_streams == stream_count:
raise HeaderError(
raise nb.trackvis.HeaderError(
"Expecting %s points, found only %s" % (stream_count, n_streams)
)
iflogger.error(
Expand Down Expand Up @@ -255,7 +253,7 @@ def _run_interface(self, runtime):

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)
nb.trackvis.write(out_filename, trk_tracks, trk_header)
iflogger.info("Saving transformed Trackvis file as %s", out_filename)
iflogger.info("New TrackVis Header:")
iflogger.info(trk_header)
Expand All @@ -271,7 +269,7 @@ def _run_interface(self, runtime):
streamlines, trk_header, affine
)
trk_tracks = ((ii, None, None) for ii in transformed_streamlines)
trk.write(out_filename, trk_tracks, trk_header)
nb.trackvis.write(out_filename, trk_tracks, trk_header)
iflogger.info("Saving Trackvis file as %s", out_filename)
iflogger.info("TrackVis Header:")
iflogger.info(trk_header)
Expand Down