Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MNT] - Added example to docstring of measures/measures.py #40

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)