Skip to content

Commit 8b7fa1b

Browse files
committed
update AP fit tut to include doublexp
1 parent 9b39897 commit 8b7fa1b

File tree

1 file changed

+31
-2
lines changed

1 file changed

+31
-2
lines changed

tutorials/plot_05-AperiodicFitting.py

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@
163163

164164
###################################################################################################
165165
# A note on interpreting the 'knee' parameter
166-
# -------------------------------------------
166+
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
167167
#
168168
# The aperiodic fit has the form:
169169
#
@@ -214,6 +214,35 @@
214214
# 'knee' mode to be able to appropriately characterize the data.
215215
#
216216

217+
###################################################################################################
218+
# Aperiodic Fit Mode: doublexp
219+
# ----------------------------
220+
#
221+
# Returning to our exploration of the available fit modes for the aperiodic component,
222+
# another avaible fit mode is the 'double exponent' or 'doublexp'.
223+
#
224+
# In the above 'knee' mode, you might have noticed that even though the knee is described as
225+
# a change in the value of the aperiodic exponent, implying there are two different
226+
# exponent values, we still only fit one exponent value. In the above case, the exponent
227+
# above the knee is fit, whereas the exponent below the knee is assumed to be zero.
228+
#
229+
# By comparison, the double exponent model fits two different exponent values, above and
230+
# below the knee.
231+
#
232+
233+
###################################################################################################
234+
235+
# Create and fit a power spectrum model in doublexp aperiodic fit mode
236+
fm = SpectralModel(peak_width_limits=[2, 8], aperiodic_mode='doublexp')
237+
fm.report(freqs, spectrum, [2, 70], plt_log=True)
238+
239+
###################################################################################################
240+
#
241+
# In the above example model fit, we can see that the aperiodic mode now includes 4 fit parameters,
242+
# including two different exponent values (exponent1, reflecting below the knee, and exponent2,
243+
# reflecting above the knee), as well as the offset and knee value.
244+
#
245+
217246
###################################################################################################
218247
# Choosing an Aperiodic Fit Mode
219248
# ------------------------------
@@ -233,7 +262,7 @@
233262
#
234263
# - This is likely across smaller frequency ranges, such as 3-30.
235264
# - Do not perform no-knee fits across a range in which this does not hold.
236-
# - If there is a clear knee, then use knee fits.
265+
# - If there is a clear knee, then use a fit mode that includes a knee.
237266
#
238267
# - This is likely across larger fitting ranges such as 1-150 Hz.
239268
# - Be wary of ambiguous ranges, where there may or may not be a knee.

0 commit comments

Comments
 (0)