Skip to content

Commit

Permalink
Update motivations
Browse files Browse the repository at this point in the history
  • Loading branch information
TomDonoghue committed Jan 19, 2020
1 parent 78db6f3 commit 0875c46
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 18 deletions.
66 changes: 55 additions & 11 deletions motivations/plot_BandRatios.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,36 @@
Band Ratio Measures
===================
Showing why band ratio measures are bad.
Exploring band ratio measures in the context of the FOOOF model.
"""

###################################################################################################
#
# Band ratios measures are a
# Band Ratios Project
# -------------------
#
# In this notebook
# Note: this example is quick demonstration of how band ratios measures relate
# to periodic and aperiodic activity.
#
# This topic is the
# This topic has been the topic of a full research project, available
# `here <https://github.com/voytekresearch/BandRatios>`_,
#

###################################################################################################
#
# Introduction
# ------------
#
# Band ratios measures are a relatively common measure, proposed to measure oscillatory,
# or periodic, activity.
#
# They are typically calculated as:
#
# .. math::
# BR = \frac{avg(low band power)}{avg(high band power)}
#
# In this notebook we will explore this measure in the context of conceptualizing
# neural power spectra as a combination of both aperiodic and periodic activity.
#

###################################################################################################
Expand All @@ -22,12 +42,7 @@

from fooof.utils import trim_spectrum

###################################################################################################

# Simulation Settings
nlv = 0
f_res = 0.5
f_range = [3, 30]
from fooof.bands import Bands

###################################################################################################

Expand All @@ -45,7 +60,36 @@ def calc_band_ratio(freqs, powers, low_band, high_band):

###################################################################################################

fs, ps = gen_power_spectrum(f_range, [0, 1.5], [[10, 0.31, 1], [22, 0.2, 2]], nlv=nlv, freq_res=f_res)
# Simulation Settings
nlv = 0
f_res = 0.5
f_range = [3, 30]

# Set our band definitions
bands = Bands({'theta' : [4, 8], 'alpha' : [8, 13], 'beta' : [13, 30]})

###################################################################################################

# Simulate a power spectrum
freqs, pows = gen_power_spectrum(f_range, [0, 1.5], [[10, 0.31, 1],
[22, 0.2, 2]], nlv=nlv, freq_res=f_res)

###################################################################################################

#


###################################################################################################

# Calculate a band ratio measure
tbr = calc_band_ratio(freqs, pows, bands.theta, bands.beta)
print('Calculate theta / beta ratio is :\t {:1.2f}'.format(tbr))

###################################################################################################

###################################################################################################

###################################################################################################

###################################################################################################

Expand Down
2 changes: 1 addition & 1 deletion motivations/plot_BandsVsAperiodic.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@
# Periodic & Aperiodic Model
# --------------------------
#
# An alternative posibility is that what is different between age groups is predominantly the 1/f.
# An alternative possibility is that what is different between age groups is predominantly the 1/f.
#
# In this simulation, we simulate child and adult power spectra as having different 1/f properties.
#
Expand Down
6 changes: 3 additions & 3 deletions motivations/plot_DoYouEvenOscillate.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@
# --------------------------------------------------
#
# In principle, signals that display power across all frequencies need not arise from, or be
# best descriped as, signals with rhythmic components.
# best described as, signals with rhythmic components.
#
# Of course, it could be the case that such a signal does indeed arise from the summation across
# many oscillations. Here we will explore that.
Expand Down Expand Up @@ -284,7 +284,7 @@
# rhythmic components, the question becomes what is the best / most likely description for
# neural signals.
#
# Neural signals clearly containt 1/f activity, as seen in their frequency representations.
# Neural signals clearly contain 1/f activity, as seen in their frequency representations.
#
# They also sometimes do contain clear rhythmic components, visible as clear and relatively
# consistent rhythms in the time series, and regions of extra power, or peaks, in the power
Expand Down Expand Up @@ -313,7 +313,7 @@
# 3.2: Local Field Potentials
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Simulate a local field potential as aggregrate activity of post-synaptic potentials.
# Simulate a local field potential as aggregate activity of post-synaptic potentials.
#

###################################################################################################
Expand Down
2 changes: 1 addition & 1 deletion motivations/plot_IfYouFilterTheyWillCome.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
###################################################################################################

import numpy as np
from neurodsp import sim, filt

# Imports from NeuroDSP to simulate time series
from neurodsp import sim, filt
from neurodsp.utils import create_times
from neurodsp.plts import plot_time_series

Expand Down
5 changes: 3 additions & 2 deletions motivations/plot_UnderdeterminedChanges.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
Underdetermined measures
Underdetermined Measures
========================
Figure 1 from the FOOOF paper, in quantitatively exact code.
Expand Down Expand Up @@ -65,7 +65,8 @@ def plot_style(ax):
for cur_ax, (title, cur_dat) in zip(ax.reshape(-1), ps_comps.items()):

# Create COMMENT
plot_spectra_shading(fs, [ps_base, cur_dat], [8, 12], log_freqs=True, log_powers=True, ax=cur_ax)
plot_spectra_shading(fs, [ps_base, cur_dat], [8, 12],
log_freqs=True, log_powers=True, ax=cur_ax)

# Add the title, and do some plot styling
cur_ax.set_title(title, {'fontsize' : 20})
Expand Down

0 comments on commit 0875c46

Please sign in to comment.