diff --git a/fishbook/reproclasses.py b/fishbook/reproclasses.py index e627438..5786bb4 100644 --- a/fishbook/reproclasses.py +++ b/fishbook/reproclasses.py @@ -11,6 +11,16 @@ from IPython import embed def _zero_crossings(x, t, interpolate=False): + """get the times at which a signal x + + Args: + x ([type]): [description] + t ([type]): [description] + interpolate (bool, optional): [description]. Defaults to False. + + Returns: + [type]: [description] + """ dt = t[1] - t[0] x_shift = np.roll(x, 1) x_shift[0] = 0.0 @@ -100,7 +110,7 @@ class BaselineData: def serial_correlation(self, max_lags=50): """ - return the serial correlation for the the spike train provided by spike_times. + Returns the serial correlation of the interspike intervals. @param max_lags: The number of lags to take into account @return: the serial correlation as a function of the lag """ @@ -114,29 +124,29 @@ class BaselineData: return scs def circular_std(self): - cstds = [] + circular_stds = [] for i in range(self.size): phases = self.__spike_phases(index=i) - cstds.append(circstd(phases)) - return cstds + circular_stds.append(circstd(phases)) + return circular_stds def eod_frequency(self): - eodfs = [] + eod_frequencies = [] for i in range(self.size): eod, time = self.eod(i) xings = _zero_crossings(eod, time, interpolate=False) - eodfs.append(len(xings)/xings[-1]) - return 0.0 if len(eodfs) < 1 else np.mean(eodfs) + eod_frequencies.append(len(xings)/xings[-1]) + return 0.0 if len(eod_frequencies) < 1 else np.mean(eod_frequencies) def __spike_phases(self, index=0): # fixme buffer this stuff - etimes = self.eod_times(index=index) - eod_period = np.mean(np.diff(etimes)) + e_times = self.eod_times(index=index) + eod_period = np.mean(np.diff(e_times)) phases = np.zeros(len(self.spikes(index))) for i, st in enumerate(self.spikes(index)): - last_eod_index = np.where(etimes <= st)[0] + last_eod_index = np.where(e_times <= st)[0] if len(last_eod_index) == 0: continue - phases[i] = (st - etimes[last_eod_index[-1]]) / eod_period * 2 * np.pi + phases[i] = (st - e_times[last_eod_index[-1]]) / eod_period * 2 * np.pi return phases def eod_times(self, index=0, interpolate=True): @@ -144,10 +154,10 @@ class BaselineData: return None if len(self.__eod_times) < len(self.__eod_data): eod, time = self.eod(index) - etimes = _zero_crossings(eod, time, interpolate=interpolate) + times = _zero_crossings(eod, time, interpolate=interpolate) else: - etimes = self.__eod_times[index] - return etimes + times = self.__eod_times[index] + return times @property def dataset(self): @@ -164,6 +174,14 @@ class BaselineData: return subjects if len(subjects) > 1 else subjects[0] def spikes(self, index: int=0): + """Get the spike times of the spikes recorded in the given baseline recording. + + Args: + index (int, optional): If the baseline activity has been recorded several times, the index can be given. Defaults to 0. + + Returns: + : [description] + """ return self.__spike_data[index] if len(self.__spike_data) >= index else None def membrane_voltage(self, index: int=0): @@ -233,7 +251,7 @@ class BaselineData: return len(self.__spike_data) def __str__(self): - str = "Baseline data of cell %s " % self.__cell.id + return "Baseline data of cell %s " % self.__cell.id def __read_eod_data_from_nix(self, r: RePro, duration) -> np.ndarray: data_source = os.path.join(self.__dataset.data_source, self.__dataset.id + ".nix") @@ -248,7 +266,7 @@ class BaselineData: try: data = t.retrieve_data("EOD")[:] except: - data = np.empty(); + data = np.empty() f.close() return data @@ -364,10 +382,10 @@ class BoltzmannFit: @property def slope(self) -> float: - """ + r""" The slope of the linear part of the Boltzmann, i.e. .. math:: - s = f_max \cdot k / 4 + s = f_max $\cdot$ k / 4 :return: the slope. """ return self.__fit_params[0] * self.__fit_params[1] / 4 @@ -758,4 +776,4 @@ if __name__ == "__main__": dataset = Dataset(dataset_id="2018-09-13-ac-invivo-1") # dataset = Dataset(dataset_id='2013-04-18-ac') fi_curve = FileStimulusData(dataset) - embed() \ No newline at end of file + embed()