docstrings, renaming etc
This commit is contained in:
parent
b86c1b2653
commit
a6a478c5d1
@ -11,6 +11,16 @@ from IPython import embed
|
|||||||
|
|
||||||
|
|
||||||
def _zero_crossings(x, t, interpolate=False):
|
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]
|
dt = t[1] - t[0]
|
||||||
x_shift = np.roll(x, 1)
|
x_shift = np.roll(x, 1)
|
||||||
x_shift[0] = 0.0
|
x_shift[0] = 0.0
|
||||||
@ -100,7 +110,7 @@ class BaselineData:
|
|||||||
|
|
||||||
def serial_correlation(self, max_lags=50):
|
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
|
@param max_lags: The number of lags to take into account
|
||||||
@return: the serial correlation as a function of the lag
|
@return: the serial correlation as a function of the lag
|
||||||
"""
|
"""
|
||||||
@ -114,29 +124,29 @@ class BaselineData:
|
|||||||
return scs
|
return scs
|
||||||
|
|
||||||
def circular_std(self):
|
def circular_std(self):
|
||||||
cstds = []
|
circular_stds = []
|
||||||
for i in range(self.size):
|
for i in range(self.size):
|
||||||
phases = self.__spike_phases(index=i)
|
phases = self.__spike_phases(index=i)
|
||||||
cstds.append(circstd(phases))
|
circular_stds.append(circstd(phases))
|
||||||
return cstds
|
return circular_stds
|
||||||
|
|
||||||
def eod_frequency(self):
|
def eod_frequency(self):
|
||||||
eodfs = []
|
eod_frequencies = []
|
||||||
for i in range(self.size):
|
for i in range(self.size):
|
||||||
eod, time = self.eod(i)
|
eod, time = self.eod(i)
|
||||||
xings = _zero_crossings(eod, time, interpolate=False)
|
xings = _zero_crossings(eod, time, interpolate=False)
|
||||||
eodfs.append(len(xings)/xings[-1])
|
eod_frequencies.append(len(xings)/xings[-1])
|
||||||
return 0.0 if len(eodfs) < 1 else np.mean(eodfs)
|
return 0.0 if len(eod_frequencies) < 1 else np.mean(eod_frequencies)
|
||||||
|
|
||||||
def __spike_phases(self, index=0): # fixme buffer this stuff
|
def __spike_phases(self, index=0): # fixme buffer this stuff
|
||||||
etimes = self.eod_times(index=index)
|
e_times = self.eod_times(index=index)
|
||||||
eod_period = np.mean(np.diff(etimes))
|
eod_period = np.mean(np.diff(e_times))
|
||||||
phases = np.zeros(len(self.spikes(index)))
|
phases = np.zeros(len(self.spikes(index)))
|
||||||
for i, st in enumerate(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:
|
if len(last_eod_index) == 0:
|
||||||
continue
|
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
|
return phases
|
||||||
|
|
||||||
def eod_times(self, index=0, interpolate=True):
|
def eod_times(self, index=0, interpolate=True):
|
||||||
@ -144,10 +154,10 @@ class BaselineData:
|
|||||||
return None
|
return None
|
||||||
if len(self.__eod_times) < len(self.__eod_data):
|
if len(self.__eod_times) < len(self.__eod_data):
|
||||||
eod, time = self.eod(index)
|
eod, time = self.eod(index)
|
||||||
etimes = _zero_crossings(eod, time, interpolate=interpolate)
|
times = _zero_crossings(eod, time, interpolate=interpolate)
|
||||||
else:
|
else:
|
||||||
etimes = self.__eod_times[index]
|
times = self.__eod_times[index]
|
||||||
return etimes
|
return times
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def dataset(self):
|
def dataset(self):
|
||||||
@ -164,6 +174,14 @@ class BaselineData:
|
|||||||
return subjects if len(subjects) > 1 else subjects[0]
|
return subjects if len(subjects) > 1 else subjects[0]
|
||||||
|
|
||||||
def spikes(self, index: int=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
|
return self.__spike_data[index] if len(self.__spike_data) >= index else None
|
||||||
|
|
||||||
def membrane_voltage(self, index: int=0):
|
def membrane_voltage(self, index: int=0):
|
||||||
@ -233,7 +251,7 @@ class BaselineData:
|
|||||||
return len(self.__spike_data)
|
return len(self.__spike_data)
|
||||||
|
|
||||||
def __str__(self):
|
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:
|
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")
|
data_source = os.path.join(self.__dataset.data_source, self.__dataset.id + ".nix")
|
||||||
@ -248,7 +266,7 @@ class BaselineData:
|
|||||||
try:
|
try:
|
||||||
data = t.retrieve_data("EOD")[:]
|
data = t.retrieve_data("EOD")[:]
|
||||||
except:
|
except:
|
||||||
data = np.empty();
|
data = np.empty()
|
||||||
f.close()
|
f.close()
|
||||||
return data
|
return data
|
||||||
|
|
||||||
@ -364,10 +382,10 @@ class BoltzmannFit:
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def slope(self) -> float:
|
def slope(self) -> float:
|
||||||
"""
|
r"""
|
||||||
The slope of the linear part of the Boltzmann, i.e.
|
The slope of the linear part of the Boltzmann, i.e.
|
||||||
.. math::
|
.. math::
|
||||||
s = f_max \cdot k / 4
|
s = f_max $\cdot$ k / 4
|
||||||
:return: the slope.
|
:return: the slope.
|
||||||
"""
|
"""
|
||||||
return self.__fit_params[0] * self.__fit_params[1] / 4
|
return self.__fit_params[0] * self.__fit_params[1] / 4
|
||||||
|
Loading…
Reference in New Issue
Block a user