Configuration

Overview

bionetlite reads BMTK’s JSON format configuration file (config.json) and automatically generates a configuration header file (config.h) for the Neulite kernel.

Role of Configuration Files

BMTK’s config.json file contains the following information:

  • Simulation execution parameters (time step, simulation time, etc.)

  • Path to network files

  • Input configuration (current injection, etc.)

  • Path to component directory

bionetlite extracts parameters required by the Neulite kernel from config.json and outputs them as a C language header file (config.h).

Structure of config.json

Basic Execution Settings

{
  "run": {
    "tstop": 2000.0,
    "dt": 0.1,
    "spike_threshold": -15.0
  }
}
  • tstop: Simulation time (ms) (default: 1000.0)

  • dt: Time step (ms) (default: 0.1)

  • spike_threshold: Spike detection threshold (mV) (default: -15.0)

Input Configuration (Current Injection)

{
  "inputs": {
    "current_clamp": {
      "input_type": "current_clamp",
      "module": "IClamp",
      "node_set": "all",
      "amp": 0.120,
      "delay": 500.0,
      "duration": 1000.0
    }
  }
}
  • amp: Amplitude of current injection (nA) (default: 0.1)

  • delay: Current injection start time (ms) (default: 500.0)

  • duration: Duration of current injection (ms) (default: 500.0)

Note

bionetlite automatically detects inputs where input_type is current_clamp or module is IClamp.

Component Configuration

{
  "components": {
    "morphologies_dir": "$COMPONENT_DIR/morphologies",
    "biophysical_neuron_models_dir": "$COMPONENT_DIR/biophysical_neuron_models",
    "synaptic_models_dir": "$COMPONENT_DIR/synaptic_models"
  }
}
  • morphologies_dir: Directory containing SWC files

  • biophysical_neuron_models_dir: Directory containing ion channel JSON files

  • synaptic_models_dir: Directory containing synapse model JSON files

Automatic Generation of config.h

How to Use bionetlite

bionetlite automatically generates config.h during network construction:

from bionetlite import NeuliteBuilder as NetworkBuilder

# Auto-generate config.h from config.json
net = NetworkBuilder('mcortex')
net.add_nodes(...)
net.build()
net.save_nodes(output_dir='network')

Generated config.h

bionetlite generates config.h from config.json as follows:

// Automatically generated by bionetlite

#pragma once

#undef DEBUG

// Simulation parameters
#define TSTOP ( 2000.0 )
#define DT ( 0.1 )
#define INV_DT ( ( int ) ( 1.0 / ( DT ) ) )

// Neuron parameters
#define SPIKE_THRESHOLD ( -15.0 )
#define ALLACTIVE ( 0 ) // Set to 1 for allactive models

// Current injection parameters
#define I_AMP ( 0.12 )
#define I_DELAY ( 500.0 )
#define I_DURATION ( 1000.0 )

Meaning of each definition:

  • TSTOP: Simulation time (ms)

  • DT: Time step (ms)

  • INV_DT: Number of steps per millisecond (int type)

  • SPIKE_THRESHOLD: Spike detection threshold (mV)

  • ALLACTIVE: Flag for using allactive model (0 or 1)

  • I_AMP: Amplitude of current injection (nA)

  • I_DELAY: Current injection start time (ms)

  • I_DURATION: Duration of current injection (ms)

Output Location

config.h is generated at the following location:

neulite/ # or {base_dir}_nl/
└── kernel/
    └── config.h

This config.h is automatically used when building the Neulite kernel.

Advanced Usage

Using the simulation_config Parameter

You can also specify settings directly in Python code without using config.json:

from bionetlite import NeuliteBuilder as NetworkBuilder
from bmtk.utils.sonata.config import SonataConfig

# Create SonataConfig object
config = SonataConfig.from_dict({
    'run': {
        'tstop': 3000.0,
        'dt': 0.05,
        'spike_threshold': -20.0
    },
    'inputs': {
        'current_clamp': {
            'input_type': 'current_clamp',
            'amp': 0.15,
            'delay': 1000.0,
            'duration': 2000.0
        }
    }
})

# Pass SonataConfig via simulation_config parameter
net = NetworkBuilder('mcortex', simulation_config=config)
net.add_nodes(...)
net.build()
net.save_nodes(output_dir='network')

Disabling config.h Generation

To disable automatic generation of config.h:

# Disable by setting generate_config_h=False
net = NetworkBuilder('mcortex', generate_config_h=False)

In this case, you need to use an existing config.h file or create config.h manually.

Compatibility with Existing BMTK config

bionetlite is fully compatible with the existing BMTK config.json format. You can use the config.json used in BMTK as is.

However, note the following limitations:

  • delay value: Neulite treats delay values as integers (int type). While decimals can be specified in config.json, bionetlite internally rounds and converts to integer.

  • Input type: Currently, only current_clamp (IClamp) format input is supported.

Next Steps