AllenInstitute / bmtk

Brain Modeling Toolkit
https://alleninstitute.github.io/bmtk/
BSD 3-Clause "New" or "Revised" License
266 stars 86 forks source link

Loading nodes from SONATA files and use them to build connections with NetworkBuilder #287

Closed MargauxCalice closed 1 year ago

MargauxCalice commented 1 year ago

How to load already existing nodes stored in a SONATA node file in order to use them to build new connections with NetworkBuilder without having to recreate these nodes ?

xpliu16 commented 1 year ago

Hi Margaux,

To load nodes from the SONATA file, one should use the function import_nodes(). For instance:

from bmtk.builder.networks import NetworkBuilder
from bmtk.builder.auxi.node_params import positions_columinar, xiter_random

net = NetworkBuilder('V1')
net.import_nodes(nodes_file_name='network/V1_nodes.h5', node_types_file_name='network/V1_node_types.csv')

net.add_edges(
    source={'node_id': [12,13]}, target={'pop_name': 'Scnn1a'},
    connection_rule=6,
    syn_weight=5e-05,
    weight_function='gaussianLL',
    weight_sigma=50.0,
    distance_range=[30.0, 150.0],
    target_sections=['basal', 'apical'],
    delay=2.0,
    dynamics_params='AMPA_ExcToExc.json',
    model_template='exp2syn'
)

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

You can also see an example of usage in the example network in bmtk/examples/bio_stp_models/build_network.py.

Thanks! Ping