Skip to content
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

Converting knee param to knee freq (double exponential) #301

Open
TomDonoghue opened this issue Mar 17, 2022 · 1 comment
Open

Converting knee param to knee freq (double exponential) #301

TomDonoghue opened this issue Mar 17, 2022 · 1 comment
Assignees
Labels
2.3 Updates to go into a 2.3.0.

Comments

@TomDonoghue
Copy link
Member

This issue is to pick up on a discussion that started in #290, for how to convert between the knee parameter and the knee frequency, specifically in the case of a double exponential model. To keep PRs a bit more modulate, this topic was split out from the rest of #290, which does more general refactors of the simulation functions.

Notes on double-exp model

The sim_knee function implements a double exponent + knee function, described as:
It's this: L(freq) = 1 / (freq**(exponent1) * freq**(exponent2 + exponent1) + knee)

This formulation uses the 'knee parameter', which isn't super easy to interpret. It would be nice to be able to use (and/or at least convert to) the knee frequency - the frequency at which the exponents change. This issue is to figure out how to do so (if it's even possible).

A candidate for converting the knee frequency and knee parameter is the following (see below):

knee_term = knee**(-2*exponent1 - exponent2)

Knee Derivation (from Ryan)

@ryanhammonds work on deriving the knee
from: #290 (comment)

The knee is defined as:
knee_freq = knee ** (1 / (2*exponent1 + exponent2))

from solving for the fwhm in the Lorenztian:

L(freq) = 1 / (freq**(exponent1) * freq**(exponent2 + exponent1) + knee)
L(knee_freq) = f(0) / 2

1 / (knee_freq**exponent1 * knee_freq**(exponent2 + exponent1)) + knee = 1 / (2 * knee)
knee_freq**exponent1 * knee_freq**(exponent2 + exponent1) + knee = 2 * knee
knee_freq**(2*exponent1 + exponent2) = knee
knee_freq = knee ** (1 / (2*exponent1 + exponent2))

I think this should be the analogous to solving knee_freq = knee**(1/exponent) in the single exponent model.

Notes from Richard

Note from Richard (#290 (comment)):
"at a quick glance, I think this might be a bit more complicated, though Ryan's derivations look good, at least in terms of the algebra. ... I'm actually not sure what the "right" answer for the knee_freq is when there's two slopes, bc it's not so easy to define where the tapering off happens when there's no flat plateau"

Other notes

In #290, there was an initial update for converting between knee parameter and knee frequency.

See the following commits for this (from Ryan).

  • adding in the knee conversion: ccc69f8
  • updating tests for knee conversion: 0f3af93

Note that to separate PR's, some of these changes were reverted in later commits in #290.

@TomDonoghue TomDonoghue added the 2.2 Updates to go into a 2.2.0 release label Mar 17, 2022
@TomDonoghue TomDonoghue added 2.3 Updates to go into a 2.3.0. and removed 2.2 Updates to go into a 2.2.0 release labels Sep 21, 2022
@rdgao
Copy link
Contributor

rdgao commented Nov 28, 2022

had this starred in my email since March lol - just following up, are there to-dos for this (for me or in general)?

I guess one way to check if the backwards derivation is right is to start from the forward model we know:

  • start from the double-exponential in time (e.g. here: https://neuronaldynamics.epfl.ch/online/Ch3.S1.html)
  • get the combined FFT by adding the two sets of complex Fourier coefficients, each of which is just the single-exponential / 1-knee model. You could probably wolfram-alpha this, e.g., "FFT of e^(t/tau1) - e^(t/tau2)"
  • take the square to get a nice expression for the magnitude
  • rearrange the f^4 and f^2, then try to find a term that is just a constant.

That last thing should be expressed as a function of tau in the exponentials (or equivalently, k in the 1-exponential model). Might have to shuffle things around so that it resembles what we have here above as the simulator, or just use that as the simulator, though the problem with that is that the exponents are not controllable.

let me know if somebody wants to take a crack at this (@ryanhammonds, I guess?), I can give it a try if not.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2.3 Updates to go into a 2.3.0.
Projects
None yet
Development

No branches or pull requests

3 participants