Skip to content

Hotfix: overflow error in correct LSB#4610

Merged
chrishalcrow merged 1 commit into
SpikeInterface:mainfrom
alejoe91:fix-overlflow-in-correct-lsb
Jun 10, 2026
Merged

Hotfix: overflow error in correct LSB#4610
chrishalcrow merged 1 commit into
SpikeInterface:mainfrom
alejoe91:fix-overlflow-in-correct-lsb

Conversation

@alejoe91

Copy link
Copy Markdown
Member

I found this bug in some sessions...when the LSB estimation overlflows, everything gets messed up.

This PR takes care of overflow errors and it also uses a mode approach to estimate LSB from channels, since LSB is set at the acquisition level. This approach is more robust against rounding errors.

@alejoe91 alejoe91 added bug Something isn't working preprocessing Related to preprocessing module labels Jun 10, 2026
Comment on lines +92 to +94
# cast to int64 to avoid integer overflow in np.diff when consecutive
# unique values are farther apart than the dtype range (e.g. int16)
unique_values = np.unique(data[:, ch]).astype(np.int64)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Never thought about this gross bug before - nice!

@chrishalcrow chrishalcrow left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Works on my local data, and looks sensible.

@chrishalcrow chrishalcrow merged commit 91af863 into SpikeInterface:main Jun 10, 2026
14 of 15 checks passed
alejoe91 added a commit that referenced this pull request Jun 10, 2026
@alejoe91 alejoe91 mentioned this pull request Jun 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working preprocessing Related to preprocessing module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants