Skip to content

Commit e331486

Browse files
committed
Rebased and addressed some comments
1 parent a91cb47 commit e331486

File tree

3 files changed

+17
-17
lines changed

3 files changed

+17
-17
lines changed

nibabel/streamlines/tractogram.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -245,10 +245,11 @@ def __init__(self, streamlines=None,
245245
of ndarrays of shape ($N_t$, $M_i$) where $N_t$ is the number of
246246
points for a particular streamline $t$ and $M_i$ is the number
247247
scalar values to store for that particular information $i$.
248-
affine_to_rasmm : ndarray of shape (4, 4)
248+
affine_to_rasmm : ndarray of shape (4, 4), optional
249249
Transformation matrix that brings the streamlines contained in
250250
this tractogram to *RAS+* and *mm* space where coordinate (0,0,0)
251-
refers to the center of the voxel.
251+
refers to the center of the voxel. By default, the streamlines
252+
are assumed to be already in *RAS+* and *mm* space.
252253
"""
253254
self.streamlines = streamlines
254255
self.data_per_streamline = data_per_streamline
@@ -608,12 +609,13 @@ def __getitem__(self, idx):
608609
raise NotImplementedError('`LazyTractogram` does not support indexing.')
609610

610611
def __iter__(self):
611-
i = 0
612-
for i, tractogram_item in enumerate(self.data, start=1):
612+
count = 0
613+
for tractogram_item in self.data:
613614
yield tractogram_item
615+
count += 1
614616

615617
# Keep how many streamlines there are in this tractogram.
616-
self._nb_streamlines = i
618+
self._nb_streamlines = count
617619

618620
def __len__(self):
619621
# Check if we know how many streamlines there are.
@@ -642,13 +644,13 @@ def copy(self):
642644
def apply_affine(self, affine):
643645
""" Applies an affine transformation to the streamlines.
644646
645-
The transformation will be applied just before returning the
646-
streamlines.
647+
The transformation given by the `affine` matrix is applied after any
648+
other pending transformations to the streamline points.
647649
648650
Parameters
649651
----------
650652
affine : 2D array (4,4)
651-
Transformation that will be applied on each streamline.
653+
Transformation matrix that will be applied on each streamline.
652654
653655
Returns
654656
-------

nibabel/streamlines/tractogram_file.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,19 @@
55

66

77
class ExtensionWarning(Warning):
8-
pass
8+
""" Base class for warnings about tractogram file extension. """
99

1010

1111
class HeaderWarning(Warning):
12-
pass
12+
""" Base class for warnings about tractogram file header. """
1313

1414

1515
class HeaderError(Exception):
16-
pass
16+
""" Raised when a tractogram file header contains invalid information. """
1717

1818

1919
class DataError(Exception):
20-
pass
20+
""" Raised when data is missing or inconsistent in a tractogram file. """
2121

2222

2323
class abstractclassmethod(classmethod):
@@ -71,12 +71,12 @@ def get_magic_number(cls):
7171

7272
@abstractclassmethod
7373
def support_data_per_point(cls):
74-
""" Tells if this tractogram format supports saving data per point. """
74+
""" Tells if this format supports saving data per point. """
7575
raise NotImplementedError()
7676

7777
@abstractclassmethod
7878
def support_data_per_streamline(cls):
79-
""" Tells if this tractogram format supports saving data per streamline. """
79+
""" Tells if this format supports saving data per streamline. """
8080
raise NotImplementedError()
8181

8282
@abstractclassmethod

nibabel/streamlines/trk.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,7 @@ class TrkFile(TractogramFile):
450450
back on save.
451451
"""
452452

453-
# Contants
453+
# Constants
454454
MAGIC_NUMBER = b"TRACK"
455455
HEADER_SIZE = 1000
456456
READ_BUFFER_SIZE = 87382 * 4 # About 4 Mb when no scalars nor properties.
@@ -514,8 +514,6 @@ def is_correct_format(cls, fileobj):
514514
f.seek(-5, os.SEEK_CUR)
515515
return magic_number == cls.MAGIC_NUMBER
516516

517-
return False
518-
519517
@classmethod
520518
def _create_arraysequence_from_generator(cls, gen):
521519
""" Creates a ArraySequence object from a generator yielding tuples of

0 commit comments

Comments
 (0)