Brian2 Parameters, Results and Monitors

Module containing results and parameters that can be used to store BRIAN2 data.

Parameters handling BRIAN2 data are instantiated by the Brian2Parameter class for any BRIAN2 Quantity.

The Brian2Result can store BRIAN2 Quantities and the Brian2MonitorResult extracts data from BRIAN2 Monitors.

Brian2Parameter

class pypet.brian2.parameter.Brian2Parameter(full_name, data=None, comment='')[source]

A Parameter class that supports BRIAN2 Quantities.

Note that only scalar BRIAN2 quantities are supported, lists, tuples or dictionaries of BRIAN2 quantities cannot be handled.

Supports data for the standard Parameter, too.

IDENTIFIER = '__brn2__'

Identification string stored into column title of hdf5 table

f_supports(data)[source]

Simply checks if data is supported

Brian2Result

class pypet.brian2.parameter.Brian2Result(full_name, *args, **kwargs)[source]

A result class that can handle BRIAN2 quantities.

Note that only scalar BRIAN2 quantities are supported, lists, tuples or dictionaries of BRIAN2 quantities cannot be handled.

Supports also all data supported by the standard Result.

IDENTIFIER = '__brn2__'

Identifier String to label brian result

f_set_single(name, item)[source]

Sets a single data item of the result.

Raises TypeError if the type of the outer data structure is not understood. Note that the type check is shallow. For example, if the data item is a list, the individual list elements are NOT checked whether their types are appropriate.

Parameters:
  • name – The name of the data item
  • item – The data item
Raises:

TypeError

Example usage:

>>> res.f_set_single('answer', 42)
>>> res.f_get('answer')
42

Brian2MonitorResult

class pypet.brian2.parameter.Brian2MonitorResult(full_name, *args, **kwargs)[source]

A Result class that supports BRIAN2 monitors.

Monitor attributes are extracted and added as results with the attribute names. Note the original monitors are NOT stored, only their attribute/property values are kept.

Add monitor on __init__ via monitor= or via f_set(monitor=brian_monitor)

IMPORTANT: You can only use 1 result per monitor. Otherwise a ‘TypeError’ is thrown.

Example:

>>> brian_result = BrianMonitorResult('example.brian_test_test.mymonitor',
                                        monitor=SpikeMonitor(...),
                                        comment='Im a SpikeMonitor Example!')
>>> brian_result.num_spikes
1337

Following monitors are supported and the following values are extraced:

  • PopulationRateMonitor

    • t

      The times of the bins.

    • rate

      An array of rates in Hz

    • source

      String representation of source

    • name

      The name of the monitor

  • SpikeMonitor

    • t

      The times of the spikes

    • i

      The neuron indices of the spikes

    • num_spikes

      Total number of spikes

    • record_variables

      If variables are recorded at spike time, this is the list of their names

    • “varname”

      Array of variable recorded at spike time

    • source

      String representation of source

    • name

      The name of the monitor

  • StateMonitor

    • t

      Recording times

    • record_variables

      List of recorded variable names

    • “varname”

      Array of variable recorded

    • source

      String representation of source

    • name

      The name of the monitor

f_set_single(name, item)[source]

To add a monitor use f_set_single(‘monitor’, brian_monitor).

Otherwise f_set_single works similar to f_set_single().

v_monitor_type

The type of the stored monitor. Each MonitorResult can only manage a single Monitor.