From 4aa06d67406dbfd0f7e679f643229dbb69bbe343 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaquier=20Aur=C3=A9lien=20Tristan?= Date: Tue, 21 May 2024 13:13:51 +0200 Subject: [PATCH] empty features should be None --- efel/pyfeatures/pyfeatures.py | 4 ++-- tests/testdata/allfeatures/expectedresults.json | 16 ++++++++-------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/efel/pyfeatures/pyfeatures.py b/efel/pyfeatures/pyfeatures.py index 097f1a8b..184e4a83 100644 --- a/efel/pyfeatures/pyfeatures.py +++ b/efel/pyfeatures/pyfeatures.py @@ -291,7 +291,7 @@ def spikes_per_burst(): burst_begin_indices = get_cpp_feature("burst_begin_indices") burst_end_indices = get_cpp_feature("burst_end_indices") - if burst_begin_indices is None: + if burst_begin_indices is None or len(burst_begin_indices) < 1: return None ap_per_bursts = [] @@ -304,7 +304,7 @@ def spikes_per_burst(): def spikes_per_burst_diff(): """Calculate the diff between the spikes in each burst and the next one""" spikes_per_burst_values = spikes_per_burst() - if spikes_per_burst_values is None: + if spikes_per_burst_values is None or len(spikes_per_burst_values) < 2: return None return spikes_per_burst_values[:-1] - spikes_per_burst_values[1:] diff --git a/tests/testdata/allfeatures/expectedresults.json b/tests/testdata/allfeatures/expectedresults.json index 27463db9..bb6e0145 100644 --- a/tests/testdata/allfeatures/expectedresults.json +++ b/tests/testdata/allfeatures/expectedresults.json @@ -435,8 +435,8 @@ "interburst_60percent_indices": null, "interburst_60percent_values": null, "interburst_duration": null, - "interburst_min_indices": [], - "interburst_min_values": [], + "interburst_min_indices": null, + "interburst_min_values": null, "interburst_voltage": [ -38.820613862535545 ], @@ -624,7 +624,7 @@ "strict_burst_number": [ 1 ], - "strict_interburst_voltage": [], + "strict_interburst_voltage": null, "time": [ 0.0, 0.1, @@ -30632,7 +30632,7 @@ "time_to_first_spike": [ 8.000000000092427 ], - "time_to_interburst_min": [], + "time_to_interburst_min": null, "time_to_last_spike": [ 1937.7999999986964 ], @@ -60680,7 +60680,7 @@ "spikes_per_burst": [ 2 ], - "spikes_per_burst_diff": [], + "spikes_per_burst_diff": null, "spikes_in_burst1_burst2_diff": null, "spikes_in_burst1_burstlast_diff": null, "depol_block": null, @@ -60723,7 +60723,7 @@ "strict_burst_mean_freq": [ 7.99041151 ], - "strict_interburst_voltage": [], + "strict_interburst_voltage": null, "ADP_peak_amplitude": [ 0.0, 2.6873666528663236, @@ -60748,8 +60748,8 @@ -41.12299346923828, -38.12341871769886 ], - "interburst_min_indices": [], - "interburst_min_values": [], + "interburst_min_indices": null, + "interburst_min_values": null, "postburst_min_indices": [ 26465 ],