|
41 | 41 | # These are used here to demonstrate the algorithm |
42 | 42 | # You do not need to import these functions for standard usage of the module |
43 | 43 | from fooof.sim.gen import gen_aperiodic |
44 | | -from fooof.plts.spectra import plot_spectrum |
| 44 | +from fooof.plts.spectra import plot_spectra |
45 | 45 | from fooof.plts.annotate import plot_annotated_peak_search |
46 | 46 |
|
47 | 47 | # Import a utility to download and load example data |
|
110 | 110 |
|
111 | 111 | # Plot the initial aperiodic fit |
112 | 112 | _, ax = plt.subplots(figsize=(12, 10)) |
113 | | -plot_spectrum(fm.freqs, fm.power_spectrum, plt_log, |
114 | | - label='Original Power Spectrum', color='black', ax=ax) |
115 | | -plot_spectrum(fm.freqs, init_ap_fit, plt_log, label='Initial Aperiodic Fit', |
116 | | - color='blue', alpha=0.5, linestyle='dashed', ax=ax) |
| 113 | +plot_spectra(fm.freqs, fm.power_spectrum, plt_log, |
| 114 | + label='Original Power Spectrum', color='black', ax=ax) |
| 115 | +plot_spectra(fm.freqs, init_ap_fit, plt_log, label='Initial Aperiodic Fit', |
| 116 | + color='blue', alpha=0.5, linestyle='dashed', ax=ax) |
117 | 117 |
|
118 | 118 | ################################################################################################### |
119 | 119 | # Step 2: Flatten the Spectrum |
|
131 | 131 | init_flat_spec = fm.power_spectrum - init_ap_fit |
132 | 132 |
|
133 | 133 | # Plot the flattened the power spectrum |
134 | | -plot_spectrum(fm.freqs, init_flat_spec, plt_log, |
135 | | - label='Flattened Spectrum', color='black') |
| 134 | +plot_spectra(fm.freqs, init_flat_spec, plt_log, |
| 135 | + label='Flattened Spectrum', color='black') |
136 | 136 |
|
137 | 137 | ################################################################################################### |
138 | 138 | # Step 3: Detect Peaks |
|
172 | 172 | ################################################################################################### |
173 | 173 |
|
174 | 174 | # Plot the peak fit: created by re-fitting all of the candidate peaks together |
175 | | -plot_spectrum(fm.freqs, fm._peak_fit, plt_log, color='green', label='Final Periodic Fit') |
| 175 | +plot_spectra(fm.freqs, fm._peak_fit, plt_log, color='green', label='Final Periodic Fit') |
176 | 176 |
|
177 | 177 | ################################################################################################### |
178 | 178 | # Step 5: Create a Peak-Removed Spectrum |
|
188 | 188 | ################################################################################################### |
189 | 189 |
|
190 | 190 | # Plot the peak removed power spectrum, created by removing peak fit from original spectrum |
191 | | -plot_spectrum(fm.freqs, fm._spectrum_peak_rm, plt_log, |
192 | | - label='Peak Removed Spectrum', color='black') |
| 191 | +plot_spectra(fm.freqs, fm._spectrum_peak_rm, plt_log, |
| 192 | + label='Peak Removed Spectrum', color='black') |
193 | 193 |
|
194 | 194 | ################################################################################################### |
195 | 195 | # Step 6: Re-fit the Aperiodic Component |
|
206 | 206 |
|
207 | 207 | # Plot the final aperiodic fit, calculated on the peak removed power spectrum |
208 | 208 | _, ax = plt.subplots(figsize=(12, 10)) |
209 | | -plot_spectrum(fm.freqs, fm._spectrum_peak_rm, plt_log, |
210 | | - label='Peak Removed Spectrum', color='black', ax=ax) |
211 | | -plot_spectrum(fm.freqs, fm._ap_fit, plt_log, label='Final Aperiodic Fit', |
212 | | - color='blue', alpha=0.5, linestyle='dashed', ax=ax) |
| 209 | +plot_spectra(fm.freqs, fm._spectrum_peak_rm, plt_log, |
| 210 | + label='Peak Removed Spectrum', color='black', ax=ax) |
| 211 | +plot_spectra(fm.freqs, fm._ap_fit, plt_log, label='Final Aperiodic Fit', |
| 212 | + color='blue', alpha=0.5, linestyle='dashed', ax=ax) |
213 | 213 |
|
214 | 214 | ################################################################################################### |
215 | 215 | # Step 7: Combine the Full Model Fit |
|
226 | 226 | ################################################################################################### |
227 | 227 |
|
228 | 228 | # Plot full model, created by combining the peak and aperiodic fits |
229 | | -plot_spectrum(fm.freqs, fm.fooofed_spectrum_, plt_log, |
230 | | - label='Full Model', color='red') |
| 229 | +plot_spectra(fm.freqs, fm.fooofed_spectrum_, plt_log, |
| 230 | + label='Full Model', color='red') |
231 | 231 |
|
232 | 232 | ################################################################################################### |
233 | 233 | # |
|
0 commit comments