Skip to content

Instantly share code, notes, and snippets.

@tjbanks
Created March 11, 2019 02:44
Show Gist options
  • Select an option

  • Save tjbanks/8228e341e33f65d641bccc6f187e0895 to your computer and use it in GitHub Desktop.

Select an option

Save tjbanks/8228e341e33f65d641bccc6f187e0895 to your computer and use it in GitHub Desktop.
Creating Recurrent Connections in BMTK
###########################################################
# Build connections
###########################################################
#Connect CA3o->CA3e Inhibitory
dynamics_file = 'CA3o2CA3e.inh.json'
conn = net.add_edges(source={'pop_name': 'CA3o'}, target={'pop_name': 'CA3e'},
connection_rule=hipp_dist_connector,
connection_params={'con_pattern':syn[dynamics_file]['con_pattern']},
syn_weight=5.0e-03,
dynamics_params=dynamics_file,
model_template=syn[dynamics_file]['level_of_detail'],
distance_range=[0.0, 300.0],
target_sections=['soma'],
delay=0.0)
conn.add_properties(['sec_id','sec_x'],rule=(0, 0.5), dtypes=[np.int32,np.float])
conn.add_properties('delay',
rule=syn_dist_delay,
rule_params={'base_delay':syn[dynamics_file]['delay']},
dtypes=np.float)
###########################################################
# Build recurrent connection rules
###########################################################
def hipp_recurrent_connector(source,target,all_edges=[],min_syn=1, max_syn=1):
"""
General logic:
1. Given a *potential* source and target
2. Look through all edges currently made
3. If any of the current edges contains
a. the current source as a previous target of
b. the current target as a prevous source
4. Return number of synapses per this connection, 0 otherwise (no connection)
"""
for e in all_edges:
if source['node_id'] == e.target_gid and target['node_id'] == e.source_gid:
return random.randint(min_syn,max_syn)
return 0
###########################################################
# Build recurrent connections
###########################################################
#Connect CA3e->CA3o Excitatory
dynamics_file = 'CA3e2CA3o.exc.json'
conn = net.add_edges(source={'pop_name': 'CA3e'}, target={'pop_name': 'CA3o'},
connection_rule=hipp_recurrent_connector,
connection_params={'all_edges':net.edges()},
syn_weight=5.0e-03,
dynamics_params=dynamics_file,
model_template=syn[dynamics_file]['level_of_detail'],
distance_range=[0.0, 300.0],
target_sections=['soma'],
delay=0.0)
conn.add_properties(['sec_id','sec_x'],rule=(0, 0.5), dtypes=[np.int32,np.float])
conn.add_properties('delay',
rule=syn_dist_delay,
rule_params={'base_delay':syn[dynamics_file]['delay'],'dist_delay':0.1}, #Connect.hoc:274 0.1 dist delay
dtypes=np.float)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment