ALLEN INSTITUTE

# bmtk.simulator.core package

## Subpackages

- bmtk.simulator.core.modules package
  - Submodules
  - bmtk.simulator.core.modules.ecephys_module module
    - `ECEphysUnitsModule`
      - `ECEphysUnitsModule.initialize()`
    - `MappingStrategy`
      - `MappingStrategy.build_map()`
      - `MappingStrategy.get_spike_trains()`
      - `MappingStrategy.nwb_files`
      - `MappingStrategy.units2nodes_map`
      - `MappingStrategy.units_table`
    - `NWBFileWrapper`
      - `NWBFileWrapper.uuid`
    - `SamplingStrategy`
      - `SamplingStrategy.build_map()`
    - `TimeWindow`
      - `TimeWindow.units_lu`
    - `UnitIdMapStrategy`
      - `UnitIdMapStrategy.build_map()`
    - `filter_table()`
  - bmtk.simulator.core.modules.iclamp module
    - `AmpsReader`
    - `CSVAmpReader`
    - `IClampMod`
      - `IClampMod.input2reader_map`
    - `NWBReader`
  - bmtk.simulator.core.modules.simulator_module module
    - `SimulatorMod`
      - `SimulatorMod.block()`
      - `SimulatorMod.finalize()`
      - `SimulatorMod.initialize()`
      - `SimulatorMod.preload()`
      - `SimulatorMod.step()`
  - Module contents
- bmtk.simulator.core.sonata_reader package
  - Submodules
  - bmtk.simulator.core.sonata_reader.edge_adaptor module
    - `EdgeAdaptor`
      - `EdgeAdaptor.batch_process`
      - `EdgeAdaptor.create_adaptor()`
      - `EdgeAdaptor.get_edge()`
      - `EdgeAdaptor.patch_adaptor()`
      - `EdgeAdaptor.preprocess_edge_types()`
    - `SonataBaseEdge`
      - `SonataBaseEdge.delay`
      - `SonataBaseEdge.dynamics_params`
      - `SonataBaseEdge.edge_type_id`
      - `SonataBaseEdge.is_gap_junction`
      - `SonataBaseEdge.model_template`
      - `SonataBaseEdge.nsyns`
      - `SonataBaseEdge.preselected_targets`
      - `SonataBaseEdge.source_node_id`
      - `SonataBaseEdge.source_population`
      - `SonataBaseEdge.syn_weight()`
      - `SonataBaseEdge.target_distance`
      - `SonataBaseEdge.target_node_id`
      - `SonataBaseEdge.target_population`
      - `SonataBaseEdge.target_sections`
      - `SonataBaseEdge.weight_function`
    - `group_dynamics_params()`
    - `no_nsyns()`
    - `nsyns()`
    - `ret_none_function()`
    - `syn_weight()`
    - `syn_weight_function()`
    - `types_dynamics_params()`
    - `weight_function()`
  - bmtk.simulator.core.sonata_reader.network_reader module
    - `SonataEdges`
      - `SonataEdges.get_edges()`
      - `SonataEdges.get_source()`
      - `SonataEdges.get_target()`
      - `SonataEdges.initialize()`
      - `SonataEdges.load()`
      - `SonataEdges.name`
      - `SonataEdges.source_nodes`
      - `SonataEdges.target_nodes`
    - `SonataNodes`
      - `SonataNodes.adaptor`
      - `SonataNodes.filter()`
      - `SonataNodes.get_node()`
      - `SonataNodes.get_nodes()`
      - `SonataNodes.initialize()`
      - `SonataNodes.load()`
      - `SonataNodes.n_nodes()`
      - `SonataNodes.name`
      - `SonataNodes.nodes_df()`
    - `load_edges()`
    - `load_nodes()`
  - bmtk.simulator.core.sonata_reader.node_adaptor module
    - `NodeAdaptor`
      - `NodeAdaptor.COL_DYNAMICS_PARAM`
      - `NodeAdaptor.COL_GID`
      - `NodeAdaptor.COL_MODEL_PROCESSING`
      - `NodeAdaptor.COL_MODEL_TEMPLATE`
      - `NodeAdaptor.COL_MODEL_TYPE`
      - `NodeAdaptor.batch_process`
      - `NodeAdaptor.create_adaptor()`
      - `NodeAdaptor.get_node()`
      - `NodeAdaptor.model_processing()`
      - `NodeAdaptor.model_template()`
      - `NodeAdaptor.model_type()`
      - `NodeAdaptor.node_id()`
      - `NodeAdaptor.patch_adaptor()`
      - `NodeAdaptor.preprocess_node_types()`
    - `SonataBaseNode`
      - `SonataBaseNode.dynamics_params`
      - `SonataBaseNode.gid`
      - `SonataBaseNode.model_processing`
      - `SonataBaseNode.model_template`
      - `SonataBaseNode.model_type`
      - `SonataBaseNode.network`
      - `SonataBaseNode.node_id`
      - `SonataBaseNode.population`
      - `SonataBaseNode.population_name`
    - `empty_list()`
    - `group_dynamics_params()`
    - `none_function()`
    - `types_dynamics_params()`
  - Module contents

## Submodules

## bmtk.simulator.core.edge_population module

class bmtk.simulator.core.edge_population.EdgePopulation

  Bases: `object`

  initialize(network)
  property source_nodes
  property target_nodes

class bmtk.simulator.core.edge_population.SimEdge

  Bases: `object`

  property gid
  property node_id

## bmtk.simulator.core.graph module

class bmtk.simulator.core.graph.SimGraph

  Bases: `object`

  add_component(key, value)

    Add a component key-value pair

    Parameters:

      - key – name of component

      - value – value

  add_edges(sonata_file, populations=None, source_pop=None, target_pop=None)
    Parameters:

      - sonata_file

      - populations

      - source_pop

      - target_pop

    Returns:

  add_nodes(sonata_file, populations=None)

    Add nodes from a network to the graph.

    Parameters:

      - sonata_file – A NodesFormat type object containing list of nodes.

      - populations – name/identifier of network. If none will attempt to retrieve from nodes object

  build_nodes()
  build_recurrent_edges()
  external_edge_populations(src_pop, trg_pop)
  classmethod from_config(conf, **properties)

    Generates a graph structure from a json config file or dictionary.

    Parameters:

      - conf – name of json config file, or a dictionary with config parameters

      - properties – optional properties.

    Returns:

      A graph object of type cls

  get_component(key)

    Get the value of item in the components dictionary.

    Parameters:

      key – name of component

    Returns:

      value assigned to component

  get_node_population(population_name)
  get_node_populations()
  get_node_set(node_set)
  property io
  model_type_col = 'model_type'
  property node_populations

## bmtk.simulator.core.io_tools module

class bmtk.simulator.core.io_tools.IOUtils

  Bases: `object`

  For logging/mkdir commands we sometimes need to use different MPI classes depending on the simulator being used (NEST and NEURON have their own barrier functions that don’t work well with mpi). We also need to be able to adjust the logging levels/format at run-time depending on the simulator/configuration options.

  Thus the bulk of the io and logging functions are put into their own class and can be overwritten by specific simulator modules

  barrier()

    MPI Barrier call

  log_debug(message, all_ranks=False)
  log_error(message)
  log_exception(message, raise_exception=True)
  log_info(message, all_ranks=False)
  property log_to_console
  log_warning(message, all_ranks=False, display_once=False)
  property logger
  quiet_simulator()

    Turns off logging/messages of the native simulator

  set_log_format(format_str)
  set_log_level(loglevel)
  setup_output_dir(output_dir, log_file, overwrite=True)

## bmtk.simulator.core.network_reader module

class bmtk.simulator.core.network_reader.EdgesReader

  Bases: `object`

  initialize(network)
  mixed = 2
  property mixed_connections
  recurrent = 0
  property recurrent_connections
  set_connection_type(src_pop, trg_pop)
  property source_nodes
  property target_nodes
  unknown = 0
  virtual = 1
  property virtual_connections

class bmtk.simulator.core.network_reader.NodesReader

  Bases: `object`

  initialize(network)
  property internal_nodes_only
  classmethod load(**properties)
  property mixed_nodes
  property name
  property virtual_nodes_only

## bmtk.simulator.core.node_population module

class bmtk.simulator.core.node_population.NodePopulation

  Bases: `object`

  initialize(network)
  property internal_nodes_only
  classmethod load(**properties)
  property mixed_nodes
  property name
  property virtual_nodes_only

class bmtk.simulator.core.node_population.SimNode

  Bases: `object`

  property gid
  property node_id

## bmtk.simulator.core.node_sets module

class bmtk.simulator.core.node_sets.NodeSet(filter_params, network)

  Bases: `object`

  fetch_nodes()
  gids()
  property node_ids
  nodes()
  population_names()
  populations()

class bmtk.simulator.core.node_sets.NodeSetAll(network)

  Bases: `NodeSet`

bmtk.simulator.core.node_sets.to_list(val)

## bmtk.simulator.core.pyfunction_cache module

bmtk.simulator.core.pyfunction_cache.add_cell_model(func, directive, model_type='*', overwrite=True)

bmtk.simulator.core.pyfunction_cache.add_cell_processor(func, name=None, overwrite=True)

bmtk.simulator.core.pyfunction_cache.add_spikes_generator(func, name=None, overwrite=True)

bmtk.simulator.core.pyfunction_cache.add_synapse_model(func, name=None, overwrite=True)

bmtk.simulator.core.pyfunction_cache.add_weight_function(func, name=None, overwrite=True)

bmtk.simulator.core.pyfunction_cache.cell_model(*wargs, **wkwargs)

  A decorator for registering NEURON cell loader functions.

bmtk.simulator.core.pyfunction_cache.load_py_modules(cell_models=None, syn_models=None, syn_weights=None, cell_processors=None)

bmtk.simulator.core.pyfunction_cache.model_processing(*wargs, **wkwargs)

bmtk.simulator.core.pyfunction_cache.spikes_generator(*wargs, **wkwargs)

bmtk.simulator.core.pyfunction_cache.synapse_model(*wargs, **wkwargs)

  A decorator for registering NEURON synapse loader functions.

bmtk.simulator.core.pyfunction_cache.synaptic_weight(*wargs, **wkwargs)

  A decorator for registering a function as a synaptic weight function. To use either:

      @synaptic_weight
      def weight_function():
          ...

  or:

      @synaptic_weight(name='name_in_edge_types')
      def weight_function():
          ...

  Once the decorator has been attached and imported the functions will automatically be added to py_modules and BMTK will when assigning synaptic/gap junction weights for edges with matching “weight_function” attribute

## bmtk.simulator.core.simulation_config module

class bmtk.simulator.core.simulation_config.SimulationConfig(*args, **kwargs)

  Bases: `SonataConfig`

  A special version of SonataConfig that contains some methods that can be used by the simulators. Mainly it contains the build_env() method which can be called to setup logging plus initialize the ‘output_dir’ folder.

  Functionality that is specific to SONATA should go in SonataConfig

  build_env(force=False)

    Creates the folder(s) set in ‘output’ section, sets up logging and copies over the configuration

  copy_to_output()
  property io
  validate()
  property validator

bmtk.simulator.core.simulation_config.from_dict(config_dict, validator=None, **opts)

bmtk.simulator.core.simulation_config.from_json(config_file, validator=None, **opts)

## bmtk.simulator.core.simulation_config_validator module

class bmtk.simulator.core.simulation_config_validator.SimulationConfigValidator(schema, resolver=None, file_formats=(), **kwargs)

  Bases: `Draft4Validator`

  A JSON Schema validator class that will store a schema (passed into the constructor) and validate a json file. It has all the functionality of the JSONSchema format, plus includes special types and parameters like making sure a value is a file or directory type, checking csv files, etc.

  To Use:

    validator = SimConfigValidator(json_schema.json) validator.validate(file.json)

  evolve(**changes)
  format_checker: FormatChecker | None
  is_type(instance, dtype)
  schema: bool | Mapping[str, Any]

## bmtk.simulator.core.simulator module

class bmtk.simulator.core.simulator.Simulator

  Bases: `object`

  add_mod(module)
  run()

## bmtk.simulator.core.simulator_network module

class bmtk.simulator.core.simulator_network.SimNetwork

  Bases: `object`

  add_component(name, path)
  add_edges(edge_population)
  add_node_set(name, node_set)
  add_nodes(node_population)
  build()
  build_nodes()
  build_recurrent_edges(**opts)
  build_virtual_connections()
  classmethod from_builder(network)
  classmethod from_config(conf, **properties)

    Generates a graph structure from a json config file or dictionary.

    Parameters:

      - conf – name of json config file, or a dictionary with config parameters

      - properties – optional properties.

    Returns:

      A graph object of type cls

  classmethod from_manifest(manifest_json)
  get_component(name)
  get_edge_adaptor(name)
  get_node_adaptor(name)
  get_node_groups(populations=None)
  get_node_population(name)
  get_node_populations()
  get_node_set(node_set)
  get_node_sets(populations=None, groupby=None, **filterby)
  has_component(name)
  property io
  load_gap_junc_files(gj_dic)
  property node_populations
  node_properties(populations=None)
  property py_function_caches
  property recurrent_edges

## Module contents