From c136ed87aca0c1a29488e122dbabe788c385acf4 Mon Sep 17 00:00:00 2001 From: Alessandra Trapani Date: Mon, 18 Sep 2023 11:37:15 +0200 Subject: [PATCH] add check function for ascending spike times --- src/nwbinspector/checks/ecephys.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/nwbinspector/checks/ecephys.py b/src/nwbinspector/checks/ecephys.py index 5044bd8d1..d18f0ee89 100644 --- a/src/nwbinspector/checks/ecephys.py +++ b/src/nwbinspector/checks/ecephys.py @@ -79,3 +79,17 @@ def check_spike_times_not_in_unobserved_interval(units_table: Units, nunits: int "observed intervals." ) ) + + +@register_check(importance=Importance.BEST_PRACTICE_VIOLATION, neurodata_type=Units) +def check_ascending_spike_times(units_table: Units): + """Check that the values in the timestamps array are strictly increasing.""" + if "spike_times" not in units_table: + return + differences = np.diff(np.asarray(units_table["spike_times"].target.data[:])) + if np.all(differences >= 0): + return InspectorMessage( + message=( + "This Units table contains spike times that are not ascending." + ) + ) \ No newline at end of file