7
7
>>> filepath = os.path.dirname( os.path.realpath( __file__ ) )
8
8
>>> datadir = os.path.realpath(os.path.join(filepath, '../../testing/data'))
9
9
>>> os.chdir(datadir)
10
-
11
10
"""
12
11
from __future__ import print_function , division , unicode_literals , absolute_import
13
- from builtins import open
12
+ from io import open
14
13
15
14
import os .path as op
16
15
import nibabel as nb
@@ -55,10 +54,11 @@ def read_mrtrix_tracks(in_file, as_generator=True):
55
54
56
55
57
56
def read_mrtrix_header (in_file ):
58
- fileobj = open (in_file , 'r ' )
57
+ fileobj = open (in_file , 'rb ' )
59
58
header = {}
60
59
iflogger .info ('Reading header data...' )
61
60
for line in fileobj :
61
+ line = line .decode ()
62
62
if line == 'END\n ' :
63
63
iflogger .info ('Reached the end of the header!' )
64
64
break
@@ -78,7 +78,7 @@ def read_mrtrix_header(in_file):
78
78
def read_mrtrix_streamlines (in_file , header , as_generator = True ):
79
79
offset = header ['offset' ]
80
80
stream_count = header ['count' ]
81
- fileobj = open (in_file , 'r ' )
81
+ fileobj = open (in_file , 'rb ' )
82
82
fileobj .seek (offset )
83
83
endianness = native_code
84
84
f4dt = np .dtype (endianness + 'f4' )
@@ -166,10 +166,8 @@ class MRTrix2TrackVis(BaseInterface):
166
166
"""
167
167
Converts MRtrix (.tck) tract files into TrackVis (.trk) format
168
168
using functions from dipy
169
-
170
169
Example
171
170
-------
172
-
173
171
>>> import nipype.interfaces.mrtrix as mrt
174
172
>>> tck2trk = mrt.MRTrix2TrackVis()
175
173
>>> tck2trk.inputs.in_file = 'dwi_CSD_tracked.tck'
0 commit comments