API Reference
This section describes the main APIs of bionetlite.
Overview
bionetlite is a Python library that extends BMTK’s network builder. By changing only the import statement in BMTK code, you can generate files for the Neulite simulator.
NeuliteBuilder Class
This is the main interface of bionetlite. It inherits from BMTK’s NetworkBuilder.
Initialization
from bionetlite import NeuliteBuilder
net = NeuliteBuilder(
name, # Network name (required)
convert_morphologies=True, # Convert SWC files for Neulite
convert_ion_channels=True, # Convert ion channel JSON to CSV
simulation_config=None, # Simulation config (optional)
generate_config_h=True # Auto-generate config.h
)
Main Methods
add_nodes()
Add nodes (neurons) to the network.
net.add_nodes(
N=100, # Number of neurons
pop_name='Exc', # Population name
model_type='biophysical', # Model type
morphology='Scnn1a.swc', # Morphology file name
dynamics_params='472363762_fit.json', # Ion channel parameters
ei='e' # 'e' (excitatory) or 'i' (inhibitory)
)
Supported models: Currently only model_type='biophysical' is supported
add_edges()
Add edges (synaptic connections) to the network.
net.add_edges(
source={'pop_name': 'Exc'}, # Source population
target={'pop_name': 'Inh'}, # Target population
connection_rule=5, # Number of connections or probability
syn_weight=0.001, # Synaptic weight
delay=2.0, # Delay (ms, rounded to integer)
target_sections=['somatic', 'basal'], # Target sections
dynamics_params='ExcToInh.json' # Synapse parameters
)
Supported models: Currently only exp2syn is supported
build()
Build the network.
net.build()
save_nodes()
Save node information (SONATA format + Neulite format).
net.save_nodes(output_dir='network')
Generated files:
SONATA format:
<name>_nodes.h5,<name>_node_types.csvNeulite format:
<name>_population.csv, SWC files, ion channel CSV
save_edges()
Save edge information (SONATA format + Neulite format).
net.save_edges(output_dir='network')
Generated files:
SONATA format:
<src>_<trg>_edges.h5,<src>_<trg>_edge_types.csvNeulite format:
<src>_<trg>_connection.csv
Configuration Methods
set_config_path()
Set the path to config.json.
net.set_config_path('config.json')
set_dir()
Set the directory path for Neulite files.
net.set_dir(ion_dir='data/ion', swc_dir='data/morphology')
Basic Usage Example
from bionetlite import NeuliteBuilder
# Network initialization
net = NeuliteBuilder('V1')
# Add excitatory neurons
net.add_nodes(N=100, pop_name='Exc', model_type='biophysical',
morphology='Scnn1a.swc',
dynamics_params='472363762_fit.json', ei='e')
# Add inhibitory neurons
net.add_nodes(N=25, pop_name='Inh', model_type='biophysical',
morphology='Pvalb.swc',
dynamics_params='472912177_fit.json', ei='i')
# Exc -> Exc connection
net.add_edges(source={'pop_name': 'Exc'}, target={'pop_name': 'Exc'},
connection_rule=5, syn_weight=0.0005, delay=2.0,
target_sections=['basal', 'apical'],
dynamics_params='ExcToExc.json')
# Exc -> Inh connection
net.add_edges(source={'pop_name': 'Exc'}, target={'pop_name': 'Inh'},
connection_rule=3, syn_weight=0.001, delay=2.0,
target_sections=['somatic', 'basal'],
dynamics_params='ExcToInh.json')
# Build and save
net.build()
net.save_nodes(output_dir='network')
net.save_edges(output_dir='network')
Parallel Execution
Large network construction can be performed in parallel with MPI.
mpirun -n 4 python build_network.py
Next Steps
File Formats - Details of generated file formats
Unit System Reference - Details of unit systems and unit conversions
Basic Usage - Practical usage examples
Tutorial 1: Steady-State Current Injection in a Single Cell - Tutorial
Specifications and Limitations - Specifications and limitations