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

mean waveforms linear regression error #82

Open
rjp109 opened this issue Jul 18, 2023 · 1 comment
Open

mean waveforms linear regression error #82

rjp109 opened this issue Jul 18, 2023 · 1 comment

Comments

@rjp109
Copy link

rjp109 commented Jul 18, 2023

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
main()
File "C:\Ecphys\ecephys_spike_sorting-master.venv\lib\site-packages\ecephys_spike_sorting\modules\mean_waveforms_main
.py", line 213, in main
output = calculate_mean_waveforms(mod.args)
File "C:\Ecphys\ecephys_spike_sorting-master.venv\lib\site-packages\ecephys_spike_sorting\modules\mean_waveforms_main
.py", line 134, in calculate_mean_waveforms
metrics = metrics_from_file(mean_waveform_fullpath, snr_fullpath, clus_table_npy,
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
run_one_probe.runOne( session_id[i],
File "C:\Ecphys\ecephys_spike_sorting-master.venv\Lib\site-packages\ecephys_spike_sorting\scripts\helpers\run_one_probe.py", line 36, in runOne
subprocess.check_call(command.split(' '))
File "c:\users\rp17047\appdata\local\programs\python\python38\lib\subprocess.py", line 364, in check_call
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['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']' returned non-zero exit status 1.

@rjp109
Copy link
Author

rjp109 commented Jul 31, 2023

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant