AllenInstitute / AllenSDK

code for reading and processing Allen Institute for Brain Science data
https://allensdk.readthedocs.io/en/latest/
Other
343 stars 149 forks source link

calculate_dvdt(v_window, t_window, filter) throwing an error #2399

Open ImagineOrange opened 2 years ago

ImagineOrange commented 2 years ago

Describe the bug I'm calling the putative_spike_detection function on some optical electrophysiology data. The data is squeezed to a range of -80,80 mV.

The function runs smoothly until it calls on the calculate_dvdt function, where it then throws the error:

Traceback (most recent call last): File "allen_sdk.py", line 258, in before_cutoff = 2000) File "allen_sdk.py", line 235, in main test = allensdk_feature_extraction(DENOISED_traces[0]) File "allen_sdk.py", line 206, in allensdk_feature_extraction spike_indices = detect_putative_spikes(voltage,time) ###we only need stimulus-times File "/opt/anaconda3/envs/allen_sdk/lib/python3.7/site-packages/allensdk/ephys/ephys_features.py", line 85, in detect_putative_spikes dvdt = calculate_dvdt(v_window, t_window, filter) File "/opt/anaconda3/envs/allen_sdk/lib/python3.7/site-packages/allensdk/ephys/ephys_features.py", line 662, in calculate_dvdt raise ValueError("bessel coeff ({:f}) is outside of valid range [0,1); cannot filter sampling frequency {:.1f} kHz with cutoff frequency {:.1f} kHz.".format(filt_coeff, sample_freq / 1e3, filter)) ValueError: bessel coeff (20000.000000) is outside of valid range [0,1); cannot filter sampling frequency 0.0 kHz with cutoff frequency 10.0 kHz.

I can eliminate the error by setting the filter parameter to anything less than or equal to 0.000099, but this returns no spike indices despite obvious spikes in the data.

To Reproduce Here is a sample of the data that I'm working with:

Screen Shot 2022-04-28 at 1 07 09 PM

and as of now I'm calling the putative spike function with the correct numpy arrays, one voltage array and the other a time array of equivalent dimension:

def allensdk_feature_extraction(denoised_trace):
    voltage = np.interp(denoised_trace,(denoised_trace.min(),denoised_trace.max()),(-80,80))
    time = np.arange(1,voltage.shape[0]+1)
    spike_indices = detect_putative_spikes(voltage,time)          
    print(f"spike indices:  : {spike_indices}")

Environment (please complete the following information):

Thank you for the help!

danielsf commented 2 years ago

@ImagineOrange Just curious: is it possible for you to provide us with a .txt file containing a sample of voltage, time values that are failing but that you would expect to succeed?

If not, we'll find a way to work through, but it will be more straightforward on our end if there is example of data that is provoking this failure.

Thanks.

ImagineOrange commented 2 years ago

@danielsf sure thing: Here are voltage,time in order. time.txt voltage.txt

thank you for the quick response.