-
Notifications
You must be signed in to change notification settings - Fork 63
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[ENH] - Simulation of Central Frequency in the Time Domain #221
[ENH] - Simulation of Central Frequency in the Time Domain #221
Conversation
This looks awesome Eric - I'm looking forward to trying it out when I get a chance! The different sign of 1/f is expected based on different conventions between FOOOF & NDSP. Sorta annoying, but sorta grand-fathered in at this point, and consistent with everything else. |
@rdgao just wanted to tag you in to let you look at the math if you're so inclined. |
holy moly that's a lot of math |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you think I should rewrite this code so that it takes as input a general time series and then adds sinusoids to augment its power spectrum, or do you think that should be a separate function and we can keep this sim as is?
I pushed an update so any aperiodic function may be used. However, it defaults to sim_powerlaw
with an exponent of -2. I also fixed a doc typo, trimmed line lengths for pep8, etc.
09090d9
to
867c5ad
Compare
@TomDonoghue I addressed all of your comments, renamed the func/variables, added array support, ran pylint to resolve multi-line white space issues. I also added an accuracy test to make sure a peak was close to the center freq: |
Overview
This PR builds a new combined aperiodic and periodic simulation which allows the user to simulate an aperiodic component with a specified power law exponent and a single oscillatory component with specified central frequency, bandwidth, and relative height above the aperiodic component in the log-power spectrum.
Here is a minimal working example with the analytical power spectrum superimposed for comparison.
Comments
The way the code is written is a bit limiting. For example, it doesn't allow the presence of multiple central frequencies. The code is easily adaptable to handle this case though. In general, given a signal in the time domain, this code adds sinusoids at the relevant frequencies to add a ``bump'' in the log power spectrum to the inputted signal. To get multiple central frequencies, you'd just do a few recursive calls on aperiodic noise with different central frequencies, bandwidths, and relative heights.
@ryanhammonds @TomDonoghue Do you think I should rewrite this code so that it takes as input a general time series and then adds sinusoids to augment its power spectrum, or do you think that should be a separate function and we can keep this sim as is?
The Math Behind The Code