jonescompneurolab / hnn-core

Simulation and optimization of neural circuits for MEG/EEG source estimates
https://jonescompneurolab.github.io/hnn-core/
BSD 3-Clause "New" or "Revised" License
53 stars 52 forks source link

[MRG] Optimize rhythmic drives #673

Closed carolinafernandezp closed 1 month ago

carolinafernandezp commented 11 months ago

The goals are:

  1. To be able to optimize parameters associated with rhythmic drives. The user sets the frequency bands and relative bandpower. In the example below, we wish to optimize power in the 9-11 Hz and 19-21 Hz bands in a ratio of 1 to 2 (i.e. twice as much power in the beta band as in the alpha band).
optim = Optimizer(net, tstop=tstop, constraints=constraints,
                  set_params=set_params, obj_fun='maximize_psd')
optim.fit(f_bands=[(9, 11), (19, 21)], relative_bandpower=(1, 2), scale_factor=scale_factor,
                  smooth_window_len=smooth_window_len)

Example output image image

Reversing the ratios

optim.fit(f_bands=[(9, 11), (19, 21)], relative_bandpower=(2, 1), scale_factor=scale_factor,
                  smooth_window_len=smooth_window_len)

image image

  1. To allow the user to define obj_fun as a callable.
codecov-commenter commented 11 months ago

Codecov Report

Attention: Patch coverage is 80.72289% with 16 lines in your changes are missing coverage. Please review.

Project coverage is 92.55%. Comparing base (54ddd40) to head (78ab67d). Report is 49 commits behind head on master.

:exclamation: Current head 78ab67d differs from pull request most recent head d046764. Consider uploading reports for the commit d046764 to get more accurate results

Files Patch % Lines
hnn_core/gui/_viz_manager.py 59.09% 9 Missing :warning:
hnn_core/optimization/objective_functions.py 83.33% 4 Missing :warning:
hnn_core/optimization/general_optimization.py 76.92% 3 Missing :warning:

:exclamation: Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files ```diff @@ 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 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

jasmainak commented 11 months ago

can you share what the example outputs in the PR description?

carolinafernandezp commented 11 months ago

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.

jasmainak commented 5 months ago

whatever happened to this PR ? Was this close to merge? Is this something this year's GSoC student can work on?

carolinafernandezp commented 5 months ago

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.

jasmainak commented 5 months ago

@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 optimize_rhythmic and force push.

jasmainak commented 4 months ago

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?

gtdang commented 4 months ago

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.

jasmainak commented 4 months ago

How do we guarantee that the examples will run as expected for the user? unit tests?

ntolley commented 4 months ago

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

jasmainak commented 4 months ago

alright, go for it ... please remove it so we can move ahead with @carolinafernandezp 's PR

ntolley commented 1 month ago

@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

carolinafernandezp commented 1 month ago

Sounds great @ntolley, how is Thursday the 18th? Any time would work for me

ntolley commented 1 month ago

Just tested this locally and everything is running great, thanks a bunch @carolinafernandezp this is a super useful contribution!!

carolinafernandezp commented 1 month ago

Thanks @ntolley and everyone that helped!👏🏻