-
Notifications
You must be signed in to change notification settings - Fork 52
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
[MRG] Optimize rhythmic drives #673
[MRG] Optimize rhythmic drives #673
Conversation
Codecov ReportAttention: Patch coverage is
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. Additional details and impacted files@@ Coverage Diff @@
## master #673 +/- ##
==========================================
- Coverage 92.66% 92.55% -0.12%
==========================================
Files 27 27
Lines 4911 4945 +34
==========================================
+ Hits 4551 4577 +26
- Misses 360 368 +8 ☔ View full report in Codecov by Sentry. |
can you share what the example outputs in the PR description? |
Updated! I'm not getting the expected ratios (1:2, α:β) so I'm looking into that now. |
initial_params, max_iter, scale_factor=1., | ||
smooth_window_len=None, target=None, f_bands=None, | ||
relative_bandpower=None): |
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.
Per our previous discussion, is there a way to pull all parameters related to the objective function (e.g., scale_factor
and smooth_window_len
, target
, etc.) out of the Optimizer
class?
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.
I don't think we can take these out. For example, to optimize evoked drives, we use the scale_factor
in _rmse_evoked
(where we call simulate_dipole
). If we don't let the user pass it in, the amplitude of the optimized dipole most likely will not match the amplitude of the target dipole. In the case of rhythmic drives, we don't really need to pass in target
(so it is just an optional argument). Are you thinking we should pass these to the fit
method instead? Or something completely different?
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.
could you pass a "partial function" instead of passing each of the arguments?
https://docs.python.org/3/library/functools.html#functools.partial
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.
The issue is that the arguments of the optimizer function/class should be general to any type of data simulated with hnn-core. For instance, smooth_window_len
and scale_factor
don't make sense if I want to optimize spike rates in the model. And it would be too chaotic to add similar sorts of preprocessing parameters to the API of this function for every conceivable type of objective function for every type of simulated data (spike timing, spike rates, dipole, LFP, CSD, membrane voltage/current, receptor conductance, etc.).
The selection and preprocessing of simulated data, in my mind, should be siloed within the objective function. My recommendation would be to allow the user to either define obj_fun
as a callable, or pass in obj_fun_kwargs
that apply to a given objective function defined with a string match. Advanced users can manipulate data preprocessing parameters by defining a partial function (as @jasmainak suggested), and less advanced users can rely on default parameters you define in the template objective functions or set them in obj_fun_kwargs
as a catch-all for parameters that are specific to a given objective function.
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.
This will also simplify your _run_opt
functions and Optimizer.fit()
methods considerably.
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.
Ok this makes sense, I just pushed a version that allows users to pass in obj_fun_kwargs
and I'm working on allowing for a callable now.
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.
The user can now pass a callable for obj_fun
. I'm testing this in test_general_optimization.py
, test_user_obj_fun
where obj_fun
is set to maxime_csd
which is just a function that maximizes CSD in a certain time range and for a certain electrode depth range.
whatever happened to this PR ? Was this close to merge? Is this something this year's GSoC student can work on? |
Hi, I'm going to work on getting this merged but I think it's definitely something this year's GSoC student can expand on. |
@carolinafernandezp you seem to have rebase conflicts ... might be easiest to create a new branch from latest master, cherry pick your commits on to that branch, rename that branch to |
The build is failing because of the GUI example ... @gtdang @kmilo9999 how best to address this? maybe we could separate the GUI examples into a separate build using Github actions? |
We can just get rid of those GUI docs from the build. New docs for the GUI will just be markdown to reduce the complexity and fragility of the notebook builds. |
How do we guarantee that the examples will run as expected for the user? unit tests? |
Exactly this, after going through the numerous problems with rendering the GUI tutorials, having hand-made tutorials with less extensive testing seems like the better option than having absolutely no tutorials due to an updated package |
alright, go for it ... please remove it so we can move ahead with @carolinafernandezp 's PR |
@carolinafernandezp we've finally fixed the documentation issues, if you have the bandwidth in the next week or so would you want to do a quick zoom call to rebase this together and go ahead and merge it? Also note for myself to close #176 once this is merged |
Sounds great @ntolley, how is Thursday the 18th? Any time would work for me |
optimize rhythmic drives
d046764
to
20d8046
Compare
Just tested this locally and everything is running great, thanks a bunch @carolinafernandezp this is a super useful contribution!! |
Thanks @ntolley and everyone that helped!👏🏻 |
The goals are:
Example output
Reversing the ratios
obj_fun
as a callable.