Skip to content
Snippets Groups Projects
Commit 17083a63 authored by Alexander van Meegen's avatar Alexander van Meegen
Browse files

Fix zero division errors

parent 760255a9
No related branches found
No related tags found
1 merge request!23Fix issues raised by golosio
...@@ -538,7 +538,7 @@ def pop_cv_isi(data_array, t_min, t_max): ...@@ -538,7 +538,7 @@ def pop_cv_isi(data_array, t_min, t_max):
for i in np.unique(data_array[:, 0]): for i in np.unique(data_array[:, 0]):
intervals = np.diff(data_array[indices][ intervals = np.diff(data_array[indices][
np.where(data_array[indices, 0] == i), 1]) np.where(data_array[indices, 0] == i), 1])
if (len(intervals) > 0): if intervals.size > 0:
cv_isi.append(np.std(intervals) / np.mean(intervals)) cv_isi.append(np.std(intervals) / np.mean(intervals))
if len(cv_isi) > 0: if len(cv_isi) > 0:
return np.mean(cv_isi) return np.mean(cv_isi)
...@@ -668,8 +668,11 @@ def synchrony(data_array, num_neur, t_min, t_max, resolution=1.0): ...@@ -668,8 +668,11 @@ def synchrony(data_array, num_neur, t_min, t_max, resolution=1.0):
spike_count_histogramm = pop_rate_time_series( spike_count_histogramm = pop_rate_time_series(
data_array, num_neur, t_min, t_max, resolution=resolution) data_array, num_neur, t_min, t_max, resolution=resolution)
mean = np.mean(spike_count_histogramm) mean = np.mean(spike_count_histogramm)
variance = np.var(spike_count_histogramm) std_dev = np.std(spike_count_histogramm)
synchrony = variance / mean if std_dev + mean != std_dev: # check for vanishing mean
synchrony = std_dev / mean
else:
synchrony = np.inf
return synchrony return synchrony
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment