Skip to content

Commit

Permalink
Merge pull request #40 from claire98han/MNT]---Added-example-to-docst…
Browse files Browse the repository at this point in the history
…ring-of-`measure/measures.py`

[MNT] - Added example to docstring of `measures/measures.py`
  • Loading branch information
TomDonoghue committed Oct 14, 2021
2 parents 15e7aac + cfbea66 commit 9c4fd62
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions spiketools/measures/measures.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,14 @@ def compute_spike_rate(spikes):
-------
float
Average firing rate.
Example
-------
Compute spike rate of 6 spikes
>>> spikes = [0.5, 1, 1.5, 2, 2.5, 3]
>>> compute_spike_rate(spikes)
2.4
"""

return len(spikes) / (spikes[-1] - spikes[0])
Expand All @@ -34,6 +42,14 @@ def compute_isis(spikes):
-------
isis : 1d array
Distribution of interspike intervals.
Example
-------
Compute inter-spike intervals of 6 spikes
>>> spikes = [0.5, 0.8, 1.4, 2, 2.2, 2.9]
>>> compute_isis(spikes)
array([0.3, 0.6, 0.6, 0.2, 0.7])
"""

return np.diff(spikes)
Expand All @@ -51,6 +67,14 @@ def compute_cv(isis):
-------
cv : float
Coefficient of variation.
Example
-------
Compute the coefficient of variation of 6 interval-spike intervals
>>> isis = [0.3, 0.6, 0.6, 0.2, 0.7]
>>> compute_cv(isis)
0.4039733214513607
"""

return np.std(isis) / np.mean(isis)
Expand All @@ -68,6 +92,14 @@ def compute_fano_factor(spike_train):
-------
fano : float
Fano factor.
Example
-------
Compute the fano factor of a spike train with 6 time points
>>> spike_train = [0, 0, 1, 1, 0, 1, 1, 1, 0, 0, 1, 0]
>>> compute_fano_factor(spike_train)
0.5
"""

return np.var(spike_train) / np.mean(spike_train)

0 comments on commit 9c4fd62

Please sign in to comment.