Brian Parameters, Results and Monitors¶
Module containing results and parameters that can be used to store BRIAN data.
Parameters handling BRIAN data are instantiated by the BrianParameter class for any BRIAN Quantity.
The BrianResult can store BRIAN Quantities and the BrianMonitorResult extracts data from BRIAN Monitors.
All these can be combined with the experimental framework in pypet.brian.network to allow fast setup of large scale BRIAN experiments.
BrianParameter¶
- class pypet.brian.parameter.BrianParameter(full_name, data=None, comment='', storage_mode='FLOAT')[source]¶
A Parameter class that supports BRIAN Quantities.
Note that only scalar BRIAN quantities are supported, lists, tuples or dictionaries of BRIAN quantities cannot be handled.
There are two storage modes, that can be either passed to constructor or changed via v_storage_mode:
FLOAT_MODE: (‘FLOAT’)
The value is stored as a float and the unit as a sting.
i.e. 12 mV is stored as 12.0 and ‘1.0 * mV’
STRING_MODE: (‘STRING’)
The value and unit are stored combined together as a string.
i.e. 12 mV is stored as ‘12.0 * mV’
Supports data for the standard Parameter, too.
- FLOAT_MODE = 'FLOAT'¶
Float storage mode
- IDENTIFIER = '__brn__'¶
Identification string stored into column title of hdf5 table
- STRING_MODE = 'STRING'¶
String storage mode
- v_storage_mode[source]¶
There are two storage modes:
FLOAT_MODE: (‘FLOAT’)
The value is stored as a float and the unit as a sting.
i.e. 12 mV is stored as 12.0 and ‘1.0 * mV’
STRING_MODE: (‘STRING’)
The value and unit are stored combined together as a string.
i.e. 12 mV is stored as ‘12.0 * mV’
BrianDurationParameter¶
- class pypet.brian.parameter.BrianDurationParameter(full_name, data=None, order=0, comment='', storage_mode='FLOAT')[source]¶
Special BRIAN parameter to specify orders and durations of subruns.
The NetworkRunner extracts the individual subruns for a given network from such duration parameters. The order of execution is defined by the property v_order. The exact values do not matter only the rank ordering.
A Duration Parameter should be in time units (ms or s, for instance).
DEPRECATED: Please use a normal BrianParameter instead and add the property order to it’s Annotations. No longer use:
>>> subrun = BrianDurationParameter('mysubrun', 10*s, order=42)
But use:
>>> subrun = BrianParameter('mysubrun', 10*s) >>> subrun.v_annotations.order=42
BrianResult¶
- class pypet.brian.parameter.BrianResult(full_name, *args, **kwargs)[source]¶
A result class that can handle BRIAN quantities.
Note that only scalar BRIAN quantities are supported, lists, tuples or dictionaries of BRIAN quantities cannot be handled.
Supports also all data supported by the standard Result.
Storage mode works as for BrianParameter.
- FLOAT_MODE = 'FLOAT'¶
Float storage mode
- IDENTIFIER = '__brn__'¶
Identifier String to label brian data
- STRING_MODE = 'STRING'¶
String storage mode
- 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
- v_storage_mode[source]¶
There are two storage modes:
FLOAT_MODE: (‘FLOAT’)
The value is stored as a float and the unit as a sting,
i.e. 12 mV is stored as 12.0 and ‘1.0 * mV’
STRING_MODE: (‘STRING’)
The value and unit are stored combined together as a string,
i.e. 12 mV is stored as ‘12.0 * mV’
BrianMonitorResult¶
- class pypet.brian.parameter.BrianMonitorResult(full_name, *args, **kwargs)[source]¶
A Result class that supports brian monitors.
Subclasses Result, NOT BrianResult. The storage mode here works slightly different than in BrianResult and BrianParameter, see below.
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(...), storage_mode='TABLE', comment='Im a SpikeMonitor Example!') >>> brian_result.nspikes 1337
There are two storage modes in case you use the SpikeMonitor and StateSpikeMonitor:
TABLE_MODE: (‘TABLE’)
Default, information is stored into a single table where one column contains the neuron index, another the spiketimes and following columns contain variable values (in case of the StateSpikeMonitor) This is a very compact storage form.
ARRAY_MODE: (‘ARRAY’)
For each neuron there will be a new hdf5 array, i.e. if you have many neurons your result node will have many entries. Note that this mode does sort everything according to the neurons but reading and writing of data might take muuuuuch longer compared to the other mode.
Following monitors are supported and the following values are extraced:
SpikeCounter
count
Array of spike counts for each neuron
nspikes
Number of recorded spikes
source
Name of source recorded from as string.
VanRossumMetric
tau
Time constant of kernel.
tau_unit
‘second’
distance
A square symmetric matrix containing the distances
N
Number of neurons.
source
PopulationSpikeCounter
delay
Recording delay
nspikes
source
StateSpikeMonitor
delay
nspikes
source
varnames
Names of recorded variables as tuple of strings.
spiketimes_unit
‘second’
variablename_unit
Unit of recorded variable as a string. ‘variablename’ is mapped to the name of a recorded variable. For instance, if you recorded the membrane potential named ‘vm’ you would get a field named ‘vm_unit’.
If you use v_storage_mode = TABLE_MODE
spikes
pandas DataFrame containing in the columns:
‘neuron’: neuron indices
‘spiketimes’: times of spiking
‘variablename’: values of the recorded variables
If you use v_storage_mode = ARRAY_MODE
spiketimes_XXX
spiketimes of neuron ‘XXX’ for each neuron you recorded from. The number of digits used to represent and format the neuron index are chosen automatically.
variablename_XXX
Value of the recorded variable at spiketimes for neuron XXX
format_string
String used to format the neuron index, for example ‘%03d’.
PopulationRateMonitor
times
The times of the bins.
times_unit
‘second’
rate
An array of rates in Hz
rate_unit
‘Hz’
source
bin
The duration of a bin (in second).
delay
ISIHistogramMonitor:
source
delay
nspikes
bins
The bins array passed at initialisation of the monitor.
count
An array of length len(bins) counting how many ISIs were in each bin.
SpikeMonitor
delay
nspikes
source
spiketimes_unit
‘second’
If you use v_storage_mode = TABLE_MODE
spikes
pandas DataFrame containing in the columns:
‘neuron’: neuron indices
‘spiketimes’: times of spiking
If you use v_storage_mode = ARRAY_MODE
spiketimes_XXX
spiketimes of neuron ‘XXX’ for each neuron you recorded from. The number of digits used to represent and format the neuron index are chosen automatically.
format_string
String used to format the neuron index, for example ‘%03d’.
StateMonitor
source
record
What to record. Can be ‘True’ to record from all neurons. A single integer value or a list of integers.
when
When recordings were made, for a list of potential values see BRIAN.
timestep
Integer defining the clock timestep a recording was made.
times
Array of recording times
times_unit
‘second’
mean
Mean value of the state variable for every neuron in the group. Only extracted if mean values are calculated by BRIAN. Note that for newer versions of BRIAN, means and variances are no longer extracted if record is NOT set to False.
var
Unbiased estimated of variances of state variable for each neuron. Only extracted if variance values are calculated by BRIAN.
values
A 2D array of the values of all recorded neurons, each row is a single neuron’s value
unit
The unit of the values as a string
varname
Name of recorded variable
MultiStateMonitor
As above but instead of values and unit, the result contains ‘varname_values’ and ‘varname_unit’, where ‘varname’ is the name of the recorded variable.
- ARRAY_MODE = 'ARRAY'¶
Array storage mode, not recommended if you have many neurons!
- TABLE_MODE = 'TABLE'¶
Table storage mode for SpikeMonitor and StateSpikeMonitor
- 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[source]¶
The type of the stored monitor. Each MonitorResult can only manage a single Monitor.
- v_storage_mode[source]¶
The storage mode for SpikeMonitor and StateSpikeMonitor
There are two storage modes:
TABLE_MODE: (‘TABLE’)
Default, information is stored into a single table where the first column is the neuron index, second column is the spike time following columns contain variable values (in case of the StateSpikeMonitor) This is a very compact storage form.
ARRAY_MODE: (‘ARRAY’)
For each neuron there will be a new hdf5 array, i.e. if you have many neurons your result node will have many entries. Note that this mode does sort everything according to the neurons but reading and writing of data might take muuuuuch longer compared to the other mode.