improve eod calculation/detection

This commit is contained in:
a.ott 2020-07-06 15:22:53 +02:00
parent 71115d83d0
commit ad62b31abc

View File

@ -284,15 +284,13 @@ def calculate_serial_correlation(spiketimes: np.ndarray, max_lag: int) -> np.nda
return cor
def calculate_eod_frequency(time, eod):
def calculate_eod_frequency(eod, sampling_interval):
# TODO for few samples very volatile measure!
up_indicies, down_indicies = threshold_crossings(eod, 0)
up_times, down_times = threshold_crossing_times(time, eod, 0, up_indicies, down_indicies)
std = np.std(eod)
peaks, _ = detect_peaks(eod, std*1)
peak_times = [p*sampling_interval for p in peaks]
if len(up_times) == 0:
return 0
durations = np.diff(up_times)
durations = np.diff(peak_times)
mean_duration = np.mean(durations)
return 1/mean_duration