-
Notifications
You must be signed in to change notification settings - Fork 190
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
Add kilosort4 wrapper tests #3085
Add kilosort4 wrapper tests #3085
Conversation
0a822f5
to
6f9dfc4
Compare
src/spikeinterface/core/datasets.py
Outdated
|
||
Parameters | ||
---------- | ||
repo : str, default: "https://gin.g-node.org/NeuralEnsemble/ephy_testing_data" | ||
The repository to download the dataset from | ||
remote_path : str, default: "mearec/mearec_test_10s.h5" | ||
A specific subdirectory in the repository to download (e.g. Mearec, SpikeGLX, etc) | ||
local_folder : str, default: None | ||
local_folder : str, optional |
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.
we use default: None
elsewhere ;)
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.
Thanks @alejoe91!! Though please ignore most of this PR ATM, it contains a lot of stray commits from random other PRs that are screwing everything up and I that need to drop! 😅
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.
Ok! I'll refrain myself ;)
aff9acd
to
a8489a5
Compare
settings=settings, | ||
probe=probe, | ||
data_dtype=recording.get_dtype(), | ||
do_CAR=do_CAR, |
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.
Ported from #3073
Chris
So, at the moment, if a user specifies
skip_kilosort_preprocessing = True
, thendo_CAR
is stillTrue
by default and is still applied. I guess: is this the expected behaviour?And then what do we want to do if someone explicitly specifies
skip_kilosort_preprocessing = True
anddo_CAR=True
?
So, at the moment, if a user specifies
skip_kilosort_preprocessing = True
, thendo_CAR
is stillTrue
by default and is still applied. I guess: is this the expected behaviour?And then what do we want to do if someone explicitly specifies
skip_kilosort_preprocessing = True
anddo_CAR=True
?
Alessio
So, at the moment, if a user specifies
skip_kilosort_preprocessing = True
, thendo_CAR
is stillTrue
by default and is still applied. I guess: is this the expected behaviour?
Chris
And then what do we want to do if someone explicitly specifies
skip_kilosort_preprocessing = True
anddo_CAR=True
?
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.
I think because do_CAR
is the default True
it is not possible to determine if the user wanted to apply CAR
or just left the default on. In this case I think most users would expect skip_kilosort_preprocessing
to skip all preprocessing and would be surprised if CAR was still performed by default. I would suggest to raise an error if skip_kilosort_preprocessing=False
and do_CAR=True
. It will be annoying for users first time because by default it will raise an error, but at least it is an easy fix and super explicit. If we get issues raised from people who want to skip KS preprocessing but keep CAR (I would imagine this is very small % of users) we could reconsider.
Further on this, I believe that the KS drift correction is performed in the code block that also performs whitening. So when whitening is turned off as part of skip_kilosort_preprocessing
then drift correct is also turned off. This makes it even weirder for skip_kilosort_preprocessing
to allow only CAR. Also (if this is correct) this behaviour can be added to the dosctring and I'd suggest raise an error if do_correction=True
while skip_kilosort_preprocessing=True
. Even though it will raise a lot of errors by default when trying to use skip_kilosort_preprocessing
I feel it is quite a complex / confusing case and so best to be super explicit.
(In quotes, Alessio original message ported from #3073)
Yes I can definitely see the advantage in not including everything, on balance though as a philosophy I think SpikeInterface, when it comes to sorters, is most effective as as a wrapper that exposes all available sorter options. In some ways it's also easier to maintain because avoids having to decide what is / isn't worthwhile to expose, and avoids potential future issues users might raise wanting things included. As such I'd probably advocate towards exposing
Agree, for some reason I thought this was leading to some large differences in results but its not. They are the same for all versions except two cases where the defaults changed in early KS versions. I made the [EDIT] Turns out it wasn't as easy to handle as I thought as the kilosort import is no longer wrapped at this stage and is causing general test failures. I am also getting weird errors on kilosort4 tests versions <= 4.0.4 (which is also where the default changes are). So I'm thinking just drop support for these versions, which also removes the different-defaults problem. If default change in future we could handle with a parameters getter on the |
On branch add_kilosort4_wrapper_tests
f451240
to
9bc1897
Compare
is there any easy way to change save_preprocessed_copy to true within the existing spikeinterface framework? |
Hi @carlacodes unfortunately not, although I think it would be quick to add. @alejoe91 would you be happy to expose |
@JoeZiminski sure! |
.github/workflows/test_kilosort4.yml
Outdated
pull_request: | ||
types: [synchronize, opened, reopened] | ||
branches: | ||
- main |
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.
@JoeZiminski I would remove this, otherwise it will run on any open PR...no?
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.
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.
Yep!
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.
Okay cheers @alejoe91, done!
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.
Actually, there is a conflict since exposing save_preprocesed_copy
, will fix now
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.
Thanks for working on this!
This PR makes some refactorings and small changes to
kilosort4.py
(Kilosort4 Wrapper) and adds tests for the wrapper across all released versions.Changes to
kilosort4.py
_default_params
based on version to always match kilosort'sDEFAULT_SETTINGS
.keep_good_only
andscaleproc
which I think were left over from earlier KS versions but are not implemented in KS4..__version__
attribute is4
for all versions <4.0.10
so I usedimportlib.version
for versioning here.CI tests
.github/scripts
so are not part of the test suite. The CI script can be adjusted to run on cron job only. I ran into problems with the module tagging inconftest.py
because the script is not a submodule of the package src, so added a try/except. Maybe there is a better solution (e.g. running the script from a different location) happy to adjust this.Some points for discussion
shift
,scale
,tmin
,tmax
,save_preprocesed_copy
.save_extra_vars
(KS4) issave_extra_kwargs
in SpikeInterface, should it be renamed for consistency?KIlosort versions <=
4.0.4
For some reason on the tests in CI, there are completely wrong results between SI wrapper vs. KS4 in
4.0.4
. Also, versions<4.0.4
seem to be susceptible to a bugValueError: negative axis 0 index: -2147483648
which looks like a KS4-side overflow error that's since fixed. Also, as all KS4DEFAULT_SETTINGS
changes that are a little tricky to handle (see below comment to Alessio) are<=4.0.4
I suggest we just don't support versions earlier than 4.0.5?Some TODOs:
duplicate_spike_bins
forduplicate_spike_ms
, also mentionsave_preprocesed_copy
typo.