Пример #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')
Пример #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
Пример #3
0
def build_input_network(net, output_dir='network/source_input'):
    def select_source_cells(sources, target, N_syn=10):
        """ Note here that "sources" are given (not "source"). So the iterations occur through every target 
         with all sources as potential inputs. Faster than before and better if will have common rules.
        """

        target_id = target.node_id
        source_ids = [s.node_id for s in sources]

        nsyns_ret = [N_syn] * len(source_ids)
        return nsyns_ret

    filter_models = {
        'inputFilter': {
            'N': 25,
            'ei': 'e',
            'pop_name': 'input_filter',
            'model_type': 'virtual'
        }
    }

    inputNetwork = NetworkBuilder("inputNetwork")
    inputNetwork.add_nodes(**filter_models['inputFilter'])

    inputNetwork.add_edges(target=net.nodes(pop_name='Scnn1a'),
                           iterator='all_to_one',
                           connection_rule=select_source_cells,
                           syn_weight=0.0007,
                           distance_range=[0.0, 150.0],
                           target_sections=['basal', 'apical'],
                           delay=2.0,
                           dynamics_params='AMPA_ExcToExc.json',
                           model_template='exp2syn')

    inputNetwork.add_edges(target=net.nodes(pop_name='LIF_exc'),
                           iterator='all_to_one',
                           connection_rule=select_source_cells,
                           syn_weight=0.07,
                           delay=2.0,
                           dynamics_params='instanteneousExc.json')

    inputNetwork.add_edges(target=net.nodes(pop_name='PV1'),
                           iterator='all_to_one',
                           connection_rule=select_source_cells,
                           syn_weight=0.002,
                           distance_range=[0.0, 1.0e+20],
                           target_sections=['basal', 'somatic'],
                           delay=2.0,
                           dynamics_params='AMPA_ExcToInh.json',
                           model_template='exp2syn')

    inputNetwork.add_edges(target=net.nodes(pop_name='LIF_inh'),
                           iterator='all_to_one',
                           connection_rule=select_source_cells,
                           syn_weight=0.01,
                           delay=2.0,
                           dynamics_params='instanteneousExc.json')

    inputNetwork.build()
    inputNetwork.save(output_dir=output_dir)
Пример #4
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')
Пример #5
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')
Пример #6
0
def build_l4():
    if not os.path.exists('output/network/VisL4'):
        os.makedirs('output/network/VisL4')

    net = NetworkBuilder("V1/L4")
    net.add_nodes(node_type_id=0, pop_name='excitatory', params_file='excitatory_pop.json')
    net.add_nodes(node_type_id=1, pop_name='inhibitory', params_file='inhibitory_pop.json')

    net.connect(target={'pop_name': 'excitatory'}, source={'pop_name': 'inhibitory'},
                edge_params={'weight': -0.001, 'delay': 0.002, 'nsyns': 2, 'params_file': 'ExcToInh.json'})

    net.connect(target={'pop_name': 'inhibitory'}, source={'pop_name': 'excitatory'},
                edge_params={'weight': 0.001, 'delay': 0.002, 'nsyns': 5, 'params_file': 'ExcToInh.json'})

    net.save_types(filename='output/network/VisL4/node_types.csv',
                   columns=['node_type_id', 'pop_name', 'params_file'])

    net.save_edge_types('output/network/VisL4/edge_types.csv',
                        opt_columns=['weight', 'delay', 'nsyns', 'params_file'])
Пример #7
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
Пример #8
0
def build_lgn():
    if not os.path.exists('output/network/LGN'):
        os.makedirs('output/network/LGN')

    net = NetworkBuilder("LGN")
    net.add_nodes(N=3000, node_type_id='tON_001', ei='e', location='LGN', pop_name='tON_001', params_file='filter_pop.json')
    net.add_nodes(N=3000, node_type_id='tOFF_001', ei='e', location='LGN', pop_name='tOFF_001', params_file='filter_pop.json')
    net.add_nodes(N=3000, node_type_id='tONOFF_001', ei='e', location='LGN', pop_name='tONOFF_001',
                  params_file='filter_pop.json')

    net.save_cells(filename='output/network/LGN/nodes.csv',
                   columns=['node_id', 'node_type_id'])
    net.save_types(filename='output/network/LGN/node_types.csv',
                   columns=['node_type_id', 'ei', 'location', 'pop_name', 'params_file'])

    net.connect(target={'pop_name': 'excitatory'},
                edge_params={'weight': 0.0015, 'delay': 0.002, 'params_file': 'ExcToExc.json', 'nsyns': 10})

    net.connect(target={'pop_name': 'inhibitory'},
                edge_params={'weight': 0.0019, 'delay': 0.002, 'params_file': 'ExcToInh.json', 'nsyns': 12})

    net.save_edge_types('output/network/LGN/edge_types.csv',
                        opt_columns=['weight', 'delay', 'nsyns', 'params_file'])
Пример #9
0
import numpy as np
import math
import random

from bmtk.builder.networks import NetworkBuilder
from bmtk.builder.aux.node_params import positions_columinar, xiter_random
from bmtk.builder.aux.edge_connectors import distance_connector

net = NetworkBuilder("V1")
net.add_nodes(N=80, pop_name='Scnn1a',
              positions=positions_columinar(N=80, center=[0, 50.0, 0], max_radius=30.0, height=100.0),
              rotation_angle_yaxis=xiter_random(N=80, min_x=0.0, max_x=2*np.pi),
              rotation_angle_zaxis=xiter_random(N=80, min_x=0.0, max_x=2*np.pi),
              tuning_angle=np.linspace(start=0.0, stop=360.0, num=80, endpoint=False),
              location='L4',
              ei='e',
              level_of_detail='biophysical',
              params_file='472363762_fit.json',
              morphology_file='Scnn1a.swc',
              set_params_function='Biophys1')

net.add_nodes(N=20, pop_name='PV',
              positions=positions_columinar(N=20, center=[0, 50.0, 0], max_radius=30.0, height=100.0),
              rotation_angle_yaxis=xiter_random(N=20, min_x=0.0, max_x=2*np.pi),
              rotation_angle_zaxis=xiter_random(N=20, min_x=0.0, max_x=2*np.pi),
              location='L4',
              ei='i',
              level_of_detail='biophysical',
              params_file='472912177_fit.json',
              morphology_file='Pvalb.swc',
              set_params_function='Biophys1')
Пример #10
0
phi_index = 0

net = NetworkBuilder("DG")
net.add_nodes(
    N=N_GC_1,  # specifiy the number of cells belong to said group.
    pop_name='GC',
    location='Granule_cell_layer',
    ei=
    'e',  # pop_name, location, and ei are optional parameters that help's identifies properties of the cells. The modeler can choose whatever key-value pairs as they deem appropiate.
    positions=generate_arc_positions_3D(
        phi_GC[phi_index:N_GC_1], rho_GC[phi_index:N_GC_1]
    ),  # The following properties we are passing in lists     # of size N. Doing so will uniquely assign different
    rotation_angle_xaxis=generate_rotation_angle_1D(rho_GC[phi_index:N_GC_1],
                                                    3.130742385893708),
    rotation_angle_yaxis=generate_rotation_angle_1D(rho_GC[phi_index:N_GC_1],
                                                    0),
    rotation_angle_zaxis=generate_rotation_angle_1D(rho_GC[phi_index:N_GC_1],
                                                    -0.524013338073954),
    phi=phi_GC[phi_index:N_GC_1],
    rho=rho_GC[phi_index:N_GC_1],
    model_type='biophysical',  # The type of cell we are using
    model_template=
    'ctdb:Biophys1.hoc',  # Tells the simulator that when building cells models use a hoc_template specially created for parsing Allen Cell-types file models. Value would be different if we were using NeuronML or different model files
    model_processing=
    'aibs_allactive',  # further instructions for how to processes a cell model. In this case aibs_perisomatic is a built-in directive to cut the axon in a specific way
    dynamics_params=
    '1706014110201.json',  # Name of file (downloaded from Allen Cell-Types) used to set model parameters and channels
    morphology_file='1706014110201.swc')  # Name of morphology file downloaded

phi_index = phi_index + N_GC_1
Пример #11
0
from bmtk.builder.auxi.node_params import positions_columinar, xiter_random
from bmtk.builder.auxi.edge_connectors import distance_connector

net = NetworkBuilder("V1")
net.add_nodes(N=80,
              pop_name='Scnn1a',
              positions=positions_columinar(N=80,
                                            center=[0, 50.0, 0],
                                            max_radius=30.0,
                                            height=100.0),
              rotation_angle_yaxis=xiter_random(N=80,
                                                min_x=0.0,
                                                max_x=2 * np.pi),
              rotation_angle_zaxis=xiter_random(N=80,
                                                min_x=0.0,
                                                max_x=2 * np.pi),
              tuning_angle=np.linspace(start=0.0,
                                       stop=360.0,
                                       num=80,
                                       endpoint=False),
              location='VisL4',
              ei='e',
              model_type='biophysical',
              model_template='ctdb:Biophys1.hoc',
              model_processing='aibs_perisomatic',
              dynamics_params='472363762_fit.json',
              morphology='Scnn1a.swc')

net.add_nodes(N=20,
              pop_name='PV',
              positions=positions_columinar(N=20,
Пример #12
0
def build_tw():
    if not os.path.exists('output/network/TW'):
        os.makedirs('output/network/TW')

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

    # Save cells.csv and cell_types.csv
    TW.save_cells(
        filename='output/network/TW/tw_nodes.csv',
        columns=['node_id', 'node_type_id', 'pop_name', 'ei', 'location'])

    TW.save_types(filename='output/network/TW/tw_node_types.csv',
                  columns=['node_type_id', 'level_of_detail'])

    VL4 = NetworkBuilder.load("V1/L4",
                              nodes='output/network/VisL4/nodes.csv',
                              node_types='output/network/VisL4/node_types.csv')
    VL4.connect(source=TW.nodes(),
                target={'pop_name': 'Rorb'},
                connector=lambda trg, src: 5,
                edge_params={
                    'weight_max': 12.75,
                    'weight_function': 'wmax',
                    'delay': 2.0,
                    'params_file': 'ExcToExc.json',
                    'synapse_model': 'static_synapse'
                })

    VL4.connect(source=TW.nodes(),
                target={'pop_name': 'Scnn1a'},
                connector=lambda trg, src: 5,
                edge_params={
                    'weight_max': 33.25,
                    'weight_function': 'wmax',
                    'delay': 2.0,
                    'params_file': 'ExcToExc.json',
                    'synapse_model': 'static_synapse'
                })

    VL4.connect(source=TW.nodes(),
                target={'pop_name': 'Nr5a1'},
                connector=lambda trg, src: 5,
                edge_params={
                    'weight_max': 19.0,
                    'weight_function': 'wmax',
                    'delay': 2.0,
                    'params_file': 'ExcToExc.json',
                    'synapse_model': 'static_synapse'
                })

    VL4.connect(source=TW.nodes(),
                target={'pop_name': 'PV1'},
                connector=lambda trg, src: 5,
                edge_params={
                    'weight_max': 83.6,
                    'weight_function': 'wmax',
                    'delay': 2.0,
                    'params_file': 'ExcToInh.json',
                    'synapse_model': 'static_synapse'
                })

    VL4.connect(source=TW.nodes(),
                target={'pop_name': 'PV2'},
                connector=lambda trg, src: 5,
                edge_params={
                    'weight_max': 32.5,
                    'weight_function': 'wmax',
                    'delay': 2.0,
                    'params_file': 'ExcToInh.json',
                    'synapse_model': 'static_synapse'
                })

    VL4.connect(source=TW.nodes(),
                target={'pop_name': 'LIF_exc'},
                connector=lambda trg, src: 5,
                edge_params={
                    'weight_max': 22.5,
                    'weight_function': 'wmax',
                    'delay': 2.0,
                    'params_file': 'ExcToInh.json',
                    'synapse_model': 'static_synapse'
                })

    VL4.connect(source=TW.nodes(),
                target={'pop_name': 'LIF_inh'},
                connector=lambda trg, src: 5,
                edge_params={
                    'weight_max': 55.0,
                    'weight_function': 'wmax',
                    'delay': 2.0,
                    'params_file': 'ExcToInh.json',
                    'synapse_model': 'static_synapse'
                })

    VL4.build()
    VL4.save_edge_types('output/network/TW/tw_edge_types.csv',
                        opt_columns=[
                            'weight_max', 'weight_function', 'delay',
                            'params_file', 'synapse_model'
                        ])

    VL4.save_edges(filename='output/network/TW/tw_edges.h5')
Пример #13
0
def build_l4():
    if not os.path.exists('output/network/VisL4'):
        os.makedirs('output/network/VisL4')

    net = NetworkBuilder("V1/L4")
    net.add_nodes(N=2,
                  pop_name='Scnn1a',
                  node_type_id='395830185',
                  position='points',
                  position_params={
                      'location': [(28.753, -364.868, -161.705),
                                   (48.753, -344.868, -141.705)]
                  },
                  array_params={"tuning_angle": [0.0, 25.0]},
                  location='VisL4',
                  ei='e',
                  gaba_synapse='y',
                  params_file='472363762_point.json',
                  model_type='iaf_psc_alpha')

    net.add_nodes(N=2,
                  pop_name='Rorb',
                  node_type_id='314804042',
                  position='points',
                  position_params={
                      'location': [(241.092, -349.263, 146.916),
                                   (201.092, -399.263, 126.916)]
                  },
                  array_params={"tuning_angle": [50.0, 75.0]},
                  location='VisL4',
                  ei='e',
                  gaba_synapse='y',
                  params_file='473863510_point.json',
                  model_type='iaf_psc_alpha')

    net.add_nodes(N=2,
                  pop_name='Nr5a1',
                  node_type_id='318808427',
                  position='points',
                  position_params={
                      'location': [(320.498, -351.259, 20.273),
                                   (310.498, -371.259, 10.273)]
                  },
                  array_params={"tuning_angle": [100.0, 125.0]},
                  location='VisL4',
                  ei='e',
                  gaba_synapse='y',
                  params_file='473863035_point.json',
                  model_type='iaf_psc_alpha')

    net.add_nodes(N=2,
                  pop_name='PV1',
                  node_type_id='330080937',
                  position='points',
                  position_params={
                      'location': [(122.373, -352.417, -216.748),
                                   (102.373, -342.417, -206.748)]
                  },
                  array_params={'tuning_angle': ['NA', 'NA']},
                  location='VisL4',
                  ei='i',
                  gaba_synapse='y',
                  params_file='472912177_fit.json',
                  model_type='iaf_psc_alpha')

    net.add_nodes(N=2,
                  pop_name='PV2',
                  node_type_id='318331342',
                  position='points',
                  position_params={
                      'location': [(350.321, -372.535, -18.282),
                                   (360.321, -371.535, -12.282)]
                  },
                  array_params={'tuning_angle': ['NA', 'NA']},
                  location='VisL4',
                  ei='i',
                  gaba_synapse='y',
                  params_file='473862421_point.json',
                  model_type='iaf_psc_alpha')

    net.add_nodes(N=2,
                  pop_name='LIF_exc',
                  node_type_id='100000101',
                  position='points',
                  position_params={
                      'location': [(-243.04, -342.352, -665.666),
                                   (-233.04, -332.352, -675.666)]
                  },
                  array_params={'tuning_angle': ['NA', 'NA']},
                  location='VisL4',
                  ei='e',
                  gaba_synapse='n',
                  params_file='IntFire1_exc_1.json',
                  model_type='iaf_psc_alpha')

    net.add_nodes(N=2,
                  pop_name='LIF_inh',
                  node_type_id='100000102',
                  position='points',
                  position_params={
                      'location': [(211.04, -321.333, -631.593),
                                   (218.04, -327.333, -635.593)]
                  },
                  array_params={'tuning_angle': [150.0, 175.0]},
                  location='VisL4',
                  ei='i',
                  gaba_synapse='n',
                  params_file='IntFire1_inh_1.json',
                  model_type='iaf_psc_alpha')

    print("Setting connections...")
    net.connect(source={'ei': 'i'},
                target={
                    'ei': 'i',
                    'gaba_synapse': 'y'
                },
                connector=lambda trg, src: 5,
                edge_params={
                    'weight_max': -1.8,
                    'weight_function': 'wmax',
                    'delay': 2.0,
                    'params_file': 'InhToInh.json',
                    'synapse_model': 'static_synapse'
                })

    net.connect(source={'ei': 'i'},
                target={
                    'ei': 'e',
                    'gaba_synapse': 'y'
                },
                connector=lambda trg, src: 5,
                edge_params={
                    'weight_max': -12.6,
                    'weight_function': 'wmax',
                    'delay': 2.0,
                    'params_file': 'InhToExc.json',
                    'synapse_model': 'static_synapse'
                })

    net.connect(source={'ei': 'i'},
                target={'pop_name': 'LIF_inh'},
                connector=lambda trg, src: 5,
                edge_params={
                    'weight_max': -1.125,
                    'weight_function': 'wmax',
                    'delay': 2.0,
                    'params_file': 'InhToInh.json',
                    'synapse_model': 'static_synapse'
                })

    net.connect(source={'ei': 'i'},
                target={'pop_name': 'LIF_exc'},
                connector=lambda trg, src: 5,
                edge_params={
                    'weight_max': -6.3,
                    'weight_function': 'wmax',
                    'delay': 2.0,
                    'params_file': 'ExcToInh.json',
                    'synapse_model': 'static_synapse'
                })

    net.connect(source={'ei': 'e'},
                target={'pop_name': 'PV1'},
                connector=lambda trg, src: 5,
                edge_params={
                    'weight_max': 7.7,
                    'weight_function': 'wmax',
                    'delay': 2.0,
                    'params_file': 'ExcToInh.json',
                    'synapse_model': 'static_synapse'
                })

    net.connect(source={'ei': 'e'},
                target={'pop_name': 'PV2'},
                connector=lambda trg, src: 5,
                edge_params={
                    'weight_max': 5.4,
                    'weight_function': 'wmax',
                    'delay': 2.0,
                    'params_file': 'ExcToInh.json',
                    'synapse_model': 'static_synapse'
                })

    net.connect(source={'ei': 'e'},
                target={'pop_name': 'LIF_inh'},
                connector=lambda trg, src: 5,
                edge_params={
                    'weight_max': 3.44,
                    'weight_function': 'wmax',
                    'delay': 2.0,
                    'params_file': 'ExcToInh.json',
                    'synapse_model': 'static_synapse'
                })

    print("Generating E-to-E connections.")
    net.connect(source={'ei': 'e'},
                target={'pop_name': 'Scnn1a'},
                connector=lambda trg, src: 5,
                edge_params={
                    'weight_max': 8.448,
                    'weight_function': 'gaussianLL',
                    'weight_sigma': 50.0,
                    'delay': 2.0,
                    'params_file': 'ExcToExc.json',
                    'synapse_model': 'static_synapse'
                })

    net.connect(source={'ei': 'e'},
                target={'pop_name': 'Rorb'},
                connector=lambda trg, src: 5,
                edge_params={
                    'weight_max': 4.292,
                    'weight_function': 'gaussianLL',
                    'weight_sigma': 50.0,
                    'delay': 2.0,
                    'params_file': 'ExcToExc.json',
                    'synapse_model': 'static_synapse'
                })

    net.connect(source={'ei': 'e'},
                target={'pop_name': 'Nr5a1'},
                connector=lambda trg, src: 5,
                edge_params={
                    'weight_max': 5.184,
                    'weight_function': 'gaussianLL',
                    'weight_sigma': 50.0,
                    'delay': 2.0,
                    'params_file': 'ExcToExc.json',
                    'synapse_model': 'static_synapse'
                })

    net.connect(source={'ei': 'e'},
                target={'pop_name': 'LIF_exc'},
                connector=lambda trg, src: 5,
                edge_params={
                    'weight_max': 1.995,
                    'weight_function': 'gaussianLL',
                    'weight_sigma': 50.0,
                    'delay': 2.0,
                    'params_file': 'ExcToExc.json',
                    'synapse_model': 'static_synapse'
                })

    net.build()
    net.save_cells(
        filename='output/network/VisL4/nodes.csv',
        columns=['node_id', 'node_type_id', 'position', 'tuning_angle'],
        position_labels=['x', 'y', 'z'])

    net.save_types(filename='output/network/VisL4/node_types.csv',
                   columns=[
                       'node_type_id', 'pop_name', 'ei', 'gaba_synapse',
                       'location', 'model_type', 'params_file'
                   ])

    net.save_edge_types('output/network/VisL4/edge_types.csv',
                        opt_columns=[
                            'weight_max', 'weight_function', 'weight_sigma',
                            'delay', 'params_file', 'synapse_model'
                        ])
    net.save_edges(filename='output/network/VisL4/edges.h5')
    return net
Пример #14
0
from bmtk.builder.networks import NetworkBuilder


def crule(src, trg):
    # print src.node_id, trg.node_id
    return 2


net1 = NetworkBuilder('NET1')
net1.add_nodes(N=100,
               position=[(0.0, 1.0, -1.0)] * 100,
               cell_type='Scnna1',
               ei='e')
net1.add_edges(source={'ei': 'e'}, target={'ei': 'e'}, connection_rule=5)
net1.build()

net2 = NetworkBuilder('NET2')
net2.add_nodes(N=10, position=[(0.0, 1.0, -1.0)] * 10, cell_type='PV1', ei='i')
net2.add_edges(connection_rule=10)
net2.add_edges(source=net1.nodes(), connection_rule=1)
net2.add_edges(target=net1.nodes(), connection_rule=crule)
net2.build()

#net1.save_edges(output_dir='tmp_output')
net2.save_edges(output_dir='tmp_output')
Пример #15
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/network/LGN'):
        os.makedirs('output/network/LGN')

    LGN = NetworkBuilder("LGN")
    LGN.add_nodes(N=3000,
                  position='points',
                  position_params={'location': generate_positions(3000)},
                  node_type_id='tON_001',
                  location='LGN',
                  model_type='spike_generator',
                  pop_name='tON',
                  ei='e',
                  params_file='filter_point.json')

    LGN.add_nodes(N=3000,
                  position='points',
                  position_params={'location': generate_positions(3000)},
                  node_type_id='tOFF_001',
                  location='LGN',
                  model_type='spike_generator',
                  pop_name='tOFF',
                  ei='e',
                  params_file='filter_point.json')

    LGN.add_nodes(N=3000,
                  position='points',
                  position_params={'location': generate_positions(3000)},
                  node_type_id='tONOFF_001',
                  location='LGN',
                  model_type='spike_generator',
                  pop_name='tONOFF',
                  ei='e',
                  params_file='filter_point.json')

    LGN.save_cells(filename='output/network/LGN/lgn_nodes.csv',
                   columns=['node_id', 'node_type_id', 'position'],
                   position_labels=['x', 'y'])
    LGN.save_types(filename='output/network/LGN/lgn_node_types.csv',
                   columns=[
                       'node_type_id', 'ei', 'location', 'model_type',
                       'params_file'
                   ])

    VL4 = NetworkBuilder.load("V1/L4",
                              nodes='output/network/VisL4/nodes.csv',
                              node_types='output/network/VisL4/node_types.csv')

    VL4.connect(source=LGN.nodes(),
                target={'pop_name': 'Rorb'},
                iterator='all_to_one',
                connector=select_source_cells,
                connector_params={'n_syns': 10},
                edge_params={
                    'weight_max': 4.125,
                    'weight_function': 'wmax',
                    'delay': 2.0,
                    'params_file': 'ExcToExc.json',
                    'synapse_model': 'static_synapse'
                })

    VL4.connect(source=LGN.nodes(),
                target={'pop_name': 'Nr5a1'},
                iterator='all_to_one',
                connector=select_source_cells,
                connector_params={'n_syns': 10},
                edge_params={
                    'weight_max': 4.5,
                    'weight_function': 'wmax',
                    'delay': 2.0,
                    'params_file': 'ExcToExc.json',
                    'synapse_model': 'static_synapse'
                })

    VL4.connect(source=LGN.nodes(),
                target={'pop_name': 'Scnn1a'},
                iterator='all_to_one',
                connector=select_source_cells,
                connector_params={'n_syns': 10},
                edge_params={
                    'weight_max': 5.6,
                    'weight_function': 'wmax',
                    'distance_range': [0.0, 150.0],
                    'delay': 2.0,
                    'params_file': 'ExcToExc.json',
                    'synapse_model': 'static_synapse'
                })

    VL4.connect(source=LGN.nodes(),
                target={'pop_name': 'PV1'},
                iterator='all_to_one',
                connector=select_source_cells,
                connector_params={'n_syns': 10},
                edge_params={
                    'weight_max': 1.54,
                    'weight_function': 'wmax',
                    'delay': 2.0,
                    'params_file': 'ExcToInh.json',
                    'synapse_model': 'static_synapse'
                })

    VL4.connect(source=LGN.nodes(),
                target={'pop_name': 'PV2'},
                iterator='all_to_one',
                connector=select_source_cells,
                connector_params={'n_syns': 10},
                edge_params={
                    'weight_max': 1.26,
                    'weight_function': 'wmax',
                    'delay': 2.0,
                    'params_file': 'ExcToInh.json',
                    'synapse_model': 'static_synapse'
                })

    VL4.connect(source=LGN.nodes(),
                target={'pop_name': 'LIF_exc'},
                iterator='all_to_one',
                connector=select_source_cells,
                connector_params={'n_syns': 10},
                edge_params={
                    'weight_max': 4.41,
                    'weight_function': 'wmax',
                    'delay': 2.0,
                    'params_file': 'ExcToInh.json',
                    'synapse_model': 'static_synapse'
                })

    VL4.connect(source=LGN.nodes(),
                target={'pop_name': 'LIF_inh'},
                iterator='all_to_one',
                connector=select_source_cells,
                connector_params={'n_syns': 10},
                edge_params={
                    'weight_max': 2.52,
                    'weight_function': 'wmax',
                    'delay': 2.0,
                    'params_file': 'ExcToInh.json',
                    'synapse_model': 'static_synapse'
                })

    VL4.build()
    VL4.save_edge_types('output/network/LGN/lgn_edge_types.csv',
                        opt_columns=[
                            'weight_max', 'weight_function', 'delay',
                            'params_file', 'synapse_model'
                        ])
    VL4.save_edges(filename='output/network/LGN/lgn_edges.h5')
Пример #16
0
from bmtk.builder.networks import NetworkBuilder

net1 = NetworkBuilder('hco_net')
net1.add_nodes(N=1, 
              cell_name='HCOCell1',
              model_type='biophysical',
              model_template='hoc:HCOcell',
              morphology='blank.swc'
            )
            
net1.add_nodes(N=1, 
              cell_name='HCOCell2',
              model_type='biophysical',
              model_template='hoc:HCOcell',
              morphology='blank.swc'
            )
            

                        
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,
Пример #17
0
print("\nCreating Cells")

# Build the main network
net = NetworkBuilder('LUT')

# Specify number of cells in each population #
numPUDaff   = 1
numPelaff   = 1
numINmplus  = 1
numINmminus = 1
numIND      = 1
numFB       = 1
numSPN      = 1

# Create the nodes ----------------------------------------
net.add_nodes(N=numPelaff, pop_name='Pelaff',model_type='biophysical',model_template='hoc:LIF_adapt',morphology=None)
net.add_nodes(N=numPUDaff, pop_name='PUDaff',model_type='biophysical',model_template='hoc:LIF_adapt',morphology=None)
net.add_nodes(N=numINmplus, pop_name='INmplus',model_type='biophysical',model_template='hoc:LIF_adapt',morphology=None)
net.add_nodes(N=numINmminus, pop_name='INmminus',model_type='biophysical',model_template='hoc:LIF_adapt',morphology=None)
net.add_nodes(N=numIND, pop_name='IND',model_type='biophysical',model_template='hoc:LIF_adapt',morphology=None)
net.add_nodes(N=numFB, pop_name='FB',model_type='biophysical',model_template='hoc:LIF_adapt',morphology=None)
net.add_nodes(N=numSPN, pop_name='SPN',model_type='biophysical',model_template='hoc:LIF_adapt',morphology=None) 

##################################################################################
####################### Connect the cells ########################################
##################################################################################
print("\nConnecting Cells")


def conn_props(source,target,mu,sigma):
    """
Пример #18
0
from bmtk.builder.networks import NetworkBuilder

# First thing is to create a network builder object
net = NetworkBuilder('mcortex')
net.add_nodes(
    cell_name='Scnn1a',
    # positions=[(0.0, 0.0, 0.0)],
    potental='exc',
    level_of_detail='biophysical',
    params_file='472363762_fit.json',
    morphology_file='Scnn1a.swc',
    set_params_function='Biophys1')

net.build()
net.save_nodes(output_dir='network')
Пример #19
0
    }
}

lgn_net = NetworkBuilder('LGN')
xcoords = []
ycoords = []
for model_name, model_params in cell_models.items():
    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:"
Пример #20
0
from bmtk.builder.networks import NetworkBuilder

net = NetworkBuilder("biophysical")
net.add_nodes(N=1,
              pop_name='Pyrc',
              potental='exc',
              model_type='biophysical',
              model_template='hoc:L5PCtemplate',
              morphology=None)

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

from bmtk.utils.sim_setup import build_env_bionet

build_env_bionet(
    base_dir='./',  # Where to save the scripts and config files 
    components_dir='../biophys_components',
    network_dir='./network',  # Location of directory containing network files
    tstop=3000.0,
    dt=0.1,  # Run a simulation for 2000 ms at 0.1 ms intervals
    report_vars=['v'],
    #clamp_reports=["se"], # 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.793,
        #'amp': 0.346,
        'delay': 700,
        'duration': 2000,
        'gids': "all"
    },
    spikes_threshold=-10,
Пример #21
0
from bmtk.builder.networks import NetworkBuilder


# First thing is to create a network builder object
net = NetworkBuilder('mcortex')
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')

net.build()
net.save_nodes(output_dir='network')
Пример #22
0

net = NetworkBuilder('V1/L4')
for name, model_params in cell_models.items():
    N = model_params['N']
    cell_props = {'position': np.random.rand(N, 3)*[100.0, -300.0, 100.0],
                  'rotation_angle': np.random.uniform(0.0, 2*np.pi, (N,))}
    if model_params['props']['ei'] == 'e':
        cell_props['tuning_angle'] = np.linspace(0, 360.0, N, endpoint=False)
    else:
        cell_props['tuning_angle'] = ['NA']*N

    cell_props.update(model_params['props'])

    net.add_nodes(N=N,
                  pop_name=name,
                  location='VisL4',
                  **cell_props)

'''
net.build()
net.save_nodes('tmp_nodes.h5', 'tmp_node_types.csv')
exit()
'''

cparameters = {'d_weight_min': 0.0, 'd_weight_max': 1.0, 'd_max': 160.0, 'nsyn_min': 3, 'nsyn_max': 7}
net.add_edges(sources={'ei': 'i'}, targets={'ei': 'i', 'level_of_detail': 'biophysical'},
              func=distance_connection_handler, func_params=cparameters,
              weight_max=0.0002,
              weight_function='wmax',
              distance_range=[0.0, 1e+20],
              target_sections=['somatic', 'basal'],
Пример #23
0
import numpy as np

from bmtk.builder.networks import NetworkBuilder
from bmtk.builder.aux.node_params import positions_columinar
from bmtk.builder.aux.edge_connectors import distance_connector

"""Create Nodes"""
net = NetworkBuilder("V1")
net.add_nodes(N=80,  # Create a population of 80 neurons
              positions=positions_columinar(N=80, center=[0, 50.0, 0], max_radius=30.0, height=100.0),
              pop_name='Scnn1a', location='VisL4', ei='e',  # optional parameters
              model_type='point_process',  # Tells the simulator to use point-based neurons
              model_template='nest:iaf_psc_alpha',  # tells the simulator to use NEST iaf_psc_alpha models
              dynamics_params='472363762_point.json'  # File containing iaf_psc_alpha mdoel parameters
             )

net.add_nodes(N=20, pop_name='PV', location='VisL4', ei='i',
              positions=positions_columinar(N=20, center=[0, 50.0, 0], max_radius=30.0, height=100.0),
              model_type='point_process',
              model_template='nest:iaf_psc_alpha',
              dynamics_params='472912177_point.json')

net.add_nodes(N=200, pop_name='LIF_exc', location='L4', ei='e',
              positions=positions_columinar(N=200, center=[0, 50.0, 0], min_radius=30.0, max_radius=60.0, height=100.0),
              model_type='point_process',
              model_template='nest:iaf_psc_alpha',
              dynamics_params='IntFire1_exc_point.json')

net.add_nodes(N=100, pop_name='LIF_inh', location='L4', ei='i',
              positions=positions_columinar(N=100, center=[0, 50.0, 0], min_radius=30.0, max_radius=60.0, height=100.0),
              model_type='point_process',
Пример #24
0
import numpy as np

from bmtk.builder.networks import NetworkBuilder
from bmtk.builder.auxi.edge_connectors import connect_random

#print np.random.geometric(p=0.5)
#print np.sqrt(1-0.005)/0.005
"""
def connect_random(source, target, nsyn_min=0, nsyn_max=10, distribution=None):
    return np.random.randint(nsyn_min, nsyn_max)
"""

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

cortex = NetworkBuilder('mcortex')
cortex.import_nodes(nodes_file_name='network/mcortex_nodes.h5',
                    node_types_file_name='network/mcortex_node_types.csv')
thalamus.add_edges(source=thalamus.nodes(),
                   target=cortex.nodes(),
                   connection_rule=connect_random,
                   connection_params={
                       'nsyn_min': 0,
                       'nsyn_max': 12
                   },
                   syn_weight=1.0e-04,
                   distance_range=[0.0, 150.0],
                   target_sections=['basal', 'apical'],
Пример #25
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()
Пример #26
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')
Пример #27
0
numBladaff  = 10
numEUSaff   = 10
numPAGaff   = 10
numIND      = 10
numHypo     = 10
numINmplus  = 10
numINmminus = 10
numPGN      = 10
numFB       = 10
numIMG      = 10 
numMPG      = 10
numEUSmn    = 10
numBladmn   = 10
# Create the nodes ----------------------------------------
net.add_nodes(N=numBladaff, level='high',pop_name='Bladaff',model_type='biophysical',model_template='hoc:PUD',morphology='blank.swc')
net.add_nodes(N=numEUSaff, level='high',pop_name='EUSaff',model_type='biophysical',model_template='hoc:PUD',morphology='blank.swc')
net.add_nodes(N=numPAGaff, pop_name='PAGaff',model_type='biophysical',model_template='hoc:PUD',morphology='blank.swc')
net.add_nodes(N=numIND, pop_name='IND',model_type='biophysical',model_template='hoc:IND',morphology='blank.swc')
net.add_nodes(N=numHypo, pop_name='Hypo',model_type='biophysical',model_template='hoc:HYPO',morphology='blank.swc')
net.add_nodes(N=numINmplus, pop_name='INmplus',model_type='biophysical',model_template='hoc:INM',morphology='blank.swc')
net.add_nodes(N=numINmminus, pop_name='INmminus',model_type='biophysical',model_template='hoc:INM',morphology='blank.swc')
net.add_nodes(N=numPGN, level='low', pop_name='PGN',model_type='biophysical',model_template='hoc:PGN',morphology='blank.swc') 
net.add_nodes(N=numFB, pop_name='FB',model_type='biophysical',model_template='hoc:PUD',morphology='blank.swc')
net.add_nodes(N=numIMG, pop_name='IMG',model_type='biophysical',model_template='hoc:IMG',morphology='blank.swc')
net.add_nodes(N=numMPG, pop_name='MPG',model_type='biophysical',model_template='hoc:MPG',morphology='blank.swc') 
net.add_nodes(N=numEUSmn, pop_name='EUSmn',model_type='biophysical',model_template='hoc:PUD',morphology='blank.swc')
net.add_nodes(N=numBladmn, pop_name='Bladmn',model_type='biophysical',model_template='hoc:PUD',morphology='blank.swc')

##################################################################################
####################### Connect the cells ########################################
Пример #28
0
def build_cortical_network(output_dir='network/recurrent_network'):
    def distance_connection_handler(source, target, d_max, nsyn_min, nsyn_max):
        """ Connect cells that are less than d_max apart with a random number of synapses in the 
          interval [nsyn_min, nsyn_max)
        """
        sid = source['node_id']  # Get source id
        tid = target['node_id']  # Get target id

        # Avoid self-connections.
        if (sid == tid):
            return None

        # first calculate euclidean distance between cells
        src_positions = np.array([source['x'], source['y'], source['z']])
        trg_positions = np.array([target['x'], target['y'], target['z']])
        separation = np.sqrt(np.sum(src_positions - trg_positions)**2)

        # drop the connection if nodes too far apart
        if separation >= d_max:
            return None

        # Add the number of synapses for every connection.
        tmp_nsyn = random.randint(nsyn_min, nsyn_max)
        return tmp_nsyn

    #### Step 1: Figure out what types, and number of, different cells to use in our network ####
    # Number of cell models desired
    N_Scnn1a = 2
    N_PV1 = 2
    N_LIF_exc = 2
    N_LIF_inh = 2

    # Define all the cell models in a dictionary (note dictionaries within a dictionary)
    biophysical_models = {
        'Scnn1a': {
            'N': N_Scnn1a,
            'ei': 'e',
            'pop_name': 'Scnn1a',
            'model_type': 'biophysical',
            'model_template': 'ctdb:Biophys1.hoc',
            'model_processing': 'aibs_perisomatic',
            'morphology_file':
            'Scnn1a-Tg3-Cre_Ai14_IVSCC_-177300.01.02.01_473845048_m.swc',
            'dynamics_params': '472363762_fit.json',
            'rotation_angle_zaxis': -3.646878266
        },
        'PV1': {
            'N': N_PV1,
            'ei': 'i',
            'pop_name': 'PV1',
            'model_type': 'biophysical',
            'model_template': 'ctdb:Biophys1.hoc',
            'model_processing': 'aibs_perisomatic',
            'dynamics_params': '472912177_fit.json',
            'morphology_file':
            'Pvalb-IRES-Cre_Ai14_IVSCC_-176847.04.02.01_470522102_m.swc',
            'rotation_angle_zaxis': -2.539551891
        }
    }

    # Define all the cell models in a dictionary.
    LIF_models = {
        'LIF_exc': {
            'N': N_LIF_exc,
            'ei': 'e',
            'pop_name': 'LIF_exc',
            'model_type': 'point_process',
            'model_template': 'nrn:IntFire1',
            'dynamics_params': 'IntFire1_exc_1.json'
        },
        'LIF_inh': {
            'N': N_LIF_inh,
            'ei': 'i',
            'pop_name': 'LIF_inh',
            'model_type': 'point_process',
            'model_template': 'nrn:IntFire1',
            'dynamics_params': 'IntFire1_inh_1.json'
        }
    }

    #### Step 2: Create NetworkBuidler object to build nodes and edges ####
    net = NetworkBuilder('Cortical')

    #### Step 3: Used add_nodes() method to add all our cells/cell-types
    for model in biophysical_models:
        # Build our biophysical cells
        params = biophysical_models[model]
        n_cells = params.pop('N')

        # We'll randomly assign positions
        positions = generate_random_positions(n_cells)

        # Use add_nodes to create a set of N cells for each cell-type
        net.add_nodes(
            N=n_cells,  # Specify the numer of cells belonging to this set of nodes 
            x=positions[:, 0],
            y=positions[:, 1],
            z=positions[:, 2],
            rotation_angle_yaxis=np.random.uniform(0.0, 2 * np.pi, n_cells),

            # The other parameters are shared by all cells of this set in the dictionary
            **params)  # python shortcut for unrolling a dictionary

    for model in LIF_models:
        # Same thing as above but for our LIF type cells
        params = LIF_models[model].copy()

        # Number of cells for this model type
        n_cells = params.pop('N')

        # Precacluate positions, rotation angles for each N neurons in the population
        positions = generate_random_positions(n_cells)

        # Adds node populations
        net.add_nodes(N=n_cells,
                      x=positions[:, 0],
                      y=positions[:, 1],
                      z=positions[:, 2],
                      rotation_angle_yaxis=np.random.uniform(
                          0.0, 2 * np.pi, n_cells),
                      **params)

    #### Step 4: Used add_edges() to set our connections between cells ####
    cparameters = {
        'd_max':
        160.0,  # Maximum separation between nodes where connection allowed 
        'nsyn_min': 3,  # If connection exist, minimum number of synapses
        'nsyn_max': 7
    }  # If connection exist, maximum number of synapses

    net.add_edges(
        source={
            'ei': 'i'
        },  # Select all inhibitory cells to apply this connection rule too
        target={
            'ei': 'i',
            'model_type': 'biophysical'
        },  # for the target cells we will use inhibitory biophysical cells
        connection_rule=distance_connection_handler,
        connection_params={
            'd_max': 160.0,
            'nsyn_min': 3,
            'nsyn_max': 7
        },
        syn_weight=0.03,
        distance_range=[0.0, 1e+20],
        target_sections=['somatic', 'basal'],
        delay=2.0,
        dynamics_params='GABA_InhToInh.json',
        model_template='exp2syn')

    # inhibitory --> point-inhibitory
    net.add_edges(source={'ei': 'i'},
                  target={
                      'ei': 'i',
                      'model_type': 'point_process'
                  },
                  connection_rule=distance_connection_handler,
                  connection_params={
                      'd_max': 160.0,
                      'nsyn_min': 3,
                      'nsyn_max': 7
                  },
                  syn_weight=0.3,
                  delay=2.0,
                  dynamics_params='instanteneousInh.json')

    # inhibiotry --> biophysical-excitatory
    net.add_edges(source={'ei': 'i'},
                  target={
                      'ei': 'e',
                      'model_type': 'biophysical'
                  },
                  connection_rule=distance_connection_handler,
                  connection_params={
                      'd_max': 160.0,
                      'nsyn_min': 3,
                      'nsyn_max': 7
                  },
                  syn_weight=0.3,
                  distance_range=[0.0, 50.0],
                  target_sections=['somatic', 'basal', 'apical'],
                  delay=2.0,
                  dynamics_params='GABA_InhToExc.json',
                  model_template='exp2syn')

    # inhibitory --> point-excitatory
    net.add_edges(source={'ei': 'i'},
                  target={
                      'ei': 'e',
                      'model_type': 'point_process'
                  },
                  connection_rule=distance_connection_handler,
                  connection_params={
                      'd_max': 160.0,
                      'nsyn_min': 3,
                      'nsyn_max': 7
                  },
                  syn_weight=0.4,
                  delay=2.0,
                  dynamics_params='instanteneousInh.json')

    # excitatory --> PV1 cells
    net.add_edges(source={'ei': 'e'},
                  target={'pop_name': 'PV1'},
                  connection_rule=distance_connection_handler,
                  connection_params={
                      'd_max': 160.0,
                      'nsyn_min': 3,
                      'nsyn_max': 7
                  },
                  syn_weight=0.05,
                  distance_range=[0.0, 1e+20],
                  target_sections=['somatic', 'basal'],
                  delay=2.0,
                  dynamics_params='AMPA_ExcToInh.json',
                  model_template='exp2syn')

    # excitatory --> LIF_inh
    net.add_edges(source={'ei': 'e'},
                  target={'pop_name': 'LIF_inh'},
                  connection_rule=distance_connection_handler,
                  connection_params=cparameters,
                  syn_weight=0.2,
                  delay=2.0,
                  dynamics_params='instanteneousExc.json')

    # excitatory --> Scnn1a
    net.add_edges(source={'ei': 'e'},
                  target={'pop_name': 'Scnn1a'},
                  connection_rule=distance_connection_handler,
                  connection_params={
                      'd_max': 160.0,
                      'nsyn_min': 3,
                      'nsyn_max': 7
                  },
                  syn_weight=0.05,
                  distance_range=[30.0, 150.0],
                  target_sections=['basal', 'apical'],
                  delay=2.0,
                  dynamics_params='AMPA_ExcToExc.json',
                  model_template='exp2syn')

    # excitatory --> LIF_exc
    net.add_edges(source={'ei': 'e'},
                  target={'pop_name': 'LIF_exc'},
                  connection_rule=distance_connection_handler,
                  connection_params={
                      'd_max': 160.0,
                      'nsyn_min': 3,
                      'nsyn_max': 7
                  },
                  syn_weight=0.05,
                  delay=2.0,
                  dynamics_params='instanteneousExc.json')

    #### Step 5: Build and save the network ####
    net.build()
    net.save(output_dir=output_dir)
    return net
Пример #29
0
from bmtk.builder.networks import NetworkBuilder
from bmtk.builder.auxi.node_params import positions_columinar, xiter_random
from bmtk.builder.auxi.edge_connectors import distance_connector

import math
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')
import os
import numpy as np

from bmtk.builder.networks import NetworkBuilder


# Step 1: Create a v1 mock network of 14 cells (nodes) with across 7 different cell "types"
net = NetworkBuilder("v1")
net.add_nodes(N=1,  # specifiy the number of cells belong to said group.
              pop_name='', location='L2', ei='e',  # pop_name, location, and ei are optional parameters that help's identifies properties of the cells. The modeler can choose whatever key-value pairs as they deem appropiate.
              positions=[(2.753, -464.868, -161.705)],  # The following properties we are passing in lists
              tuning_angle=[0.0],                 #  values to each individual cell
	      rotation_angle_xaxis=-0.010516,
              rotation_angle_yaxis=0,
              rotation_angle_zaxis=-3.011895, # Note that the y-axis rotation is differnt for each cell (ie. given a list of size N), but with z-axis rotation all cells have the same value
              model_type='biophysical',  # The type of cell we are using
              model_template='ctdb:Biophys1.hoc',  # Tells the simulator that when building cells models use a hoc_template specially created for parsing Allen Cell-types file models. Value would be different if we were using NeuronML or different model files
              model_processing='aibs_allactive_ani_directed',  # further instructions for how to processes a cell model. In this case aibs_perisomatic is a built-in directive to cut the axon in a specific way
              dynamics_params='optim_param_571654895.json',  # Name of file (downloaded from Allen Cell-Types) used to set model parameters and channels
              morphology='571654895.swc'),  # Name of morphology file downloaded


# Step 2: We want to connect our network. Just like how we have node-types concept we group our connections into
# "edge-types" that share rules and properties
net.add_edges(source={'ei': 'e'}, target={'pop_name': ''},
              connection_rule=5,
              syn_weight=4e-05,
              weight_function='gaussianLL',
              weight_sigma=50.0,
              distance_range=[30.0, 150.0],
              target_sections=['basal', 'apical'],