Closed mdmornin closed 1 month ago
Maybe something with bad channels is messing with this for the KS wrapper: @chrishalcrow , @JoeZiminski , and @alejoe91 recently updated the wrapper, but it won't appear until the next release (0.101.1). so if you want to install from main you could test that.
Which version of KS4 are you using. It is listed as 4.0 in your list, but that doesn't really help us. Could you do
import kilosort
print(kilosort.__version__)
The most recent is 4.0.17 and the one we will support with 0.101.1 (to be released soon) will be at least up to 4.0.16.
Thanks for the response! print(kilosort.__version__)
returns just the integer 4. I remember downgrading a while ago because I was having issues with pytorch, although I no longer remember what those specific issues were.
Unfortunately with Kilosort there have been many changes and many bug fixes. So our wrapper only supports certain version of Kilosort4. It is very hard to make sure everything is in sync so our new policy is just to support the most up-to-date kilosort until the codebase over there stabilizes. MS5 is more stable and it's wrapper is stable. If you are comfortable with it you could try to update to KS4==4.0.16 and do spikeinterface from main or wait around a week for us to update and get spikeinterface 0.101.1 (which will only support 4.0.16). If this is really a cuda/pytorch issue on your computer and you can only use 4.0 (which I believe has bugs in it that the Kilosort team has fixed) then you would have to use it outside of the spikeinterface wrapper.
Hi @mdmornin , I've had problems with kilosort when using recordings with less than 10 channels, so this your problems might be related to that. I've not looked into it properly yet - just flagging it while I remember!
Hi Chris,
I had some of those issues before with a 16ch electrode, but was able to solve them by skipping drift correction and passing the following parameters:
params_sort = {'dminx' : 400, 'nearest_templates' : 50, 'nblocks' : 0}
I upgraded KS4 to 4.0.16, 4.0.14, and 4.0.17 and received the following traceback:
SpikeSortingError: Spike sorting error trace:
Traceback (most recent call last):
File "C:\Users\Mitch\.conda\envs\HDR\lib\site-packages\spikeinterface\sorters\basesorter.py", line 261, in run_from_folder
SorterClass._run_from_folder(sorter_output_folder, sorter_params, verbose)
File "C:\Users\Mitch\.conda\envs\HDR\lib\site-packages\spikeinterface\sorters\external\kilosort4.py", line 208, in _run_from_folder
filename, data_dir, results_dir, probe = set_files(settings, filename, probe, probe_name, data_dir, results_dir)
TypeError: set_files() missing 1 required positional argument: 'bad_channels'
Spike sorting failed. You can inspect the runtime trace in C:\Users\Mitch\test\0/spikeinterface_log.json.
I am assuming this is because of the missing, new wrapper based on some of the comments I saw in #3339. I attempted to build from Main with the setup.py file in my existing environment but it didn't change the traceback. It's possible I didn't run setup.py correctly as well, I haven't ran a setup.py file in a while so I will try again tomorrow.
Hi @mdmornin, indeed I think bad channels was added to the wrapper in #3339 and should be included on the latest version on main.
Could you do pip show spikeinterface --version
to see the version. You should get 0.101.0rc1
if the install-from-main worked correctly. Otherwise you can change directly to the top level spikeinterface
folder your downloaded and try:
pip uninstall spikeinterface
pip install -e .
this will give you an 'editable' install so if you change the code in your downloaded repo it will be reflected in your installed, imported spikeinterface. Spikeinterface uses the pyproject.toml
now to coordinate the install as far as I know, so maybe the most recent version was not installing properly.
It will be interesting to see whether this resolves the problem. If not, a couple of potential causes:
run_sorter_by_property
wrapper, although I doubt it as it is quite lightweight.Running pip show spikeinterface --version
returned 0.101.0. I followed the provided instructions and reinstalled, it then returned 0.101.1.
I installed originally with: python setup.py
so having the .toml handled with pip probably fixed it.
Rerunning the code as is provided the following warning, but so far it seems to be working now with 0.101.1 and KS4 4.0.17.
C:\Users\Mitch\.conda\envs\HDR\lib\site-packages\kilosort\run_kilosort.py:345: UserWarning:
Parameter `nearest_chans` must be less than or equal to the number
of data channels being sorted.
Changing from 10 to 8.
warnings.warn(msg, UserWarning)
INFO:kilosort.run_kilosort:
INFO:kilosort.run_kilosort:Computing preprocessing variables.
INFO:kilosort.run_kilosort:----------------------------------------
INFO:kilosort.run_kilosort:N samples: 143981568
INFO:kilosort.run_kilosort:N seconds: 7199.0784
INFO:kilosort.run_kilosort:N batches: 2400
INFO:kilosort.run_kilosort:Preprocessing filters computed in 87.20s; total 87.20s
INFO:kilosort.run_kilosort:
INFO:kilosort.run_kilosort:Computing drift correction.
INFO:kilosort.run_kilosort:----------------------------------------
INFO:kilosort.spikedetect:Re-computing universal templates from data.
If something weird happens in the results, I'll report back, but so far this issue has been cleared up. Thanks all!
Great glad to hear it's working @mdmornin, I'll close this for now but please feel free to reopen if any problems arise.
I am revamping my spikesorting workflow to individually sort shanks. I have been able to do all the prerequisite steps, code included below.
When attempting to run Kilosort4, the following traceback is called:
The key message being:
ValueError: could not broadcast input array from shape (252,8,6) into shape (252,10,6)
Running get_traces and get_probe produce the correct shape (8 channels). Running mountainsort5 has so far worked leading me to believe there may be an issue with how the wrapper is handling the grouped information?
The full code minus imports is below:
environment information:
It's entirely possible I am missing a step somewhere, but maybe that's informative.