ecephys_spike_sorting
ecephys_spike_sorting copied to clipboard
mean waveforms linear regression error
Hello,
I'm trying to run the mean_waveforms module on KS3 data but keep getting an error of 'Cannot calculate a linear regression if all x values are identical' . How can I solve this? The other modules seem to work ok.
##############
(.venv) C:\Ecphys\ecephys_spike_sorting-master.venv\Lib\site-packages\ecephys_spike_sorting\scripts>python sglx_filelist_pipeline.py
E:\R_data\Rat_V\Psilo_day0\CorrectCM\kilosort3\RatV_P_day0_g0_t0.imec0.ap_CAR.meta
SpikeGLX params read from meta
probe type: NP1, sample_rate: 30000.44078, num_channels: 385, uVPerBit: 2.3438
ks_nNeighbors: 32
C:\Ecphys\ecephys_spike_sorting-master.venv\Scripts\python.exe -W ignore -m ecephys_spike_sorting.modules.mean_waveforms --input_json E:\output\json_files3\RatV_P_day0_g0_t0.imec0.ap_CAR.b-input.json --output_json E:\output\json_files3\RatV_P_day0_g0_t0.imec0.ap_CAR.b-mean_waveforms-output.json
ecephys spike sorting: mean waveforms module
Calculating mean waveforms using C_waves.
C:\Ecphys_depends\C_WavesWinApp\C_Waves-win\runit.bat -spikeglx_bin=E:\R_data\Rat_V\Psilo_day0\CorrectCM\kilosort3\RatV_P_day0_g0_t0.imec0.ap_CAR.bin -clus_table_npy=E:\R_data\Rat_V\Psilo_day0\CorrectCM\kilosort3\RatV_P_day0_g0_t0.imec0.ap_CAR.b\imecay0_g0_t0.imec0_ks2\clus_Table_2.npy -clus_time_npy=E:\R_data\Rat_V\Psilo_day0\CorrectCM\kilosort3\RatV_P_day0_g0_t0.imec0.ap_CAR.b\imecay0_g0_t0.imec0_ks2\spike_times.npy -clus_lbl_npy=E:\R_data\Rat_V\Psilo_day0\CorrectCM\kilosort3\RatV_P_day0_g0_t0.imec0.ap_CAR.b\imecay0_g0_t0.imec0_ks2\spike_clusters.npy -dest=E:\R_data\Rat_V\Psilo_day0\CorrectCM\kilosort3\RatV_P_day0_g0_t0.imec0.ap_CAR.b\imecay0_g0_t0.imec0_ks2 -samples_per_spike=82 -pre_samples=20 -num_spikes=1000 -snr_radius=8
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ 0% Traceback (most recent call last):
File "c:\users\rp17047\appdata\local\programs\python\python38\lib\runpy.py", line 194, in run_module_as_main
return run_code(code, main_globals, None,
File "c:\users\rp17047\appdata\local\programs\python\python38\lib\runpy.py", line 87, in run_code
exec(code, run_globals)
File "C:\Ecphys\ecephys_spike_sorting-master.venv\lib\site-packages\ecephys_spike_sorting\modules\mean_waveforms_main.py", line 223, in
File "C:\Ecphys\ecephys_spike_sorting-master.venv\lib\site-packages\ecephys_spike_sorting\modules\mean_waveforms\metrics_from_file.py", line 116, in metrics_from_file
metrics = pd.concat([metrics, calculate_waveform_metrics_from_avg(mean_waveforms[cluster_idx,:],
File "C:\Ecphys\ecephys_spike_sorting-master.venv\lib\site-packages\ecephys_spike_sorting\modules\mean_waveforms\waveform_metrics.py", line 167, in calculate_waveform_metrics_from_avg
amplitude, spread, velocity_above, velocity_below = calculate_2D_features(
File "C:\Ecphys\ecephys_spike_sorting-master.venv\lib\site-packages\ecephys_spike_sorting\modules\mean_waveforms\waveform_metrics.py", line 486, in calculate_2D_features
velocity_above, velocity_below = get_velocity(yDist, trough_times)
File "C:\Ecphys\ecephys_spike_sorting-master.venv\lib\site-packages\ecephys_spike_sorting\modules\mean_waveforms\waveform_metrics.py", line 529, in get_velocity
slope_below, intercept, r_value, p_value, std_err = linregress(yDist[below_soma], times[below_soma])
File "C:\Ecphys\ecephys_spike_sorting-master.venv\lib\site-packages\scipy\stats_stats_mstats_common.py", line 150, in linregress
raise ValueError("Cannot calculate a linear regression "
ValueError: Cannot calculate a linear regression if all x values are identical
Traceback (most recent call last):
File "sglx_filelist_pipeline.py", line 198, in
Just a brief update, i have no problems when running all the modules from the beginning (kilosort_helper onwards), it just seems to cause this error when i run the mean_waveforms in isolation. I don't want to re-spike sort all the data again though. Any ideas would be much appreciated!