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

MRG: optimization updates after hnn-core integration #282

Merged
merged 14 commits into from
Mar 31, 2021

Conversation

blakecaldwell
Copy link
Member

@blakecaldwell blakecaldwell commented Mar 29, 2021

This PR is about fixing the remaining bugs in the optimization code and "reproducing" the optimization tutorial.

  • Busy wheel after termination (nrniv still running)
  • After an error, optimization keeps running
  • Optimization dialog gets hidden when another dialog selected
  • Number of spikes isn’t treated as an integer in opt dialog
  • Optimization dialog range sliders aren’t working
  • The order of input tabs is not consistent with their occurrence in simulation time
  • Initial optimization fit is not displayed on completion and the final fit is shown in black
  • Disable the number of spikes parameter by default
  • Optimize over reasonable integer values for number of spikes
  • Confirm optimization tutorial produces expected results

@blakecaldwell blakecaldwell changed the title WIP: optimization updates after hnn-core integration MRG: optimization updates after hnn-core integration Mar 29, 2021

sorted_inputs = dict(sorted(times_dict.items(), key=lambda item: item[1]))
for input_str in sorted_inputs.keys():
input_list.append(input_str)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if this is a realistic failure point, but perhaps a test to ensure the numbering is sequential (t_evprox_1 -> t_exprox5) for example. Something like assert np.all(np.diff(ev_index_list) == 1))

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, very reasonable... that is the check that would have alerted me to the issue addressed by commit 35352a4. I just won't have the time to implement CI checks for HNN GUI.

@blakecaldwell
Copy link
Member Author

I'm good with this PR, which should wrap up the code changes for the hnn-core integration. Documentation PRs will follow and bug fixes as revealed by testing.

@blakecaldwell
Copy link
Member Author

Following the optimization tutorial produces a good fit. Slightly higher RMSE, but there are many reasons for that. This is after 2 optimization passes starting from ERPYes3Trials fit to S1_SupraT.txt
Screen Shot 2021-03-30 at 8 11 49 AM

Copy link
Collaborator

@jasmainak jasmainak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not fully familiar with GUI code yet to give a proper review. I'd suggest merging so we can continue with the testing!

@blakecaldwell
Copy link
Member Author

I agree GUI code is not necessary to review now, but here are some commits that are still important. @ntolley maybe you could look at these?

afae29d
bc3cb81
e7b6f73

record_vsoma=record_vsoma)
record_vsoma = bool(net.params['record_vsoma'])

numspikes_params = net.params['numspikes_*']
Copy link
Contributor

@ntolley ntolley Mar 31, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jasmainak was it settled that it's ok to pass >2 spikes during the meeting? (as long as the tutorial is updated)

sim_params = hnn_core_compat_params(self.params)
if sim_length is not None:
sim_params['tstop'] = sim_length
sim_params['tstop'] = round(sim_length, 8)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not clear to me why the rounding is necessary? I saw in the old commit that it is to avoid "precision errors"

Copy link
Member Author

@blakecaldwell blakecaldwell Mar 31, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah hnn-core fails if tstop is 170.0000000002. the error is in adding vectors of different length for summing up dipole contributions


# make copy of params dict in Params object before
# modifying tstop
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# modifying tstop
# modifying tstop (necessary to avoid precision errors)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not quite the reason for copying params. tstop here can be reduced to run a shortened simulation (i.e. 110 ms).

hnn/simdata.py Outdated
@@ -231,7 +231,7 @@ class SimData(object):

def __init__(self):
self._sim_data = {}
self._opt_data = {}
self._opt_data = {'initial_dpl': None, 'initial_error': 1e9}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this a placeholder or is there a reason for using 1e9? If not I would just got with float

Copy link
Member Author

@blakecaldwell blakecaldwell Mar 31, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The key 'initial_error' just needed to exist. 1e9 is used elsewhere as an initial error (subsequent RMSE will always be lower)

Blake Caldwell added 14 commits March 31, 2021 08:48
Depends on terminate function in hnn-core 76162b10

Update exception handling for threads with a custom excepthook
that doesn't emit an extra done signal. Also protect SimThread.killed
variable with a lock because the main GUI thread accesses it
via the stop method.
Caused range sliders not to work after merging code from hnn-core
integration.
Correctly save initial dipole and initial error in SimData._opt_data
dict so that plot_dipole can find it.
@blakecaldwell
Copy link
Member Author

Thanks for the review @ntolley. Rebased and addressed comments. Please merge if OK

@ntolley
Copy link
Contributor

ntolley commented Mar 31, 2021

Thanks @blakecaldwell! I'll dig into the GUI code more as we move forward.

@ntolley ntolley merged commit b6e791f into jonescompneurolab:master Mar 31, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants