-
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?
Changes from 13 commits
65bae58
14f24d3
8911ed3
f4b3f6e
9c06b59
878bc38
ace93d4
dbc20f7
94b8108
3cc0756
d46f2a5
05a3cf2
1fb51cc
d807c6c
2348421
1f9be74
cc6da02
bed5427
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -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): | ||||||
"""Returns the indexes of excitatory and inhibitory cells in the network. | ||||||
gtdang marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
|
||||||
This function extracts the source GIDs (Global Identifiers) of excitatory | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||||||
and inhibitory cells based on their connection types. Excitatory cells are | ||||||
identified by their synaptic connections using AMPA and NMDA receptors, | ||||||
while inhibitory cells are identified by their connections using GABAA and | ||||||
GABAB receptors. | ||||||
|
||||||
Parameters | ||||||
---------- | ||||||
net : Instance of Network object | ||||||
The Network object | ||||||
|
||||||
Returns | ||||||
------- | ||||||
tuple: A tuple containing two lists: | ||||||
- e_cells (list): The source GIDs of excitatory cells. | ||||||
- i_cells (list): The source GIDs of inhibitory cells. | ||||||
""" | ||||||
|
||||||
def list_src_gids(indices): | ||||||
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 commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
I like to use e_conns = [net.connectivity[p] for p in picks_e] so it's clear from the variable name that one is an element of |
||||||
e_cells = list_src_gids(e_conns) | ||||||
|
||||||
i_conns = pick_connection(net, receptor=['gabaa', 'gabab']) | ||||||
i_cells = list_src_gids(i_conns) | ||||||
|
||||||
return e_cells, i_cells | ||||||
|
||||||
|
||||||
class Network: | ||||||
"""The Network class. | ||||||
|
||||||
|
@@ -1427,8 +1461,8 @@ def add_electrode_array(self, name, electrode_pos, *, conductivity=0.3, | |||||
method=method, | ||||||
min_distance=min_distance)}) | ||||||
|
||||||
def update_weights(self, e_e=None, e_i=None, | ||||||
i_e=None, i_i=None, copy=False): | ||||||
def set_synaptic_gains(self, e_e=None, e_i=None, | ||||||
i_e=None, i_i=None, copy=False): | ||||||
"""Update synaptic weights of the network. | ||||||
|
||||||
Parameters | ||||||
|
@@ -1466,13 +1500,7 @@ def update_weights(self, e_e=None, e_i=None, | |||||
|
||||||
net = self.copy() if copy else self | ||||||
|
||||||
e_conns = pick_connection(self, receptor=['ampa', 'nmda']) | ||||||
e_cells = np.concatenate([list(net.connectivity[ | ||||||
conn_idx]['src_gids']) for conn_idx in e_conns]).tolist() | ||||||
|
||||||
i_conns = pick_connection(self, receptor=['gabaa', 'gabab']) | ||||||
i_cells = np.concatenate([list(net.connectivity[ | ||||||
conn_idx]['src_gids']) for conn_idx in i_conns]).tolist() | ||||||
e_cells, i_cells = _get_cell_index_by_synapse_type(net) | ||||||
conn_types = { | ||||||
'e_e': (e_e, e_cells, e_cells), | ||||||
'e_i': (e_i, e_cells, i_cells), | ||||||
|
@@ -1497,6 +1525,49 @@ def update_weights(self, e_e=None, e_i=None, | |||||
if copy: | ||||||
return net | ||||||
|
||||||
def get_synaptic_gains(self): | ||||||
"""Retrieve gain values for different connection types in the network. | ||||||
|
||||||
This function identifies excitatory and inhibitory cells in the network | ||||||
and retrieves the gain value for each type of synaptic connection: | ||||||
- excitatory to excitatory (e_e) | ||||||
- excitatory to inhibitory (e_i) | ||||||
- inhibitory to excitatory (i_e) | ||||||
- inhibitory to inhibitory (i_i) | ||||||
|
||||||
The gain is assumed to be uniform within each connection type, and only | ||||||
the first connection's gain value is used for each type. | ||||||
|
||||||
Returns | ||||||
------- | ||||||
dict: A dictionary with the connection types ('e_e', 'e_i', 'i_e', | ||||||
gtdang marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
'i_i') as keys and their corresponding gain values. | ||||||
""" | ||||||
values = {} | ||||||
e_cells, i_cells = _get_cell_index_by_synapse_type(self) | ||||||
|
||||||
# Define the connection types and source/target cell indexes | ||||||
conn_types = { | ||||||
'e_e': (e_cells, e_cells), | ||||||
'e_i': (e_cells, i_cells), | ||||||
'i_e': (i_cells, e_cells), | ||||||
'i_i': (i_cells, i_cells) | ||||||
} | ||||||
|
||||||
# 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 commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
just for sake of consistency |
||||||
conn_indices = pick_connection(self, | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
see above comment too ... would try to be consistent with naming |
||||||
src_gids=src_indexes, | ||||||
target_gids=target_indexes) | ||||||
|
||||||
if conn_indices: | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
to be explicit that There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||||||
# Extract the gain from the first connection | ||||||
values[conn_type] = ( | ||||||
self.connectivity[conn_indices[0]]['nc_dict']['gain'] | ||||||
) | ||||||
|
||||||
return values | ||||||
|
||||||
def plot_cells(self, ax=None, show=True): | ||||||
"""Plot the cells using Network.pos_dict. | ||||||
|
||||||
|
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.
missing docstring!