Skip to content

Instantly share code, notes, and snippets.

@jasmainak
Last active January 18, 2022 08:02
Show Gist options
  • Save jasmainak/15766c60001340c9eb699290b27bef32 to your computer and use it in GitHub Desktop.
Save jasmainak/15766c60001340c9eb699290b27bef32 to your computer and use it in GitHub Desktop.
from itertools import permutations
from hnn_core.network_models import calcium_model
from hnn_core import read_params
params = read_params('L_contra.param')
#code for manually adding drives
net_manual = calcium_model(params, add_drives_from_params=False)
# Add empty bursty drives
location = 'proximal'
burst_std = 20
weights_ampa_p = {'L2_pyramidal': 0, 'L5_pyramidal': 0}
syn_delays_p = {'L2_pyramidal': 0.1, 'L5_pyramidal': 1.}
net_manual.add_bursty_drive(
'bursty1', tstart=50., burst_rate=10, burst_std=burst_std, numspikes=2,
spike_isi=10, n_drive_cells=10, location=location,
weights_ampa=weights_ampa_p, synaptic_delays=syn_delays_p, event_seed=-14)
net_manual.add_bursty_drive(
'bursty2', tstart=50., burst_rate=10, burst_std=burst_std, numspikes=2,
spike_isi=10, n_drive_cells=10, location=location,
weights_ampa=weights_ampa_p, synaptic_delays=syn_delays_p, event_seed=-14)
# d1 drive
weights_ampa_d1 = {'L2_basket': 0.624131, 'L2_pyramidal': 0.606619, 'L5_pyramidal':0.25807}
weights_nmda_d1 = {'L2_basket': 0.95291, 'L2_pyramidal': 0.242383, 'L5_pyramidal': 0.156725}
synaptic_delays_d1 = {'L2_basket': 0.1, 'L2_pyramidal': 0.1, 'L5_pyramidal': 0.1}
net_manual.add_evoked_drive('evdist1', mu=82.9915, sigma=13.208408, numspikes=1,
weights_ampa=weights_ampa_d1,weights_nmda=weights_nmda_d1,
location='distal', synaptic_delays = synaptic_delays_d1, event_seed=-14)
# p1 drive
weights_ampa_p1 = {'L2_basket': 0.997291, 'L2_pyramidal':0.990722, 'L5_basket':0.614932, 'L5_pyramidal': 0.004153}
weights_nmda_p1 = {'L2_basket': 0.984337, 'L2_pyramidal':1.714247, 'L5_basket':0.061868, 'L5_pyramidal': 0.010042}
synaptic_delays_prox = {'L2_basket': 0.1, 'L2_pyramidal': 0.1,'L5_basket': 1., 'L5_pyramidal': 1.}
net_manual.add_evoked_drive('evprox1', mu=54.897936, sigma=5.401034, numspikes=1, weights_ampa=weights_ampa_p1, weights_nmda=weights_nmda_p1, location='proximal', synaptic_delays=synaptic_delays_prox, event_seed=-14)
# p2 drive
weights_ampa_p2 = {'L2_basket': 0.758537, 'L2_pyramidal': 0.854454, 'L5_basket': 0.979846, 'L5_pyramidal': 0.012483}
weights_nmda_p2 = {'L2_basket': 0.851444, 'L2_pyramidal':0.067491 , 'L5_basket': 0.901834, 'L5_pyramidal': 0.003818}
net_manual.add_evoked_drive('evprox2', mu=161.306837, sigma=19.843986, numspikes=1, weights_ampa=weights_ampa_p2,weights_nmda= weights_nmda_p2, location='proximal', event_seed=-14)
# Create network with permuted order of drives
# and check if they create same events
drive_permutations = permutations(net_manual.external_drives.keys())
for drive_permutation in list(drive_permutations)[:5]: # only try 5 permutations
print(f'permutation: {drive_permutation}')
net_permuted = net_manual.copy()
net_permuted.external_drives = dict()
for drive_name in drive_permutation:
net_permuted.external_drives[drive_name] = net_manual.external_drives[drive_name]
net_manual._instantiate_drives(tstop=40)
net_permuted._instantiate_drives(tstop=40)
for drive_name in net_manual.external_drives:
assert net_manual.external_drives[drive_name]['events'] == net_permuted.external_drives[drive_name]['events']
print('[passed]')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment