bionetlite Setup
This page explains the setup procedure for bionetlite, a Python package for network construction.
Prerequisites
The following software is required:
Python 3.7 or higher
Setup Procedure
Step 1: Create Virtual Environment (Recommended)
It is recommended to create a Python virtual environment:
# Create virtual environment
python -m venv neulite_env
# Activate virtual environment (Linux/Mac)
source neulite_env/bin/activate
Step 2: Install BMTK and NEURON
bionetlite depends on Brain Modeling Toolkit (BMTK) and NEURON.
Installing BMTK:
pip install bmtk
Installing NEURON:
Install NEURON (biophysical neuron simulator):
pip install neuron
Step 3: Install Required Packages
Installing scikit-learn:
bionetlite requires scikit-learn because it uses PCA (Principal Component Analysis) for axon orientation estimation:
pip install scikit-learn
Step 4: Clone the neulite Repository
Clone the neulite repository:
git clone https://github.com/neulite/neulite.git
The repository contains the following:
bionetlite/- bionetlite modulekernel/- Neulite kernel (default)flavors/- Kernel variations
Step 5: Place bionetlite
Place bionetlite.py from the cloned repository in the same directory as your network construction code:
cp neulite/bionetlite/bionetlite.py /path/to/your/network/code/
Directory Structure:
Place bionetlite.py in the same directory level as your network construction script:
your_project/
├── bionetlite.py # Copy here
├── build_network.py # Your network construction script
└── config.json # Configuration file (if needed)
With this arrangement, you can import in build_network.py as follows:
# build_network.py
from bionetlite import NeuliteBuilder as NetworkBuilder
net = NetworkBuilder('my_network')
net.add_nodes(...)
net.build()
net.save_nodes(output_dir='network')
Step 6: Verification
Verify that the placement is correct:
# Move to network construction code directory
cd /path/to/your/network/code/
# Verify that bionetlite.py exists
ls bionetlite.py
# Start Python interpreter to verify
python
>>> from bionetlite import NeuliteBuilder
>>> print("bionetlite is ready to use!")
If no errors are displayed, the setup is successful.
Basic Usage
Converting existing bionet code to bionetlite is very simple. Just change the import statement, and the rest of the code can be used as-is.
Changing the Import
Before (bionet):
from bmtk.builder.networks import NetworkBuilder
After (bionetlite):
from bionetlite import NeuliteBuilder as NetworkBuilder
Network Construction
The rest of the code is exactly the same as bionet:
# Create network
net = NetworkBuilder('v1')
# Add nodes
net.add_nodes(
N=1,
pop_name='Scnn1a',
model_type='biophysical',
model_template='ctdb:Biophys1.hoc',
dynamics_params='472363762_fit.json',
morphology='Scnn1a_473845048_m.swc'
)
# Build network
net.build()
# Save to files
net.save_nodes(output_dir='network')
net.save_edges(output_dir='network')
Confirming Output Files
bionetlite generates files for Neulite in the neulite/ directory:
Directory Structure
neulite/
├── v1_population.csv # Population information
├── v1_v1_connection.csv # Connection information
└── data/
├── *.swc # Processed morphology files
└── *.csv # Ion channel settings
Note
Filenames are generated based on the name specified in NetworkBuilder (in this example, 'v1').
Details of each file:
<network_name>_population.csv - Neuron population information
#n_cell,n_comp,name,swc_file,ion_file
#n_cell: Number of cells in the populationn_comp: Number of compartmentsname: Population nameswc_file: Path to morphology fileion_file: Path to ion channel configuration file
<src>_<trg>_connection.csv - Synapse connection information
#pre nid,post nid,post cid,weight,tau_decay,tau_rise,erev,delay,e/i
#pre nid: Presynaptic neuron IDpost nid: Postsynaptic neuron IDpost cid: Postsynaptic compartment IDweight: Synaptic weighttau_decay: Decay time constant (ms)tau_rise: Rise time constant (ms)erev: Reversal potential (mV)delay: Transmission delay (ms)e/i: Excitatory (e) or inhibitory (i)
Optional Settings
NeuliteBuilder can accept the following optional parameters:
net = NetworkBuilder(
'v1',
convert_morphologies=True, # Whether to convert SWC files
convert_ion_channels=True # Whether to convert ion channel settings
)
convert_morphologies and convert_ion_channels are True by default. In subsequent runs, you can skip conversion by setting these to False.
Details of Dependent Packages
Major Dependent Packages of bionetlite
bionetlite depends on the following Python packages:
bmtk>=1.0.0 # Brain Modeling Toolkit
neuron>=8.0.0 # NEURON simulator (required)
numpy>=1.19.0 # Numerical computing
pandas>=1.2.0 # Data manipulation
h5py>=3.0.0 # HDF5 file support
scikit-learn>=0.24.0 # PCA for axon direction estimation (required)
mpi4py>=3.0.0 # MPI parallel processing (optional)
Required Packages:
pip install bmtk neuron scikit-learn
Optional Packages:
# When using MPI parallel processing
pip install mpi4py
Next Steps
Building Neulite Kernel - Building Neulite Kernel
Tutorial 1: Steady-State Current Injection in a Single Cell - Practical Tutorial
Basic Usage - Detailed Usage