Skip to content

Commit

Permalink
Merge pull request #36 from zm711/more-doc-updates
Browse files Browse the repository at this point in the history
fix autodoc and typos
  • Loading branch information
zm711 authored Aug 22, 2023
2 parents ba17c5c + eee79b1 commit 1104ebe
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 17 deletions.
7 changes: 7 additions & 0 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
sphinx==5.3.0
sphinx_rtd_theme==1.1.1
readthedocs-sphinx-search==0.1.1
numpy
scipy
matplotlib
numba
seaborn
pandas
spikeanalysis @ git+https://github.com/zm711/spikeanalysis@main


8 changes: 7 additions & 1 deletion docs/source/API.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,20 @@ spikeanalysis

.. autoclass:: SpikeAnalysis
:members:

.. autoclass:: SpikeData
:members:

.. autoclass:: StimulusData
:members:

.. autoclass:: IntrinsicPlotter
:members:

.. autoclass:: SpikePlotter
:members:

.. autoclass:: AnalogAnalysis
:members:
.. autofunction:: kolmo_smir_stats

.. autofunction:: kolmo_smir_stats
8 changes: 4 additions & 4 deletions docs/source/submodules/intrinsic_plotter.rst
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Or we can change some default settings to zoom in looking for refractory period
# window_ms indicates only calculate 10 ms around each spike
# ref_dur_ms indicates that a line should be drawn at 2 ms to help
# visualization potential violations.
iplotter.plot_acgs(sp=spiketrain, window = 10, ref_dur_ms = 2)
iplotter.plot_acgs(sp=spiketrain, window_ms = 10, ref_dur_ms = 2)
Note, to use the :code:`autocorrelograms` for further analyis the code for :code:`SpikeAnalysis` has its own :code:`autocorrelogram()` These values
Expand Down Expand Up @@ -66,8 +66,8 @@ and then indices these features to only take the top 2 PCs for each unit and com
Plot firing rate by depth
-------------------------

Simple function for looking at the firing rates at each depth. This could be useful to quickly see if a particular layer of the cortex of
lamina of the cord has most of the units found during sorting.
Simple function for looking at the firing rates at each depth. This could be useful to quickly see if a particular layer of the cortex or
lamina of the spinal cord has most of the units found during sorting.

.. code-block:: python
Expand All @@ -76,7 +76,7 @@ lamina of the cord has most of the units found during sorting.
CDF
---

A cumulative distribution function helps indicate the distribition of spike rates, depths, and amplitudes of a dataset based on the templates
A cumulative distribution function helps indicate the distribution of spike rates, depths, and amplitudes of a dataset based on the templates
analyzed.

.. code-block:: python
Expand Down
15 changes: 8 additions & 7 deletions docs/source/submodules/spike_analysis.rst
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ a :code:`window=[-10, 20]` would be 10 seconds before each stimulus to 20 second
The window can always be shrunk for plotting functions, but keeping a wide, but non-overlapping
window can demonstrate some patterns that might be missed by only focusing on right around the stimulus
onset. Also traditionally PSTHs should only have 0 or 1 spikes/bin and so the code will indicate
if your current time_bin_ms is too large to fulfil this condition. It is up to the user whether this
if your current :code:`time_bin_ms`` is too large to fulfil this condition. It is up to the user whether this
matters for their purposes. Additionally this function can globally apply values or each stimulus can have
a value given.

Expand Down Expand Up @@ -109,7 +109,7 @@ and the :code:`num_shuffles` indicates how many baseline shuffles to store.
Above 2Hz Assuming a Poisson
^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Adapted from Chase and Young **PNAS** 2007 the neurons firing rate is assumed to follow a Poisson distribution with a PMF of:
Adapted from Chase and Young **PNAS** 2007 the neuron's firing rate is assumed to follow a Poisson distribution with a PMF of:

.. math::
Expand All @@ -121,18 +121,18 @@ To calculate the potential deviation from this distribution we perform a calcula
P_{t_n}(\geq n) = 1 - \sum_{m=0}^{n-1} \frac{( \lambda t_n)^m e^{- \lambda t_n}}{m!}
In this case the :math:`\lambda` is the baseline firing rate of the neuron and :math:`t_n` will be the time window. They calcuate to see
In this case the :math:`\lambda` is the baseline firing rate of the neuron and :math:`t_n` will be the time window. Chase and Young calculate to see
first latency to spike based on all trials being merged, but in :code:`spikeanalysis` each trial is taken separately so that a distribution
can be determined of the latencies rather than just one value. The take a threshold of :math:`10^{-6}`, which is maintained, but may be
can be determined for all the latencies rather than just one value. They take a threshold of :math:`10^{-6}`, which is maintained, but may be
changed in the future.

Note :math:`\lambda` * :math:`t_n` gives us the :math:`\mu` from the standard Poisson PMF.

Below 2Hz Taking the first-spike
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

If the mean firing rate is below 2Hz for a neuron, the first spike is taken to be the true first spike as related to the stimulus. This
means that the neuron is not following a Poisson distribution and so taking the first spike time is likely acceptable see Emmanuel et al. 2021
If the mean firing rate is below 2Hz for a neuron, the first spike is taken to be the true first spike as related to the stimulus. This relies on the fact that
neurons which fire at lower rates typically do not follow a Poisson distribution. For papers that use first spike time see Emmanuel et al. 2021
for use of this technique in DRG neurons and Mornmann et al. 2008 for use in human cortex.


Expand All @@ -157,7 +157,8 @@ Autocorrelogram
---------------

Calculating an Autocorrelogram for each unit based on its spike times. The 0 lag sample is removed. This is returned as a :code:`np.ndarray` for ease of use.
Currently it is based on bins with size :math:`\frac{1}{2} SampleSize`, but this may evenutually become an argument in the function.
Currently it is based on take 500 ms after stimulus onset and dividing this into bins which are sized at :math:`2 * sample_rate`. In the future these may
become user specifiable agruments.

.. code-block:: python
Expand Down
9 changes: 5 additions & 4 deletions docs/source/submodules/spike_data.rst
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ method can be used to switching caching to False

.. code-block:: python
spikes.set_cahcing(cache=False) # files will not be saved
spikes.set_caching(cache=False) # files will not be saved
Caching the data is done as either :code:`json` or :code:`.npy` depending on whether the data being saved is a
Expand Down Expand Up @@ -93,7 +93,8 @@ matrix of cluster distances it helps reduce less significant and highly coordina
as well as the fact that many contacts of the probes are in similar locations and so should have correlated PC spaces. The Isolation
Distance relies on the mahalobnis distances and is reported as the smallest mahalobnis distance of the nearest spike not found in the
current cluster. Proposed by Harris et al (2001) and equation adapted from Schmitzer-Torbert et al (2005). Isolation distances can vary
from :math:`0` to :math:`\infty` with great distance indicating that clusters are farther apart in PC space.
from :math:`0` to :math:`\infty` with greater distance indicating that clusters are farther apart in PC space and thus likely cleaner
clusters.

.. math::
Expand Down Expand Up @@ -121,7 +122,7 @@ The silhouette score is than:
s(i) = \frac{b(i) - a(i)}{max(a(i), b(i))}
For :code:`spikenalysis`, rather than this implementation proposed by Rousseeuw, the simplified silhouette is used as proposed by Hruschka et al.
This makes use of the centroid distance rather than pair wise. So,
This makes use of the centroid distance rather than pairwise. So,

.. math::
Expand Down Expand Up @@ -186,7 +187,7 @@ as understandable and maintainable a weighted average is used (faster, slightly

.. math::
\frac{1}{\Sigma amplitudes} \Sigma amplitudes * y-coords
\frac{1}{\Sigma amplitudes} \sum{amplitudes * depths}
Pipeline Function
Expand Down
2 changes: 1 addition & 1 deletion docs/source/submodules/spike_plotter.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ seaborn features, which have been mostly removed to reduce the dependencies.
Initializing Plotting Classes
-----------------------------

Utilizing matplotlib under the hood allows for some customization. During the intialization of the class
Utilizing :code:`matplotlib`` under the hood allows for some customization. During the intialization of the class
different defaults can be applied using the :code:`kwargs`. These should be a dictionary of standard matplotlib
values, eg, :code:`{"dpi": 300, "figsize": (10,8)}`. The class will warn if the attempted value is not currently
customizable (ie, it is not used internally currently). Defaults are reasonable :code:`x-axis` defaults to :code:`"Time (s)"`
Expand Down

0 comments on commit 1104ebe

Please sign in to comment.