Skip to content

extract_traces: build sparse-mask indices as integer tensors - #1268

Open
cindykrafft wants to merge 1 commit into
MouseLand:mainfrom
cindykrafft:fix/extract-index-dtype
Open

extract_traces: build sparse-mask indices as integer tensors#1268
cindykrafft wants to merge 1 commit into
MouseLand:mainfrom
cindykrafft:fix/extract-index-dtype

Conversation

@cindykrafft

Copy link
Copy Markdown

extract_traces creates the pixel/ROI index tensors for the sparse cell and neuropil mask matrices with torch.Tensor([...]), i.e. float32, which represents integers exactly only up to 2**24 = 16,777,216 (torch.Tensor([16777217]).long() gives 16777216). Flattened pixel indices in fields of view larger than about 4096 × 4096 are therefore rounded to a neighbouring pixel, silently mixing pixels between ROIs. This creates the index tensors as int64 directly; behaviour is unchanged for smaller fields of view.

🤖 Generated with Claude Code

https://claude.ai/code/session_012d2sJAD5EUp4GqAStqoBX7

The pixel and ROI indices for the sparse cell and neuropil mask matrices
were created with torch.Tensor(...), i.e. float32, which cannot represent
integers above 2**24 exactly; for fields of view larger than 16.7 million
pixels flattened pixel indices would be rounded to the wrong pixel. Create
them as int64 directly.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012d2sJAD5EUp4GqAStqoBX7
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants