cortex-lab / phy

phy: interactive visualization and manual spike sorting of large-scale ephys data
BSD 3-Clause "New" or "Revised" License
313 stars 157 forks source link

template full of NaN values causing the template gui to crash on start #1060

Closed jbhunt closed 3 years ago

jbhunt commented 3 years ago

I'm totally new to phy so maybe this is more of an issue with me not being familiar with the contents of the data files it needs to run, but I'm posting this here anyway in-case anyone else has this problem. I am using Kilosort2.5 to autosort my recording, but when I try to open the template-gui from the command line, I get this massive traceback (see the log file attached). I dropped a debugger into the line where the AssertionError is raised and it looks the template matrix passed to the _find_best_channel method in the io module is full of NaN values.

This is the command I executed from the command line:

cd <file path to my data files>
phy template-gui ./params.py

When I enter the debugger and check out the values of some of the variables in the scope of this method (NOTE: this assertion error is only raised after multiple successful calls to the _get_best_channel method):

> /home/jbhunt/anaconda3/envs/sandbox/lib/python3.7/site-packages/phylib/io/model.py(791)_find_best_channels()
-> assert amplitude.shape == (len(channel_ids),)
(Pdb) l
786             amplitude = amplitude[order]
787             try:
788                 assert best_channel in channel_ids
789             except:
790                 import pdb; pdb.set_trace()
791  ->         assert amplitude.shape == (len(channel_ids),)
792             return channel_ids, amplitude, best_channel
793     
794         def _get_template_dense(self, template_id, channel_ids=None):
795             """Return data for one template."""
796             if not self.sparse_templates:
(Pdb) amplitude
array([], dtype=float32)
(Pdb) best_channel
0
(Pdb) channel_ids
array([], dtype=int64)
(Pdb) template
array([[nan, nan, nan, ..., nan, nan, nan],
       [nan, nan, nan, ..., nan, nan, nan],
       [nan, nan, nan, ..., nan, nan, nan],
       ...,
       [nan, nan, nan, ..., nan, nan, nan],
       [nan, nan, nan, ..., nan, nan, nan],
       [nan, nan, nan, ..., nan, nan, nan]], dtype=float32)
(Pdb) 

Supporting files [1] working directory contents - download [2] phy log file - download

Versions OS : Ubuntu 18.04 Phy : 2.0b1 (installed from PYPI 2020-12-12) Kilosort : 2.5

EDIT 1

So I compared the contents of my working directory with that of the example data provided on the repo and I noticed I do not have the channel_shanks.npy file in my working directory. Could this be the cause of my problems, and what information does this file contain?

EDIT 2

It seems this is a known issue: #1051; however, I tried the workarounds suggested toward the end of this thread and still no luck. Specifically, I tried setting the value for ops.minFR to 1 / 600 and the value for ops.nblocks to 0.

rossant commented 3 years ago

Thanks for the report. I pushed a tentative fix on phylib (master branch), it should hopefully fix this issue but feel free to reopen if not