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
postprocessing #188
postprocessing #188
Conversation
b2704be
to
b6007f0
Compare
@blakecaldwell do you mind taking a look to see if it addresses what you had in mind for #183 ? @kohl-carmen one thing that remains to be checked is what does the GUI output as |
another thing to do here is to add a test for the new |
hnn_core/pyramidal.py
Outdated
@@ -19,7 +19,6 @@ | |||
|
|||
class Pyr(_Cell): | |||
"""Pyramidal neuron. | |||
|
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.
changes are unrelated to the PR, so best to undo them as we discussed!
Just getting around to reviewing this. Sorry for the delay. Yes, this is looking very good and should resolve #183 with some minor updates. We briefly touched on this on Monday, but I have some specific suggestions now. Since HNN GUI needs to write both
Note, the relevant params could be passed instead of the dictionary, perhaps preferable? I didn't look up what params |
hnn_core/network_builder.py
Outdated
if neuron_net.net.params['save_dpl']: | ||
dpl.write('rawdpl.txt') | ||
|
||
dpl.baseline_renormalize(neuron_net.net.params) | ||
dpl.convert_fAm_to_nAm() | ||
dpl.scale(neuron_net.net.params['dipole_scalefctr']) | ||
dpl.smooth(neuron_net.net.params['dipole_smooth_win'] / h.dt) | ||
if postproc: | ||
dpl.scale(neuron_net.net.params['dipole_scalefctr']) | ||
dpl.smooth(neuron_net.net.params['dipole_smooth_win'] / h.dt) |
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.
if postproc:
self.postproc(params)
I see, I would make it @kohl-carmen I saw you pushed some new commits. Let us know when we should take a look again. I get notifications only for comments, not for commits. |
I agree with using specific parameters. It somewhat negates the point below, but I think it's worth pointing out. I blanket disagree with making functions that HNN use private. HNN should be considered a first-class use case of hnn-core. |
Sure, of course HNN is a first class citizen of hnn-core. However, the reason I suggested using a private method is that it gives us flexibility to change the internals. If users start using hnn-core by passing params, they will complain if we try to change it in the future. |
Codecov Report
@@ Coverage Diff @@
## master #188 +/- ##
==========================================
- Coverage 68.16% 67.50% -0.66%
==========================================
Files 21 21
Lines 2202 2219 +17
==========================================
- Hits 1501 1498 -3
- Misses 701 721 +20
Continue to review full report at Codecov.
|
params : dict | ||
The parameters | ||
N_pyr_x : int | ||
Nr of cells (x) |
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.
Nr of cells (x) | |
Number of Pyramidal cells in x direction |
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.
add this change in next commit?
@kohl-carmen can you update a test? |
@klankinen and I tried to fix the postproc test. We set the std of the inputs to 0, rather than changing the tolerance on assert_allclose() because we didn't know what a reasonable tolerance would be? The postproc test is currently still in test_dipole.py but we're happy to move it (might need some help) |
Hmm, setting the std of the input times to 0 won't control for error induced by smoothing vs. not smoothing a given trial. My recommendation would be leave jitter in-between trials (i.e., reset start time std values to default) and solve for a reasonable tolerance as follows:
This method might be overkill but it should only take a few lines of code and can serve as a sanity check for any subsequent changes made to the post-processing steps in later PRs.
Idk, @jasmainak @ntolley what do you think? |
If you guys are working together you can both get credit for commits by co-authoring them. Just wanted to put it out there for future commits. You can also edit older commits and add authors but probably not worth the effort unless @klankinen insists ;-) |
Something reasonably small ... Is there a reason they are not exactly equal? Usually the defaults should do but if not you can look around in the codebase for tolerance used. |
@@ -186,21 +194,21 @@ def plot(self, ax=None, layer='agg', show=True): | |||
""" | |||
return plot_dipole(dpl=self, ax=ax, layer=layer, show=show) | |||
|
|||
def baseline_renormalize(self, params): |
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.
lovely!
hnn_core/parallel_backends.py
Outdated
if postproc: | ||
N_pyr_x = net.params['N_pyr_x'] | ||
N_pyr_y = net.params['N_pyr_y'] | ||
winsz = net.params['dipole_smooth_win'] / net.params['dt'] | ||
fctr = net.params['dipole_scalefctr'] | ||
for idx in range(n_trials): | ||
dpls[idx].post_proc(N_pyr_x, N_pyr_y, winsz, fctr) |
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 we could avoid the duplication of code between the backends by putting this inside _gather_trial_data
with postproc
as an argument?
ideally, we should avoid duplication but let's get the other stuff working first also you need to rebase. Do you need help? I think @ntolley is an expert ;-) last thing is you need to update |
On first glance it looks like the rebase should be pretty easy, I think most of the conflicts can be resolved by accepting both changes (one exception is adding the new argument to |
This probably won't work because the error here is induced by rounding error rather than by convolution with a smoothing kernel. |
not sure I follow. There are two tests: 1) checking if |
Oops, somehow I missed test_dipole.py L67. For some reason I thought the goal was to simultaneously test the scope of the post-processing. |
Co-authored-by: Kaisu Lankinen <klankinen@mgh.harvard.edu>
Co-authored-by: Kaisu Lankinen <klankinen@mgh.harvard.edu>
Co-authored-by: Kaisu Lankinen <klankinen@mgh.harvard.edu>
Co-authored-by: Kaisu Lankinen <klankinen@mgh.harvard.edu>
Co-authored-by: Kaisu Lankinen <klankinen@mgh.harvard.edu>
Co-authored-by: Kaisu Lankinen <klankinen@mgh.harvard.edu>
Co-authored-by: Kaisu Lankinen <klankinen@mgh.harvard.edu>
Co-authored-by: Kaisu Lankinen <klankinen@mgh.harvard.edu>
Co-authored-by: Kaisu Lankinen <klankinen@mgh.harvard.edu>
hnn_core/tests/conftest.py
Outdated
@pytest.fixture(scope='module') | ||
def run_hnn_core(): | ||
def _run_hnn_core(backend=None, n_procs=None, n_jobs=1, reduced=False, | ||
record_vsoma=False, record_isoma=False): |
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.
@kohl-carmen if you add a postproc
parameter here, then you can avoid duplication of code
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.
PR is good for me now! I snuck in a couple of fixes related to requires_mpi4py and moving run_hnn_core into a pytest fixture.
@ntolley @blakecaldwell @rythorpe if you guys are happy please feel free to merge and/or leave comments if something is to be fixed
assert len(joblib_net.cell_response.isoma[ | ||
trial][gid]['soma_gabaa']) == n_times | ||
|
||
@requires_mpi4py |
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.
Nice, I didn't even realize we had a MPIBackend test in another file besides parallel_backends.py. Thanks @jasmainak for making the testing changes.
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.
Ah those would be my changes, thanks for fixing my ad-hoc MPI tests @jasmainak.
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.
Just have a few suggestions, mainly in the new testing code added. So close!
hnn_core/tests/conftest.py
Outdated
|
||
|
||
@pytest.fixture(scope='module') | ||
def run_hnn_core(): |
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.
what about putting "fixture" in this function name? Otherwise it looks like a mysterious parameter to other testing functions.
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.
+1 @kohl-carmen can you make the changes yourself?
params : dict | ||
The parameters | ||
N_pyr_x : int | ||
Nr of cells (x) |
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.
add this change in next commit?
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 looks great! Thanks @kohl-carmen
@jasmainak would you do a "squash and merge" or an automatic rebase to merge this PR? Not sure what your preference is. |
I would do a "rebase and merge". Would give @kohl-carmen the full credit for the effort over the past month. Once we have establish set of contributors, we can move to "squash and merge" model |
Closes #183
closes #172