-
Notifications
You must be signed in to change notification settings - Fork 52
Remove intervals dimension from decoding results #1476
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
Co-authored-by: edeno <[email protected]>
Co-authored-by: edeno <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR removes the intervals dimension from decoding results and replaces it with concatenation along the time dimension, adding an interval_labels coordinate to track interval membership. This change eliminates memory waste from zero-padding shorter time series and reduces confusion for users.
Key changes:
- Concatenate decoding results along
timeinstead ofintervalsdimension - Add
interval_labelscoordinate for tracking which interval each time point belongs to - Update tests to verify the new structure and demonstrate 12.4% memory savings
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| src/spyglass/decoding/v1/sorted_spikes.py | Modified to concatenate results along time dimension and add interval_labels tracking |
| src/spyglass/decoding/v1/clusterless.py | Modified to concatenate results along time dimension and add interval_labels tracking |
| tests/decoding/conftest.py | Updated mock decoder fixtures to simulate the new concatenation behavior |
| tests/decoding/test_intervals_removal.py | Integration tests verifying the new structure with actual decoder tables |
| tests/decoding/test_intervals_removal_simple.py | Standalone unit tests demonstrating memory savings and basic functionality |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
tests/decoding/conftest.py
Outdated
| if len(results_list) == 1: | ||
| results = results_list[0] | ||
| else: | ||
| results = xr.concat(results_list, dim="time") |
Copilot
AI
Nov 20, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The mock decoder handles the single-interval case specially but doesn't handle the case where results_list is empty. Add a check: if not results_list: raise ValueError(\"No intervals to decode\") before the length check.
tests/decoding/conftest.py
Outdated
| if len(results_list) == 1: | ||
| results = results_list[0] | ||
| else: | ||
| results = xr.concat(results_list, dim="time") |
Copilot
AI
Nov 20, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The mock decoder handles the single-interval case specially but doesn't handle the case where results_list is empty. Add a check: if not results_list: raise ValueError(\"No intervals to decode\") before the length check.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #1476 +/- ##
==========================================
- Coverage 71.12% 71.09% -0.03%
==========================================
Files 114 114
Lines 13306 13318 +12
==========================================
+ Hits 9464 9469 +5
- Misses 3842 3849 +7
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Co-authored-by: Copilot <[email protected]>
Introduces an interval_labels coordinate to the results in both ClusterlessDecodingV1 and SortedSpikesDecodingV1 for consistency with the predict branch. This uses scipy.ndimage.label to identify intervals, ensuring that results outside intervals are marked as -1 and intervals are 0-indexed.
Expanded mock decoders and tests to cover both estimate_decoding_params=True and False branches. Tests now verify interval_labels behavior for all time points, including handling of -1 for points outside intervals and groupby/filtering operations. Mock decoders updated to match real logic for interval_labels assignment.
The tests for interval_labels with estimate_decoding_params=True expected -1 labels for time points outside the decoding interval, but the fixture created decode_interval covering the same range as the position data. Changed decode_interval from [raw_begin, raw_begin+15] to [raw_begin+2, raw_begin+13] so position_info has time points outside the decoding interval, which correctly get interval_labels=-1. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
The mock decoding results had 'states' and 'state_ind' coordinates that could conflict with the 'state' dimension, causing xarray broadcasting errors during groupby operations. Removed these redundant coordinates. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
Changed dimension name from 'state' to 'states' to match the actual non_local_detector output. Also restored state_ind coordinate which is part of the real detector output. This fixes the xarray broadcasting error in groupby operations. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
The intervals dimension caused memory waste from zero-padding and confused users with its 3D structure. Decoding results now concatenate along
timewith aninterval_labelscoordinate for grouping.Changes
sorted_spikes.py,clusterless.py): Changedxr.concat(results, dim="intervals")todim="time"withinterval_labels=("time", [0,0,...,1,1,...])coordinateImpact
Memory: 12-48% reduction by eliminating padding zeros (varies with interval length distribution)
Structure:
(n_intervals, max_time, n_position)with padding(total_time, n_position)without paddingUsage:
Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.