AllenInstitute / ecephys_spike_sorting

Modules for processing extracellular electrophysiology data from Neuropixels probes
Other
109 stars 91 forks source link

Mean waveforms: Value error #57

Open Kasia-Bz opened 3 years ago

Kasia-Bz commented 3 years ago

Hello, I have been trying to calculate mean waveforms on my data. I used all three: Kilosort2, Kilosort 2.5 and Kilosort 3 outputs and I always get the same error:

Loading data...
Traceback (most recent call last):
  File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "D:\.venv\lib\site-packages\ecephys_spike_sorting\modules\mean_waveforms\__main__.py", line 69, in <module>
    main()
  File "D:\.venv\lib\site-packages\ecephys_spike_sorting\modules\mean_waveforms\__main__.py", line 59, in main
    output = calculate_mean_waveforms(mod.args)
  File "D:\.venv\lib\site-packages\ecephys_spike_sorting\modules\mean_waveforms\__main__.py", line 23, in calculate_mean_waveforms
    data = np.reshape(rawData, (int(rawData.size/args['ephys_params']['num_channels']), args['ephys_params']['num_channels']))
  File "<__array_function__ internals>", line 6, in reshape
  File "D:\.venv\lib\site-packages\numpy\core\fromnumeric.py", line 299, in reshape
    return _wrapfunc(a, 'reshape', newshape, order=order)
  File "D:\.venv\lib\site-packages\numpy\core\fromnumeric.py", line 58, in _wrapfunc
    return bound(*args, **kwds)
ValueError: cannot reshape array of size 22608838945 into shape (59030911,383)

Could you please help me with how I could fix this error?

I also tried to run the post processing module, but I get an error: ecephys spike sorting: kilosort postprocessing module

Loading data...
Removing within-unit overlapping spikes...
 ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒░ 99% Traceback (most recent call last):
  File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\lib\runpy.py", line 193, in _run_module_as_main
    "_main_", mod_spec)
  File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "D:\.venv\lib\site-packages\ecephys_spike_sorting\modules\kilosort_postprocessing\_main_.py", line 76, in <module>
    main()
  File "D:\.venv\lib\site-packages\ecephys_spike_sorting\modules\kilosort_postprocessing\_main_.py", line 66, in main
    output = run_postprocessing(mod.args)
  File "D:\.venv\lib\site-packages\ecephys_spike_sorting\modules\kilosort_postprocessing\_main_.py", line 38, in run_postprocessing
    args['ks_postprocessing_params'])
  File "D:\.venv\lib\site-packages\ecephys_spike_sorting\modules\kilosort_postprocessing\postprocessing.py", line 88, in remove_double_counted_spikes
    spikes_to_remove)
  File "D:\.venv\lib\site-packages\ecephys_spike_sorting\modules\kilosort_postprocessing\postprocessing.py", line 219, in remove_spikes
    spike_times = np.delete(spike_times, spikes_to_remove, 0)
  File "<__array_function__ internals>", line 6, in delete
  File "D:\.venv\lib\site-packages\numpy\lib\function_base.py", line 4480, in delete
    keep[obj,] = False
IndexError: arrays used as indices must be of integer (or boolean) type

Lastly, I noticed that in the output from Kilosort3, there are no longer files: pc_feature_ind.npy and pc_feature.npy. Are you planning to switch to Kilosort3 in the future?

Thank you in advance for your help.

jsiegle commented 3 years ago

Hi @Kasia-Bz , for the first error, it looks like the number of data channels indicated in the create_input_json.py file is incorrect. 22608838945 is evenly divisible by 385, so I'm guessing that's what the value of "num_channels" should be.

I'm not sure what's going on with the second error, can you print out the values of spike_times and spikes_to_remove?

The latest changes to the code base add compatibility with Kilosort3, including the option to ignore the PC-based metrics when pc_features.npy is not available.