Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions cuslines/cuda_python/cu_propagate_seeds.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import numpy as np
import math
import gc
from cuda.bindings import runtime
from cuda.bindings.runtime import cudaMemcpyKind
Expand Down Expand Up @@ -240,7 +241,7 @@ def get_buffer_size(self):
lens = self.sline_lens[ii]
for jj in range(self.nSlines[ii]):
buffer_size += lens[jj] * 3 * REAL_SIZE
return buffer_size
return math.ceil(buffer_size / MEGABYTE)

def as_generator(self):
def _yield_slines():
Expand All @@ -256,4 +257,4 @@ def _yield_slines():
return _yield_slines()

def as_array_sequence(self):
return ArraySequence(self.as_generator(), self.get_buffer_size() // MEGABYTE)
return ArraySequence(self.as_generator(), self.get_buffer_size())
2 changes: 1 addition & 1 deletion cuslines/cuda_python/cu_tractography.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ def generate_sft(self, seeds, ref_img):
seeds[idx * global_chunk_sz : (idx + 1) * global_chunk_sz].shape[0]
)
array_sequence = ArraySequence(
(item for gen in generators for item in gen), buffer_size // MEGABYTE
(item for gen in generators for item in gen), buffer_size
)
Comment on lines 248 to 252
Copy link

Copilot AI Jan 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In generate_sft, the ArraySequence is built from generators that are created from SeedBatchPropagator state. Because SeedBatchPropagator.as_generator() reads from self.slines/self.sline_lens (which are overwritten on each propagate() call), collecting generators across multiple chunks and consuming them after the loop will yield the last chunk’s data repeatedly (earlier chunk results are lost). Consider materializing/copying each chunk’s results before the next propagate(), or restructure to yield streamlines immediately per chunk instead of storing generators.

Copilot uses AI. Check for mistakes.
Comment on lines 250 to 252
Copy link

Copilot AI Jan 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the conversion by MEGABYTE was removed here, MEGABYTE appears to be unused in this module now. Removing the unused import will avoid lint/static-analysis failures and keep the unit handling clear.

Copilot uses AI. Check for mistakes.
return StatefulTractogram(array_sequence, ref_img, Space.VOX)

Expand Down
Loading