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 probability arguments to drives API #416

Merged
merged 13 commits into from
Sep 22, 2021

Conversation

ntolley
Copy link
Contributor

@ntolley ntolley commented Aug 20, 2021

Closes #410. Thanks to #369, this task is quite straightforward. The goal of this PR is to add a probability argument to the drives API, such that net.add_evoked_drive(..., probability=0.5) randomly removes half the drive connections, and only a subset are actually targeted by the drive. Additionally, the probability argument should also accept a dictionary which specifies probabilities for each individual connection (same was the weight and delay arguments).

After completing this, I think the final task for fully merging the drives and connection API's is enabling the manual targeting of target_gids, but let's leave that as a topic of discussion for the upcoming retreat ;).

@ntolley
Copy link
Contributor Author

ntolley commented Aug 20, 2021

Also I want to mention a potential concern I had that ended up not being a problem. net.connectivity contains a separate element for each receptor type, there is the potential that a given src_gid -> target_gid pair may be missing the full suite of receptors intended for that connection. For example, the GABAa and GABAb connections from the same inhibitory src_gid targeting different neurons.

Rather conveniently, this is gracefully handled by making sure the same seed is used when calling net.add_connection for the receptors contained in the same "connection class". I'll add some tests to check this explicitly, but by manual inspection the src-target pairs agree across receptors for the same connection class.

hnn_core/network.py Outdated Show resolved Hide resolved
hnn_core/network.py Outdated Show resolved Hide resolved
@jasmainak
Copy link
Collaborator

add a test?

@jasmainak
Copy link
Collaborator

Also, can you add closes #410 in the description of the PR ?

@ntolley ntolley changed the title WIP: Add probability arguments to drives API [MRG] Add probability arguments to drives API Aug 20, 2021
@codecov-commenter
Copy link

codecov-commenter commented Aug 20, 2021

Codecov Report

Merging #416 (9611b3b) into master (46e26f1) will decrease coverage by 0.69%.
The diff coverage is 100.00%.

❗ Current head 9611b3b differs from pull request most recent head ec6f3b8. Consider uploading reports for the commit ec6f3b8 to get more accurate results
Impacted file tree graph

@@            Coverage Diff             @@
##           master     #416      +/-   ##
==========================================
- Coverage   88.49%   87.80%   -0.70%     
==========================================
  Files          18       18              
  Lines        3267     3287      +20     
==========================================
- Hits         2891     2886       -5     
- Misses        376      401      +25     
Impacted Files Coverage Δ
hnn_core/network_models.py 100.00% <ø> (ø)
hnn_core/dipole.py 91.55% <100.00%> (+0.11%) ⬆️
hnn_core/drives.py 92.98% <100.00%> (+0.21%) ⬆️
hnn_core/network.py 92.03% <100.00%> (+0.26%) ⬆️
hnn_core/params.py 90.90% <100.00%> (ø)
hnn_core/viz.py 78.15% <0.00%> (-5.14%) ⬇️
hnn_core/cell_response.py 83.92% <0.00%> (-0.60%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 46e26f1...ec6f3b8. Read the comment docs.

hnn_core/network.py Outdated Show resolved Hide resolved
@jasmainak
Copy link
Collaborator

Few minor comments otherwise LGTM

I see that there are a couple of other todos in the release checklist but this was not amongst them. Would you mind updating that checklist to reflect the latest shopping list?

@ntolley ntolley mentioned this pull request Aug 23, 2021
15 tasks
@ntolley
Copy link
Contributor Author

ntolley commented Aug 23, 2021

Can do! And apologies going off script w.r.t. release priorities, this came up as being very necessary for some preliminary grant analysis.

@jasmainak
Copy link
Collaborator

@ntolley looks like we have a CI failure due to MNE. Can you reproduce the import issue locally (with a Python 3.6 conda env and doing pip install mne)? If so, we should report it to MNE, otherwise we can just restart the CI

@ntolley
Copy link
Contributor Author

ntolley commented Aug 25, 2021

Reproduces locally, just posted an issue: mne-tools/mne-python#9700

Copy link
Contributor

@rythorpe rythorpe left a comment

Choose a reason for hiding this comment

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

Aside from my two nitpicks above, this looks good to me!

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.

merge button is yours @rythorpe

@ntolley ntolley changed the title [MRG] Add probability arguments to drives API WIP: Add probability arguments to drives API Sep 5, 2021
delay=delays, lamtha=space_constant,
probability=probability,
conn_seed=drive['conn_seed'] + seed_increment)
# Ensure that AMPA/NMDA connections target the same gids
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@rythorpe I think this addresses your problem with enforcing shared connections with seeding. The connections for the same receptor are explicitly set to be equal to one another.

I additionally added seed_increment to make sure that there aren't weird structural dependencies for the random subsets. I see a PR in the future that takes care of all the seeding as we discussed previously (seeds drawn from a single RNG).

Copy link
Collaborator

Choose a reason for hiding this comment

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

perhaps raise an issue with crosslink here to not forget?

@ntolley ntolley changed the title WIP: Add probability arguments to drives API [MRG] Add probability arguments to drives API Sep 17, 2021
Comment on lines +845 to +900
if receptor_idx > 0:
self.connectivity[-1]['src_gids'] = \
self.connectivity[-2]['src_gids']
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 necessary given that conn_seed applies the same seed_increment for each receptor of a given cell type?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is actually the root of the problem we were discussing with respect to enforcing matching connections. While technically these would share the same connections when providing the same seed, it's not very transparent, so they are explicitly set equal here.

Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm, I think the root problem is addressed by explicitly implementing (with documentation) that random connections are assigned on a cell-by-cell basis rather than a synapse-by-synapse basis. This is perfectly implemented by setting the seed increment for each cell type in an outer loop and then establishing each receptor's connection in an inner loop. That said, maybe the explicit check is good for maintaining this established convention in the future....

@jasmainak
Copy link
Collaborator

@ntolley you need to rebase

@jasmainak
Copy link
Collaborator

@ntolley don't forget to update whats_new.rst !

@jasmainak
Copy link
Collaborator

@rythorpe I'm not available until Sunday due to coding sprint in another project. Merge button is yours!

@rythorpe rythorpe merged commit 1c2662c into jonescompneurolab:master Sep 22, 2021
@rythorpe
Copy link
Contributor

I'll definitely be using this feature in the near future. Thanks @ntolley!!

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.

warning for no connections in Network object
4 participants