Пример #1
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')
Пример #2
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')