Interpolate waveforms to 30kHz for classifier compatibility#648
Open
abuzarmahmood wants to merge 2 commits into
Open
Interpolate waveforms to 30kHz for classifier compatibility#648abuzarmahmood wants to merge 2 commits into
abuzarmahmood wants to merge 2 commits into
Conversation
Addresses issue katzlabbrandeis#193 by adding waveform interpolation to match the expected sampling rate of the classifier. This allows the classifier to work with data recorded at different sampling rates as long as the pre and post spike windows are the same. Changes: - Add interpolate_waveforms_to_30khz() function to clustering.py - Add interpolate_waveforms() method to spike_handler class - Update blech_process.py to interpolate waveforms before classification Co-authored-by: Ona <no-reply@ona.com>
for more information, see https://pre-commit.ci
Member
Author
Solution OverviewThis implementation solves the sampling rate compatibility issue by interpolating waveforms to a standard 30kHz sampling rate before classification. Technical DetailsThe solution adds a new interpolation step in the processing pipeline:
Key Implementation Points
ExampleFor a 1.5ms window (0.5ms pre + 1.0ms post):
After interpolation, all waveforms have 45 samples, matching the classifier's expectations. Testing RecommendationsTo verify this works correctly:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #193
This PR adds waveform interpolation to enable the classifier to work with data recorded at different sampling rates, as long as the pre and post spike windows are the same.
Changes
interpolate_waveforms_to_30khz()function inutils/clustering.py: Interpolates waveforms from any sampling rate to match the expected 30kHz sampling rate using cubic interpolationinterpolate_waveforms()method tospike_handlerclass inutils/blech_process_utils.py: Wrapper method that uses the spike snapshot parameters and actual sampling rate from the datablech_process.py: Interpolates waveforms before passing them to the classifierHow it works
When data is recorded at a different sampling rate (e.g., 20kHz), the same time window (e.g., 0.5ms pre + 1.0ms post) will contain a different number of samples than at 30kHz. The interpolation function:
This allows the classifier, which was trained on 30kHz data, to work correctly with data from any sampling rate.