-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
doc: update statistics documentation page
- Loading branch information
Showing
10 changed files
with
145 additions
and
128 deletions.
There are no files selected for viewing
6 changes: 6 additions & 0 deletions
6
docs/api/_toctree/StatisticsAPI/miv.statistics.firing_rates.rst
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
miv.statistics.firing\_rates | ||
============================ | ||
|
||
.. currentmodule:: miv.statistics | ||
|
||
.. autofunction:: firing_rates |
6 changes: 6 additions & 0 deletions
6
docs/api/_toctree/StatisticsAPI/miv.statistics.inter_spike_intervals.rst
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
miv.statistics.inter\_spike\_intervals | ||
====================================== | ||
|
||
.. currentmodule:: miv.statistics | ||
|
||
.. autofunction:: inter_spike_intervals |
6 changes: 6 additions & 0 deletions
6
docs/api/_toctree/StatisticsAPI/miv.statistics.signal_to_noise.rst
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
miv.statistics.signal\_to\_noise | ||
================================ | ||
|
||
.. currentmodule:: miv.statistics | ||
|
||
.. autofunction:: signal_to_noise |
6 changes: 0 additions & 6 deletions
6
docs/api/_toctree/StatisticsAPI/miv.statistics.spikestamps_statistics.rst
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
from miv.statistics.summarizer import * | ||
from miv.statistics.utility import * | ||
from miv.statistics.signal_statistics import * | ||
from miv.statistics.spiketrain_statistics import * |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
159 changes: 74 additions & 85 deletions
159
miv/statistics/summarizer.py → miv/statistics/spiketrain_statistics.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,85 +1,74 @@ | ||
__doc__ = """ | ||
Statistics Tools | ||
================ | ||
Spikestamps | ||
----------- | ||
.. currentmodule:: miv.statistics | ||
.. autosummary:: | ||
:nosignatures: | ||
:toctree: _toctree/StatisticsAPI | ||
spikestamps_statistics | ||
Useful External Packages | ||
======================== | ||
Here are few external `python` packages that can be used for further statistical analysis. | ||
scipy statistics | ||
---------------- | ||
`scipy <https://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.describe.html>`_ | ||
.. autosummary:: | ||
scipy.stats.describe | ||
elephant.statistics | ||
------------------- | ||
`elephant documentation: <https://elephant.readthedocs.io/en/latest/reference/statistics.html>`_ | ||
.. autosummary:: | ||
elephant.statistics.mean_firing_rate | ||
elephant.statistics.instantaneous_rate | ||
""" | ||
__all__ = ["spikestamps_statistics"] | ||
|
||
from typing import Any, Dict, Iterable, Optional, Union | ||
|
||
import datetime | ||
|
||
import elephant.statistics | ||
import matplotlib.pyplot as plt | ||
import neo | ||
import numpy as np | ||
import quantities as pq | ||
import scipy | ||
import scipy.signal | ||
|
||
|
||
# FIXME: For now, we provide the free function for simple usage. For more | ||
# advanced statistical analysis, we should have a module wrapper. | ||
def spikestamps_statistics( | ||
spiketrains: Union[pq.Quantity, Iterable[neo.core.SpikeTrain]], | ||
# t_start: Optional[float] = None, | ||
# t_stop: Optional[float] = None, | ||
) -> Dict[str, Any]: | ||
""" | ||
Process basic spiketrains statistics: rates, mean, variance. | ||
Parameters | ||
---------- | ||
spiketrains : Iterable[neo.core.SpikeTrain] | ||
Returns | ||
------- | ||
Iterable[Any] | ||
""" | ||
rates = [ | ||
float(elephant.statistics.mean_firing_rate(spikestamp).magnitude) | ||
for spikestamp in spiketrains | ||
] | ||
rates_mean_over_channel = np.mean(rates) | ||
rates_variance_over_channel = np.var(rates) | ||
return { | ||
"rates": rates, | ||
"mean": rates_mean_over_channel, | ||
"variance": rates_variance_over_channel, | ||
} | ||
__all__ = ["firing_rates", "inter_spike_intervals"] | ||
|
||
from typing import Any, Dict, Iterable, Optional, Union | ||
|
||
import datetime | ||
|
||
import elephant.statistics | ||
import matplotlib.pyplot as plt | ||
import neo | ||
import numpy as np | ||
import quantities as pq | ||
import scipy | ||
import scipy.signal | ||
|
||
from miv.typing import SpikestampsType | ||
|
||
|
||
# FIXME: For now, we provide the free function for simple usage. For more | ||
# advanced statistical analysis, we should have a module wrapper. | ||
def firing_rates( | ||
spiketrains: Union[pq.Quantity, Iterable[neo.core.SpikeTrain]], | ||
# t_start: Optional[float] = None, | ||
# t_stop: Optional[float] = None, | ||
) -> Dict[str, Any]: | ||
""" | ||
Process basic spiketrains statistics: rates, mean, variance. | ||
Parameters | ||
---------- | ||
spiketrains : Iterable[neo.core.SpikeTrain] | ||
Returns | ||
------- | ||
Iterable[Any] | ||
""" | ||
rates = [ | ||
float(elephant.statistics.mean_firing_rate(spikestamp).magnitude) | ||
for spikestamp in spiketrains | ||
] | ||
rates_mean_over_channel = np.mean(rates) | ||
rates_variance_over_channel = np.var(rates) | ||
return { | ||
"rates": rates, | ||
"mean": rates_mean_over_channel, | ||
"variance": rates_variance_over_channel, | ||
} | ||
|
||
|
||
def inter_spike_intervals(spikes): | ||
""" | ||
Compute the inter-spike intervals of the given spike train. | ||
Examples | ||
-------- | ||
How to draw Inter-spike interval histogram (ISIH) | ||
>>> from miv.statistics import inter_spike_intervals | ||
>>> import matplotlib.pyplot as plt | ||
>>> interval = inter_spike_intervals(spikestamps) | ||
>>> plt.hist(interval) | ||
Parameters | ||
---------- | ||
spikes : SpikestampsType | ||
Returns | ||
------- | ||
numpy.ndarray | ||
""" | ||
|
||
return np.diff(spikes) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters