Skip to content

Commit

Permalink
+ spike spectra
Browse files Browse the repository at this point in the history
  • Loading branch information
Mark-Kramer committed Oct 29, 2024
1 parent b37a33d commit ee70fe2
Show file tree
Hide file tree
Showing 19 changed files with 996 additions and 75 deletions.
2 changes: 1 addition & 1 deletion Analyzing_Rhythms_Lab_2b.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.18"
"version": "3.12.4"
}
},
"nbformat": 4,
Expand Down
177 changes: 177 additions & 0 deletions Analyzing_Rhythms_Lab_3.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,177 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"---\n",
"title: Analyzing Rhythms Part 3 (Spectra of spike trains)\n",
"project:\n",
" type: website\n",
"format:\n",
" html:\n",
" code-fold: false\n",
" code-tools: true\n",
"jupyter: python 3\n",
"number-sections: false\n",
"---"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Load modules we'll need.\n",
"import numpy as np\n",
"import matplotlib.pyplot as plt"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Example: a randomly spiking neuron"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"To start, let's create a fake spike train for a randomly spiking neuron, and compute the autocovariance and spectrum."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"N = 5000; # Number of bins. \n",
"dt = 0.001; # Duration of each bin [s].\n",
"T = N*dt; # Total time of observation [s].\n",
"tm = np.arange(0,N)*dt; # Time axis for plotting\n",
"\n",
"lambda0 = 5 # Average firing rate [Hz]\n",
"p0 = lambda0*dt; # Probability of a spike in a time bin\n",
"dn = np.random.binomial(1,p0,N)# Create the spike train as \"coin flips\"\n",
"\n",
"plt.plot(tm, dn) # Plot it.\n",
"plt.xlabel('Time [s]');"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Compute the autocovariance."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Compute the spectrum."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Repeat the entire simulation many times, and plot the average spectrum"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Example: a randomly spiking neuron + refractory period"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Now, let's create a fake spike train for a randomly spiking neuron with a refractory period, and compute the autocovariance and spectrum."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"N = 5000; # Number of bins. \n",
"dt = 0.001; # Duration of each bin [s].\n",
"T = N*dt; # Total time of observation [s].\n",
"tm = np.arange(0,N)*dt; # Time axis for plotting\n",
"\n",
"lambda0 = 5 # Average firing rate [Hz]\n",
"p0 = lambda0*dt; # Probability of a spike in a time bin\n",
"dn = np.random.binomial(1,p0,N)# Create the spike train as \"coin flips\"\n",
"\n",
"???????????????????????????????\n",
"??? ADD A REFRACTORY PERIOD ???\n",
"???????????????????????????????\n",
"\n",
"plt.plot(tm, dn) # Plot it.\n",
"plt.xlabel('Time [s]');"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Compute the autocovariance."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Compute the spectrum."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Repeat the entire simulation many times, and plot the average spectrum"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.12.4"
}
},
"nbformat": 4,
"nbformat_minor": 4
}
Binary file modified Slides/Analyzing_Rhythms_Lecture_2.pdf
Binary file not shown.
Binary file added Slides/Analyzing_Rhythms_Lecture_3.pdf
Binary file not shown.
3 changes: 1 addition & 2 deletions _quarto.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ website:
- href: Regression.html
text: Regression
- href: Rhythms_1.html
text: Rhythms 1

text: Rhythms Intro

format:
html:
Expand Down
2 changes: 1 addition & 1 deletion docs/Analyzing_Rhythms_Lab_1.html
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@
</li>
<li class="nav-item">
<a class="nav-link" href="./Rhythms_1.html">
<span class="menu-text">Rhythms 1</span></a>
<span class="menu-text">Rhythms Intro</span></a>
</li>
</ul>
</div> <!-- /navcollapse -->
Expand Down
2 changes: 1 addition & 1 deletion docs/Analyzing_Rhythms_Lab_2a.html
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@
</li>
<li class="nav-item">
<a class="nav-link" href="./Rhythms_1.html">
<span class="menu-text">Rhythms 1</span></a>
<span class="menu-text">Rhythms Intro</span></a>
</li>
</ul>
</div> <!-- /navcollapse -->
Expand Down
2 changes: 1 addition & 1 deletion docs/Analyzing_Rhythms_Lab_2b.html
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@
</li>
<li class="nav-item">
<a class="nav-link" href="./Rhythms_1.html">
<span class="menu-text">Rhythms 1</span></a>
<span class="menu-text">Rhythms Intro</span></a>
</li>
</ul>
</div> <!-- /navcollapse -->
Expand Down
Loading

0 comments on commit ee70fe2

Please sign in to comment.