From 2a37d5aa0613f28c63570bb380ea1a1b1561b357 Mon Sep 17 00:00:00 2001 From: Zach McKenzie <92116279+zm711@users.noreply.github.com> Date: Tue, 22 Aug 2023 18:11:56 -0400 Subject: [PATCH 1/5] test update docs --- docs/source/API.rst | 1 - 1 file changed, 1 deletion(-) diff --git a/docs/source/API.rst b/docs/source/API.rst index aba658f..6205bfa 100644 --- a/docs/source/API.rst +++ b/docs/source/API.rst @@ -18,4 +18,3 @@ spikeanalysis :members: .. autoclass:: AnalogAnalysis :members: - .. autofunction:: kolmo_smir_stats \ No newline at end of file From c8f91b262610d3e814ffffd9be1803e3f6fe9e09 Mon Sep 17 00:00:00 2001 From: zm711 <92116279+zm711@users.noreply.github.com> Date: Tue, 22 Aug 2023 18:21:57 -0400 Subject: [PATCH 2/5] another doc test --- docs/source/API.rst | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/docs/source/API.rst b/docs/source/API.rst index 6205bfa..6483eda 100644 --- a/docs/source/API.rst +++ b/docs/source/API.rst @@ -8,13 +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 From 8506fba12011797286948e84224b7c680573aef4 Mon Sep 17 00:00:00 2001 From: zm711 <92116279+zm711@users.noreply.github.com> Date: Tue, 22 Aug 2023 18:28:47 -0400 Subject: [PATCH 3/5] try adding to requirements --- requirements.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/requirements.txt b/requirements.txt index 5bc1869..90c2c6a 100644 --- a/requirements.txt +++ b/requirements.txt @@ -4,3 +4,4 @@ matplotlib numba seaborn pandas +spikeanalysis @ git+https://github.com/zm711/spikeanalysis@main \ No newline at end of file From a74a026ec0012b04de45ea20fc889bb314033041 Mon Sep 17 00:00:00 2001 From: zm711 <92116279+zm711@users.noreply.github.com> Date: Tue, 22 Aug 2023 18:35:13 -0400 Subject: [PATCH 4/5] changes the correct requirements --- docs/requirements.txt | 7 +++++++ requirements.txt | 1 - 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/docs/requirements.txt b/docs/requirements.txt index 15097f1..bd8aad4 100644 --- a/docs/requirements.txt +++ b/docs/requirements.txt @@ -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 diff --git a/requirements.txt b/requirements.txt index 90c2c6a..5bc1869 100644 --- a/requirements.txt +++ b/requirements.txt @@ -4,4 +4,3 @@ matplotlib numba seaborn pandas -spikeanalysis @ git+https://github.com/zm711/spikeanalysis@main \ No newline at end of file From eee79b1241a0f42a09907557af244adb7435a514 Mon Sep 17 00:00:00 2001 From: zm711 <92116279+zm711@users.noreply.github.com> Date: Tue, 22 Aug 2023 18:48:12 -0400 Subject: [PATCH 5/5] fix docs typos --- docs/source/submodules/intrinsic_plotter.rst | 8 ++++---- docs/source/submodules/spike_analysis.rst | 15 ++++++++------- docs/source/submodules/spike_data.rst | 9 +++++---- docs/source/submodules/spike_plotter.rst | 2 +- 4 files changed, 18 insertions(+), 16 deletions(-) diff --git a/docs/source/submodules/intrinsic_plotter.rst b/docs/source/submodules/intrinsic_plotter.rst index 63a9d1c..a372280 100644 --- a/docs/source/submodules/intrinsic_plotter.rst +++ b/docs/source/submodules/intrinsic_plotter.rst @@ -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 @@ -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 @@ -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 diff --git a/docs/source/submodules/spike_analysis.rst b/docs/source/submodules/spike_analysis.rst index 978e3b4..5f603c5 100644 --- a/docs/source/submodules/spike_analysis.rst +++ b/docs/source/submodules/spike_analysis.rst @@ -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. @@ -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:: @@ -121,9 +121,9 @@ 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. @@ -131,8 +131,8 @@ Note :math:`\lambda` * :math:`t_n` gives us the :math:`\mu` from the standard Po 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. @@ -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 diff --git a/docs/source/submodules/spike_data.rst b/docs/source/submodules/spike_data.rst index 9803306..dfae651 100644 --- a/docs/source/submodules/spike_data.rst +++ b/docs/source/submodules/spike_data.rst @@ -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 @@ -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:: @@ -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:: @@ -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 diff --git a/docs/source/submodules/spike_plotter.rst b/docs/source/submodules/spike_plotter.rst index 002fd2b..e02ccaf 100644 --- a/docs/source/submodules/spike_plotter.rst +++ b/docs/source/submodules/spike_plotter.rst @@ -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)"`