Skip to content
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

Kilosort4 being passed wrong information in run_sorter_by_property #3397

Closed
mdmornin opened this issue Sep 11, 2024 · 8 comments
Closed

Kilosort4 being passed wrong information in run_sorter_by_property #3397

mdmornin opened this issue Sep 11, 2024 · 8 comments
Labels
bug in sorter The bug is in sorter code itself, not in SI

Comments

@mdmornin
Copy link

mdmornin commented Sep 11, 2024

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:

========================================
Loading recording with SpikeInterface...
number of samples: 143981568
number of channels: 8
numbef of segments: 1
sampling rate: 20000.0
dtype: int16
========================================
Preprocessing filters computed in  82.52s; total  82.52s

computing drift
Re-computing universal templates from data.
  0%|          | 0/2400 [00:00<?, ?it/s]Error running kilosort4

Traceback (most recent call last):

  Cell In[1], line 68
    aggregate_sorting = ss.run_sorter_by_property(sorter_name='kilosort4',

  File ~\.conda\envs\HDR\lib\site-packages\spikeinterface\sorters\launcher.py:306 in run_sorter_by_property
    sorting_list = run_sorter_jobs(job_list, engine=engine, engine_kwargs=engine_kwargs, return_output=True)

  File ~\.conda\envs\HDR\lib\site-packages\spikeinterface\sorters\launcher.py:106 in run_sorter_jobs
    sorting = run_sorter(**kwargs)

  File ~\.conda\envs\HDR\lib\site-packages\spikeinterface\sorters\runsorter.py:216 in run_sorter
    return run_sorter_local(**common_kwargs)

  File ~\.conda\envs\HDR\lib\site-packages\spikeinterface\sorters\runsorter.py:276 in run_sorter_local
    SorterClass.run_from_folder(folder, raise_error, verbose)

  File ~\.conda\envs\HDR\lib\site-packages\spikeinterface\sorters\basesorter.py:301 in run_from_folder
    raise SpikeSortingError(

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 256, in _run_from_folder
    ops, bfile, st0 = compute_drift_correction(
  File "C:\Users\Mitch\.conda\envs\HDR\lib\site-packages\kilosort\run_kilosort.py", line 344, in compute_drift_correction
    ops, st = datashift.run(ops, bfile, device=device, progress_bar=progress_bar)
  File "C:\Users\Mitch\.conda\envs\HDR\lib\site-packages\kilosort\datashift.py", line 192, in run
    st, _, ops  = spikedetect.run(ops, bfile, device=device, progress_bar=progress_bar)
  File "C:\Users\Mitch\.conda\envs\HDR\lib\site-packages\kilosort\spikedetect.py", line 243, in run
    tF[k:k+nsp] = xfeat.transpose(0,1).cpu().numpy()
ValueError: could not broadcast input array from shape (252,8,6) into shape (252,10,6)

Spike sorting failed. You can inspect the runtime trace in C:\Users\Mitch\test\0/spikeinterface_log.json.

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:

recording_file = r'ID-HDR3_Day-16_Epoch-1_numCh-64_probe-F_headstage-miniAmp_sessionType-cueSwap_09-Sep-2024-12-20-18_ephys.dat'
num_channels = 64
sampling_frequency = 20000
   
dtype = 'uint16'
sorter = 'kilosort4'
gain_to_uV = 0.195
offset_to_uV = 32768


recording = si.read_binary(recording_file, 
                           num_channels=num_channels, 
                           sampling_frequency=sampling_frequency,
                           dtype=dtype,
                           gain_to_uV=gain_to_uV,
                           offset_to_uV=offset_to_uV)



manufacturer = 'cambridgeneurotech'
probe_name = 'ASSY-236-F'
probe = get_probe(manufacturer,probe_name)
plot_probe(probe, with_contact_id=True)
probe.wiring_to_device('cambridgeneurotech_mini-amp-64')
plot_probe(probe, with_contact_id=True)

       

recording = recording.set_probe(probe,group_mode='by_shank')

preprocessed_recordings = []
badCh = []
split_recording_dict = recording.split_by('group')
for chan_group_rec in split_recording_dict.values():
    cleanRec = spre.bandpass_filter(recording=chan_group_rec, freq_min=300, freq_max=6000)
    badCHIDs, chLabels = spre.detect_bad_channels(recording=cleanRec,method='coherence+psd');
    cleanRec = cleanRec.remove_channels(remove_channel_ids=badCHIDs)
    print(chLabels)
    cleanRec = spre.common_reference(recording=cleanRec)
    preprocessed_recordings.append(cleanRec)
    badCh.append(badCHIDs)
    
cleanRecComb = si.aggregate_channels(preprocessed_recordings)



#params_sort = {'dminx' : 400, 'nearest_templates' : 50, 'nblocks' : 0}

aggregate_sorting = ss.run_sorter_by_property(sorter_name='mountainsort5', 
                    recording=cleanRecComb, 
                    folder='test', 
                    verbose=True,
                    grouping_property='group',
                    remove_existing_folder=True)

environment information:

     active environment : HDR
    active env location : C:\Users\Mitch\.conda\envs\HDR
            shell level : 2
       user config file : C:\Users\Mitch\.condarc
 populated config files :
          conda version : 24.1.2
    conda-build version : 24.1.2
         python version : 3.11.7.final.0
                 solver : libmamba (default)
       virtual packages : __archspec=1=x86_64
                          __conda=24.1.2=0
                          __cuda=12.5=0
                          __win=0=0
       base environment : C:\ProgramData\anaconda3  (read only)
      conda av data dir : C:\ProgramData\anaconda3\etc\conda
  conda av metadata url : None
           channel URLs : https://repo.anaconda.com/pkgs/main/win-64
                          https://repo.anaconda.com/pkgs/main/noarch
                          https://repo.anaconda.com/pkgs/r/win-64
                          https://repo.anaconda.com/pkgs/r/noarch
                          https://repo.anaconda.com/pkgs/msys2/win-64
                          https://repo.anaconda.com/pkgs/msys2/noarch
          package cache : C:\ProgramData\anaconda3\pkgs
                          C:\Users\Mitch\.conda\pkgs
                          C:\Users\Mitch\AppData\Local\conda\conda\pkgs
       envs directories : C:\Users\Mitch\.conda\envs
                          C:\ProgramData\anaconda3\envs
                          C:\Users\Mitch\AppData\Local\conda\conda\envs
               platform : win-64
             user-agent : conda/24.1.2 requests/2.31.0 CPython/3.11.7 Windows/10 Windows/10.0.22631 solver/libmamba conda-libmamba-solver/24.1.0 libmambapy/1.5.6 aau/0.4.3 c/LQqsKndfB9ncQ_IEMEVUEA s/msw9c-LROP7KLSZPZP7zHw e/SlVwHnue7S_x3fPmdri2eg
          administrator : False
             netrc file : None
           offline mode : False
           
           
           
           absl-py                   2.1.0                    pypi_0    pypi
aiohttp                   3.9.5                    pypi_0    pypi
aiosignal                 1.3.1                    pypi_0    pypi
alabaster                 0.7.16                   pypi_0    pypi
altair                    5.3.0                    pypi_0    pypi
anyio                     4.3.0              pyhd8ed1ab_0    conda-forge
aom                       3.9.0                he0c23c2_0    conda-forge
app-model                 0.2.7                    pypi_0    pypi
appdirs                   1.4.4                    pypi_0    pypi
argon2-cffi               23.1.0             pyhd8ed1ab_0    conda-forge
argon2-cffi-bindings      21.2.0           py39ha55989b_4    conda-forge
arrow                     1.3.0              pyhd8ed1ab_0    conda-forge
asciitree                 0.3.3                    pypi_0    pypi
astroid                   2.14.2           py39haa95532_0
asttokens                 2.4.1              pyhd8ed1ab_0    conda-forge
astunparse                1.6.3                    pypi_0    pypi
async-timeout             4.0.3                    pypi_0    pypi
atomicwrites              1.4.0                      py_0
attrs                     23.2.0             pyh71513ae_0    conda-forge
autopep8                  2.0.4              pyhd3eb1b0_0
babel                     2.15.0                   pypi_0    pypi
bcrypt                    3.2.0            py39h2bbff1b_1
beautifulsoup4            4.12.3             pyha770c72_0    conda-forge
binaryornot               0.4.4              pyhd3eb1b0_1
black                     24.4.2           py39haa95532_0
blas                      1.0                         mkl
bleach                    6.1.0              pyhd8ed1ab_0    conda-forge
blosc2                    2.5.1                    pypi_0    pypi
brotli-python             1.1.0            py39h99910a6_1    conda-forge
build                     1.2.1                    pypi_0    pypi
bzip2                     1.0.8                hcfcfb64_5    conda-forge
ca-certificates           2024.6.2             h56e8100_0    conda-forge
cached-property           1.5.2                hd8ed1ab_1    conda-forge
cached_property           1.5.2              pyha770c72_1    conda-forge
cachetools                5.3.3                    pypi_0    pypi
cachey                    0.2.1                    pypi_0    pypi
cairo                     1.18.0               h1fef639_0    conda-forge
cbor2                     5.6.3                    pypi_0    pypi
certifi                   2024.6.2         py39haa95532_0
cffi                      1.16.0           py39ha55989b_0    conda-forge
chardet                   4.0.0           py39haa95532_1003
charset-normalizer        3.3.2              pyhd8ed1ab_0    conda-forge
click                     8.1.7            py39haa95532_0
cloudpickle               3.0.0                    pypi_0    pypi
colorama                  0.4.6              pyhd8ed1ab_0    conda-forge
comm                      0.2.2              pyhd8ed1ab_0    conda-forge
contourpy                 1.2.1                    pypi_0    pypi
cookiecutter              2.6.0            py39haa95532_0
cryptography              42.0.8                   pypi_0    pypi
cuda-cccl                 12.4.127                      0    nvidia
cuda-cudart               11.8.89                       0    nvidia
cuda-cudart-dev           11.8.89                       0    nvidia
cuda-cupti                11.8.87                       0    nvidia
cuda-libraries            11.8.0                        0    nvidia
cuda-libraries-dev        11.8.0                        0    nvidia
cuda-nvrtc                11.8.89                       0    nvidia
cuda-nvrtc-dev            11.8.89                       0    nvidia
cuda-nvtx                 11.8.86                       0    nvidia
cuda-profiler-api         12.4.127                      0    nvidia
cuda-python               12.5.0                   pypi_0    pypi
cuda-runtime              11.8.0                        0    nvidia
cuda-version              11.2                 hb11dac2_3    conda-forge
cudatoolkit               11.2.2              h7d7167e_13    conda-forge
cudnn                     8.1.0.77             h3e0f4f4_0    conda-forge
cycler                    0.12.1                   pypi_0    pypi
dask                      2024.5.2                 pypi_0    pypi
dask-expr                 1.1.2                    pypi_0    pypi
dask-image                2024.5.3                 pypi_0    pypi
dav1d                     1.2.1                hcfcfb64_0    conda-forge
debugpy                   1.8.1            py39h99910a6_0    conda-forge
decorator                 5.1.1              pyhd8ed1ab_0    conda-forge
deeplabcut                2.3.9                    pypi_0    pypi
defusedxml                0.7.1              pyhd8ed1ab_0    conda-forge
diff-match-patch          20200713           pyhd3eb1b0_0
dill                      0.3.8            py39haa95532_0
distinctipy               1.3.4                    pypi_0    pypi
distributed               2024.5.2                 pypi_0    pypi
dlclibrary                0.0.6                    pypi_0    pypi
docstring-parser          0.16                     pypi_0    pypi
docstring-to-markdown     0.11             py39haa95532_0
docutils                  0.17.1                   pypi_0    pypi
entrypoints               0.4                pyhd8ed1ab_0    conda-forge
et_xmlfile                1.1.0            py39haa95532_0
exceptiongroup            1.2.0              pyhd8ed1ab_2    conda-forge
executing                 2.0.1              pyhd8ed1ab_0    conda-forge
expat                     2.6.2                h63175ca_0    conda-forge
faiss-cpu                 1.8.0                    pypi_0    pypi
fasteners                 0.19                     pypi_0    pypi
ffmpeg                    7.0.1           gpl_h7cec250_100    conda-forge
figurl                    0.2.22                   pypi_0    pypi
filelock                  3.15.3                   pypi_0    pypi
filterpy                  1.4.5                    pypi_0    pypi
flake8                    7.0.0            py39haa95532_0
flatbuffers               24.3.25                  pypi_0    pypi
font-ttf-dejavu-sans-mono 2.37                 hab24e00_0    conda-forge
font-ttf-inconsolata      3.000                h77eed37_0    conda-forge
font-ttf-source-code-pro  2.038                h77eed37_0    conda-forge
font-ttf-ubuntu           0.83                 h77eed37_2    conda-forge
fontconfig                2.14.2               hbde0cde_0    conda-forge
fonts-conda-ecosystem     1                             0    conda-forge
fonts-conda-forge         1                             0    conda-forge
fonttools                 4.53.0                   pypi_0    pypi
fqdn                      1.5.1              pyhd8ed1ab_0    conda-forge
freetype                  2.12.1               hdaf720e_2    conda-forge
freetype-py               2.4.0                    pypi_0    pypi
frozenlist                1.4.1                    pypi_0    pypi
fsspec                    2024.6.0                 pypi_0    pypi
gast                      0.4.0                    pypi_0    pypi
glib                      2.80.2               h0df6a38_0    conda-forge
glib-tools                2.80.2               h2f9d560_0    conda-forge
gmpy2                     2.1.2            py39h7f96b67_0
google-auth               2.29.0                   pypi_0    pypi
google-auth-oauthlib      0.4.6                    pypi_0    pypi
google-pasta              0.2.0                    pypi_0    pypi
graphite2                 1.3.13            h63175ca_1003    conda-forge
grpcio                    1.64.1                   pypi_0    pypi
gst-plugins-base          1.24.4               hba88be7_0    conda-forge
gstreamer                 1.24.4               h5006eae_0    conda-forge
h5py                      3.11.0                   pypi_0    pypi
harfbuzz                  8.5.0                h81778c3_0    conda-forge
hdmf                      3.14.0                   pypi_0    pypi
heapdict                  1.0.1                    pypi_0    pypi
hsluv                     5.0.4                    pypi_0    pypi
huggingface-hub           0.23.3                   pypi_0    pypi
icu                       73.2                 h63175ca_0    conda-forge
idna                      3.7                pyhd8ed1ab_0    conda-forge
imageio                   2.34.1                   pypi_0    pypi
imageio-ffmpeg            0.5.1                    pypi_0    pypi
imagesize                 1.4.1            py39haa95532_0
imgaug                    0.4.0                    pypi_0    pypi
importlib-metadata        7.1.0                    pypi_0    pypi
importlib_metadata        7.0.1                hd3eb1b0_0
importlib_resources       6.4.0              pyhd8ed1ab_0    conda-forge
in-n-out                  0.2.1                    pypi_0    pypi
inflection                0.5.1            py39haa95532_0
intel-openmp              2021.4.0                 pypi_0    pypi
intervaltree              3.1.0              pyhd3eb1b0_0
ipykernel                 6.29.3             pyha63f2e9_0    conda-forge
ipympl                    0.9.4                    pypi_0    pypi
ipython                   8.18.1             pyh7428d3b_3    conda-forge
ipython_genutils          0.2.0              pyhd8ed1ab_1    conda-forge
ipywidgets                8.1.3              pyhd8ed1ab_0    conda-forge
isoduration               20.11.0            pyhd8ed1ab_0    conda-forge
isort                     5.9.3              pyhd3eb1b0_0
isosplit6                 0.1.4                    pypi_0    pypi
jaraco.classes            3.2.1              pyhd3eb1b0_0
jedi                      0.19.1             pyhd8ed1ab_0    conda-forge
jellyfish                 1.0.1            py39h36a85e1_0
jinja2                    3.1.4              pyhd8ed1ab_0    conda-forge
joblib                    1.4.2                    pypi_0    pypi
jsonpointer               2.4              py39hcbf5309_3    conda-forge
jsonschema                4.22.0             pyhd8ed1ab_0    conda-forge
jsonschema-specifications 2023.12.1          pyhd8ed1ab_0    conda-forge
jsonschema-with-format-nongpl 4.22.0             pyhd8ed1ab_0    conda-forge
jupyter                   1.0.0             pyhd8ed1ab_10    conda-forge
jupyter_client            7.4.9              pyhd8ed1ab_0    conda-forge
jupyter_console           6.6.3              pyhd8ed1ab_0    conda-forge
jupyter_core              5.7.2            py39hcbf5309_0    conda-forge
jupyter_events            0.10.0             pyhd8ed1ab_0    conda-forge
jupyter_server            2.14.1             pyhd8ed1ab_0    conda-forge
jupyter_server_terminals  0.5.3              pyhd8ed1ab_0    conda-forge
jupyterlab_pygments       0.3.0              pyhd8ed1ab_1    conda-forge
jupyterlab_widgets        3.0.11             pyhd8ed1ab_0    conda-forge
kachery-cloud             0.4.9                    pypi_0    pypi
keras                     2.10.0                   pypi_0    pypi
keras-preprocessing       1.1.2                    pypi_0    pypi
keyring                   24.3.1           py39haa95532_0
kilosort                  4.0                      pypi_0    pypi
kiwisolver                1.4.5                    pypi_0    pypi
krb5                      1.21.2               heb0366b_0    conda-forge
lazy-loader               0.4                      pypi_0    pypi
lazy-object-proxy         1.10.0           py39h2bbff1b_0
libclang                  18.1.1                   pypi_0    pypi
libclang13                18.1.6          default_hf64faad_0    conda-forge
libcublas                 11.11.3.6                     0    nvidia
libcublas-dev             11.11.3.6                     0    nvidia
libcufft                  10.9.0.58                     0    nvidia
libcufft-dev              10.9.0.58                     0    nvidia
libcurand                 10.3.5.147                    0    nvidia
libcurand-dev             10.3.5.147                    0    nvidia
libcusolver               11.4.1.48                     0    nvidia
libcusolver-dev           11.4.1.48                     0    nvidia
libcusparse               11.7.5.86                     0    nvidia
libcusparse-dev           11.7.5.86                     0    nvidia
libexpat                  2.6.2                h63175ca_0    conda-forge
libffi                    3.4.4                hd77b12b_1
libglib                   2.80.2               h0df6a38_0    conda-forge
libiconv                  1.17                 hcfcfb64_2    conda-forge
libintl                   0.22.5               h5728263_2    conda-forge
libintl-devel             0.22.5               h5728263_2    conda-forge
libjpeg-turbo             3.0.0                hcfcfb64_1    conda-forge
libnpp                    11.8.0.86                     0    nvidia
libnpp-dev                11.8.0.86                     0    nvidia
libnvjpeg                 11.9.0.86                     0    nvidia
libnvjpeg-dev             11.9.0.86                     0    nvidia
libogg                    1.3.5                h2bbff1b_1
libopus                   1.3.1                h8ffe710_1    conda-forge
libpng                    1.6.43               h19919ed_0    conda-forge
libsodium                 1.0.18               h8d14728_1    conda-forge
libspatialindex           1.9.3                h6c2663c_0
libsqlite                 3.45.3               hcfcfb64_0    conda-forge
libuv                     1.44.2               h2bbff1b_0
libvorbis                 1.3.7                he774522_0
libxml2                   2.12.7               h283a6d9_1    conda-forge
libzlib                   1.3.1                h2466b09_1    conda-forge
llvmlite                  0.43.0                   pypi_0    pypi
locket                    1.0.0                    pypi_0    pypi
magicgui                  0.8.3                    pypi_0    pypi
markdown                  3.6                      pypi_0    pypi
markdown-it-py            3.0.0                    pypi_0    pypi
markupsafe                2.1.5            py39ha55989b_0    conda-forge
matplotlib                3.9.0                    pypi_0    pypi
matplotlib-inline         0.1.7              pyhd8ed1ab_0    conda-forge
mccabe                    0.7.0              pyhd3eb1b0_0
mdurl                     0.1.2                    pypi_0    pypi
mistune                   3.0.2              pyhd8ed1ab_0    conda-forge
mkl                       2021.4.0                 pypi_0    pypi
more-itertools            10.1.0           py39haa95532_0
mountainsort5             0.5.6                    pypi_0    pypi
mpc                       1.1.0                h7edee0f_1
mpfr                      4.0.2                h62dcd97_1
mpir                      3.0.0                hec2e145_1
mpmath                    1.3.0            py39haa95532_0
msgpack                   1.0.8                    pypi_0    pypi
msgpack-numpy             0.4.8                    pypi_0    pypi
multidict                 6.0.5                    pypi_0    pypi
mypy_extensions           1.0.0            py39haa95532_0
napari                    0.4.18                   pypi_0    pypi
napari-console            0.0.9                    pypi_0    pypi
napari-deeplabcut         0.2.1.6                  pypi_0    pypi
napari-plugin-engine      0.2.0                    pypi_0    pypi
napari-svg                0.1.10                   pypi_0    pypi
natsort                   8.4.0                    pypi_0    pypi
nb_conda                  2.2.1                     win_7    conda-forge
nb_conda_kernels          2.5.1              pyh7428d3b_2    conda-forge
nbclassic                 1.1.0              pyhd8ed1ab_0    conda-forge
nbclient                  0.10.0             pyhd8ed1ab_0    conda-forge
nbconvert                 7.16.4               hd8ed1ab_0    conda-forge
nbconvert-core            7.16.4             pyhd8ed1ab_0    conda-forge
nbconvert-pandoc          7.16.4               hd8ed1ab_0    conda-forge
nbformat                  5.10.4             pyhd8ed1ab_0    conda-forge
ndindex                   1.8                      pypi_0    pypi
neo                       0.13.1                   pypi_0    pypi
nest-asyncio              1.6.0              pyhd8ed1ab_0    conda-forge
networkx                  3.2.1            py39haa95532_0
notebook                  6.5.7              pyha770c72_0    conda-forge
notebook-shim             0.2.4              pyhd8ed1ab_0    conda-forge
npe2                      0.7.5                    pypi_0    pypi
numba                     0.60.0                   pypi_0    pypi
numcodecs                 0.12.1                   pypi_0    pypi
numexpr                   2.10.0                   pypi_0    pypi
numpy                     1.26.4                   pypi_0    pypi
numpydoc                  1.5.0            py39haa95532_0
oauthlib                  3.2.2                    pypi_0    pypi
opencv-python             4.10.0.82                pypi_0    pypi
opencv-python-headless    4.10.0.82                pypi_0    pypi
openh264                  2.4.1                h63175ca_0    conda-forge
openpyxl                  3.1.2            py39h2bbff1b_0
openssl                   3.3.1                h2466b09_0    conda-forge
opt-einsum                3.3.0                    pypi_0    pypi
overrides                 7.7.0              pyhd8ed1ab_0    conda-forge
packaging                 24.1                     pypi_0    pypi
pandas                    2.2.2                    pypi_0    pypi
pandoc                    3.2                  h57928b3_0    conda-forge
pandocfilters             1.5.0              pyhd8ed1ab_0    conda-forge
paramiko                  2.8.1              pyhd3eb1b0_0
parso                     0.8.4              pyhd8ed1ab_0    conda-forge
partd                     1.4.2                    pypi_0    pypi
pathspec                  0.10.3           py39haa95532_0
patsy                     0.5.6                    pypi_0    pypi
pcre2                     10.43                h17e33f8_0    conda-forge
pexpect                   4.8.0              pyhd3eb1b0_3
pickleshare               0.7.5                   py_1003    conda-forge
pillow                    10.3.0                   pypi_0    pypi
pims                      0.6.1                    pypi_0    pypi
pint                      0.23                     pypi_0    pypi
pip                       24.0               pyhd8ed1ab_0    conda-forge
pixman                    0.43.4               h63175ca_0    conda-forge
pkgutil-resolve-name      1.3.10             pyhd8ed1ab_1    conda-forge
platformdirs              4.2.2              pyhd8ed1ab_0    conda-forge
pluggy                    1.0.0            py39haa95532_1
ply                       3.11             py39haa95532_0
pooch                     1.8.1                    pypi_0    pypi
probeinterface            0.2.23                   pypi_0    pypi
prometheus_client         0.20.0             pyhd8ed1ab_0    conda-forge
prompt-toolkit            3.0.46             pyha770c72_0    conda-forge
prompt_toolkit            3.0.46               hd8ed1ab_0    conda-forge
protobuf                  3.19.6                   pypi_0    pypi
psutil                    5.9.8            py39ha55989b_0    conda-forge
psygnal                   0.11.1                   pypi_0    pypi
ptyprocess                0.7.0              pyhd3eb1b0_2
pubnub                    8.0.0                    pypi_0    pypi
pure_eval                 0.2.2              pyhd8ed1ab_0    conda-forge
py-cpuinfo                9.0.0                    pypi_0    pypi
pyarrow                   16.1.0                   pypi_0    pypi
pyasn1                    0.6.0                    pypi_0    pypi
pyasn1-modules            0.4.0                    pypi_0    pypi
pybind11                  2.13.5                   pypi_0    pypi
pycodestyle               2.11.1           py39haa95532_0
pyconify                  0.1.6                    pypi_0    pypi
pycparser                 2.22               pyhd8ed1ab_0    conda-forge
pycryptodomex             3.20.0                   pypi_0    pypi
pydantic                  1.10.15                  pypi_0    pypi
pydantic-compat           0.1.2                    pypi_0    pypi
pydocstyle                6.3.0            py39haa95532_0
pyflakes                  3.2.0            py39haa95532_0
pygments                  2.18.0             pyhd8ed1ab_0    conda-forge
pylint                    2.16.2           py39haa95532_0
pylint-venv               3.0.3            py39haa95532_0
pyls-spyder               0.4.0              pyhd3eb1b0_0
pynacl                    1.5.0            py39h8cc25b3_0
pynwb                     2.8.0                    pypi_0    pypi
pyopengl                  3.1.7                    pypi_0    pypi
pyparsing                 3.1.2                    pypi_0    pypi
pyproject-hooks           1.1.0                    pypi_0    pypi
pyqt                      5.15.10          py39hd77b12b_0
pyqt5-sip                 12.13.0          py39h2bbff1b_0
pyqt6                     6.7.0                    pypi_0    pypi
pyqt6-qt6                 6.7.1                    pypi_0    pypi
pyqt6-sip                 13.6.0                   pypi_0    pypi
pyqtgraph                 0.13.7                   pypi_0    pypi
pyqtwebengine             5.15.10          py39hd77b12b_0
pyside6                   6.3.1                    pypi_0    pypi
pyside6-addons            6.3.1                    pypi_0    pypi
pyside6-essentials        6.3.1                    pypi_0    pypi
pysocks                   1.7.1              pyh0701188_6    conda-forge
python                    3.9.19          h4de0772_0_cpython    conda-forge
python-dateutil           2.9.0              pyhd8ed1ab_0    conda-forge
python-fastjsonschema     2.19.1             pyhd8ed1ab_0    conda-forge
python-json-logger        2.0.7              pyhd8ed1ab_0    conda-forge
python-lsp-black          2.0.0            py39haa95532_0
python-lsp-jsonrpc        1.1.2              pyhd3eb1b0_0
python-lsp-server         1.10.0           py39haa95532_0
python-slugify            5.0.2              pyhd3eb1b0_0
python_abi                3.9                      4_cp39    conda-forge
pytoolconfig              1.2.6            py39haa95532_0
pytorch-cuda              11.8                 h24eeafa_5    pytorch
pytorch-mutex             1.0                        cuda    pytorch
pytz                      2024.1           py39haa95532_0
pywin32                   306              py39h99910a6_2    conda-forge
pywin32-ctypes            0.2.2            py39haa95532_0
pywinpty                  2.0.13           py39h99910a6_0    conda-forge
pyyaml                    6.0.1            py39ha55989b_1    conda-forge
pyzmq                     26.0.3           py39h03e5c00_0    conda-forge
qdarkstyle                3.2                      pypi_0    pypi
qstylizer                 0.2.2            py39haa95532_0
qt-main                   5.15.8              hcef0176_21    conda-forge
qt-webengine              5.15.9               h5bd16bc_7
qtawesome                 1.2.2            py39haa95532_0
qtconsole                 5.5.1            py39haa95532_0
qtconsole-base            5.5.2              pyha770c72_0    conda-forge
qtpy                      2.4.1              pyhd8ed1ab_0    conda-forge
quantities                0.15.0                   pypi_0    pypi
referencing               0.35.1             pyhd8ed1ab_0    conda-forge
requests                  2.32.3             pyhd8ed1ab_0    conda-forge
requests-oauthlib         2.0.0                    pypi_0    pypi
rfc3339-validator         0.1.4              pyhd8ed1ab_0    conda-forge
rfc3986-validator         0.1.1              pyh9f0ad1d_0    conda-forge
rich                      13.7.1                   pypi_0    pypi
rope                      1.12.0           py39haa95532_0
rpds-py                   0.18.1           py39h92a245a_0    conda-forge
rsa                       4.9                      pypi_0    pypi
rtree                     1.0.1            py39h2eaa2aa_0
ruamel-yaml               0.18.6                   pypi_0    pypi
ruamel-yaml-clib          0.2.8                    pypi_0    pypi
scikit-image              0.22.0                   pypi_0    pypi
scikit-learn              1.5.0                    pypi_0    pypi
scipy                     1.13.1                   pypi_0    pypi
send2trash                1.8.3              pyh5737063_0    conda-forge
setuptools                70.0.0             pyhd8ed1ab_0    conda-forge
shapely                   2.0.4                    pypi_0    pypi
shellingham               1.5.4                    pypi_0    pypi
shiboken6                 6.3.1                    pypi_0    pypi
simplejson                3.19.2                   pypi_0    pypi
sip                       6.7.12           py39hd77b12b_0
six                       1.16.0             pyh6c4a22f_0    conda-forge
slicerator                1.1.0                    pypi_0    pypi
sniffio                   1.3.1              pyhd8ed1ab_0    conda-forge
snowballstemmer           2.2.0              pyhd3eb1b0_0
sortedcontainers          2.4.0              pyhd3eb1b0_0
sortingview               0.13.3                   pypi_0    pypi
soupsieve                 2.5                pyhd8ed1ab_1    conda-forge
sphinx                    4.5.0                    pypi_0    pypi
sphinxcontrib-applehelp   1.0.8                    pypi_0    pypi
sphinxcontrib-devhelp     1.0.6                    pypi_0    pypi
sphinxcontrib-htmlhelp    2.0.5                    pypi_0    pypi
sphinxcontrib-jsmath      1.0.1              pyhd3eb1b0_0
sphinxcontrib-qthelp      1.0.7                    pypi_0    pypi
sphinxcontrib-serializinghtml 1.1.10                   pypi_0    pypi
spikeinterface            0.101.0                  pypi_0    pypi
spyder                    5.5.1            py39haa95532_0
spyder-kernels            2.5.0            py39haa95532_0
sqlite                    3.45.3               h2bbff1b_0
stack_data                0.6.2              pyhd8ed1ab_0    conda-forge
statsmodels               0.14.2                   pypi_0    pypi
superqt                   0.6.6                    pypi_0    pypi
svt-av1                   2.1.0                he0c23c2_0    conda-forge
sympy                     1.12.1                   pypi_0    pypi
tables                    3.9.2                    pypi_0    pypi
tabulate                  0.9.0                    pypi_0    pypi
tbb                       2021.12.0                pypi_0    pypi
tblib                     3.0.0                    pypi_0    pypi
tensorboard               2.10.1                   pypi_0    pypi
tensorboard-data-server   0.6.1                    pypi_0    pypi
tensorboard-plugin-wit    1.8.1                    pypi_0    pypi
tensorflow                2.10.1                   pypi_0    pypi
tensorflow-estimator      2.10.0                   pypi_0    pypi
tensorflow-io-gcs-filesystem 0.31.0                   pypi_0    pypi
tensorpack                0.11                     pypi_0    pypi
termcolor                 2.4.0                    pypi_0    pypi
terminado                 0.18.1             pyh5737063_0    conda-forge
text-unidecode            1.3                pyhd3eb1b0_0
textdistance              4.2.1              pyhd3eb1b0_0
tf-slim                   1.1.0                    pypi_0    pypi
threadpoolctl             3.5.0                    pypi_0    pypi
three-merge               0.1.1              pyhd3eb1b0_0
tifffile                  2024.5.22                pypi_0    pypi
tinycss2                  1.3.0              pyhd8ed1ab_0    conda-forge
tk                        8.6.13               h5226925_1    conda-forge
tomli                     2.0.1            py39haa95532_0
tomli-w                   1.0.0                    pypi_0    pypi
tomlkit                   0.11.1           py39haa95532_0
toolz                     0.12.1                   pypi_0    pypi
torch                     1.12.0                   pypi_0    pypi
tornado                   6.4              py39ha55989b_0    conda-forge
tqdm                      4.66.4                   pypi_0    pypi
traitlets                 5.14.3             pyhd8ed1ab_0    conda-forge
typer                     0.12.3                   pypi_0    pypi
types-python-dateutil     2.9.0.20240316     pyhd8ed1ab_0    conda-forge
typing-extensions         4.12.2                   pypi_0    pypi
typing_utils              0.1.0              pyhd8ed1ab_0    conda-forge
tzdata                    2024.1                   pypi_0    pypi
ucrt                      10.0.22621.0         h57928b3_0    conda-forge
ujson                     5.10.0           py39h5da7b33_0
unidecode                 1.2.0              pyhd3eb1b0_0
uri-template              1.3.0              pyhd8ed1ab_0    conda-forge
urllib3                   2.2.1              pyhd8ed1ab_0    conda-forge
vc                        14.2                 h2eaa2aa_1
vc14_runtime              14.38.33135         h835141b_20    conda-forge
vispy                     0.12.2                   pypi_0    pypi
vs2015_runtime            14.38.33135         h22015db_20    conda-forge
watchdog                  4.0.1            py39haa95532_0
wcwidth                   0.2.13             pyhd8ed1ab_0    conda-forge
webcolors                 1.13               pyhd8ed1ab_0    conda-forge
webencodings              0.5.1              pyhd8ed1ab_2    conda-forge
websocket-client          1.8.0              pyhd8ed1ab_0    conda-forge
werkzeug                  3.0.3                    pypi_0    pypi
whatthepatch              1.0.2            py39haa95532_0
wheel                     0.43.0             pyhd8ed1ab_1    conda-forge
widgetsnbextension        4.0.11             pyhd8ed1ab_0    conda-forge
win_inet_pton             1.1.0              pyhd8ed1ab_6    conda-forge
winpty                    0.4.3                         4    conda-forge
wrapt                     1.16.0                   pypi_0    pypi
x264                      1!164.3095           h8ffe710_2    conda-forge
x265                      3.5                  h2d74725_3    conda-forge
xarray                    2024.5.0                 pypi_0    pypi
xz                        5.2.6                h8d14728_0    conda-forge
yaml                      0.2.5                h8ffe710_2    conda-forge
yapf                      0.40.2           py39haa95532_0
yarl                      1.9.4                    pypi_0    pypi
zarr                      2.17.2                   pypi_0    pypi
zeromq                    4.3.5                he1f189c_4    conda-forge
zict                      3.0.0                    pypi_0    pypi
zipp                      3.17.0             pyhd8ed1ab_0    conda-forge
zlib                      1.3.1                h2466b09_1    conda-forge
zstd                      1.5.6                h0ea2cb4_0    conda-forge


It's entirely possible I am missing a step somewhere, but maybe that's informative.

@zm711
Copy link
Collaborator

zm711 commented Sep 11, 2024

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.

@zm711 zm711 added the sorters Related to sorters module label Sep 11, 2024
@mdmornin
Copy link
Author

mdmornin commented Sep 11, 2024

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.

@zm711
Copy link
Collaborator

zm711 commented Sep 11, 2024

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.

@zm711 zm711 added bug in sorter The bug is in sorter code itself, not in SI and removed sorters Related to sorters module labels Sep 11, 2024
@chrishalcrow
Copy link
Collaborator

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!

@mdmornin
Copy link
Author

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.

@JoeZiminski
Copy link
Collaborator

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:

  • Like Zach said maybe there is something strange in how the spikeinterface wrapper in KS4 is handling things when bad channels are removed. There are workarounds, but could you try removing the bad channel removal and seeing if it runs?
  • maybe there is something specifically in the run_sorter_by_property wrapper, although I doubt it as it is quite lightweight.

@mdmornin
Copy link
Author

mdmornin commented Sep 12, 2024

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!

@JoeZiminski
Copy link
Collaborator

Great glad to hear it's working @mdmornin, I'll close this for now but please feel free to reopen if any problems arise.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug in sorter The bug is in sorter code itself, not in SI
Projects
None yet
Development

No branches or pull requests

4 participants