From 3d70e3151264a93b8a8e72a6f49ba7364441ae6b Mon Sep 17 00:00:00 2001 From: Jan Grewe Date: Thu, 13 Aug 2020 15:54:46 +0200 Subject: [PATCH] [relacs] ignore trials with less than 5 spikes ... fix run and trial duration info --- fishbook/frontend/relacs_classes.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/fishbook/frontend/relacs_classes.py b/fishbook/frontend/relacs_classes.py index ffe5413..8f6b813 100644 --- a/fishbook/frontend/relacs_classes.py +++ b/fishbook/frontend/relacs_classes.py @@ -756,7 +756,7 @@ class FileStimulusData: r_settings = yaml.safe_load(repro.settings.replace("\t", "")) stimuli, _ = Stimulus.find(cell_id=repro.cell_id, repro_id=repro.id) if len(stimuli) == 0: - return spikes, contrasts, stim_files, [] + return spikes, contrasts, stim_files, [], [], [] data_source = os.path.join(self.__dataset.data_source, self.__dataset.id + ".nix") if not os.path.exists(data_source): print("Data not found! Trying from directory") @@ -771,7 +771,7 @@ class FileStimulusData: mt = b.multi_tags[s.multi_tag_id] sp, c, stim, delay, duration = self.__do_read_spike_data_from_nix(mt, s, repro) - if len(sp) > 0: + if len(sp) > 5: spikes.append(sp) contrasts.append(c) stim_files.append(stim) @@ -797,10 +797,14 @@ class FileStimulusData: s_settings = yaml.safe_load(s.settings.replace("\t", "")) s_settings = s_settings["project"] if "project" in s_settings.keys() else s_settings contrast = self.__find_contrast(r_settings, s_settings, False) - duration = float(s_settings["duration"][:-2]) / 1000 - sp = self.__stimspikes.get(s.run, s.index) - if not sp or len(sp) < 1: + dur, sp = self.__stimspikes.get(s.run, s.index) + if not sp or len(sp) < 5: continue + + if "duration" in s_settings.keys(): + duration = float(s_settings["duration"][:-2]) / 1000 + else: + duration = dur contrasts.append(contrast) delays.append(float(r_settings["before"][:-2]) / 1000) durations.append(duration)