Skip to content

BUG: ValueError : Found array with 0 sample(s) (shape=(0, 41)) while a minimum of 1 is required by TruncatedSVD. #606

Closed
@j-moore94

Description

@j-moore94

Describe the issue:

Hi,
(Sorry if this is just me not setting things up properly - I'm not very experienced with Kilosort.)

Every time I try to run kilosort (both from the GUI or using a notebook), I get this error. From doing some debugging, it seems like the whitening/drift correction steps results in the data becoming only zeros. I also seem to get no drift at all, which seems unlikely.

I first thought it was an issue with the way I was setting up the probe. I am using the same .mat file we used for Kilosort 2 but it seems like it is loading correctly so I'm not sure.

Any help would be very much appreciated! :)

Maybe it's helpful to add my probe variable that I get when I load my channel map file:

probe
{'xc': array([ 580., 580., 620., 420., 620., 420., 620., 180., 180.,
180., 380., 220., 380., 220., 380., 220., 620., 820.,
420., 580., 180., 180., 220., 380., 220., 380., 420.,
380., 420., 620., 580., 580., 820., 820., 780., 980.,
780., 1180., 1020., 1220., 980., 1180., 1020., 1220., 780.,
780., 980., 820., 1180., 1020., 1180., 1020., 1180., 1020.,
1220., 1220., 980., 1220., 980., 780., 980., 780., 580.,
820.], dtype=float32),
'yc': array([ -20., -180., -40., -160., -160., -40., -120., -20., -140.,
-60., -60., -200., -100., -120., -180., -80., -200., -80.,
-80., -140., -180., -100., -160., -20., -40., -140., -200.,
-220., -120., -80., -220., -100., -160., -200., -20., -60.,
-140., -140., -80., -200., -220., -60., -160., -80., -60.,
-220., -140., -40., -100., -40., -180., -200., -20., -120.,
-40., -120., -20., -160., -180., -100., -100., -180., -60.,
-120.], dtype=float32),
'kcoords': array([3., 3., 3., 2., 3., 2., 3., 1., 1., 1., 2., 1., 2., 1., 2., 1., 3.,
4., 2., 3., 1., 1., 1., 2., 1., 2., 2., 2., 2., 3., 3., 3., 4., 4.,
4., 5., 4., 6., 5., 6., 5., 6., 5., 6., 4., 4., 5., 4., 6., 5., 6.,
5., 6., 5., 6., 6., 5., 6., 5., 4., 5., 4., 3., 4., 8., 7., 7., 7.,
9.], dtype=float32),
'chanMap': array([ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33,
34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50,
51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63]),
'n_chan': 69}

Reproduce the bug:

Error message:

drift computed in  746.40s; total  748.88s


Traceback (most recent call last):

  File "C:\Users\jmoore\.conda\envs\kilosort\lib\site-packages\kilosort\gui\run_box.py", line 241, in add_plot_data

    
plot_drift_scatter(plot_window2, st0, settings)


  File "C:\Users\jmoore\.conda\envs\kilosort\lib\site-packages\kilosort\gui\sanity_plots.py", line 57, in plot_drift_scatter

    
p1.setTitle('Spike amplitude across time and depth', color='black')


  File "C:\Users\jmoore\.conda\envs\kilosort\lib\site-packages\pyqtgraph\graphicsItems\PlotItem\PlotItem.py", line 1155, in setTitle

    
self.titleLabel.setText(title, **args)


  File "C:\Users\jmoore\.conda\envs\kilosort\lib\site-packages\pyqtgraph\graphicsItems\LabelItem.py", line 58, in setText

    
color = fn.mkColor(color)


  File "C:\Users\jmoore\.conda\envs\kilosort\lib\site-packages\pyqtgraph\functions.py", line 297, in mkColor

    
args = [r,g,b,a]


UnboundLocalError
: 
local variable 'r' referenced before assignment



Extracting spikes using templates


Re-computing universal templates from data.


Traceback (most recent call last):

  File "C:\Users\jmoore\.conda\envs\kilosort\lib\site-packages\kilosort\gui\sorter.py", line 82, in run

    
st, tF, Wall0, clu0 = detect_spikes(ops, self.device, bfile, tic0=tic0,


  File "C:\Users\jmoore\.conda\envs\kilosort\lib\site-packages\kilosort\run_kilosort.py", line 332, in detect_spikes

    
st0, tF, ops = spikedetect.run(ops, bfile, device=device, progress_bar=progress_bar)


  File "C:\Users\jmoore\.conda\envs\kilosort\lib\site-packages\kilosort\spikedetect.py", line 193, in run

    
ops['wPCA'], ops['wTEMP'] = extract_wPCA_wTEMP(


  File "C:\Users\jmoore\.conda\envs\kilosort\lib\site-packages\kilosort\spikedetect.py", line 70, in extract_wPCA_wTEMP

    
model = TruncatedSVD(n_components=ops['settings']['n_pcs']).fit(clips)


  File "C:\Users\jmoore\.conda\envs\kilosort\lib\site-packages\sklearn\decomposition\_truncated_svd.py", line 209, in fit

    
self.fit_transform(X)


  File "C:\Users\jmoore\.conda\envs\kilosort\lib\site-packages\sklearn\utils\_set_output.py", line 157, in wrapped

    
data_to_wrap = f(self, X, *args, **kwargs)


  File "C:\Users\jmoore\.conda\envs\kilosort\lib\site-packages\sklearn\base.py", line 1152, in wrapper

    
return fit_method(estimator, *args, **kwargs)


  File "C:\Users\jmoore\.conda\envs\kilosort\lib\site-packages\sklearn\decomposition\_truncated_svd.py", line 229, in fit_transform

    
X = self._validate_data(X, accept_sparse=["csr", "csc"], ensure_min_features=2)


  File "C:\Users\jmoore\.conda\envs\kilosort\lib\site-packages\sklearn\base.py", line 605, in _validate_data

    
out = check_array(X, input_name="X", **check_params)


  File "C:\Users\jmoore\.conda\envs\kilosort\lib\site-packages\sklearn\utils\validation.py", line 967, in check_array

    
raise ValueError(


ValueError
: 
Found array with 0 sample(s) (shape=(0, 41)) while a minimum of 1 is required by TruncatedSVD.

Version information:

Windows 10, Python 3.9, CUDA 11.8

Context for the issue:

No response

Experiment information:

64-channel silicon probe, plus 5 non-ephys channels included in the binary file (total 69 channels). Recorded in Intan at 20000 samples/s.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions