-
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
0948dba
commit d0f4cb8
Showing
31 changed files
with
927 additions
and
30 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
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 not shown.
Binary file not shown.
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.