Example #1
0
def build_hippocampus():

    net = NetworkBuilder('CA3')
    net.add_nodes(N=1,
                  pop_name='CA3e',
                  model_type='biophysical',
                  model_template='hoc:Spikingcell',
                  morphology='blank.swc')

    inputnet = NetworkBuilder('input')
    inputnet.add_nodes(N=1, model_type='virtual', pat='pat1', pop_name='virt')
    conn = inputnet.add_edges(
        target=net.nodes(pop_name='CA3e'),
        source={'pat': 'pat1'},
        connection_rule=1,
        dynamics_params='stsp.json',
        model_template='Exp2Syn1_STSP',
        delay=0,
        syn_weight=.5,
        target_sections=['soma'],  # target soma
        distance_range=[0.0, 300])
    conn.add_properties(['sec_id', 'sec_x'],
                        rule=(0, 0.9),
                        dtypes=[np.int32, np.float])

    net.build()
    net.save_nodes(output_dir='network')
    net.save_edges(output_dir='network')

    inputnet.build()
    inputnet.save(output_dir='network')
Example #2
0
def build_net():
    net = NetworkBuilder("slice")
    net.add_nodes(
        N=5,
        pop_name='Scnn1a',
        synapse_model='a',
        firing_rate=firing_rate,
        model_type='biophysical',
        model_template='ctdb:Biophys1.hoc',
        dynamics_params='472363762_fit.json',
        morphology='Scnn1a-Tg3-Cre_Ai14_IVSCC_-177300.01.02.01_473845048_m.swc',
        rotation_angle_zaxis=-3.646878266,
        model_processing='aibs_perisomatic,extracellular')

    net.add_nodes(
        N=5,
        pop_name='Scnn1a',
        synapse_model='b',
        firing_rate=firing_rate,
        model_type='biophysical',
        model_template='ctdb:Biophys1.hoc',
        model_processing='aibs_perisomatic,extracellular',
        dynamics_params='472363762_fit.json',
        morphology='Scnn1a-Tg3-Cre_Ai14_IVSCC_-177300.01.02.01_473845048_m.swc',
        rotation_angle_zaxis=-3.646878266)

    net.build()
    net.save_nodes(nodes_file_name='network/slice_nodes.h5',
                   node_types_file_name='network/slice_node_types.csv')

    return net
Example #3
0
def build_sim():
    from bmtk.builder.networks import NetworkBuilder

    # My all active-model (does not work):
    #Model ID 496497595
    #Cell ID 487667205

    # Other perisomatic model (available on Allen Brain Institute - CellTypes):
    #Model ID 491623973
    #Cell  ID 490387590

    print('BMTK import success')
    net = NetworkBuilder('mcortex')
    print('Network builder initiated')
    # Testing other models: # Surprise, surprise, this does not work...
    net.add_nodes(cell_name='Pvalb_490387590_m',
                  model_type='biophysical',
                  model_template='ctdb:Biophys1.hoc',
                  model_processing='aibs_perisomatic',
                  dynamics_params='491623973_fit.json',
                  morphology='Pvalb_490387590_m.swc')
    ''' # Standard
    net.add_nodes(cell_name='Scnn1a_473845048',
                  potental='exc',
                  model_type='biophysical',
                  model_template='ctdb:Biophys1.hoc',
                  model_processing='aibs_perisomatic',
                  dynamics_params='472363762_fit.json',
                  morphology='Scnn1a_473845048_m.swc')
    '''
    print('Node added')

    net.build()
    net.save_nodes(output_dir='network')
    for node in net.nodes():
        print(node)
    print('Node printed')

    from bmtk.utils.sim_setup import build_env_bionet
    print('Setting environment')

    build_env_bionet(
        base_dir='sim_ch01',  # Where to save the scripts and config files
        network_dir='network',  # Location of directory containing network files
        tstop=1200.0,
        dt=0.1,  # Run a simulation for 2000 ms at 0.1 ms intervals
        report_vars=[
            'v'
        ],  # Tells simulator we want to record membrane potential and calcium traces
        current_clamp={  # Creates a step current from 500.ms to 1500.0 ms
            'amp': 0.61,  # 0.12#0.610
            'delay': 100.0,  # 100, #500
            'duration': 1000.0
        },
        include_examples=True,  # Copies components files
        compile_mechanisms=True  # Will try to compile NEURON mechanisms
    )
    print('Build done')
Example #4
0
def build_tw():
    if not os.path.exists('output'):
        os.makedirs('output')

    TW = NetworkBuilder("TW")
    TW.add_nodes(N=3000, pop_name='TW', ei='e', location='TW', level_of_detail='filter')

    # Save cells.csv and cell_types.csv
    TW.save_nodes(nodes_file_name='output/tw_nodes.h5', node_types_file_name='output/tw_node_types.csv')

    VL4 = NetworkBuilder('V1/L4')
    VL4.import_nodes(nodes_file_name='output/v1_nodes.h5', node_types_file_name='output/v1_node_types.csv')
    VL4.add_edges(source=TW.nodes(), target={'pop_name': 'Rorb'},
                  connection_rule=lambda trg, src: 5,
                  **({'weight_max': 0.00015, 'weight_function': 'wmax', 'distance_range': [30.0, 150.0],
                      'target_sections': ['basal', 'apical'], 'delay': 2.0, 'params_file': 'AMPA_ExcToExc.json',
                      'set_params_function': 'exp2syn'}))

    VL4.add_edges(source=TW.nodes(), target={'pop_name': 'Scnn1a'},
                  connection_rule=lambda trg, src: 5,
                  **({'weight_max': 0.00019, 'weight_function': 'wmax', 'distance_range': [30.0, 150.0],
                      'target_sections': ['basal', 'apical'], 'delay': 2.0, 'params_file': 'AMPA_ExcToExc.json',
                      'set_params_function': 'exp2syn'}))

    VL4.add_edges(source=TW.nodes(), target={'pop_name': 'Nr5a1'},
                  connection_rule=lambda trg, src: 5,
                  **({'weight_max': 0.00019, 'weight_function': 'wmax', 'distance_range': [30.0, 150.0],
                      'target_sections': ['basal', 'apical'], 'delay': 2.0, 'params_file': 'AMPA_ExcToExc.json',
                      'set_params_function': 'exp2syn'}))

    VL4.add_edges(source=TW.nodes(), target={'pop_name': 'PV1'},
                  connection_rule=lambda trg, src: 5,
                  **({'weight_max': 0.0022, 'weight_function': 'wmax', 'distance_range': [0.0, 1.0e+20],
                      'target_sections': ['somatic', 'basal'], 'delay': 2.0, 'params_file': 'AMPA_ExcToInh.json',
                      'set_params_function': 'exp2syn'}))

    VL4.add_edges(source=TW.nodes(), target={'pop_name': 'PV2'},
                  connection_rule=lambda trg, src: 5,
                  **({'weight_max': 0.0013, 'weight_function': 'wmax', 'distance_range': [0.0, 1.0e+20],
                      'target_sections': ['somatic', 'basal'], 'delay': 2.0, 'params_file': 'AMPA_ExcToInh.json',
                      'set_params_function': 'exp2syn'}))

    VL4.add_edges(source=TW.nodes(), target={'pop_name': 'LIF_exc'},
                  connection_rule=lambda trg, src: 5,
                  **({'weight_max': 0.015, 'weight_function': 'wmax', 'delay': 2.0,
                      'params_file': 'instanteneousExc.json', 'set_params_function': 'exp2syn'}))

    VL4.add_edges(source=TW.nodes(), target={'pop_name': 'LIF_inh'},
                  connection_rule=lambda trg, src: 5,
                  **({'weight_max': 0.05, 'weight_function': 'wmax', 'delay': 2.0,
                      'params_file': 'instanteneousExc.json', 'set_params_function': 'exp2syn'}))

    VL4.build()
    VL4.save_edges(edges_file_name='output/tw_v1_edges.h5', edge_types_file_name='output/tw_v1_edge_types.csv')
Example #5
0
def build_l4():
    net = NetworkBuilder("V1/L4")
    net.add_nodes(N=1, pop_name='DG_GC', node_type_id=478230220,
                  positions=[(28.753, -364.868, -161.705)],
                  #tuning_angle=[0.0, 25.0],
                  rotation_angle_yaxis=[3.55501],
                  #location='VisL4',
                  ei='e',
                  level_of_detail='biophysical',
                  params_file='478230220.json',
                  morphology_file='478230220.swc',
                  rotation_angle_zaxis=-3.646878266,
                  set_params_function='Biophys1')

    net.build()
    net.save_nodes(nodes_file_name='output/v1_nodes.h5', node_types_file_name='output/v1_node_types.csv')
  #  net.save_edges(edges_file_name='output/v1_v1_edges.h5', edge_types_file_name='output/v1_v1_edge_types.csv')

    return net
Example #6
0
                   syn_weight=20.0e-03,
                   target_sections=['somatic'],
                   delay=2.0,
                   distance_range=[0.0, 300.0],
                   dynamics_params='AMPA_ExcToExc.json',
                   model_template='Exp2Syn')

####################################################################################
########################## Build and save network ##################################
####################################################################################

print("\nBuilding network and saving to directory \"" + output_dir + "\"")
net.build()
Blad_aff_virt.build()
EUS_aff_virt.build()
PAG_aff_virt.build()

net.save_nodes(output_dir=output_dir)
net.save_edges(output_dir=output_dir)

Blad_aff_virt.save_nodes(output_dir=output_dir)
Blad_aff_virt.save_edges(output_dir=output_dir)

EUS_aff_virt.save_nodes(output_dir=output_dir)
EUS_aff_virt.save_edges(output_dir=output_dir)

PAG_aff_virt.save_nodes(output_dir=output_dir)
PAG_aff_virt.save_edges(output_dir=output_dir)

print("Done")
Example #7
0
            

                        
net1.add_edges(source={'cell_name': 'HCOCell1'}, target={'cell_name':'HCOCell2'},
              connection_rule=1,
              syn_weight=40.0e-02,
              dynamics_params='GABA_InhToInh.json',
              model_template='Exp2Syn',
              delay=0.0,
              target_sections=["soma"],
              distance_range=[0,999])
              
net1.add_edges(source={'cell_name': 'HCOCell2'}, target={'cell_name':'HCOCell1'},
              connection_rule=1,
              syn_weight=40.0e-02,
              dynamics_params='GABA_InhToInh.json',
              model_template='Exp2Syn',
              delay=0.0,
              target_sections=["soma"],
              distance_range=[0,999])

net1.build()
net1.save_nodes(output_dir='network')             
              
net1.build()
net1.save_edges(output_dir='network')


#from bmtk.analyzer import node_types_table
#node_types_table(node_types_file='network/mcortex_node_types.csv', population='mcortex')
Example #8
0
from bmtk.builder.networks import NetworkBuilder

cortex = NetworkBuilder('mcortex')
cortex.add_nodes(cell_name='Scnn1a',
                 potental='exc',
                 level_of_detail='biophysical',
                 params_file='472363762_fit.json',
                 morphology_file='Scnn1a.swc',
                 set_params_function='Biophys1')

cortex.build()
cortex.save_nodes(output_dir='network')

thalamus = NetworkBuilder('mthalamus')
thalamus.add_nodes(N=10,
                   pop_name='tON',
                   potential='exc',
                   level_of_detail='filter')

thalamus.add_edges(source={'pop_name': 'tON'},
                   target=cortex.nodes(),
                   connection_rule=5,
                   weight_max=5e-05,
                   weight_function='wmax',
                   distance_range=[0.0, 150.0],
                   target_sections=['basal', 'apical'],
                   delay=2.0,
                   params_file='AMPA_ExcToExc.json',
                   set_params_function='exp2syn')

thalamus.build()
Example #9
0
              syn_weight=15.0,
              delay=2.0,
              dynamics_params='ExcToInh.json',
              model_template='static_synapse')


net.add_edges(source={'ei': 'e'}, target={'pop_name': 'LIF_inh'},
              connection_rule=distance_connector,
              connection_params={'d_weight_min': 0.0, 'd_weight_max': 0.26, 'd_max': 300.0, 'nsyn_min': 3, 'nsyn_max': 7},
              syn_weight=5.0,
              delay=2.0,
              dynamics_params='instanteneousExc.json',
              model_template='static_synapse')

net.build()
net.save_nodes(output_dir='network')
net.save_edges(output_dir='network')



lgn = NetworkBuilder('LGN')
lgn.add_nodes(N=500,
              pop_name='tON',
              potential='exc',
              model_type='virtual')


def select_source_cells(sources, target, nsources_min=10, nsources_max=30, nsyns_min=3, nsyns_max=12):
    total_sources = len(sources)
    nsources = np.random.randint(nsources_min, nsources_max)
    selected_sources = np.random.choice(total_sources, nsources, replace=False)
Example #10
0
    positions = positions_table[model_name]
    xcoords += [p[0] for p in positions]
    ycoords += [p[1] for p in positions]
    tuning_angles = [calc_tuning_angle(o) for o in offset_table[model_name]]

    lgn_net.add_nodes(model_params['N'],
                      position=positions,
                      tuning_angle=tuning_angles,
                      ei=model_params['ei'],
                      location=model_params['location'],
                      level_of_detail=model_params['level_of_detail'],
                      pop_name=model_params['pop_name'],
                      pop_id=model_params['pop_id'])

lgn_net.build()
lgn_net.save_nodes('lgn_nodes.h5', 'lgn_node_types.csv')
exit()

v1_net = NetworkBuilder('V1')
v1_net.import_nodes('v1_nodes.h5', 'v1_node_types.csv')

lgn_mean = (np.mean(xcoords), np.mean(ycoords))
lgn_dim = (140.0, 70.0)
print "> LGN mean center:"

# Determine the mean center of the CC cells
xcoords = [n['position'][0] for n in v1_net.nodes()]
ycoords = [n['position'][1] for n in v1_net.nodes()]
zcoords = [n['position'][2] for n in v1_net.nodes()]
l4_mean = (np.mean(xcoords), np.mean(ycoords), np.mean(zcoords))
l4_dim = (max(xcoords) - min(xcoords), max(ycoords) - min(ycoords),
Example #11
0
              target_sections=['basal', 'apical'],
              delay=2.0,
              params_file='AMPA_ExcToExc.json',
              set_params_function='exp2syn')

net.add_edges(sources={'ei': 'e'}, targets={'name': 'Nr5a1'},
              func=distance_tuning_connection_handler,
              func_params=cparameters,
              weight_max=7.2e-05,
              weight_function='gaussianLL',
              weight_sigma=50.0,
              distance_range=[30.0, 150.0],
              target_sections=['basal', 'apical'],
              delay=2.0,
              params_file='AMPA_ExcToExc.json',
              set_params_function='exp2syn')

net.add_edges(sources={'ei': 'e'}, targets={'name': 'LIF_exc'},
              func=distance_tuning_connection_handler,
              func_params=cparameters,
              weight_max=0.0019,
              weight_function='gaussianLL',
              weight_sigma=50.0,
              delay=2.0,
              params_file='instanteneousExc.json',
              set_params_function='exp2syn')

net.build()
net.save_nodes('v1_nodes.h5', 'v1_node_types.csv')
net.save_edges('v1_edges.h5', 'v1_edge_types.csv')
Example #12
0
def build_lgn():
    def generate_positions(N, x0=0.0, x1=300.0, y0=0.0, y1=100.0):
        X = np.random.uniform(x0, x1, N)
        Y = np.random.uniform(y0, y1, N)
        return np.column_stack((X, Y))

    def select_source_cells(src_cell, trg_cell, n_syns_exc, n_syns_inh):
        #if trg_cell['tuning_angle'] is not None:
        #    synapses = [n_syns if src['pop_name'] == 'tON' or src['pop_name'] == 'tOFF' else 0 for src in src_cells]
        #else:
        #    synapses = [n_syns if src['pop_name'] == 'tONOFF' else 0 for src in src_cells]

        # will always give synapse number depending on type
        if n_syns_exc > 0:
            n_synapses = n_syns_exc
        if n_syns_inh > 0:
            n_synapses = n_syns_inh

        return n_synapses

        # varible number of synapses
        #return np.random.randint(n_syns_min, n_syns_max)
        #return synapses

    if not os.path.exists('output'):
        os.makedirs('output')

    LGN = NetworkBuilder("LGN")
    LGN.add_nodes(N=1000,
                  positions=generate_positions(1000),
                  location='LGN',
                  level_of_detail='filter',
                  pop_name='ExcIN',
                  ei='e')

    LGN.add_nodes(N=1,
                  positions=generate_positions(1),
                  location='LGN',
                  level_of_detail='filter',
                  pop_name='InhIN',
                  ei='i')
  


    VL4 = NetworkBuilder('V1/L4')
    VL4.import_nodes(nodes_file_name='output/v1_nodes.h5', node_types_file_name='output/v1_node_types.csv')
    cm = VL4.add_edges(source=LGN.nodes(ei='e'), #target={'pop_name': 'DG_GC'},
                  connection_rule=select_source_cells,
                  connection_params={'n_syns_exc': 1, 'n_syns_inh': 0},
                  weight_max=10e-03,
                  weight_function='wmax',
                  distance_range=[1, 1e+20],
                  target_sections=['apical'],
                  delay=2.0,
                  params_file='AMPA_ExcToExc.json',
                  set_params_function='exp2syn')



    VL4.build()
    LGN.save_nodes(nodes_file_name='output/lgn_nodes.h5', node_types_file_name='output/lgn_node_types.csv')
    VL4.save_edges(edges_file_name='output/lgn_v1_edges.h5', edge_types_file_name='output/lgn_v1_edge_types.csv')
Example #13
0
def build_lgn():
    def generate_positions(N, x0=0.0, x1=300.0, y0=0.0, y1=100.0):
        X = np.random.uniform(x0, x1, N)
        Y = np.random.uniform(y0, y1, N)
        return np.column_stack((X, Y))

    def select_source_cells(src_cells, trg_cell, n_syns):
        if trg_cell['tuning_angle'] is not None:
            synapses = [n_syns if src['pop_name'] == 'tON' or src['pop_name'] == 'tOFF' else 0 for src in src_cells]
        else:
            synapses = [n_syns if src['pop_name'] == 'tONOFF' else 0 for src in src_cells]

        return synapses

    if not os.path.exists('output'):
        os.makedirs('output')

    LGN = NetworkBuilder("LGN")
    LGN.add_nodes(N=3000,
                  positions=generate_positions(3000),
                  location='LGN',
                  level_of_detail='filter',
                  pop_name='tON',
                  ei='e')

    LGN.add_nodes(N=3000,
                  positions=generate_positions(3000),
                  location='LGN',
                  level_of_detail='filter',
                  pop_name='tOFF',
                  ei='e')

    LGN.add_nodes(N=3000,
                  positions=generate_positions(3000),
                  location='LGN',
                  level_of_detail='filter',
                  pop_name='tONOFF',
                  ei='e')

    VL4 = NetworkBuilder('V1/L4')
    VL4.import_nodes(nodes_file_name='output/v1_nodes.h5', node_types_file_name='output/v1_node_types.csv')
    VL4.add_edges(source=LGN.nodes(), target={'pop_name': 'Rorb'},
                  iterator='all_to_one',
                  connection_rule=select_source_cells,
                  connection_params={'n_syns': 10},
                  weight_max=5e-05,
                  weight_function='wmax',
                  distance_range=[0.0, 150.0],
                  target_sections=['basal', 'apical'],
                  delay=2.0,
                  params_file='AMPA_ExcToExc.json',
                  set_params_function='exp2syn')

    VL4.add_edges(source=LGN.nodes(), target={'pop_name': 'Nr5a1'},
                  iterator='all_to_one',
                  connection_rule=select_source_cells,
                  connection_params={'n_syns': 10},
                  weight_max=5e-05,
                  weight_function='wmax',
                  distance_range=[0.0, 150.0],
                  target_sections=['basal', 'apical'],
                  delay=2.0,
                  params_file='AMPA_ExcToExc.json',
                  set_params_function='exp2syn')

    VL4.add_edges(source=LGN.nodes(), target={'pop_name': 'Scnn1a'},
                  iterator='all_to_one',
                  connection_rule=select_source_cells,
                  connection_params={'n_syns': 10},
                  weight_max=4e-05,
                  weight_function='wmax',
                  distance_range=[0.0, 150.0],
                  target_sections=['basal', 'apical'],
                  delay=2.0,
                  params_file='AMPA_ExcToExc.json',
                  set_params_function='exp2syn')

    VL4.add_edges(source=LGN.nodes(), target={'pop_name': 'PV1'},
                  iterator='all_to_one',
                  connection_rule=select_source_cells,
                  connection_params={'n_syns': 10},
                  weight_max=0.0001,
                  weight_function='wmax',
                  distance_range=[0.0, 1.0e+20],
                  target_sections=['somatic', 'basal'],
                  delay=2.0,
                  params_file='AMPA_ExcToInh.json',
                  set_params_function='exp2syn')

    VL4.add_edges(source=LGN.nodes(), target={'pop_name': 'PV2'},
                  iterator='all_to_one',
                  connection_rule=select_source_cells,
                  connection_params={'n_syns': 10},
                  weight_max=9e-05,
                  weight_function='wmax',
                  distance_range=[0.0, 1.0e+20],
                  target_sections=['somatic', 'basal'],
                  delay=2.0,
                  params_file='AMPA_ExcToInh.json',
                  set_params_function='exp2syn')

    VL4.add_edges(source=LGN.nodes(), target={'pop_name': 'LIF_exc'},
                  iterator='all_to_one',
                  connection_rule=select_source_cells,
                  connection_params={'n_syns': 10},
                  weight_max=0.0045,
                  weight_function='wmax',
                  delay=2.0,
                  params_file='instanteneousExc.json',
                  set_params_function='exp2syn')

    VL4.add_edges(source=LGN.nodes(), target={'pop_name': 'LIF_inh'},
                  iterator='all_to_one',
                  connection_rule=select_source_cells,
                  connection_params={'n_syns': 10},
                  weight_max=0.002,
                  weight_function='wmax',
                  delay=2.0,
                  params_file='instanteneousExc.json',
                  set_params_function='exp2syn')

    VL4.build()
    LGN.save_nodes(nodes_file_name='output/lgn_nodes.h5', node_types_file_name='output/lgn_node_types.csv')
    VL4.save_edges(edges_file_name='output/lgn_v1_edges.h5', edge_types_file_name='output/lgn_v1_edge_types.csv')

    assert(os.path.exists('output/lgn_node_types.csv'))
    node_types_csv = pd.read_csv('output/lgn_node_types.csv', sep=' ')
    assert(len(node_types_csv) == 3)
    assert(set(node_types_csv.columns) == {'node_type_id', 'location', 'ei', 'level_of_detail', 'pop_name'})


    assert(os.path.exists('output/lgn_nodes.h5'))
    nodes_h5 = h5py.File('output/lgn_nodes.h5')
    assert(len(nodes_h5['/nodes/node_gid']) == 9000)
    assert(len(nodes_h5['/nodes/node_type_id']) == 9000)
    assert(len(nodes_h5['/nodes/node_group']) == 9000)
    assert(len(nodes_h5['/nodes/node_group_index']) == 9000)
    assert(set(nodes_h5['/nodes/0'].keys()) == {'positions'})
    assert(len(nodes_h5['/nodes/0/positions']) == 9000)

    assert(os.path.exists('output/lgn_v1_edge_types.csv'))
    edge_types_csv = pd.read_csv('output/lgn_v1_edge_types.csv', sep=' ')
    assert(len(edge_types_csv) == 7)
    assert(set(edge_types_csv.columns) == {'weight_max', 'edge_type_id', 'target_query', 'params_file',
                                           'set_params_function', 'delay', 'target_sections', 'weight_function',
                                           'source_query', 'distance_range'})

    assert(os.path.exists('output/lgn_v1_edges.h5'))
    edges_h5 = h5py.File('output/lgn_v1_edges.h5')
    assert(len(edges_h5['/edges/index_pointer']) == 14+1)
    assert(len(edges_h5['/edges/target_gid']) == 6000*14)
    assert(len(edges_h5['/edges/source_gid']) == 6000*14)
    assert(len(edges_h5['/edges/0/nsyns']) == 6000*14)
Example #14
0
def build_l4():
    net = NetworkBuilder("V1/L4")
    net.add_nodes(N=2, pop_name='Scnn1a',
                  positions=[(28.753, -364.868, -161.705), (48.753, -344.868, -141.705)],
                  tuning_angle=[0.0, 25.0],
                  rotation_angle_yaxis=[3.55501, 3.55501],
                  location='VisL4',
                  ei='e',
                  level_of_detail='biophysical',
                  params_file='472363762_fit.json',
                  morphology_file='Scnn1a-Tg3-Cre_Ai14_IVSCC_-177300.01.02.01_473845048_m.swc',
                  rotation_angle_zaxis=-3.646878266,
                  set_params_function='Biophys1')

    net.add_nodes(N=2, pop_name='Rorb',
                  positions=[(241.092, -349.263, 146.916), (201.092, -399.263, 126.916)],
                  tuning_angle=[50.0, 75.0],
                  rotation_angle_yaxis=[3.50934, 3.50934],
                  location='VisL4',
                  ei='e',
                  level_of_detail='biophysical',
                  params_file='473863510_fit.json',
                  morphology_file='Rorb-IRES2-Cre-D_Ai14_IVSCC_-168053.05.01.01_325404214_m.swc',
                  rotation_angle_zaxis=-4.159763785,
                  set_params_function='Biophys1')

    net.add_nodes(N=2, pop_name='Nr5a1',
                  positions=[(320.498, -351.259, 20.273), (310.498, -371.259, 10.273)],
                  tuning_angle=[100.0, 125.0],
                  rotation_angle_yaxis=[0.72202, 0.72202],
                  location='VisL4',
                  ei='e',
                  level_of_detail='biophysical',
                  params_file='473863035_fit.json',
                  morphology_file='Nr5a1-Cre_Ai14_IVSCC_-169250.03.02.01_471087815_m.swc',
                  rotation_angle_zaxis=-2.639275277,
                  set_params_function='Biophys1')

    net.add_nodes(N=2, pop_name='PV1',
                  positions=[(122.373, -352.417, -216.748), (102.373, -342.417, -206.748)],
                  tuning_angle=['NA', 'NA'],
                  rotation_angle_yaxis=[2.92043, 2.92043],
                  location='VisL4',
                  ei='i',
                  level_of_detail='biophysical',
                  params_file='472912177_fit.json',
                  morphology_file='Pvalb-IRES-Cre_Ai14_IVSCC_-176847.04.02.01_470522102_m.swc',
                  rotation_angle_zaxis=-2.539551891,
                  set_params_function='Biophys1')

    net.add_nodes(N=2, pop_name='PV2',
                  positions=[(350.321, -372.535, -18.282), (360.321, -371.535, -12.282)],
                  tuning_angle=['NA', 'NA'],
                  rotation_angle_yaxis=[5.043336, 5.043336],
                  location='VisL4',
                  ei='i',
                  level_of_detail='biophysical',
                  params_file='473862421_fit.json',
                  morphology_file='Pvalb-IRES-Cre_Ai14_IVSCC_-169125.03.01.01_469628681_m.swc',
                  rotation_angle_zaxis=-3.684439949,
                  set_params_function='Biophys1')

    net.add_nodes(N=2, pop_name='LIF_exc',
                  positions=[(-243.04, -342.352, -665.666), (-233.04, -332.352, -675.666)],
                  tuning_angle=['NA', 'NA'],
                  #rotation_angle_yaxis=[5.11801, 5.11801],
                  location='VisL4',
                  ei='e',
                  level_of_detail='intfire',
                  params_file='IntFire1_exc_1.json',
                  set_params_function='IntFire1')

    net.add_nodes(N=2, pop_name='LIF_inh',
                  positions=[(211.04, -321.333, -631.593), (218.04, -327.333, -635.593)],
                  tuning_angle=[150.0, 175.0],
                  #rotation_angle_yaxis=[4.566091, 4.566091],
                  location='VisL4',
                  ei='i',
                  level_of_detail='intfire',
                  params_file='IntFire1_inh_1.json',
                  set_params_function='IntFire1')

    print("Setting connections...")
    print("Generating I-to-I connections.")
    net.add_edges(source={'ei': 'i'}, target={'ei': 'i', 'level_of_detail': 'biophysical'},
                  connection_rule=5,
                  weight_max=0.0002,
                  weight_function='wmax',
                  distance_range=[0.0, 1e+20],
                  target_sections=['somatic', 'basal'],
                  delay=2.0,
                  params_file='GABA_InhToInh.json',
                  set_params_function='exp2syn')

    net.add_edges(source={'ei': 'i'}, target={'ei': 'i', 'level_of_detail': 'intfire'},
                  connection_rule=5,
                  weight_max=0.00225,
                  weight_function='wmax',
                  delay=2.0,
                  params_file='instanteneousInh.json',
                  set_params_function='exp2syn')

    print("Generating I-to-E connections.")
    net.add_edges(source={'ei': 'i'}, target={'ei': 'e', 'level_of_detail': 'biophysical'},
                  connection_rule=lambda trg, src: 5,
                  weight_max=0.00018,
                  weight_function='wmax',
                  distance_range=[0.0, 50.0],
                  target_sections=['somatic', 'basal', 'apical'],
                  delay=2.0,
                  params_file='GABA_InhToExc.json',
                  set_params_function='exp2syn')

    net.add_edges(source={'ei': 'i'}, target={'ei': 'e', 'level_of_detail': 'intfire'},
                  connection_rule=5,
                  weight_max=0.009,
                  weight_function='wmax',
                  delay=2.0,
                  params_file='instanteneousInh.json',
                  set_params_function='exp2syn')

    print("Generating E-to-I connections.")
    net.add_edges(source={'ei': 'e'}, target={'pop_name': 'PV1'},
                  connection_rule=5,
                  weight_max=0.00035,
                  weight_function='wmax',
                  distance_range=[0.0, 1e+20],
                  target_sections=['somatic', 'basal'],
                  delay=2.0,
                  params_file='AMPA_ExcToInh.json',
                  set_params_function='exp2syn')

    net.add_edges(source={'ei': 'e'}, target={'pop_name': 'PV2'},
                  connection_rule=5,
                  weight_max=0.00027,
                  weight_function='wmax',
                  distance_range=[0.0, 1e+20],
                  target_sections=['somatic', 'basal'],
                  delay=2.0,
                  params_file='AMPA_ExcToInh.json',
                  set_params_function='exp2syn')

    net.add_edges(source={'ei': 'e'}, target={'pop_name': 'LIF_inh'},
                  connection_rule=5,
                  weight_max=0.0043,
                  weight_function='wmax',
                  delay=2.0,
                  params_file='instanteneousExc.json',
                  set_params_function='exp2syn')

    print("Generating E-to-E connections.")
    net.add_edges(source={'ei': 'e'}, target={'pop_name': 'Scnn1a'},
                  connection_rule=5,
                  weight_max=6.4e-05,
                  weight_function='gaussianLL',
                  weight_sigma=50.0,
                  distance_range=[30.0, 150.0],
                  target_sections=['basal', 'apical'],
                  delay=2.0,
                  params_file='AMPA_ExcToExc.json',
                  set_params_function='exp2syn')

    net.add_edges(source={'ei': 'e'}, target={'pop_name': 'Rorb'},
                  connection_rule=5,
                  weight_max=5.5e-05,
                  weight_function='gaussianLL',
                  weight_sigma=50.0,
                  distance_range=[30.0, 150.0],
                  target_sections=['basal', 'apical'],
                  delay=2.0,
                  params_file='AMPA_ExcToExc.json',
                  set_params_function='exp2syn')

    net.add_edges(source={'ei': 'e'}, target={'pop_name': 'Nr5a1'},
                  connection_rule=5,
                  weight_max=7.2e-05,
                  weight_function='gaussianLL',
                  weight_sigma=50.0,
                  distance_range=[30.0, 150.0],
                  target_sections=['basal', 'apical'],
                  delay=2.0,
                  params_file='AMPA_ExcToExc.json',
                  set_params_function='exp2syn')

    net.add_edges(source={'ei': 'e'}, target={'pop_name': 'LIF_exc'},
                  connection_rule=5,
                  weight_max=0.0019,
                  weight_function='gaussianLL',
                  weight_sigma=50.0,
                  delay=2.0,
                  params_file='instanteneousExc.json',
                  set_params_function='exp2syn')


    net.build()
    net.save_nodes(nodes_file_name='output/v1_nodes.h5', node_types_file_name='output/v1_node_types.csv')
    net.save_edges(edges_file_name='output/v1_v1_edges.h5', edge_types_file_name='output/v1_v1_edge_types.csv')

    assert(os.path.exists('output/v1_node_types.csv'))
    node_types_csv = pd.read_csv('output/v1_node_types.csv', sep=' ')
    assert(len(node_types_csv) == 7)
    assert(set(node_types_csv.columns) == {'node_type_id', 'location', 'ei', 'level_of_detail', 'params_file',
                                           'pop_name', 'set_params_function', 'rotation_angle_zaxis',
                                           'morphology_file'})

    assert(os.path.exists('output/v1_nodes.h5'))
    nodes_h5 = h5py.File('output/v1_nodes.h5')
    assert(len(nodes_h5['/nodes/node_gid']) == 14)
    assert(len(nodes_h5['/nodes/node_type_id']) == 14)
    assert(len(nodes_h5['/nodes/node_group']) == 14)
    assert(len(nodes_h5['/nodes/node_group_index']) == 14)
    assert(set(nodes_h5['/nodes/0'].keys()) == {'positions', 'rotation_angle_yaxis', 'tuning_angle'})
    assert(len(nodes_h5['/nodes/0/positions']) == 10)
    assert(len(nodes_h5['/nodes/1/positions']) == 4)

    assert(os.path.exists('output/v1_v1_edge_types.csv'))
    edge_types_csv = pd.read_csv('output/v1_v1_edge_types.csv', sep=' ')
    assert(len(edge_types_csv) == 11)
    assert(set(edge_types_csv.columns) == {'weight_max', 'edge_type_id', 'target_query', 'params_file',
                                           'set_params_function', 'delay', 'target_sections', 'weight_function',
                                           'weight_sigma', 'source_query', 'distance_range'})

    assert(os.path.exists('output/v1_v1_edges.h5'))
    edges_h5 = h5py.File('output/v1_v1_edges.h5')
    assert(len(edges_h5['/edges/index_pointer']) == 14+1)
    assert(len(edges_h5['/edges/target_gid']) == 14*14)
    assert(len(edges_h5['/edges/source_gid']) == 14*14)
    assert(len(edges_h5['/edges/0/nsyns']) == 14*14)

    return net
Example #15
0
                   distance_range=[0.0, 300.0],
                   dynamics_params='AMPA_ExcToExc.json',
                   model_template='Exp2Syn')

conn = net.add_edges(source=net.nodes(pop_name='PMC'), target=net.nodes(pop_name='IND'),
                   connection_rule=one_to_one,
                   delay=0.5,
                   syn_weight = 0.033,
                   target_sections=['somatic'],
                   distance_range=[0.0, 300.0],
                   dynamics_params='AMPA_ExcToExc.json',
                   model_template='Exp2Syn')


net.build()
net.save_nodes(output_dir=output_dir)
net.save_edges(output_dir=output_dir)

#inp = NetworkBuilder('INPUT') # Virtual cells delivering input to PUD
#inp.add_nodes(N=1, pop_name = 'Pel_aff_virt', model_type='virtual', potential='exc')
#inp.add_edges(source=inp.nodes(pop_name='Pel_aff_virt'), target=net.nodes(pop_name='SPN'),
#                   connection_rule=1,
#                   syn_weight=0.06,
#                   target_sections=['somatic'],
#				   delay=0.5,
#                   distance_range=[0.0, 300.0],
#                   dynamics_params='AMPA_ExcToExc.json',
#                   model_template='Exp2Syn')
#
#inp.build()
#inp.save_nodes(output_dir=output_dir)
Example #16
0
def build_ext5_nodes():
    if not os.path.exists('network'):
        os.makedirs('network')

    EXT = NetworkBuilder("EXT")
    # need 5 cells to stimulate at 5 different frequencies
    EXT.add_nodes(N=5,
                  pop_name='EXT',
                  model_type='virtual',
                  firing_rate=firing_rate)

    # Save cells.csv and cell_types.csv
    EXT.save_nodes(nodes_file_name='network/ext_nodes.h5',
                   node_types_file_name='network/ext_node_types.csv')

    net = NetworkBuilder('slice')
    net.import_nodes(nodes_file_name='network/slice_nodes.h5',
                     node_types_file_name='network/slice_node_types.csv')

    net.add_edges(source=EXT.nodes(firing_rate=10),
                  target=net.nodes(firing_rate=10, synapse_model='a'),
                  connection_rule=5,
                  **({
                      'syn_weight': 0.002,
                      'weight_function': 'wmax',
                      'distance_range': [0.0, 50.0],
                      'target_sections': ['somatic', 'basal', 'apical'],
                      'delay': 2.0,
                      'dynamics_params': 'AMPA_ExcToExc.json',
                      'model_template': 'expsyn'
                  }))

    net.add_edges(source=EXT.nodes(firing_rate=20),
                  target=net.nodes(firing_rate=20, synapse_model='a'),
                  connection_rule=5,
                  **({
                      'syn_weight': 0.002,
                      'weight_function': 'wmax',
                      'distance_range': [0.0, 50.0],
                      'target_sections': ['somatic', 'basal', 'apical'],
                      'delay': 2.0,
                      'dynamics_params': 'AMPA_ExcToExc.json',
                      'model_template': 'expsyn'
                  }))

    net.add_edges(source=EXT.nodes(firing_rate=50),
                  target=net.nodes(firing_rate=50, synapse_model='a'),
                  connection_rule=5,
                  **({
                      'syn_weight': 0.002,
                      'weight_function': 'wmax',
                      'distance_range': [0.0, 50.0],
                      'target_sections': ['somatic', 'basal', 'apical'],
                      'delay': 2.0,
                      'dynamics_params': 'AMPA_ExcToExc.json',
                      'model_template': 'expsyn'
                  }))

    net.add_edges(source=EXT.nodes(firing_rate=100),
                  target=net.nodes(firing_rate=100, synapse_model='a'),
                  connection_rule=5,
                  **({
                      'syn_weight': 0.002,
                      'weight_function': 'wmax',
                      'distance_range': [0.0, 50.0],
                      'target_sections': ['somatic', 'basal', 'apical'],
                      'delay': 2.0,
                      'dynamics_params': 'AMPA_ExcToExc.json',
                      'model_template': 'expsyn'
                  }))

    net.add_edges(source=EXT.nodes(firing_rate=200),
                  target=net.nodes(firing_rate=200, synapse_model='a'),
                  connection_rule=5,
                  **({
                      'syn_weight': 0.002,
                      'weight_function': 'wmax',
                      'distance_range': [0.0, 50.0],
                      'target_sections': ['somatic', 'basal', 'apical'],
                      'delay': 2.0,
                      'dynamics_params': 'AMPA_ExcToExc.json',
                      'model_template': 'expsyn'
                  }))

    net.add_edges(source=EXT.nodes(firing_rate=10),
                  target=net.nodes(firing_rate=10, synapse_model='b'),
                  connection_rule=5,
                  **({
                      'syn_weight': 0.002,
                      'weight_function': 'wmax',
                      'distance_range': [0.0, 50.0],
                      'target_sections': ['somatic', 'basal', 'apical'],
                      'delay': 2.0,
                      'dynamics_params': 'pvalb_pvalb.json',
                      'model_template': 'stp2syn'
                  }))

    net.add_edges(source=EXT.nodes(firing_rate=20),
                  target=net.nodes(firing_rate=20, synapse_model='b'),
                  connection_rule=5,
                  **({
                      'syn_weight': 0.002,
                      'weight_function': 'wmax',
                      'distance_range': [0.0, 50.0],
                      'target_sections': ['somatic', 'basal', 'apical'],
                      'delay': 2.0,
                      'dynamics_params': 'pvalb_pvalb.json',
                      'model_template': 'stp2syn'
                  }))

    net.add_edges(source=EXT.nodes(firing_rate=50),
                  target=net.nodes(firing_rate=50, synapse_model='b'),
                  connection_rule=5,
                  **({
                      'syn_weight': 0.002,
                      'weight_function': 'wmax',
                      'distance_range': [0.0, 50.0],
                      'target_sections': ['somatic', 'basal', 'apical'],
                      'delay': 2.0,
                      'dynamics_params': 'pvalb_pvalb.json',
                      'model_template': 'stp2syn'
                  }))

    net.add_edges(source=EXT.nodes(firing_rate=100),
                  target=net.nodes(firing_rate=100, synapse_model='b'),
                  connection_rule=5,
                  **({
                      'syn_weight': 0.002,
                      'weight_function': 'wmax',
                      'distance_range': [0.0, 50.0],
                      'target_sections': ['somatic', 'basal', 'apical'],
                      'delay': 2.0,
                      'dynamics_params': 'pvalb_pvalb.json',
                      'model_template': 'stp2syn'
                  }))

    net.add_edges(source=EXT.nodes(firing_rate=200),
                  target=net.nodes(firing_rate=200, synapse_model='b'),
                  connection_rule=5,
                  **({
                      'syn_weight': 0.002,
                      'weight_function': 'wmax',
                      'distance_range': [0.0, 50.0],
                      'target_sections': ['somatic', 'basal', 'apical'],
                      'delay': 2.0,
                      'dynamics_params': 'pvalb_pvalb.json',
                      'model_template': 'stp2syn'
                  }))

    net.build()
    net.save_edges(edges_file_name='network/ext_to_slice_edges.h5',
                   edge_types_file_name='network/ext_to_slice_edge_types.csv')
Example #17
0
import numpy as np
import random


cortex = NetworkBuilder('mcortex')
cortex.add_nodes(N=100,
                 pop_name='Scnn1a',
                 positions=positions_columinar(N=100, center=[0, 50.0, 0], max_radius=30.0, height=100.0),
                 rotation_angle_yaxis=xiter_random(N=100, min_x=0.0, max_x=2*np.pi),
                 rotation_angle_zaxis=3.646878266,
                 potental='exc',
                 model_type='biophysical',
                 model_template='ctdb:Biophys1.hoc',
                 model_processing='aibs_perisomatic',
                 dynamics_params='472363762_fit.json',
                 morphology='Scnn1a_473845048_m.swc')

cortex.add_edges(source={'pop_name': 'Scnn1a'}, target={'pop_name': 'Scnn1a'},
                 connection_rule=distance_connector,
                 connection_params={'d_weight_min': 0.0, 'd_weight_max': 0.34, 'd_max': 50.0, 'nsyn_min': 0, 'nsyn_max': 10},
                 syn_weight=2.0e-04,
                 distance_range=[30.0, 150.0],
                 target_sections=['basal', 'apical', 'soma'],
                 delay=2.0,
                 dynamics_params='AMPA_ExcToExc.json',
                 model_template='exp2syn')

cortex.build()
cortex.save_nodes(output_dir='network')
cortex.save_edges(output_dir='network')
Example #18
0
                     'd_weight_min': 0.0,
                     'd_weight_max': 0.34,
                     'd_max': 50.0,
                     'nsyn_min': 0,
                     'nsyn_max': 10
                 },
                 syn_weight=2.0e-04,
                 distance_range=[30.0, 150.0],
                 target_sections=['basal', 'apical', 'soma'],
                 delay=2.0,
                 dynamics_params='AMPA_ExcToExc.json',
                 model_template='exp2syn')

# Build and save the network
cortex.build()
cortex.save_nodes(output_dir='%s/network' % (savedir))

##########################################
# External network
##########################################

# Add spike generating (thalamus) cells
'''We will also want a collection of external spike-generating cells that will synapse onto our cell. To do this we create
a second network which can represent thalamic input. We will call our network "mthalamus", and it will consist of 10 cells.
These cells are not biophysical but instead "virtual" cells. Virtual cells don't have a morphology or the normal properties
of a neuron, but rather act as spike generators'''
thalamus = NetworkBuilder('mthalamus')
thalamus.add_nodes(N=100,
                   pop_name='tON',
                   potential='exc',
                   model_type='virtual')