hbp_nrp_cle.tf_framework package

This package contains the classes to specify transfer functions and connect them to communication adapters of both the neuronal simulator and the world simulator

exception BrainParameterException(message)[source]

Bases: Exception

Exception raised when a brain connection parameter fails to create the underlying adapter

Parameters
  • source – the exception source

  • message – the brain

exception TFException(tf_name, message, error_type)[source]

Bases: hbp_nrp_cle.tf_framework.UserCodeException

Exception class used to return a meaningful message to ExD front-end in case the update of TF’s user code fails.

Parameters
  • tf_name – name of the TF updated by the user.

  • message – message that needs to be forwarded to the front-end.

exception TFLoadingException(tf_name, message)[source]

Bases: hbp_nrp_cle.tf_framework.TFException

Exception class used to return a meaningful message to ExD front-end in case the loading of a TF with updated user code fails.

Parameters
  • tf_name – name of the TF updated by the user.

  • message – message that needs to be forwarded to the front-end.

exception TFRunningException(message)[source]

Bases: hbp_nrp_cle.tf_framework.UserCodeException

Exception class used to communicate the TF with the TransferFunction manager

Parameters
  • tf_name – name of the TF updated by the user.

  • message – message that needs to be forwarded to the front-end.

exception UserCodeException(message, error_type)[source]

Bases: Exception

General exception class returning a meaningful message to the ExD frontend when user code fails to be loaded or run.

Parameters
  • message – message that needs to be forwarded to the frontend.

  • error_type – Type of error (like ‘CLE Error’)

activate_transfer_function(tf, activate)[source]

Set the activation state of the transfer function In case of errors the change is not applied.

Parameters
  • tf – the tf to (de-)activate

  • activate – a boolean value denoting the new activation state

chain_neurons(*neuron_selectors)[source]

Chains the given neuron selectors

Parameters

neuron_selectors – The neuron selectors

cle_write_guard(ob)

No guard at all

clean_csv_recorders_files()[source]

Clean out all CSV recorders generated files.

delete_flawed_transfer_function(name)[source]

Delete a flawed transfer function. If the transfer function does not exist, nothing will happen.

Parameters

name – The name of the transfer function

Returns

True if the transfer function is correctly deleted. False if the transfer function does not exist.

delete_transfer_function(name)[source]

Delete a transfer function. If the transfer function does not exist, nothing will happen.

Parameters

name – The name of the transfer function

Returns

True if the transfer function is correctly deleted. False if the transfer function does not exist.

dump_csv_recorder_to_files()[source]

Find out all CSV recorders and dump their values to CSV files.

Returns

an array containing a string with the CSV filename, an array containing the CSV headers separated by a comma and an array containing the CSV values

get_brain_populations()[source]

Get the brain populations as a dictionary If the brain model is not loaded, the function returns None.

Returns

A dictionary containing the brain populations The dictionary keys are population names and its values are one of the following types: list, or a ‘slice’ dictionary of the following form {‘from’: 1, ‘to’: 10, ‘step’: 1}.

get_brain_source()[source]

Get the source of the brain (if loaded from a python file). Otherwise, returns None.

Returns

The source of the brain model

get_flawed_transfer_function(name)[source]

Get the flawed transfer function with the given name

Parameters

name – The name of the flawed transfer function

Returns

The flawed transfer function with the given name

get_transfer_function(name)[source]

Get the transfer function with the given name

Parameters

name – The name of the transfer function

Returns

The transfer function with the given name

get_transfer_functions(flawed=True)[source]

Get all the transfer functions if flawed is True, only (R2N, N2R, Silent) otherwise

Returns

All the transfer functions if flawed is True, only (R2N, N2R, Silent) otherwise.

initialize(name)[source]

Initializes and starts the TF node

Parameters

name – The name of the TF node

map_neurons(neuron_range, mapping)[source]

Maps the given range to neurons using the provided mapping

Parameters
  • neuron_range – A range that can be iterated

  • mapping – A mapping function or lambda

nrange(start, stop, step=None)[source]

Defines a range of neurons

Parameters
  • start – The start of the range

  • stop – The stop of the range

  • step – The step of the range

resolve(fun)[source]

Resolves the given function when the neural network is available

Parameters

fun – The function that selects the item from the network

resolve_brain_variable(var)[source]

Resolves the given brain variable for the current brain

Parameters

var – The brain variable

Returns

If the variable does not depend on the neural network, it is returned unchanged. Otherwise, it is resolved for the current neural network

set_flawed_transfer_function(source, name='NO_NAME', error=None)[source]

Creates a new flawed transfer function, i.e. a TF that is not valid due to some error in the source code. The user will correct it at a later stage (e.g. during an experiment)

Parameters
  • source – the source code

  • name – The name of the transfer function

  • error – the Exception raised during the compilation/loading of the code

set_nest_adapter(nest_adapter)[source]

Sets the brainsim adapter.

Parameters

nest_adapter – The brainsim adapter

Warning

Must be executed before tf node initialization

set_robot_adapter(robot_adapter)[source]

Sets the robot adapter.

Parameters

robot_adapter – The robot adapter

Warning

Must be executed before tf node initialization

set_transfer_function(new_source, new_code, new_name, activation=True, priority=None)[source]

Apply transfer function changes made by a client

Parameters
  • new_source – Transfer function’s updated source

  • new_code – Compiled code of the updated source

  • new_name – Transfer function’s updated name

  • activation – Activation state of the transfer function

  • priority – execution order of the transfer function. Transfer functions with higher priority are executed first.

start_new_tf_manager()[source]

Start a new transfer function manager