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] Add ability to record voltages and currents from all sections #502

Merged
merged 16 commits into from
Dec 16, 2022

Conversation

ntolley
Copy link
Contributor

@ntolley ntolley commented Jul 15, 2022

This is an enhancement I've been meaning to add for awhile. Not sure if this is going to cause a lot of problems in terms of data transfer, but we'll see!

The way things are currently written are very redundant with the somatic recording functionality. Once I know this is working, the record_vsoma and record_isoma options to simulate_dipole can use the same code as here by restricting the section names considered to only be the 'soma'.

hnn_core/cell.py Outdated
@@ -548,6 +550,39 @@ def record_soma(self, record_vsoma=False, record_isoma=False):
if record_vsoma:
self.rec_v.record(self._nrn_sections['soma'](0.5)._ref_v)

def record_sec(self, record_vsec=False, record_isec=False):
Copy link
Collaborator

Choose a reason for hiding this comment

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

soma is also a section in the Neuron scheme of things. Would it make sense to unify the API with the recording of soma?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For sure! While I'm still testing things I want to keep the code separate until I know recordings work for all sections. Then I can delete all the soma specific code (and set an option between recording just the soma, or all sections).

@ntolley ntolley changed the title WIP: Add ability to record voltages and currents from all sections [MRG] Add ability to record voltages and currents from all sections Dec 8, 2022
@codecov-commenter
Copy link

codecov-commenter commented Dec 8, 2022

Codecov Report

Merging #502 (af2a8f0) into master (1f22230) will decrease coverage by 0.04%.
The diff coverage is 98.30%.

❗ Current head af2a8f0 differs from pull request most recent head 280878e. Consider uploading reports for the commit 280878e to get more accurate results

@@            Coverage Diff             @@
##           master     #502      +/-   ##
==========================================
- Coverage   91.81%   91.77%   -0.05%     
==========================================
  Files          22       22              
  Lines        4214     4229      +15     
==========================================
+ Hits         3869     3881      +12     
- Misses        345      348       +3     
Impacted Files Coverage Δ
hnn_core/params_default.py 100.00% <ø> (ø)
hnn_core/cell.py 96.85% <95.65%> (-0.26%) ⬇️
hnn_core/cell_response.py 84.00% <100.00%> (ø)
hnn_core/dipole.py 92.45% <100.00%> (-0.05%) ⬇️
hnn_core/network_builder.py 93.85% <100.00%> (+0.08%) ⬆️
hnn_core/parallel_backends.py 81.38% <100.00%> (-0.56%) ⬇️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@ntolley
Copy link
Contributor Author

ntolley commented Dec 8, 2022

@rythorpe @jasmainak took a little sabbatical from this PR but everything seems to be working now! Might be a nice add-on to the 0.3 😉

hnn_core/cell.py Outdated Show resolved Hide resolved
@@ -85,6 +88,12 @@ API
:meth:`~hnn_core.extracellular.ExtracellularArray.plot_lfp`, by
`Steven Brandt`_ and `Ryan Thorpe`_ in :gh:`517`.

- Recorded voltages/currents from the soma, as well all sections, are enabled by
setting either `record_vsoma` and `record_isoma`, or `record_vsec` and `record_isec`
Copy link
Contributor

Choose a reason for hiding this comment

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

As I also suggested below, why do we need record_vsoma and record_isoma?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thought process here is

  1. Consistency with old API (although I'm renaming the attributes of net.cell_response here so perhaps it's a moot point)
  2. Have to imagine there's going to be a memory issue with larger networks or some computational burden when storing all this data. Could be nice to not store all currents/voltages if you only care about those in the soma

hnn_core/cell.py Outdated
Option to record somatic currents from cells

Option to record somatic currents from cells. Default: False.
record_vsec : bool
Copy link
Collaborator

Choose a reason for hiding this comment

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

voltage_secs : 'soma' | 'all' | list

? But you decide, I don't want to add unnecessary complexity

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What do you think of record_vsec : 'soma' | 'all' | None?

I'm all for it, but if we propagate this change to simulate_dipole() it'd be an API change. I don't know of anyone (besides me) using this functionality in hnn-core so a deprecation warning seems unnecessary, but worth bringing up here.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think it's okay to make a breaking change here ... we'll at least know who are using hnn-core for real if they complain :P

Copy link
Contributor Author

@ntolley ntolley Dec 16, 2022

Choose a reason for hiding this comment

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

Just pushed the change! I think the code definitely reads better without lugging around 4 parameters everywhere

@jasmainak
Copy link
Collaborator

Cursorily looks fine barring the tiny comment. I trust you tested it properly :)

hnn_core/cell.py Outdated
Contains recording of somatic currents indexed
by synapse type. (keys are soma_gabaa, soma_gabab etc.)
Must be enabled by running simulate_dipole(net, record_isoma=True)
rec_vsec : dict
Copy link
Collaborator

Choose a reason for hiding this comment

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

should we just call it vsec to avoid confusion with record_vsec which is the boolean that decides whether to record vsec or not?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sounds good! Will be ready to merge once I push this change

@jasmainak
Copy link
Collaborator

good to go from your end @ntolley ?

@ntolley
Copy link
Contributor Author

ntolley commented Dec 16, 2022

good to go from your end @ntolley ?

All good with me once the CI's are green! Just pushed the last commit addressing your comment

@jasmainak jasmainak merged commit 9447ab7 into jonescompneurolab:master Dec 16, 2022
@jasmainak
Copy link
Collaborator

Thanks @ntolley ! great stuff 🥳 🥳 🥳

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.

4 participants