Skip to content

Commit

Permalink
aperiodic exponent
Browse files Browse the repository at this point in the history
  • Loading branch information
Mark-Kramer committed Dec 5, 2024
1 parent 0948dba commit d0f4cb8
Show file tree
Hide file tree
Showing 31 changed files with 927 additions and 30 deletions.
Binary file modified .DS_Store
Binary file not shown.
142 changes: 142 additions & 0 deletions Aperiodic_Exponent_Lab.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
{
"cells": [
{
"cell_type": "markdown",
"id": "4df4e957-7ea5-4b20-891a-d2f4cad354a4",
"metadata": {},
"source": [
"---\n",
"title: Aperiodic exponent example\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": "markdown",
"id": "22374a1b-dcae-472b-8d44-68f803e630eb",
"metadata": {},
"source": [
"Let's try this [example code](https://fooof-tools.github.io/fooof/auto_tutorials/plot_01-ModelDescription.html#sphx-glr-auto-tutorials-plot-01-modeldescription-py)."
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "29838749-1da3-467c-9868-cd8afb3e1dba",
"metadata": {},
"outputs": [],
"source": [
"# Import required code for visualizing example models\n",
"from fooof import FOOOF\n",
"from fooof.sim.gen import gen_power_spectrum\n",
"from fooof.sim.utils import set_random_seed\n",
"from fooof.plts.spectra import plot_spectra\n",
"from fooof.plts.annotate import plot_annotated_model"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "27503282-4a90-452e-944e-892a6d41c60e",
"metadata": {},
"outputs": [],
"source": [
"# Set random seed, for consistency generating simulated data\n",
"set_random_seed(21)\n",
"\n",
"# Simulate example power spectra\n",
"freqs1, powers1 = gen_power_spectrum([3, 40], [1, 1],\n",
" [[10, 0.2, 1.25], [30, 0.15, 2]])\n",
"freqs2, powers2 = gen_power_spectrum([1, 150], [1, 125, 1.25],\n",
" [[8, 0.15, 1.], [30, 0.1, 2]])"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "f9cdff44-e207-4e35-b978-a3703d89342f",
"metadata": {},
"outputs": [],
"source": [
"# Initialize power spectrum model objects and fit the power spectra\n",
"fm1 = FOOOF(min_peak_height=0.05, verbose=False)\n",
"fm2 = FOOOF(min_peak_height=0.05, aperiodic_mode='knee', verbose=False)\n",
"fm1.fit(freqs1, powers1)\n",
"fm2.fit(freqs2, powers2)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "63424cc3-a85f-499d-8f32-412379f358bf",
"metadata": {},
"outputs": [],
"source": [
"# Plot one of the example power spectra\n",
"plot_spectra(freqs1, powers1, log_powers=True,\n",
" color='black', label='Original Spectrum')"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "a249c27a-e396-413f-b6ed-29ae2a96a886",
"metadata": {},
"outputs": [],
"source": [
"# Plot an example power spectrum, with a model fit\n",
"fm1.plot(plot_peaks='shade', peak_kwargs={'color' : 'green'})"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "2e0a0d99-aaae-4726-ba22-8e134ba70144",
"metadata": {},
"outputs": [],
"source": [
"# Plot an annotated version of the power spectrum model\n",
"plot_annotated_model(fm1, annotate_aperiodic=False)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "f29075fa-285b-425f-923d-d3d9c0b735c9",
"metadata": {},
"outputs": [],
"source": [
"# Report: fit the model, print the resulting parameters, and plot the reconstruction\n",
"fm1.report()"
]
}
],
"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": 5
}
Binary file added Readings/Donoghue_2020.pdf
Binary file not shown.
Binary file added Readings/Gao_2017.pdf
Binary file not shown.
Binary file added Readings/Kramer_2024.pdf
Binary file not shown.
Binary file added _extensions/.DS_Store
Binary file not shown.
2 changes: 1 addition & 1 deletion docs/Analyzing_Rhythms_Lab_1.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"><head>

<meta charset="utf-8">
<meta name="generator" content="quarto-1.5.56">
<meta name="generator" content="quarto-1.5.57">

<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes">

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 @@ -2,7 +2,7 @@
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"><head>

<meta charset="utf-8">
<meta name="generator" content="quarto-1.5.56">
<meta name="generator" content="quarto-1.5.57">

<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes">

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 @@ -2,7 +2,7 @@
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"><head>

<meta charset="utf-8">
<meta name="generator" content="quarto-1.5.56">
<meta name="generator" content="quarto-1.5.57">

<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes">

Expand Down
2 changes: 1 addition & 1 deletion docs/Analyzing_Rhythms_Lab_3.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"><head>

<meta charset="utf-8">
<meta name="generator" content="quarto-1.5.56">
<meta name="generator" content="quarto-1.5.57">

<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes">

Expand Down
Loading

0 comments on commit d0f4cb8

Please sign in to comment.