7
7
8
8
import os
9
9
import warnings
10
- from collections import OrderedDict
11
10
12
11
import numpy as np
13
12
25
24
26
25
def create_empty_header ():
27
26
''' Return an empty compliant TCK header. '''
28
- header = OrderedDict ()
27
+ header = {}
29
28
30
29
# Default values
31
30
header [Field .MAGIC_NUMBER ] = TckFile .MAGIC_NUMBER
@@ -45,14 +44,14 @@ class TckFile(TractogramFile):
45
44
46
45
Moreover, streamlines coordinates coming from a TCK file are considered
47
46
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]_ .
49
48
50
49
References
51
50
----------
52
51
[1] http://www.nitrc.org/pipermail/mrtrix-discussion/2014-January/000859.html
53
52
"""
54
53
55
- # Contants
54
+ # Constants
56
55
MAGIC_NUMBER = "mrtrix tracks"
57
56
SUPPORTS_DATA_PER_POINT = False # Not yet
58
57
SUPPORTS_DATA_PER_STREAMLINE = False # Not yet
@@ -66,8 +65,9 @@ def __init__(self, tractogram, header=None):
66
65
----------
67
66
tractogram : :class:`Tractogram` object
68
67
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.
71
71
72
72
Notes
73
73
-----
@@ -214,7 +214,7 @@ def save(self, fileobj):
214
214
for t in tractogram :
215
215
s = t .streamline .astype (dtype )
216
216
data = np .r_ [s , self .FIBER_DELIMITER ]
217
- f .write (asbytes ( data .tostring () ))
217
+ f .write (data .tostring ())
218
218
nb_streamlines += 1
219
219
220
220
header [Field .NB_STREAMLINES ] = nb_streamlines
@@ -283,7 +283,7 @@ def _read_header(fileobj):
283
283
Parameters
284
284
----------
285
285
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
287
287
pointing to TCK file (and ready to read from the beginning
288
288
of the TCK header). Note that calling this function
289
289
does not change the file position.
0 commit comments