-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b37a33d
commit ee70fe2
Showing
19 changed files
with
996 additions
and
75 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -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 not shown.
Binary file not shown.
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
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
Oops, something went wrong.