1010
1111"""
1212from __future__ import print_function , division , unicode_literals , absolute_import
13- from io import open
13+ from builtins import open
1414
1515import os .path as op
1616import nibabel as nb
@@ -55,11 +55,10 @@ def read_mrtrix_tracks(in_file, as_generator=True):
5555
5656
5757def read_mrtrix_header (in_file ):
58- fileobj = open (in_file , 'rb ' )
58+ fileobj = open (in_file , 'r ' )
5959 header = {}
6060 iflogger .info ('Reading header data...' )
6161 for line in fileobj :
62- line = line .decode ()
6362 if line == 'END\n ' :
6463 iflogger .info ('Reached the end of the header!' )
6564 break
@@ -79,7 +78,7 @@ def read_mrtrix_header(in_file):
7978def read_mrtrix_streamlines (in_file , header , as_generator = True ):
8079 offset = header ['offset' ]
8180 stream_count = header ['count' ]
82- fileobj = open (in_file , 'rb ' )
81+ fileobj = open (in_file , 'r ' )
8382 fileobj .seek (offset )
8483 endianness = native_code
8584 f4dt = np .dtype (endianness + 'f4' )
@@ -91,7 +90,7 @@ def points_per_track(offset):
9190 n_points = 0
9291 track_points = []
9392 iflogger .info ('Identifying the number of points per tract...' )
94- all_str = fileobj .read (). decode ()
93+ all_str = fileobj .read ()
9594 num_triplets = int (len (all_str ) / bytesize )
9695 pts = np .ndarray (shape = (num_triplets , pt_cols ), dtype = 'f4' , buffer = all_str )
9796 nonfinite_list = np .where (np .isfinite (pts [:, 2 ]) == False )
0 commit comments