From bafecac53819e02694ee1157aa3700f23c1aaace Mon Sep 17 00:00:00 2001 From: Tom Donoghue Date: Thu, 11 Jun 2026 01:44:19 +0100 Subject: [PATCH 1/9] update references to external papers --- examples/analyses/plot_dev_demo.py | 33 ++++++++++++++------- motivations/measurements/plot_BandRatios.py | 30 +++++++++++-------- 2 files changed, 39 insertions(+), 24 deletions(-) diff --git a/examples/analyses/plot_dev_demo.py b/examples/analyses/plot_dev_demo.py index 6c1246b3..57b52379 100644 --- a/examples/analyses/plot_dev_demo.py +++ b/examples/analyses/plot_dev_demo.py @@ -3,21 +3,33 @@ ======================= An example analysis applied to developmental data, demonstrating best practices. + +This guide is part of a broader project on +'Spectral parameterization for studying neurodevelopment: how and why'. + +.. seealso:: + + Reference for the full project on best-practices for parameterizing developmental data: + + Ostlund B, Donoghue T, Anaya B, Gunther KE, Karalunas SL, Voytek B, Pérez-Edgar KE (2022). + Spectral parameterization for studying neurodevelopment: How and why. + Developmental Cognitive Neuroscience, 54, 101073. + https://doi.org/10.1016/j.dcn.2022.101073 + +For more information, find the full project in the +`journal article `_ and/or the +`Github repository `_. + +If you wish to reference this example or use guidelines from it, +please cite the associated paper. """ ################################################################################################### # Spectral Parameterization for studying neurodevelopment # ------------------------------------------------------- # -# This example is adapted from the -# `Developmental Data Demo `_. -# -# If you wish to reference this example or use guidelines from it, please cite the associated -# paper `Spectral parameterization for studying neurodevelopment: how and why` by -# Brendan Ostlund, Thomas Donoghue, Berenice Anaya, Kelley E Gunther, Sarah L Karalunas, -# Bradley Voytek, and Koraly E Pérez-Edgar. -# -# Paper link: https://doi.org/10.1016/j.dcn.2022.101073 +# This guide provides an overview of best-practice guidelines and considerations for applying +# spectral parameterization to developmental data. # ################################################################################################### @@ -678,6 +690,5 @@ # For more on this topic, see the # `DevelopmentalDemo repository `_ # and/or the -# `associated paper `_ -# for further information. +# `associated paper `_. # diff --git a/motivations/measurements/plot_BandRatios.py b/motivations/measurements/plot_BandRatios.py index da008462..09522a71 100644 --- a/motivations/measurements/plot_BandRatios.py +++ b/motivations/measurements/plot_BandRatios.py @@ -3,6 +3,23 @@ =================== Exploring how band ratio measures relate to periodic & aperiodic activity. + +This example is a brief overview of how band ratios measures relate to periodic and +aperiodic activity, drawing from a full project on this topic. + +.. seealso:: + Reference for the full project on methodological properties of band ratio measures: + + Donoghue T, Dominguez J & Voytek B (2020). Electrophysiological Frequency Band Ratio + Measures Conflate Periodic and Aperiodic Neural Activity. eNeuro, 7(6) + https://doi.org/10.1523/ENEURO.0192-20.2020 + +For more information, find the full project in the +`journal article `_ and/or the +`Github repository `_. + +If you wish to reference this example or use guidelines from it, +please cite the associated paper. """ ################################################################################################### @@ -21,19 +38,6 @@ # spectra as a combination of aperiodic and periodic activity. # -################################################################################################### -# Band Ratios Project -# ~~~~~~~~~~~~~~~~~~~ -# -# This example offers a relatively quick demonstration of how band ratios measures -# relate to periodic and aperiodic activity. -# -# We have completed a full project investigating methodological properties of band -# ratio measures, which is available as a -# `published paper `_ and/or on -# `Github `_. -# - ################################################################################################### # Import numpy and matplotlib From 0ccc761206a2d27be994e1f1895177a08230cb7a Mon Sep 17 00:00:00 2001 From: Tom Donoghue Date: Thu, 11 Jun 2026 01:52:25 +0100 Subject: [PATCH 2/9] initialize clinical example --- examples/analyses/plot_clinical_analyses.py | 62 +++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 examples/analyses/plot_clinical_analyses.py diff --git a/examples/analyses/plot_clinical_analyses.py b/examples/analyses/plot_clinical_analyses.py new file mode 100644 index 00000000..d6d4d026 --- /dev/null +++ b/examples/analyses/plot_clinical_analyses.py @@ -0,0 +1,62 @@ +""" +Clinical Analyses +================= + +An overview of clinically-related analyses using spectral parameterization. + +This overview draws from recommendations from a review on analysis of aperiodic activity +in clinical applications, which also discusses a series of recommendations. + +.. seealso:: + + Reference for the full project on reviewing clinical examinations of aperiodic activity: + + Donoghue T (2025). A systematic review of aperiodic neural activity in + clinical investigations. European Journal of Neuroscience, 62(7), e70255. + https://doi.org/10.1111/ejn.70255 + +For more information, find the full project in the +`journal article `_ and/or the +`Github repository `_. + +If you wish to reference this example or use guidelines from it, +please cite the associated paper. +""" + +################################################################################################### +# Introduction +# ------------ +# +# Words, words, words. +# + +################################################################################################### +# Group-Level Analyses +# -------------------- +# +# + +################################################################################################### +# Evaluating Model Fit Quality +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# + +################################################################################################### +# Visualizing Results +# ~~~~~~~~~~~~~~~~~~~ +# +# + +################################################################################################### +# Checklist of Recommendations +# ---------------------------- +# +# + +################################################################################################### +# Conclusion +# ---------- +# +# Words, words, words. +# From 3ea897bb7b5b5dde5e9e83e2ac116ac77ec4eb55 Mon Sep 17 00:00:00 2001 From: Tom Donoghue Date: Thu, 11 Jun 2026 02:30:36 +0100 Subject: [PATCH 3/9] link in algo visualizer to relevant tutorial --- tutorials/plot_03-Algorithm.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tutorials/plot_03-Algorithm.py b/tutorials/plot_03-Algorithm.py index 102300ab..3dba23df 100644 --- a/tutorials/plot_03-Algorithm.py +++ b/tutorials/plot_03-Algorithm.py @@ -27,6 +27,19 @@ # and goodness of fit metrics are calculated. # +################################################################################################### +# Algorithm Visualizer +# ~~~~~~~~~~~~~~~~~~~~ +# +# Before stepping through the procedure step-by-step in code, we can first examine the fitting +# algorithm in the following visualizer: +# +# .. image:: https://raw.githubusercontent.com/fooof-tools/Visualizers/main/gifs/specparam-algorithm.gif +# :width: 650 px +# :align: center +# :alt: algorithm_visualizer +# + ################################################################################################### # sphinx_gallery_thumbnail_number = 4 From 43133319fe6e787e156534b090f94ff54eea8859 Mon Sep 17 00:00:00 2001 From: Tom Donoghue Date: Thu, 11 Jun 2026 02:30:53 +0100 Subject: [PATCH 4/9] add algo visualizer to viz page --- doc/visualizers.rst | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/doc/visualizers.rst b/doc/visualizers.rst index d4d9f3cf..9c98d9a9 100644 --- a/doc/visualizers.rst +++ b/doc/visualizers.rst @@ -6,6 +6,13 @@ This page includes animated visualizers to explore topics related to spectral pa The source code to create these visualizations is in the `visualizers repository `_. +Fitting Algorithm +----------------- + +Animated visualizer showing the fitting algorithm: + +.. image:: https://raw.githubusercontent.com/fooof-tools/Visualizers/main/gifs/specparam-algorithm.gif + Spectral Rotation ----------------- From f46c9634fa7c1d6e43279f43ce80cfbe6b2257b4 Mon Sep 17 00:00:00 2001 From: Tom Donoghue Date: Thu, 11 Jun 2026 02:36:00 +0100 Subject: [PATCH 5/9] initialize models sub-section of motivations --- doc/conf.py | 3 ++- motivations/models/README.txt | 7 +++++++ 2 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 motivations/models/README.txt diff --git a/doc/conf.py b/doc/conf.py index c5b76fdb..f9b5ffde 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -143,7 +143,8 @@ def setup(app): '../examples/sims', '../examples/analyses', '../motivations/concepts', - '../motivations/measurements']), + '../motivations/measurements', + '../motivations/models']), 'within_subsection_order': FileNameSortKey, 'default_thumb_file': 'img/spectrum.png', 'backreferences_dir': 'generated', # Where to drop linking files between examples & API diff --git a/motivations/models/README.txt b/motivations/models/README.txt new file mode 100644 index 00000000..802da43e --- /dev/null +++ b/motivations/models/README.txt @@ -0,0 +1,7 @@ +Models +------ + +This section examines potential models and/or putative generating principles for neural recordings. + +In particular, it seeks to examine potential generative principles of aperiodic and periodic +components, briefly introducing and discussing potential generators. From 41e40f119d0c9434deeabbbd5305af42af095d18 Mon Sep 17 00:00:00 2001 From: Tom Donoghue Date: Thu, 11 Jun 2026 02:36:13 +0100 Subject: [PATCH 6/9] update motivations readmes --- motivations/README.txt | 11 ++++++----- motivations/concepts/README.txt | 7 +++++-- motivations/measurements/README.txt | 5 +++-- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/motivations/README.txt b/motivations/README.txt index 9f31a8d0..d9305ffc 100644 --- a/motivations/README.txt +++ b/motivations/README.txt @@ -3,14 +3,15 @@ Motivations =========== -This section explores conceptual and methodological ideas that motivate parameterizing neural power spectra. +This section explores motivations for parameterizing neural power spectra. -Using code examples, topics are organized into: +Using code-driven examples, topics are organized into: -- conceptual points about approaches for analyzing neural data and related topics in digital signal processing -- methodological points investigating if and how current approaches may conflate different aspects of the data +- 'concepts' : conceptual points about digital signal processing and analyzing aperiodic and periodic components +- 'measurements' : methodological topics examining if and how measurements may conflate different components of the data +- 'models' : theoretical models and findings relating to way to interpret aperiodic and periodic components -These examples can be explored in any order. +These topics and pages can be explored in any order. .. contents:: Contents :local: diff --git a/motivations/concepts/README.txt b/motivations/concepts/README.txt index 774d0371..fbf4eabc 100644 --- a/motivations/concepts/README.txt +++ b/motivations/concepts/README.txt @@ -1,6 +1,9 @@ Concepts -------- -This section seeks to motivate the idea of conceptualizing neural data as being comprised of both periodic and aperiodic activity. +This section seeks to motivate the conceptualization of neural data as having +periodic and aperiodic components. -In particular, these examples investigate how the notion of different components in neural data relates to practices in digital signal processing, and why this motivates approaches such as parameterizing neural power spectra. \ No newline at end of file +In particular, these examples investigate how the notion of different components in neural data +relates to practices in digital signal processing, and why this motivates approaches such as +parameterizing neural power spectra. diff --git a/motivations/measurements/README.txt b/motivations/measurements/README.txt index f8e39fa9..a93a87b5 100644 --- a/motivations/measurements/README.txt +++ b/motivations/measurements/README.txt @@ -1,6 +1,7 @@ Measurements ------------ -This section compares how existing approaches relate and compare to parameterizing neural power spectra. +This section examines how other measurements relate to applying spectral parameterization. -In particular, these examples investigate how various methods work in the context of conceptualize neural time series as a combination of periodic and aperiodic activity. +In particular, these examples investigate how various methods work in the context of +conceptualize neural time series as a combination of periodic and aperiodic activity. From ba70fcd0db51ee7ab1b002b538acdb7f7da1df8a Mon Sep 17 00:00:00 2001 From: Tom Donoghue Date: Sun, 21 Jun 2026 20:35:25 +0100 Subject: [PATCH 7/9] initialize / outline motivations pages --- motivations/concepts/plot_ColourfulNoises.py | 144 +++++++++++++++ .../concepts/plot_DoYouEvenOscillate.py | 164 ++++++------------ motivations/concepts/plot_WigglyPeaks.py | 8 +- .../plot_PeriodicAperiodicFeatures.py | 4 +- .../measurements/plot_RelativePower.py | 26 +++ motivations/models/plot_DampedOscillations.py | 16 ++ motivations/models/plot_EImodel.py | 16 ++ motivations/models/plot_OtherInfluences?.py | 16 ++ motivations/models/plot_SummedEvents.py | 16 ++ 9 files changed, 290 insertions(+), 120 deletions(-) create mode 100644 motivations/concepts/plot_ColourfulNoises.py create mode 100644 motivations/measurements/plot_RelativePower.py create mode 100644 motivations/models/plot_DampedOscillations.py create mode 100644 motivations/models/plot_EImodel.py create mode 100644 motivations/models/plot_OtherInfluences?.py create mode 100644 motivations/models/plot_SummedEvents.py diff --git a/motivations/concepts/plot_ColourfulNoises.py b/motivations/concepts/plot_ColourfulNoises.py new file mode 100644 index 00000000..63de8f51 --- /dev/null +++ b/motivations/concepts/plot_ColourfulNoises.py @@ -0,0 +1,144 @@ +""" +Aperiodic Activity +================== + +Exploring properties of aperiodic signals, with power across all frequencies. + +This example uses the +`neurodsp `_ +module for time series simulations & analyses. + +... + +colours of noise +synaptic noise +knees / multi-fractals? +""" + +################################################################################################### +# Non-Frequency Specific Power +# ---------------------------- +# +# + + +################################################################################################### + + +################################################################################################### +# Colored Noise Signals +# ~~~~~~~~~~~~~~~~~~~~~ +# +# Let's now look at 'noise' signals. +# +# In the signals below, we will simulate colored noise signals, in which samples are +# drawn randomly from noise distributions, with no rhythmic properties. +# +# As we will see, in the power spectrum, these signals exhibit power at all frequencies, +# with specific patterns of powers across frequencies, which is dependent on the 'color' +# of the noise. +# + +################################################################################################### +# White Noise +# ^^^^^^^^^^^ +# +# A 'white noise' signal is one that is created with uncorrelated samples drawn from +# a random distribution. Since each element of the signal is sampled randomly, +# there is no consistent rhythmic structure in the signal. +# + +################################################################################################### + +# Simulate a white noise time series signal +white_sig = np.random.normal(0, 1, n_points) + +################################################################################################### + +# Plot the white noise time series +plot_time_series(times, white_sig) + +################################################################################################### +# +# As before, we can compute and visualize the power spectrum of this signal. +# + +################################################################################################### + +# Compute the power spectrum of the white noise signal +freqs, powers = compute_spectrum_welch(white_sig, s_rate) + +################################################################################################### + +# Visualize the power spectrum of the white noise signal +plot_power_spectra(freqs, powers) + +################################################################################################### +# +# In the frequency representation, we can see that white noise has a flat power spectrum, +# with equal power across all frequencies. This is the definition of white noise. +# +# This is similar to the delta function, though note that in this case the power across +# frequencies is representing continuous aperiodic activity, rather than a single transient. +# + +################################################################################################### +# Pink Noise +# ^^^^^^^^^^ +# +# Other 'colors' of noise refer to different patterns of power distributions +# in the power spectrum. +# +# For example, pink noise is a signal where power systematically decreases across +# frequencies in the power spectrum. +# + +################################################################################################### + +# Simulate a pink noise signal +pink_sig = sim_powerlaw(n_seconds, s_rate, exponent=-1) + +################################################################################################### + +# Plot the pink noise time series +plot_time_series(times, pink_sig) + +################################################################################################### + +# Compute the power spectrum of the pink noise signal +freqs, powers = compute_spectrum_welch(pink_sig, s_rate) + +################################################################################################### + +# Visualize the power spectrum of the pink noise signal +plot_power_spectra(freqs, powers) + +################################################################################################### +# Section Conclusion +# ^^^^^^^^^^^^^^^^^^ +# +# The 'colored noise' signals above are simulated signals with no rhythmic properties, +# in the sense that there are no characteristic frequencies or visible rhythms in the data. +# +# Nevertheless, and by definition, in the power spectra of such signals, there is power across +# all frequencies, with some pattern of power across frequencies. +# +# However, there are no frequencies at which power is different from expected from an +# aperiodic noise signal. These signals are statistically, by definition, aperiodic. +# + + + +################################################################################################### + + + +################################################################################################### + + + +################################################################################################### + + + +################################################################################################### \ No newline at end of file diff --git a/motivations/concepts/plot_DoYouEvenOscillate.py b/motivations/concepts/plot_DoYouEvenOscillate.py index 1af5963f..1897510d 100644 --- a/motivations/concepts/plot_DoYouEvenOscillate.py +++ b/motivations/concepts/plot_DoYouEvenOscillate.py @@ -1,8 +1,8 @@ """ -Rhythmicity of Time Series -========================== +Spectral Representations +======================== -Exploring the rhythmicity of time series and their frequency representations. +Exploring properties of time series and their corresponding frequency domain representations. This example uses the `neurodsp `_ @@ -10,16 +10,16 @@ """ ################################################################################################### -# Rhythmicity of Time Series -# -------------------------- +# Frequency Domain Representations +# -------------------------------- # -# Central to the motivation for parameterizing neural power is the claim that power at a +# Central to the motivation for parameterizing power spectra is the claim that power at a # given frequency is not sufficient to claim that there is evidence for rhythmic, or # periodic, activity at that frequency. # -# In this example, we will explore this idea by examining some example signals in the -# time domain, and their frequency domain representations. We will use these signals to -# motivate if and when signals should be interpreted as containing periodic activity. +# This example explores and seeks to motivate this idea, by examining the relationship between +# time domain signals and their frequency domain representations, with the goal of examining +# how we can move between different representations and what this means for interpreting signals. # ################################################################################################### @@ -29,16 +29,15 @@ # Stated informally, the Fourier theorem tells us that any time series can be represented # as a sum of sinusoids. # -# This is a powerful and useful theorem, as it means that we can use tools such as the -# Fourier transform and other similar measures, to compute frequency representations -# of any time series data. +# This is a powerful idea, as it means that we can use tools such as the Fourier transform and +# other similar measures, to compute frequency representations of *any* time series. # -# However, just because a signal can be represented by sinusoids does not mean that any -# given signal, or any given aspect of a signal, for which a power spectrum can be computed -# should be conceptualized as being comprised of rhythmic components. +# However, just because a signal can be *represented* by sinusoids does not mean that the +# signal should be *interpreted* in terms of sine waves. # -# The power spectrum is just a possible representation of the original data, not a -# descriptive claim of the actual components of the data. +# Alternately stated, a frequency domain representation by itself does not mean we can or +# should conceptualize a time series as being comprised of rhythmic activity - it provides +# a possible representation of the data, not a claim for the actual components of the data. # ################################################################################################### @@ -70,18 +69,19 @@ n_points = len(times) ################################################################################################### -# Frequency Representations of Aperiodic Signals -# ---------------------------------------------- +# Frequency Representations of a Transient Signal +# ----------------------------------------------- # -# Let's start with aperiodic signals, and examine how different types of aperiodic -# signals are represented in the frequency domain. +# To examine this idea - that we can represent any signal as a power spectrum, but this does +# not mean that we should interpret them as sine waves per se - we can start with some simple +# signals with transients. # ################################################################################################### # The Dirac Delta # ~~~~~~~~~~~~~~~ # -# The Dirac delta is arguably the simplest signal, as it's a signal of all zeros, +# The Dirac delta is arguably the simplest signal: a signal of all 0s, # except for a single value of 1. # @@ -98,7 +98,7 @@ ################################################################################################### # -# Next, lets compute the frequency representation of the delta function. +# Next, lets compute the frequency domain representation of the Dirac delta. # ################################################################################################### @@ -115,105 +115,53 @@ # Section Conclusions # ^^^^^^^^^^^^^^^^^^^ # -# As we can see above, the power spectrum of the Dirac delta function has -# power across all frequencies. -# -# This is despite it containing containing a single non-zero value, and thus having -# no rhythmic properties to it in the time domain. -# -# The Dirac delta example can be taken as a proof of principle that observing power -# at a particular frequency does not necessarily imply that one should consider that -# there are any rhythmic properties at that frequency in the original time series. -# -# In this case, and many like it, power across all frequencies is a representation of -# transient (or aperiodic) activity in the time series. Broadly, when there are transients, -# or aperiodic components, lots of sinusoids have to be added together in order to represent -# aperiodic activity out of a basis set of periodic sine waves, and this is why such -# signals typically look very broadband in the frequency domain. -# - -################################################################################################### -# Colored Noise Signals -# ~~~~~~~~~~~~~~~~~~~~~ -# -# Let's now look at 'noise' signals. +# As we can see above, the power spectrum of the Dirac delta function has power +# across all frequencies! # -# In the signals below, we will simulate colored noise signals, in which samples are -# drawn randomly from noise distributions, with no rhythmic properties. +# This is despite it containing a single non-zero value, and thus having no rhythmic +# properties in the time domain. # -# As we will see, in the power spectrum, these signals exhibit power at all frequencies, -# with specific patterns of powers across frequencies, which is dependent on the 'color' -# of the noise. +# The Dirac delta example serves as a proof-of-principle that observing power at a particular +# frequency does not necessarily imply that one should consider that there are any rhythmic +# properties at that frequency in the original time series. # +# In this case, the power we see across all frequencies is a representation of transient activity +# in the time series. When there are transients (or as we will see next, aperiodic activity more +# generally) the signal can still be represented in the frequency domain as a combination of +# sine waves. However, in order to represent aperiodic activity from a basis set of periodic sine +# waves, lots of sinusoids have to be added together, giving -################################################################################################### -# White Noise -# ^^^^^^^^^^^ -# -# A 'white noise' signal is one that is created with uncorrelated samples drawn from -# a random distribution. Since each element of the signal is sampled randomly, -# there is no consistent rhythmic structure in the signal. -# - -################################################################################################### - -# Simulate a white noise time series signal -white_sig = np.random.normal(0, 1, n_points) - -################################################################################################### +# signals typically look very broadband in the frequency domain. -# Plot the white noise time series -plot_time_series(times, white_sig) +# or aperiodic components, -################################################################################################### # -# As before, we can compute and visualize the power spectrum of this signal. +# Notably # -################################################################################################### - -# Compute the power spectrum of the white noise signal -freqs, powers = compute_spectrum_welch(white_sig, s_rate) ################################################################################################### - -# Visualize the power spectrum of the white noise signal -plot_power_spectra(freqs, powers) - -################################################################################################### -# -# In the frequency representation, we can see that white noise has a flat power spectrum, -# with equal power across all frequencies. This is the definition of white noise. -# -# This is similar to the delta function, though note that in this case the power across -# frequencies is representing continuous aperiodic activity, rather than a single transient. -# - -################################################################################################### -# Pink Noise -# ^^^^^^^^^^ -# -# Other 'colors' of noise refer to different patterns of power distributions -# in the power spectrum. +# Frequency Representations of Aperiodic Signals +# --------------------------------------------- # -# For example, pink noise is a signal where power systematically decreases across -# frequencies in the power spectrum. +# Let's start with aperiodic signals, and examine how different types of aperiodic +# signals are represented in the frequency domain. # ################################################################################################### -# Simulate a pink noise signal -pink_sig = sim_powerlaw(n_seconds, s_rate, exponent=-1) +# Simulate an aperiodic signal +aperiodic_sig = sim_powerlaw(n_seconds, s_rate, exponent=-1) ################################################################################################### -# Plot the pink noise time series -plot_time_series(times, pink_sig) +# Plot the aperiodic time series +plot_time_series(times, aperiodic_sig) ################################################################################################### -# Compute the power spectrum of the pink noise signal -freqs, powers = compute_spectrum_welch(pink_sig, s_rate) +# Compute the power spectrum of the aperiodic signal +freqs, powers = compute_spectrum_welch(aperiodic_sig, s_rate) ################################################################################################### @@ -221,21 +169,7 @@ plot_power_spectra(freqs, powers) ################################################################################################### -# Section Conclusion -# ^^^^^^^^^^^^^^^^^^ -# -# The 'colored noise' signals above are simulated signals with no rhythmic properties, -# in the sense that there are no characteristic frequencies or visible rhythms in the data. -# -# Nevertheless, and by definition, in the power spectra of such signals, there is power across -# all frequencies, with some pattern of power across frequencies. -# -# However, there are no frequencies at which power is different from expected from an -# aperiodic noise signal. These signals are statistically, by definition, aperiodic. -# - -################################################################################################### -# Frequency Representations of Rhythmic Signals +# Frequency Representations of Periodic Signals # --------------------------------------------- # # Next, lets check what frequency representations look like for time series that do have diff --git a/motivations/concepts/plot_WigglyPeaks.py b/motivations/concepts/plot_WigglyPeaks.py index 37d29f3c..a6003944 100644 --- a/motivations/concepts/plot_WigglyPeaks.py +++ b/motivations/concepts/plot_WigglyPeaks.py @@ -11,7 +11,7 @@ ################################################################################################### -# Imports from NeuroDSP to simulate & plot time series +# Imports from neurodsp to simulate & plot time series from neurodsp.sim import sim_powerlaw, sim_oscillation, sim_combined, set_random_seed from neurodsp.spectral import compute_spectrum from neurodsp.plts import plot_time_series, plot_power_spectra @@ -32,8 +32,10 @@ # # Part of the motivation behind spectral parameterization is dissociating aperiodic # activity, with no characteristic frequency, to periodic power, which is defined as -# having frequency specific power. This leads to the idea of oscillations as 'peaks' -# of power in the power spectrum, which can be detected and measured. +# having frequency specific power. +# +# This leads to the idea of oscillations as 'peaks' of power in the power spectrum, +# which can be detected and measured. # # In this exploration, we will use simulated time series to examine how rhythmic signals # do display as 'peaks' of power in frequency domain representations. We will also diff --git a/motivations/measurements/plot_PeriodicAperiodicFeatures.py b/motivations/measurements/plot_PeriodicAperiodicFeatures.py index 1e01252b..b88d19f4 100644 --- a/motivations/measurements/plot_PeriodicAperiodicFeatures.py +++ b/motivations/measurements/plot_PeriodicAperiodicFeatures.py @@ -5,8 +5,8 @@ Demonstrating how changes in periodic & aperiodic parameters can be conflated. This example is a code implementation and quantitatively exact version of Figure 1 from the -`Parameterizing Neural Power Spectra `_ -paper. +`Parameterizing neural power spectra into periodic and aperiodic component +`_ paper. """ ################################################################################################### diff --git a/motivations/measurements/plot_RelativePower.py b/motivations/measurements/plot_RelativePower.py new file mode 100644 index 00000000..4ff80dc3 --- /dev/null +++ b/motivations/measurements/plot_RelativePower.py @@ -0,0 +1,26 @@ +""" +Relative & Absolute Measures +============================ + +And normalization measures + +""" + + +################################################################################################### + + + +################################################################################################### + + + +################################################################################################### + + + +################################################################################################### + + + +################################################################################################### \ No newline at end of file diff --git a/motivations/models/plot_DampedOscillations.py b/motivations/models/plot_DampedOscillations.py new file mode 100644 index 00000000..2aee2619 --- /dev/null +++ b/motivations/models/plot_DampedOscillations.py @@ -0,0 +1,16 @@ +""" +TITLE +===== + +""" + +################################################################################################### +# SUB-TITLE +# --------- +# + + +################################################################################################### + + +################################################################################################### \ No newline at end of file diff --git a/motivations/models/plot_EImodel.py b/motivations/models/plot_EImodel.py new file mode 100644 index 00000000..2aee2619 --- /dev/null +++ b/motivations/models/plot_EImodel.py @@ -0,0 +1,16 @@ +""" +TITLE +===== + +""" + +################################################################################################### +# SUB-TITLE +# --------- +# + + +################################################################################################### + + +################################################################################################### \ No newline at end of file diff --git a/motivations/models/plot_OtherInfluences?.py b/motivations/models/plot_OtherInfluences?.py new file mode 100644 index 00000000..2aee2619 --- /dev/null +++ b/motivations/models/plot_OtherInfluences?.py @@ -0,0 +1,16 @@ +""" +TITLE +===== + +""" + +################################################################################################### +# SUB-TITLE +# --------- +# + + +################################################################################################### + + +################################################################################################### \ No newline at end of file diff --git a/motivations/models/plot_SummedEvents.py b/motivations/models/plot_SummedEvents.py new file mode 100644 index 00000000..2aee2619 --- /dev/null +++ b/motivations/models/plot_SummedEvents.py @@ -0,0 +1,16 @@ +""" +TITLE +===== + +""" + +################################################################################################### +# SUB-TITLE +# --------- +# + + +################################################################################################### + + +################################################################################################### \ No newline at end of file From 84a7639c3d3e843ced8b00a5a9bbadf8cacf30d3 Mon Sep 17 00:00:00 2001 From: Tom Donoghue Date: Tue, 23 Jun 2026 15:46:46 +0100 Subject: [PATCH 8/9] sketch out damped osc model motiv --- motivations/models/plot_DampedOscillations.py | 181 +++++++++++++++++- 1 file changed, 176 insertions(+), 5 deletions(-) diff --git a/motivations/models/plot_DampedOscillations.py b/motivations/models/plot_DampedOscillations.py index 2aee2619..a7fcd152 100644 --- a/motivations/models/plot_DampedOscillations.py +++ b/motivations/models/plot_DampedOscillations.py @@ -1,16 +1,187 @@ """ -TITLE -===== +Damped & Modulated Oscillations +=============================== + +Words, words, words. """ +# Import spectral model object & plot function +from specparam import SpectralModel +from specparam.plts import plot_spectra + +# Import time domain simulation function for damped oscillations +from neurodsp.sim.periodic import sim_damped_oscillation + +# Import time domain simulation function for modulated signals +from neurodsp.sim.combined import sim_modulated_signal + +# Import neurodsp functionality of computer power spectra & plotting +from neurodsp.utils import create_times +from neurodsp.spectral import compute_spectrum_welch +from neurodsp.plts.spectral import plot_power_spectra +from neurodsp.plts.time_series import plot_time_series, plot_multi_time_series + +################################################################################################### + +# General simulation parameters +n_seconds = 10 +fs = 250 +freq = 25 +exp = -1.5 + +# Damping settings +damp_coef = 1 + +# Define fitting frequency range +freq_range = [2, 75] + +################################################################################################### +# Damped Oscillations +# ------------------- +# +# Words, words, words +# + +################################################################################################### + +# Create a times vector for the time series +times = create_times(n_seconds, fs) + +################################################################################################### + +# Simulate a damped oscillation +d_osc = sim_damped_oscillation(n_seconds, fs, freq, damp_coef) + +################################################################################################### + +# .. +plot_time_series(times, d_osc, xlim=[0, 3]) + +################################################################################################### + +# ... +freqs, powers_dosc = compute_spectrum_welch(d_osc, fs) + +################################################################################################### + +# ... +fm = SpectralModel(aperiodic_mode='fixed', verbose=False) + +################################################################################################### + +# ... +fm.add_data(freqs_dosc, powers_dosc, freq_range) +fm.plot() + +################################################################################################### + +# ... +fm.report() + +################################################################################################### +# XXXX +# ---- +# +# + +################################################################################################### + +# ... +damp_coefs = [0.1, 1, 10] + +################################################################################################### + +damped_sigs = [] +damped_powers = [] +for d_coef in damp_coefs: + + # ... + csig = sim_damped_oscillation(n_seconds, fs, freq, d_coef) + cfreqs, cpowers = compute_spectrum_welch(csig, fs) + + # ... + damped_sigs.append(csig) + damped_powers.append(cpowers) + +################################################################################################### + +# ... +plot_multi_time_series(times, damped_sigs, xlim=[0, 3]) + +################################################################################################### + +plot_spectra(freqs, damped_powers, log_powers=True) + +################################################################################################### + +for damping, cpowers in zip(damp_coefs, damped_powers): + fm.fit(freqs, cpowers, freq_range) + print('Damping co-efficient: {:4.1f} - aperiodic exponent: {:1.2f}'.format(\ + damping, fm.results.get_params('aperiodic', 'exponent'))) + +################################################################################################### +# +# Words, words, words. +# + +################################################################################################### +# Modulated Oscillators +# --------------------- +# +# + +################################################################################################### + +# Simulate another modulated signal +m_osc = sim_modulated_signal(n_seconds, fs, + 'sim_oscillation', {'freq' : freq}, + 'sim_powerlaw', {'exponent' : exp}) + +################################################################################################### + +# ... +plot_time_series(times, msig) + +################################################################################################### + +# ... +freqs, powers_mosc = compute_spectrum_welch(m_osc, fs) + +################################################################################################### + +# ... +fm.add_data(freqs_dosc, powers_mosc, freq_range) +fm.plot() + +################################################################################################### + +# ... +fm.report() + ################################################################################################### -# SUB-TITLE -# --------- +# +# Words, words, words. # +################################################################################################### + +# Simulate a modulated signal, passing in instruction for the main and modulating signal +m_osc2 = sim_modulated_signal(n_seconds, fs, + 'sim_oscillation', {'freq' : 1}, + 'sim_oscillation', {'freq' : 10}) ################################################################################################### +# ... +plot_time_series(times, m_osc2) -################################################################################################### \ No newline at end of file +################################################################################################### + +# ... +fm.report(*compute_spectrum_welch(m_osc2, fs)) + +################################################################################################### +# +# Words, words, words. +# From b2305b8818d1a96f5e1d62752cf46b62b02ba083 Mon Sep 17 00:00:00 2001 From: Tom Donoghue Date: Wed, 24 Jun 2026 00:13:49 +0100 Subject: [PATCH 9/9] interim start to motivs --- motivations/concepts/plot_ColourfulNoises.py | 22 ++++++------- motivations/models/plot_EImodel.py | 33 ++++++++++++++++++-- motivations/models/plot_OtherInfluences?.py | 6 ++-- motivations/models/plot_SummedEvents.py | 6 ++-- 4 files changed, 50 insertions(+), 17 deletions(-) diff --git a/motivations/concepts/plot_ColourfulNoises.py b/motivations/concepts/plot_ColourfulNoises.py index 63de8f51..08e5f789 100644 --- a/motivations/concepts/plot_ColourfulNoises.py +++ b/motivations/concepts/plot_ColourfulNoises.py @@ -7,23 +7,26 @@ This example uses the `neurodsp `_ module for time series simulations & analyses. - -... - -colours of noise -synaptic noise -knees / multi-fractals? """ ################################################################################################### # Non-Frequency Specific Power # ---------------------------- # +# colours of noise +# synaptic noise +# knees / multi-fractals? # - ################################################################################################### +# Import numpy +import numpy as np + +# ... +from neurodsp.plts import plot_time_series +from neurodsp.spectral import compute_spectrum_welch +from neurodsp.sim import sim_powerlaw, set_random_seed ################################################################################################### # Colored Noise Signals @@ -132,13 +135,10 @@ ################################################################################################### - ################################################################################################### - ################################################################################################### - -################################################################################################### \ No newline at end of file +################################################################################################### diff --git a/motivations/models/plot_EImodel.py b/motivations/models/plot_EImodel.py index 2aee2619..eb003a81 100644 --- a/motivations/models/plot_EImodel.py +++ b/motivations/models/plot_EImodel.py @@ -1,6 +1,8 @@ """ -TITLE -===== +E/I Model of Aperiodic Activity +=============================== + +Words, words, words. """ @@ -10,6 +12,33 @@ # +################################################################################################### + +# Simulation settings +n_seconds = None +fs = None + +################################################################################################### + +# Simulate aperiodic activity from the synaptic kernel model +syn_ap = sim_synaptic_current(n_seconds, fs) + +################################################################################################### + +# Plot the simulated data, in the time domain +plot_time_series(times, syn_ap, title='Simulated Synaptic Activity') + +################################################################################################### + +# ... +freqs, syn_psd = compute_spectrum(syn_ap, fs) + +################################################################################################### + + +################################################################################################### + + ################################################################################################### diff --git a/motivations/models/plot_OtherInfluences?.py b/motivations/models/plot_OtherInfluences?.py index 2aee2619..1142b9e1 100644 --- a/motivations/models/plot_OtherInfluences?.py +++ b/motivations/models/plot_OtherInfluences?.py @@ -1,6 +1,8 @@ """ -TITLE -===== +Other Influences (?) +==================== + +Words, words, words. """ diff --git a/motivations/models/plot_SummedEvents.py b/motivations/models/plot_SummedEvents.py index 2aee2619..090cb9e3 100644 --- a/motivations/models/plot_SummedEvents.py +++ b/motivations/models/plot_SummedEvents.py @@ -1,6 +1,8 @@ """ -TITLE -===== +Summed Events (?) +================= + +Words, words, words. """