From 5b1ac166e1c11c8636b7b9ed5ed2faae15f3719e Mon Sep 17 00:00:00 2001 From: ilkankilic Date: Thu, 10 Jul 2025 16:08:03 +0200 Subject: [PATCH 1/3] check if any protocol is missing in all cells --- bluepyefe/extract.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/bluepyefe/extract.py b/bluepyefe/extract.py index 494ccf2..124a2f2 100644 --- a/bluepyefe/extract.py +++ b/bluepyefe/extract.py @@ -451,6 +451,17 @@ def group_efeatures( efel_settings=efel_settings, ) + # Check if any protocol is missing in all cells + for protocol in protocols: + found = any( + cell.get_recordings_by_protocol_name(protocol.name) + for cell in cells + ) + if not found: + logger.warning( + f"Protocol '{protocol.name}' not found in any cell recordings." + ) + for protocol in protocols: for cell in cells: From 76618dd7bc02d37f3f51a916706fba46ad6d26c1 Mon Sep 17 00:00:00 2001 From: ilkankilic Date: Mon, 14 Jul 2025 16:10:06 +0200 Subject: [PATCH 2/3] Add protocol filtering to TRTNWBReader to allow only 'step' --- bluepyefe/nwbreader.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/bluepyefe/nwbreader.py b/bluepyefe/nwbreader.py index 63034fb..db13d20 100644 --- a/bluepyefe/nwbreader.py +++ b/bluepyefe/nwbreader.py @@ -277,6 +277,16 @@ def read(self): data (list of dict): list of traces """ data = [] + + # Only return data if target_protocols is None or includes "step" + if self.target_protocols: + allowed = [p.lower() for p in self.target_protocols] + if not any(proto in allowed for proto in ["step"]): + logger.warning( + f"TRTNWBReader only supports 'step' protocols, but requested: {self.target_protocols}. Skipping." + ) + return [] + # possible paths in content: # /acquisition/index_00 # or /acquisition/index_000 From b2fa40c2459bc4dc242c6093c3c050a1b3c8e2ca Mon Sep 17 00:00:00 2001 From: ilkankilic Date: Mon, 14 Jul 2025 17:25:11 +0200 Subject: [PATCH 3/3] optimisation --- bluepyefe/extract.py | 35 +++++++++++++++-------------------- bluepyefe/nwbreader.py | 2 +- 2 files changed, 16 insertions(+), 21 deletions(-) diff --git a/bluepyefe/extract.py b/bluepyefe/extract.py index 124a2f2..9659aa4 100644 --- a/bluepyefe/extract.py +++ b/bluepyefe/extract.py @@ -451,33 +451,28 @@ def group_efeatures( efel_settings=efel_settings, ) - # Check if any protocol is missing in all cells - for protocol in protocols: - found = any( - cell.get_recordings_by_protocol_name(protocol.name) - for cell in cells - ) - if not found: - logger.warning( - f"Protocol '{protocol.name}' not found in any cell recordings." - ) + missing_protocols = set() for protocol in protocols: + found = False for cell in cells: - if cell.rheobase is None and not absolute_amplitude: continue + recordings = cell.get_recordings_by_protocol_name(protocol.name) + if not recordings: + continue + found = True - for recording in cell.get_recordings_by_protocol_name( - protocol.name - ): - - if recording.in_target( - protocol.amplitude, - protocol.tolerance, - absolute_amplitude - ): + for recording in recordings: + if recording.in_target(protocol.amplitude, + protocol.tolerance, + absolute_amplitude): protocol.append(recording) + if not found: + missing_protocols.add(protocol.name) + + for name in missing_protocols: + logger.warning(f"Protocol '{name}' not found in any cell recordings.") return protocols diff --git a/bluepyefe/nwbreader.py b/bluepyefe/nwbreader.py index db13d20..2a8ed8c 100644 --- a/bluepyefe/nwbreader.py +++ b/bluepyefe/nwbreader.py @@ -281,7 +281,7 @@ def read(self): # Only return data if target_protocols is None or includes "step" if self.target_protocols: allowed = [p.lower() for p in self.target_protocols] - if not any(proto in allowed for proto in ["step"]): + if "step" not in allowed: logger.warning( f"TRTNWBReader only supports 'step' protocols, but requested: {self.target_protocols}. Skipping." )