Add amplitude calculation to kilosort4 importer#4503
Draft
chrishalcrow wants to merge 11 commits intoSpikeInterface:mainfrom
Draft
Add amplitude calculation to kilosort4 importer#4503chrishalcrow wants to merge 11 commits intoSpikeInterface:mainfrom
chrishalcrow wants to merge 11 commits intoSpikeInterface:mainfrom
Conversation
for more information, see https://pre-commit.ci
Member
Author
|
@JoeZiminski might also be interested in testing this. At the moment, it's just amplitudes and just for KS4. |
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.
VERY DRAFTY!!!
For @oliche to play with.
This PR adds the ability to estimate what we would call spike_amplitudes (uV valued amp estimates for each spike) from KiloSort4 output.
How?
Take the pc features. These are whitened, PC'd waveforms on each channel (note: PC sparsity does not match template sparisty).
First, invert the PC mapping using the
wPCAmapping stored in ops. You now have approx whitened waveforms (approx because PC+inversePC smooths out the waveforms).Second, approximately unwhiten these by using the inverse whitening matrix (restricted to the channels your unit is on.) (this is an approx because you should really apply the full inverse matrix to the full waveform instead of the restricted matrix on the restricted waveform). You now have unwhitened waveforms.
Third, find the minimum of the unwhitened waveforms.
Fourth, scale these with
gain_to_uVandoffset_to_uV.Main logic in
_make_amplitudesfunctionTo see if this works, I loaded the kilosort ouput, attached the recording and computed spike amplitudes from scratch. Note that our spike ampltiude calculation is different than this. In ours, you just take the value of the trace at the spike time, on the main channel.
So: the calculations are a bit different and the calculation is only approximate on the KS side. How do the results look? Like this:
Amplitudes from this PR on the left. Amplitudes recomputed from the recording on the right.
I'll do some more thorough analysis when I get some time. For now: this PR is ready to play with!! It's possible that we don't want this much KS4-specific wrangling in spikeinterface. Could be worth doing this in another repo??