Skip to content

Commit 029f853

Browse files
committed
PEP8 + addressed's @matthew-brett's comments
1 parent 2df7518 commit 029f853

File tree

3 files changed

+14
-16
lines changed

3 files changed

+14
-16
lines changed

nibabel/streamlines/tck.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88
import os
99
import warnings
10-
from collections import OrderedDict
1110

1211
import numpy as np
1312

@@ -25,7 +24,7 @@
2524

2625
def create_empty_header():
2726
''' Return an empty compliant TCK header. '''
28-
header = OrderedDict()
27+
header = {}
2928

3029
# Default values
3130
header[Field.MAGIC_NUMBER] = TckFile.MAGIC_NUMBER
@@ -45,14 +44,14 @@ class TckFile(TractogramFile):
4544
4645
Moreover, streamlines coordinates coming from a TCK file are considered
4746
to be in world space (RAS+ and mm space). MRtrix refers to that space
48-
as the "real" or "scanner" space _[1].
47+
as the "real" or "scanner" space [1]_.
4948
5049
References
5150
----------
5251
[1] http://www.nitrc.org/pipermail/mrtrix-discussion/2014-January/000859.html
5352
"""
5453

55-
# Contants
54+
# Constants
5655
MAGIC_NUMBER = "mrtrix tracks"
5756
SUPPORTS_DATA_PER_POINT = False # Not yet
5857
SUPPORTS_DATA_PER_STREAMLINE = False # Not yet
@@ -66,8 +65,9 @@ def __init__(self, tractogram, header=None):
6665
----------
6766
tractogram : :class:`Tractogram` object
6867
Tractogram that will be contained in this :class:`TckFile`.
69-
header : dict (optional)
70-
Metadata associated to this tractogram file.
68+
header : None or dict, optional
69+
Metadata associated to this tractogram file. If None, make
70+
default empty header.
7171
7272
Notes
7373
-----
@@ -214,7 +214,7 @@ def save(self, fileobj):
214214
for t in tractogram:
215215
s = t.streamline.astype(dtype)
216216
data = np.r_[s, self.FIBER_DELIMITER]
217-
f.write(asbytes(data.tostring()))
217+
f.write(data.tostring())
218218
nb_streamlines += 1
219219

220220
header[Field.NB_STREAMLINES] = nb_streamlines
@@ -283,7 +283,7 @@ def _read_header(fileobj):
283283
Parameters
284284
----------
285285
fileobj : string or file-like object
286-
If string, a filename; otherwise an open file-like object
286+
If string, a filename; otherwise an open binary file-like object
287287
pointing to TCK file (and ready to read from the beginning
288288
of the TCK header). Note that calling this function
289289
does not change the file position.

nibabel/streamlines/tests/test_streamlines.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -246,11 +246,9 @@ def test_save_complex_file(self):
246246
# If streamlines format does not support saving data
247247
# per point or data per streamline, warning messages
248248
# should be issued.
249-
nb_expected_warnings = 0
250-
if not cls.SUPPORTS_DATA_PER_POINT:
251-
nb_expected_warnings += 1
252-
if not cls.SUPPORTS_DATA_PER_STREAMLINE:
253-
nb_expected_warnings += 1
249+
nb_expected_warnings = \
250+
((not cls.SUPPORTS_DATA_PER_POINT) +
251+
(not cls.SUPPORTS_DATA_PER_STREAMLINE))
254252

255253
assert_equal(len(w), nb_expected_warnings)
256254
for i in range(nb_expected_warnings):

nibabel/streamlines/tests/test_tck.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ def setup():
3131
# standard.tck contains only streamlines
3232
DATA['standard_tck_fname'] = pjoin(data_path, "standard.tck")
3333

34-
DATA['streamlines'] = [np.arange(1*3, dtype="f4").reshape((1, 3)),
35-
np.arange(2*3, dtype="f4").reshape((2, 3)),
36-
np.arange(5*3, dtype="f4").reshape((5, 3))]
34+
DATA['streamlines'] = [np.arange(1 * 3, dtype="f4").reshape((1, 3)),
35+
np.arange(2 * 3, dtype="f4").reshape((2, 3)),
36+
np.arange(5 * 3, dtype="f4").reshape((5, 3))]
3737

3838
DATA['empty_tractogram'] = Tractogram(affine_to_rasmm=np.eye(4))
3939
DATA['simple_tractogram'] = Tractogram(DATA['streamlines'],

0 commit comments

Comments
 (0)