-
Notifications
You must be signed in to change notification settings - Fork 52
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] GUI synaptic gains implementation #918
base: master
Are you sure you want to change the base?
Conversation
…iguration to align with the tab name.
…nd updated gui.cell_parameters_widgets calls.
update_weights was too vague.
Did some initial simulation tests using the new tab, and the simulated changes do appear to have the expected effects. Still need to actually review both the code and the tests. |
Please see #915 for some discussion on planning this for the GUI. Also, @dylansdaniels had a great idea: Instead of creating a new I will try to add the per-connection |
Would that involve a change to the API to set per-connection gain? |
I don't think it would need a change to the API, since it should be analogous to changing |
Yes, but you don't want to be applying the gain and updating the weight there. The nc_dict has a gain parameter. The multiplication should be left to the Network at simulation runtime. |
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.
Looks good! Just left tiny nitpicks ... I didn't test though. I am hoping @dylansdaniels or @asoplata took care of that ;)
hnn_core/network.py
Outdated
def _get_cell_index_by_synapse_type(net): | ||
"""Returns the indexes of excitatory and inhibitory cells in the network. | ||
|
||
This function extracts the source GIDs (Global Identifiers) of excitatory |
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.
"Global Identifiers" isn't too descriptive either ... it's a bit of a misnomer since it's mainly a programming construct. I like to say "cell ID" to be clear.
hnn_core/network.py
Outdated
return np.concatenate([list(net.connectivity[conn_idx]['src_gids']) | ||
for conn_idx in indices]).tolist() | ||
|
||
e_conns = pick_connection(net, receptor=['ampa', 'nmda']) |
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.
e_conns = pick_connection(net, receptor=['ampa', 'nmda']) | |
picks_e = pick_connection(net, receptor=['ampa', 'nmda']) |
I like to use e_conn
after the indexing, i.e.:
e_conns = [net.connectivity[p] for p in picks_e]
so it's clear from the variable name that one is an element of net.connectivity
and the other is simply an index
hnn_core/network.py
Outdated
} | ||
|
||
# Retrieve the gain value for each connection type | ||
for conn_type, (src_indexes, target_indexes) in conn_types.items(): |
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.
for conn_type, (src_indexes, target_indexes) in conn_types.items(): | |
for conn_type, (src_idxs, target_idxs) in conn_types.items(): |
just for sake of consistency
hnn_core/network.py
Outdated
|
||
# Retrieve the gain value for each connection type | ||
for conn_type, (src_indexes, target_indexes) in conn_types.items(): | ||
conn_indices = pick_connection(self, |
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.
conn_indices = pick_connection(self, | |
picks = pick_connection(self, |
see above comment too ... would try to be consistent with naming
hnn_core/network.py
Outdated
src_gids=src_indexes, | ||
target_gids=target_indexes) | ||
|
||
if conn_indices: |
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 conn_indices: | |
if len(picks) > 0: |
to be explicit that picks
is a list, not a bool
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 think using the truthyness of collections is more concise and pythonic. If we really wanted to be explicit we could also name the variable "picks_list".
But I'll open it up to the rest of the group to define a style guide. @ntolley @asoplata @dylansdaniels
Co-authored-by: Mainak Jas <[email protected]>
Co-authored-by: Mainak Jas <[email protected]>
@@ -299,6 +299,40 @@ def pick_connection(net, src_gids=None, target_gids=None, | |||
return sorted(conn_set) | |||
|
|||
|
|||
def _get_cell_index_by_synapse_type(net): |
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.
Is there a reason to put this outside of the Network
class as a standalone function if it requires an existing Network
?
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.
my general rule is to keep methods of a class minimal, so the structure of the class/object is clear. Just because it takes the object as input doesn't mean it should be a method. The method should have an explicit purpose. For example:
ica = ICA()
ica.fit(X)
y = ica.predict(X)
once something becomes a method, it's very hard to disentangle it from the class
This looks good, but @dylansdaniels and I have separately discussed that we would like to move these gain settings from their own subtab to the top of |
Added synaptic gains widgets to the GUI.
Changes:
Network
class methods2. Renamed
update_weights
method toset_synaptic_gains
for more clarity3. Added
get_synaptic_gains
method and test_init_network_from_widgets
function to update synaptic gains