From 2c4f3afa5676271b1c9d341102cc9b0a5d8006cb Mon Sep 17 00:00:00 2001 From: Jan Grewe Date: Wed, 9 Oct 2019 11:38:58 +0200 Subject: [PATCH] [reproclasses/FICurve] buffer spike times when reading from nix ... fix spike indices during rate calculation --- fishbook/reproclasses.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/fishbook/reproclasses.py b/fishbook/reproclasses.py index 411f1aa..95cfab3 100644 --- a/fishbook/reproclasses.py +++ b/fishbook/reproclasses.py @@ -440,9 +440,8 @@ class FIData: end_index_eod = eod_da.dimensions[0].index_of(end_time) local_eod = eod_da[start_index_eod:end_index_eod] - spikes = spikes_da[start_index_spikes:end_index_spikes] - start_time - time = np.asarray(eod_da.dimensions[0].axis(len(local_eod))) - delay - + spikes = self.__all_spikes[(self.__all_spikes >= start_time) & (self.__all_spikes < end_time)] - start_time - delay + time = np.asarray(eod_da.dimensions[0].axis(end_index_eod - start_index_eod)) - delay return spikes, local_eod, time, contrast def __read_spikes_from_nix(self, repro: RePro): @@ -459,6 +458,7 @@ class FIData: return self.__read_spikes_from_directory(repro) f = nix.File.open(data_source, nix.FileMode.ReadOnly) b = f.blocks[0] + self.__all_spikes = b.data_arrays["Spikes-1"][:] mt = None for i in tqdm(range(len(stimuli)), desc="Loading data"): s = stimuli[i] @@ -594,7 +594,7 @@ class FIData: dt = np.mean(np.diff(t)) sp = self.spikes(index) binary = np.zeros(t.shape) - spike_indices = (sp / dt).astype(int) + spike_indices = ((sp - t[0]) / dt).astype(int) binary[spike_indices[(spike_indices >= 0) & (spike_indices < len(binary))]] = 1 g = gaussian_kernel(kernel_width, dt) rate = np.convolve(binary, g, mode='same')