Skip to content

Commit 94c5390

Browse files
committed
Addressed Matthew's comment
1 parent c0f5120 commit 94c5390

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

nibabel/streamlines/trk.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -424,11 +424,16 @@ def save(self, fileobj):
424424
i4_dtype = np.dtype("<i4") # Always save in little-endian.
425425
f4_dtype = np.dtype("<f4") # Always save in little-endian.
426426

427-
# Make sure streamlines are in rasmm then send them to voxmm.
427+
# Since the TRK format requires the streamlines to be saved in
428+
# voxmm, we first transform them accordingly. The transformation
429+
# is performed lazily since `self.tractogram` might be a
430+
# LazyTractogram object, which means we might be able to loop
431+
# over the streamlines only once.
428432
tractogram = self.tractogram.to_world(lazy=True)
429433
affine_to_trackvis = get_affine_rasmm_to_trackvis(header)
430434
tractogram = tractogram.apply_affine(affine_to_trackvis, lazy=True)
431-
# Assume looping over the streamlines can be done only once.
435+
436+
# Create the iterator we'll be using for the rest of the funciton.
432437
tractogram = iter(tractogram)
433438

434439
try:

0 commit comments

Comments
 (0)