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] Add functionality to record somatic voltage from all cells in simulation #190
[MRG] Add functionality to record somatic voltage from all cells in simulation #190
Conversation
starting a PR after changing 3 lines, I think you're getting the hang of open source and open science now ;-) umm ... the cleanest API would probably be to rename |
Just to elaborate a bit. You should be able to do: >>> net = Network(...)
>>> net.cells[50].spikes
>>> net.plot_spikes()
>>> net.cells[50].vsoma
>>> plt.plot(net.cells[50].vsoma) |
I'll give it a shot! I have a bit more free time in the coming weeks so ideally I can make decent progress. |
Implemented some basic slicing functionality for the spikes class (the next commit will allow for arbitrary lists/arrays) At the moment the slice operation returns a smaller One consideration is that indexing gids that do not exist will return an empty list. Considering the structure of |
Codecov Report
@@ Coverage Diff @@
## master #190 +/- ##
==========================================
+ Coverage 68.07% 68.08% +0.01%
==========================================
Files 19 19
Lines 2039 2040 +1
==========================================
+ Hits 1388 1389 +1
Misses 651 651
Continue to review full report at Codecov.
|
a8c6e88
to
9d16038
Compare
Well this is no fun, the test Travis is failing on seems to run fine on my machine. In any case I restructured storage of @rythorpe @jasmainak If you have the chance can you try running In the mean time I may push some variants on handling somatic voltages to try and appease Travis/MPI. |
yep I could replicate. The problem is that the you don't have import mpi4py in the ipython terminal? Also try putting a breakpoint (e.g., just add a line saying "1/0") in your test, and run it with "--pdb" flag and try doing "import mpi4py". I think it won't work. Now the issue is the following -- we don't get a message that the test was skipped when |
also cc-ing @blakecaldwell since he's the MPI expert :-) |
By the way, just for your info. When you have something finicky that you can't replicate on your box, there is also the option of ssh-ing into the Travis build and trying there. It's a pain (because Travis box won't have a bunch of stuff installed) but you can use it as a last resort. |
The way I did it preserves comparing results when the joblib backend is used. Maybe you want to split this test up like it was before e847137#diff-c85e4dc16a1586adb223901f0de74fdf |
@ntolley I found a problem in how the results are being passed between @jasmainak since you have a specific plan in mind for how the tests should look, what about taking that on in a future PR? |
While #192 is still open, you can work around this by
|
Thanks @blakecaldwell! @jasmainak to finish off this PR I'll work on cleaning up indexing the Keeping the integration timeline in mind, do you think the proposed test PR can be merged afterwards? |
Just to provide more context, the commit that combined running both backends under a single test was designed to speed up and simplify the test. The idea was that each backend needed two simulations: one for comparing to the default 'ground truth' simulation and one for comparing consistency between the other backends. It looks like we'll need to rethink this, however, given the mpi2py import issue. Maybe we can also consider shortening the default 'ground truth' simulation in order to speed up the tests that require simulations. |
we can use pytest fixtures to avoid duplicating the same test. |
I would say bring this PR to a mergeable state as soon as you can. I would also like to work on other PRs which could create merge conflicts and slow things down. Adding the currents should be easy once we have this working, no? |
Yeah adding currents would work nearly identically as somatic voltage. A cleaner solution might actually be to combine |
@ntolley I'd agree with making the code as simple as possible first, then let's see if it's necessary to add back any optimizations |
9d16038
to
507d637
Compare
Will dig into the Travis error tomorrow. The error message is actually being printed now since the voltage data isn't passed through stderr, but I am unsure if it is related to how I am storing voltage data or some other issue: In any case, I've flushed out Once the Travis error is resolved I'd be happy to merge, please feel free to suggest changes to the gid indexing or voltage recording. |
should we remove this example: https://jonescompneurolab.github.io/hnn-core/auto_examples/plot_firing_pattern.html#sphx-glr-auto-examples-plot-firing-pattern-py and instead use your function to plot the soma voltage? |
b6a8bda
to
4968a23
Compare
Finished adding tests for the dimensions of that |
|
||
simulate_dipole(net, n_trials=2, record_vsoma=True) | ||
assert len(net.spikes.vsoma) == 2 | ||
assert len(net.spikes.vsoma[0]) == 24 |
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'm going to merge this, but could you clarify where 24 comes from?
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.
It's just the length of the recording. I figure hard coding is preferable in this situation since the length of all the recording vectors is derived from spikes.times
. For example, it'd be useful to know if a future commit somehow changes the length of the simulation/recording.
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 see ... you could have also used tstop
and dt
from params
and recomputed the length, I guess. Anyway, no strong feelings either way
if record_vsoma is not None and isinstance(record_vsoma, bool): | ||
net.params['record_vsoma'] = record_vsoma | ||
else: | ||
raise TypeError("record_vsoma must be bool, got %s" | ||
% type(record_vsoma).__name__) | ||
|
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.
Hi @ntolley @jasmainak! I had a followup on this PR. Enforcing a bool here causes an issue with how the HNN GUI displays parameter values. Normally, the user enters 0 or 1, which gets saved to the params dict. Here, it changes that value and the GUI shows "False", which is not suitable for a text box. I could change the GUI to automatically reconvert to 0 or 1 pretty easily, but this seems to be the first parameter hnn-core enforces. Is that the convention you are aiming for?
BTW, I realize a better GUI solution would be checkboxes but am kind of hoping hnn-core will allow 0 or 1 and I can leave the code as-is.
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'd defer to @jasmainak's opinion for this one, but I but I believe this has come up in the past and the decision was to avoids int
s for boolean values.
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.
yeah, we're aiming to have this to be boolean in hnn-core
. Do you mind type-casting it in HNN for now? We can convert to checkboxes in the future!
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.
sure, thanks for the clarification
closes #181. Starting this PR to discuss how this should be implemented. At the moment I am considering a dictionary indexed by gids, the values would be an array of the somatic voltage recorded. Alternatively it could be implemented as its own object like the
Spikes
class.Another point to consider is if we want to record and save voltages by default, or have it enabled when specified by the user.