Skip to content

Commit bf61ba6

Browse files
committed
fix: decode instead of ignore
1 parent 61978ad commit bf61ba6

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

nipype/interfaces/mrtrix/convert.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
1111
"""
1212
from __future__ import print_function, division, unicode_literals, absolute_import
13-
from builtins import open
13+
from io import open
1414

1515
import os.path as op
1616
import nibabel as nb
@@ -55,10 +55,11 @@ def read_mrtrix_tracks(in_file, as_generator=True):
5555

5656

5757
def read_mrtrix_header(in_file):
58-
fileobj = open(in_file, 'r')
58+
fileobj = open(in_file, 'rb')
5959
header = {}
6060
iflogger.info('Reading header data...')
6161
for line in fileobj:
62+
line = line.decode()
6263
if line == 'END\n':
6364
iflogger.info('Reached the end of the header!')
6465
break
@@ -78,7 +79,7 @@ def read_mrtrix_header(in_file):
7879
def read_mrtrix_streamlines(in_file, header, as_generator=True):
7980
offset = header['offset']
8081
stream_count = header['count']
81-
fileobj = open(in_file, 'r')
82+
fileobj = open(in_file, 'rb')
8283
fileobj.seek(offset)
8384
endianness = native_code
8485
f4dt = np.dtype(endianness + 'f4')
@@ -90,7 +91,7 @@ def points_per_track(offset):
9091
n_points = 0
9192
track_points = []
9293
iflogger.info('Identifying the number of points per tract...')
93-
all_str = fileobj.read()
94+
all_str = fileobj.read().decode()
9495
num_triplets = int(len(all_str) / bytesize)
9596
pts = np.ndarray(shape=(num_triplets, pt_cols), dtype='f4', buffer=all_str)
9697
nonfinite_list = np.where(np.isfinite(pts[:, 2]) == False)

0 commit comments

Comments
 (0)