|
2 | 2 | 01: Model Description |
3 | 3 | ===================== |
4 | 4 |
|
5 | | -A description and introduction to the power spectrum model. |
| 5 | +A description of and introduction to the power spectrum model. |
6 | 6 | """ |
7 | 7 |
|
8 | 8 | ################################################################################################### |
|
57 | 57 |
|
58 | 58 | ################################################################################################### |
59 | 59 |
|
60 | | -# Initialize a power spectrum models and fit the power spectra |
| 60 | +# Initialize power spectrum model objects and fit the power spectra |
61 | 61 | fm1 = FOOOF(min_peak_height=0.05, verbose=False) |
62 | 62 | fm2 = FOOOF(min_peak_height=0.05, aperiodic_mode='knee', verbose=False) |
63 | 63 | fm1.fit(freqs1, powers1) |
64 | 64 | fm2.fit(freqs2, powers2) |
65 | 65 |
|
66 | 66 | ################################################################################################### |
67 | 67 | # |
68 | | -# Now, we have some data & models to work with. |
| 68 | +# Now, we have some data and models to work with. |
69 | 69 | # |
70 | 70 | # To start with, we can plot one of our simulated power spectra. |
71 | 71 | # |
|
74 | 74 | # |
75 | 75 | # In the plot, we see a power spectrum in which there is decreasing power across increasing |
76 | 76 | # frequencies. In some frequency regions, there is a 'peak' of power, over and above the general |
77 | | -# trend across frequencies. These properties - a pattern of power across all frequencies, with |
78 | | -# overlying peaks - are considered to be hallmarks of neural field data. |
| 77 | +# trend across frequencies. These properties - a pattern of decreasing power across frequencies, |
| 78 | +# with overlying peaks - are considered to be hallmarks of neural field data. |
79 | 79 | # |
80 | 80 |
|
81 | 81 | ################################################################################################### |
|
96 | 96 | # |
97 | 97 | # By components, we mean that we are going to conceptualize neural field data as consisting |
98 | 98 | # of a combination of periodic (oscillatory) and aperiodic activity. Restated, we could say |
99 | | -# that neural data contains both periodic and aperiodic components (or activity). |
| 99 | +# that neural data contains both periodic and aperiodic components. |
100 | 100 | # |
101 | 101 | # The goal of the model is to measure these components, separately and explicitly, |
102 | 102 | # from frequency representations of neural field data (neural power spectra). |
|
124 | 124 | # Given the full model, in red, we can then describe this spectrum in terms of the |
125 | 125 | # 'components' that make up the model fit, which are: |
126 | 126 | # |
127 | | -# - `aperiodic`: activity, with no characteristic frequency (or 'non-frequency specific' activity) |
| 127 | +# - `aperiodic`: activity with no characteristic frequency (or 'non-frequency specific' activity) |
128 | 128 | # |
129 | 129 | # - in power spectra, this looks like a trend across all frequencies |
130 | | -# - in the plot above, this is what's captured by the dashed blue line |
131 | | -# - `periodic` : activity, with a characteristic frequency |
| 130 | +# - in the plot above, this is what is captured by the dashed blue line |
| 131 | +# - `periodic` : activity with a characteristic frequency |
132 | 132 | # |
133 | 133 | # - in power spectra, this looks like a 'peak', or 'bump', reflecting frequency specific power |
134 | | -# - in the plot above, this is what's captured by the green shaded peaks |
| 134 | +# - in the plot above, this is what is captured by the green shaded peaks |
135 | 135 | # |
136 | | -# Each of these components also has different 'features' or 'properties', that we can and |
137 | | -# want to describe and measure. Since these 'features' are things that we will be fitting in |
| 136 | +# Each of these components also has different 'features' or 'properties', that we want to |
| 137 | +# describe and measure. Since these 'features' are things that we will be fitting in |
138 | 138 | # the model, we will call them `parameters` (as in, the 'model parameters'). |
139 | 139 | # |
140 | 140 | # The full model of the power spectrum is the combination of the two components: |
141 | | -# the aperiodic component and the periodic component, which is the set of peaks. |
| 141 | +# the aperiodic component and the periodic component (the set of peaks). |
142 | 142 | # |
143 | 143 | # The goal of the model is to measure these two components, to create the full model |
144 | 144 | # fit, in a way that accurately and quantitatively describes the data. |
|
148 | 148 | # Mathematical Description of Overall Model |
149 | 149 | # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
150 | 150 | # |
151 | | -# To enact the conceptual idea and description above, we will need to formalize the |
152 | | -# model described above. To do so, throughout the rest of this tutorial, we will lay out the |
153 | | -# mathematical description of how neural power spectra can be modeled as a combination of |
154 | | -# periodic and aperiodic activity. |
| 151 | +# To enact the conceptual idea described above, we will need to formalize the model. To do |
| 152 | +# so, throughout the rest of this tutorial, we will lay out the mathematical description of |
| 153 | +# how neural power spectra can be modeled as a combination of periodic and aperiodic activity. |
155 | 154 | # |
156 | 155 | # Overall, the goal is to describe a neural power spectrum, described as :math:`NPS`, as |
157 | 156 | # a combination of periodic and aperiodic components. We will describe each of these |
|
177 | 176 | # |
178 | 177 | # To measure the periodic activity, we would like to describe these peaks, without our |
179 | 178 | # measures of these peaks being influenced by co-occurring aperiodic activity. |
180 | | -# This is important, since as we can see in the plots above, the aperiodic and periodic |
| 179 | +# This is important, since, as we can see in the plots above, the aperiodic and periodic |
181 | 180 | # components of the data can 'overlap', in frequency space. This means the total power |
182 | 181 | # at a given frequency may have contributions from both components. To measure periodic power, |
183 | 182 | # specifically, we need to measure the power relative to the aperiodic component of the data. |
|
202 | 201 | # |
203 | 202 | # - the `center frequency` of the peak, in units of frequency |
204 | 203 | # - the `power` of the peak, over the aperiodic component, in units of power |
205 | | -# - the `bandwidth`, or the width of the peak, units of frequency |
| 204 | +# - the `bandwidth`, or the width of the peak, in units of frequency |
206 | 205 | # |
207 | 206 | # Wherever we detect a peak, these are the parameters that we will fit to the peak, |
208 | 207 | # to describe this component of the data. |
|
212 | 211 | # Mathematical Description of the Periodic Component |
213 | 212 | # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
214 | 213 | # |
215 | | -# To fit these periodic components - the regions of power over above the aperiodic component, |
| 214 | +# To fit this periodic activity - the regions of power over above the aperiodic component, |
216 | 215 | # or 'peaks' - the model uses Gaussians. As we've seen, there can be multiple peaks in the model. |
217 | 216 | # |
218 | 217 | # Each Gaussian, :math:`n`, referred to as :math:`G(F)_n`, is of the form: |
|
239 | 238 | # the power across frequencies decreases with a :math:`\frac{1}{F^\chi}` relationship. |
240 | 239 | # |
241 | 240 | # To measure the aperiodic activity, we would like to describe the pattern of activity |
242 | | -# across all frequencies, without our measure being influenced by any co-occurring periodic |
| 241 | +# across all frequencies, without our measure being influenced by co-occurring periodic |
243 | 242 | # activity (peaks). |
244 | 243 | # |
245 | 244 |
|
|
274 | 273 | # define the aperiodic component, as: |
275 | 274 | # |
276 | 275 | # - :math:`b` is the broadband 'offset' |
277 | | -# - :math:`k` relates to the 'knee' |
| 276 | +# - :math:`k` is the 'knee' |
278 | 277 | # - :math:`\chi` is the 'exponent' of the aperiodic fit |
279 | 278 | # - :math:`F` is the array of frequency values |
280 | 279 | # |
|
284 | 283 | # |
285 | 284 | # This function form is technically described as a Lorentzian function. We use the option |
286 | 285 | # of adding a knee parameter, since even though neural data is often discussed in terms |
287 | | -# of having `1/f` activity, across broader frequency ranges, there is typically not a single |
288 | | -# `1/f` characteristic. Using this form allows for modeling bends in the power spectrum of |
289 | | -# the aperiodic component, if and when they occur. |
| 286 | +# of having `1/f` activity, there is often not a single `1/f` characteristic, especially |
| 287 | +# across broader frequency ranges. Therefore, using this function form allows for modeling |
| 288 | +# bends in the power spectrum of the aperiodic component, if and when they occur. |
290 | 289 | # |
291 | 290 | # Note that if we were to want the equivalent function in linear power, using :math:`AP` |
292 | 291 | # to indicate the aperiodic component in linear spacing, it would be: |
|
308 | 307 | # not affect how the data is stored and/or how models are fit. |
309 | 308 | # |
310 | 309 | # Below we can see the same spectrum again, with all the annotations on, plotted in log-log. |
311 | | -# The most notable difference, is that the aperiodic component is a straight line in log-log |
| 310 | +# The most notable difference is that the aperiodic component is a straight line in log-log |
312 | 311 | # spacing. This is a hallmark of `1/f` activity. |
313 | 312 | # |
314 | 313 |
|
|
0 commit comments