The Virtual Brain Project

Previous topic

Noise

Next topic

Phase-Plane Interactive

This Page

Monitors

Class diagram for tvb.simulator.monitors

Monitors record significant values from the simulation. In their simplest form they return all the simulated data, Raw(), directly subsampled data, SubSample() spatially averaged temporally subsampled, GlobalAverage(), or temporally averaged subsamples, TemporalAverage(). The more elaborate monitors instantiate a physically realistic measurement process on the simulation, such as EEG, MEG, and fMRI (BOLD).

Conversion of power of 2 sample-rates(Hz) to Monitor periods(ms)

4096 Hz => 0.244140625 ms
2048 Hz => 0.48828125 ms
1024 Hz => 0.9765625 ms
 512 Hz => 1.953125 ms
 256 Hz => 3.90625 ms
 128 Hz => 7.8125 ms
class tvb.simulator.monitors.Bold(**kwargs)[source]

Bases: tvb.simulator.monitors.Monitor

Base class for the Bold monitor.

Attributes

hrf_kernel: the haemodynamic response function (HRF) used to compute
the BOLD (Blood Oxygenation Level Dependent) signal.

length : duration of the hrf in seconds.

period : the monitor’s period

References:

[B_1997]Buxton, R. and Frank, L., A Model for the Coupling between Cerebral Blood Flow and Oxygen Metabolism During Neural Stimulation, 17:64-72, 1997.
[Fr_2000]Friston, K., Mechelli, A., Turner, R., and Price, C., Nonlinear Responses in fMRI: The Balloon Model, Volterra Kernels, and Other Hemodynamics, NeuroImage, 12, 466 - 477, 2000.
[Bo_1996]Geoffrey M. Boynton, Stephen A. Engel, Gary H. Glover and David J. Heeger (1996). Linear Systems Analysis of Functional Magnetic Resonance Imaging in Human V1. J Neurosci 16: 4207-4221
[Po_2000]Alex Polonsky, Randolph Blake, Jochen Braun and David J. Heeger (2000). Neuronal activity in human primary visual cortex correlates with perception during binocular rivalry. Nature Neuroscience 3: 1153-1159
[Gl_1999]Glover, G. Deconvolution of Impulse Response in Event-Related BOLD fMRI. NeuroImage 9, 416-429, 1999.

Note

gamma and polonsky are based on the nitime implementation http://nipy.org/nitime/api/generated/nitime.fmri.hrf.html

Note

see Tutorial_Exploring_The_Bold_Monitor

period : tvb.simulator.monitors.Bold.period = Float(field_type=<class ‘float’>, default=2000.0, required=True)
For the BOLD monitor, sampling period in milliseconds must be an integral multiple of 500. Typical measurment interval (repetition time TR) is between 1-3 s. If TR is 2s, then Bold period is 2000ms.
hrf_kernel : tvb.simulator.monitors.Bold.hrf_kernel = Attr(field_type=<class ‘tvb.datatypes.equations.HRFKernelEquation’>, default=<tvb.datatypes.equations.FirstOrderVolterra object at 0x7f71ae9f6350>, required=True)
A tvb.datatypes.equation object which describe the haemodynamic response function used to compute the BOLD signal.
hrf_length : tvb.simulator.monitors.Bold.hrf_length = Float(field_type=<class ‘float’>, default=20000.0, required=True)
Duration of the hrf kernel
variables_of_interest : tvb.simulator.monitors.Monitor.variables_of_interest = NArray(label=’Model variables to watch’, dtype=int64, default=None, dim_names=(), ndim=None, required=False)
Indices of model’s variables of interest (VOI) that this monitor should record. Note that the indices should start at zero, so that if a model offers VOIs V, W and V+W, and W is selected, and this monitor should record W, then the correct index is 0.

gid : tvb.basic.neotraits._core.HasTraits.gid = Attr(field_type=<class ‘uuid.UUID’>, default=None, required=True)

compute_hrf()[source]

Compute the hemodynamic response function.

config_for_sim(simulator)[source]
hemodynamic_response_function = None
hrf_kernel

An Attr declares the following about the attribute it describes: * the type * a default value shared by all instances * if the value might be missing * documentation It will resolve to attributes on the instance.

hrf_length

Declares a float. This is different from Attr(field_type=float). The former enforces float subtypes. This allows any type that can be safely cast to the declared float type according to numpy rules.

Reading and writing this attribute is slower than a plain python attribute. In performance sensitive code you might want to use plain python attributes or even better local variables.

period

Declares a float. This is different from Attr(field_type=float). The former enforces float subtypes. This allows any type that can be safely cast to the declared float type according to numpy rules.

Reading and writing this attribute is slower than a plain python attribute. In performance sensitive code you might want to use plain python attributes or even better local variables.

sample(step, state)[source]
class tvb.simulator.monitors.BoldRegionROI(**kwargs)[source]

Bases: tvb.simulator.monitors.Bold

The BoldRegionROI monitor assumes that it is being used on a surface and uses the region mapping of the surface to generate regional signals which are the spatial average of all vertices in the region.

This was originated to compare the results of a Bold monitor with a region level simulation with that of an otherwise identical surface simulation.

period : tvb.simulator.monitors.Bold.period = Float(field_type=<class ‘float’>, default=2000.0, required=True)
For the BOLD monitor, sampling period in milliseconds must be an integral multiple of 500. Typical measurment interval (repetition time TR) is between 1-3 s. If TR is 2s, then Bold period is 2000ms.
hrf_kernel : tvb.simulator.monitors.Bold.hrf_kernel = Attr(field_type=<class ‘tvb.datatypes.equations.HRFKernelEquation’>, default=<tvb.datatypes.equations.FirstOrderVolterra object at 0x7f71ae9f6350>, required=True)
A tvb.datatypes.equation object which describe the haemodynamic response function used to compute the BOLD signal.
hrf_length : tvb.simulator.monitors.Bold.hrf_length = Float(field_type=<class ‘float’>, default=20000.0, required=True)
Duration of the hrf kernel
variables_of_interest : tvb.simulator.monitors.Monitor.variables_of_interest = NArray(label=’Model variables to watch’, dtype=int64, default=None, dim_names=(), ndim=None, required=False)
Indices of model’s variables of interest (VOI) that this monitor should record. Note that the indices should start at zero, so that if a model offers VOIs V, W and V+W, and W is selected, and this monitor should record W, then the correct index is 0.

gid : tvb.basic.neotraits._core.HasTraits.gid = Attr(field_type=<class ‘uuid.UUID’>, default=None, required=True)

config_for_sim(simulator)[source]
sample(step, state, array=<built-in function array>)[source]
class tvb.simulator.monitors.EEG(**kwargs)[source]

Bases: tvb.simulator.monitors.Projection

Forward solution monitor for electroencephalogy (EEG). If a precomputed lead field is not available, a single sphere analytic formula due to Sarvas 1987 is used.

References:

[Sarvas_1987](1, 2) Sarvas, J., Basic mathematical and electromagnetic concepts of the biomagnetic inverse problem, Physics in Medicine and Biology, 1987.
projection : tvb.simulator.monitors.EEG.projection = Attr(field_type=<class ‘tvb.datatypes.projections.ProjectionSurfaceEEG’>, default=None, required=True)
Projection matrix to apply to sources.
reference : tvb.simulator.monitors.EEG.reference = Attr(field_type=<class ‘str’>, default=None, required=False)
EEG Electrode to be used as reference, or “average” to apply an average reference. If none is provided, the produced time-series are the idealized or reference-free.
sensors : tvb.simulator.monitors.EEG.sensors = Attr(field_type=<class ‘tvb.datatypes.sensors.SensorsEEG’>, default=None, required=True)
Sensors to use for this EEG monitor
sigma : tvb.simulator.monitors.EEG.sigma = Float(field_type=<class ‘float’>, default=1.0, required=True)
When a projection matrix is not used, this provides the value of conductivity in the formula for the single sphere approximation of the head (Sarvas 1987).
region_mapping : tvb.simulator.monitors.Projection.region_mapping = Attr(field_type=<class ‘tvb.datatypes.region_mapping.RegionMapping’>, default=None, required=False)
A region mapping specifies how vertices of a surface correspond to given regions in the connectivity. For iEEG/EEG/MEG monitors, this must be specified when performing a region simulation but is optional for a surface simulation.
obsnoise : tvb.simulator.monitors.Projection.obsnoise = Attr(field_type=<class ‘tvb.simulator.noise.Noise’>, default=<tvb.simulator.noise.Additive object at 0x7f71ae9e5d90>, required=False)
The monitor’s noise source. It incorporates its own instance of Numpy’s RandomState.
period : tvb.simulator.monitors.Monitor.period = Float(field_type=<class ‘float’>, default=0.9765625, required=True)
Sampling period in milliseconds, must be an integral multiple of integration-step size. As a guide: 2048 Hz => 0.48828125 ms ; 1024 Hz => 0.9765625 ms ; 512 Hz => 1.953125 ms.
variables_of_interest : tvb.simulator.monitors.Monitor.variables_of_interest = NArray(label=’Model variables to watch’, dtype=int64, default=None, dim_names=(), ndim=None, required=False)
Indices of model’s variables of interest (VOI) that this monitor should record. Note that the indices should start at zero, so that if a model offers VOIs V, W and V+W, and W is selected, and this monitor should record W, then the correct index is 0.

gid : tvb.basic.neotraits._core.HasTraits.gid = Attr(field_type=<class ‘uuid.UUID’>, default=None, required=True)

analytic(loc, ori)[source]

Equation 12 of [Sarvas_1987]

config_for_sim(simulator)[source]
create_time_series(connectivity=None, surface=None, region_map=None, region_volume_map=None)[source]
classmethod from_file(sensors_fname='eeg_brainstorm_65.txt', projection_fname='projection_eeg_65_surface_16k.npy', **kwargs)[source]
projection

An Attr declares the following about the attribute it describes: * the type * a default value shared by all instances * if the value might be missing * documentation It will resolve to attributes on the instance.

reference

An Attr declares the following about the attribute it describes: * the type * a default value shared by all instances * if the value might be missing * documentation It will resolve to attributes on the instance.

sample(step, state)[source]
sensors

An Attr declares the following about the attribute it describes: * the type * a default value shared by all instances * if the value might be missing * documentation It will resolve to attributes on the instance.

sigma

Declares a float. This is different from Attr(field_type=float). The former enforces float subtypes. This allows any type that can be safely cast to the declared float type according to numpy rules.

Reading and writing this attribute is slower than a plain python attribute. In performance sensitive code you might want to use plain python attributes or even better local variables.

class tvb.simulator.monitors.GlobalAverage(**kwargs)[source]

Bases: tvb.simulator.monitors.Monitor

Monitors the averaged value for the model’s variables of interest over all the nodes at each sampling period. This mainly exists as a “convenience” monitor for quickly checking the “global” state of a simulation.
period : tvb.simulator.monitors.Monitor.period = Float(field_type=<class ‘float’>, default=0.9765625, required=True)
Sampling period in milliseconds, must be an integral multiple of integration-step size. As a guide: 2048 Hz => 0.48828125 ms ; 1024 Hz => 0.9765625 ms ; 512 Hz => 1.953125 ms.
variables_of_interest : tvb.simulator.monitors.Monitor.variables_of_interest = NArray(label=’Model variables to watch’, dtype=int64, default=None, dim_names=(), ndim=None, required=False)
Indices of model’s variables of interest (VOI) that this monitor should record. Note that the indices should start at zero, so that if a model offers VOIs V, W and V+W, and W is selected, and this monitor should record W, then the correct index is 0.

gid : tvb.basic.neotraits._core.HasTraits.gid = Attr(field_type=<class ‘uuid.UUID’>, default=None, required=True)

create_time_series(connectivity=None, surface=None, region_map=None, region_volume_map=None)[source]
sample(step, state)[source]

Records if integration step corresponds to sampling period.

class tvb.simulator.monitors.MEG(**kwargs)[source]

Bases: tvb.simulator.monitors.Projection

Forward solution monitor for magnetoencephalography (MEG).

projection : tvb.simulator.monitors.MEG.projection = Attr(field_type=<class ‘tvb.datatypes.projections.ProjectionSurfaceMEG’>, default=None, required=True)
Projection matrix to apply to sources.
sensors : tvb.simulator.monitors.MEG.sensors = Attr(field_type=<class ‘tvb.datatypes.sensors.SensorsMEG’>, default=None, required=True)
The set of MEG sensors for which the forward solution will be calculated.
region_mapping : tvb.simulator.monitors.Projection.region_mapping = Attr(field_type=<class ‘tvb.datatypes.region_mapping.RegionMapping’>, default=None, required=False)
A region mapping specifies how vertices of a surface correspond to given regions in the connectivity. For iEEG/EEG/MEG monitors, this must be specified when performing a region simulation but is optional for a surface simulation.
obsnoise : tvb.simulator.monitors.Projection.obsnoise = Attr(field_type=<class ‘tvb.simulator.noise.Noise’>, default=<tvb.simulator.noise.Additive object at 0x7f71ae9e5d90>, required=False)
The monitor’s noise source. It incorporates its own instance of Numpy’s RandomState.
period : tvb.simulator.monitors.Monitor.period = Float(field_type=<class ‘float’>, default=0.9765625, required=True)
Sampling period in milliseconds, must be an integral multiple of integration-step size. As a guide: 2048 Hz => 0.48828125 ms ; 1024 Hz => 0.9765625 ms ; 512 Hz => 1.953125 ms.
variables_of_interest : tvb.simulator.monitors.Monitor.variables_of_interest = NArray(label=’Model variables to watch’, dtype=int64, default=None, dim_names=(), ndim=None, required=False)
Indices of model’s variables of interest (VOI) that this monitor should record. Note that the indices should start at zero, so that if a model offers VOIs V, W and V+W, and W is selected, and this monitor should record W, then the correct index is 0.

gid : tvb.basic.neotraits._core.HasTraits.gid = Attr(field_type=<class ‘uuid.UUID’>, default=None, required=True)

analytic(loc, ori)[source]

Compute single sphere analytic form of MEG lead field. Equation 25 of [Sarvas_1987].

create_time_series(connectivity=None, surface=None, region_map=None, region_volume_map=None)[source]
classmethod from_file(sensors_fname='meg_brainstorm_276.txt', projection_fname='projection_meg_276_surface_16k.npy', **kwargs)[source]
projection

An Attr declares the following about the attribute it describes: * the type * a default value shared by all instances * if the value might be missing * documentation It will resolve to attributes on the instance.

sensors

An Attr declares the following about the attribute it describes: * the type * a default value shared by all instances * if the value might be missing * documentation It will resolve to attributes on the instance.

class tvb.simulator.monitors.Monitor(**kwargs)[source]

Bases: tvb.basic.neotraits._core.HasTraits

Abstract base class for monitor implementations.
period : tvb.simulator.monitors.Monitor.period = Float(field_type=<class ‘float’>, default=0.9765625, required=True)
Sampling period in milliseconds, must be an integral multiple of integration-step size. As a guide: 2048 Hz => 0.48828125 ms ; 1024 Hz => 0.9765625 ms ; 512 Hz => 1.953125 ms.
variables_of_interest : tvb.simulator.monitors.Monitor.variables_of_interest = NArray(label=’Model variables to watch’, dtype=int64, default=None, dim_names=(), ndim=None, required=False)
Indices of model’s variables of interest (VOI) that this monitor should record. Note that the indices should start at zero, so that if a model offers VOIs V, W and V+W, and W is selected, and this monitor should record W, then the correct index is 0.

gid : tvb.basic.neotraits._core.HasTraits.gid = Attr(field_type=<class ‘uuid.UUID’>, default=None, required=True)

config_for_sim(simulator)[source]

Configure monitor for given simulator.

Grab the Simulator’s integration step size. Set the monitor’s variables of interest based on the Monitor’s ‘variables_of_interest’ attribute, if it was specified, otherwise use the ‘variables_of_interest’ specified for the Model. Calculate the number of integration steps (isteps) between returns by the record method. This method is called from within the the Simulator’s configure() method.

create_time_series(connectivity=None, surface=None, region_map=None, region_volume_map=None)[source]

Create a time series instance that will be populated by this monitor :param surface: if present a TimeSeriesSurface is returned :param connectivity: if present a TimeSeriesRegion is returned Otherwise a plain TimeSeries will be returned

dt = None
istep = None
period

Declares a float. This is different from Attr(field_type=float). The former enforces float subtypes. This allows any type that can be safely cast to the declared float type according to numpy rules.

Reading and writing this attribute is slower than a plain python attribute. In performance sensitive code you might want to use plain python attributes or even better local variables.

record(step, observed)[source]

Record a sample of the observed state at given step.

This is a final method called by the simulator to obtain samples from a monitor instance. Monitor subclasses should not override this method, but rather implement the sample method.

sample(step, state)[source]

This method provides monitor output, and should be overridden by subclasses.

variables_of_interest

Declares a numpy array. dtype enforces the dtype. The default dtype is float32. An optional symbolic shape can be given, as a tuple of Dim attributes from the owning class. The shape will be enforced, but no broadcasting will be done. domain declares what values are allowed in this array. It can be any object that can be checked for membership Defaults are checked if they are in the declared domain. For performance reasons this does not happen on every attribute set.

voi = None
class tvb.simulator.monitors.ProgressLogger(**kwargs)[source]

Bases: tvb.simulator.monitors.Monitor

Logs progress of simulation; only for use in console scripts.

period : tvb.simulator.monitors.Monitor.period = Float(field_type=<class ‘float’>, default=0.9765625, required=True)
Sampling period in milliseconds, must be an integral multiple of integration-step size. As a guide: 2048 Hz => 0.48828125 ms ; 1024 Hz => 0.9765625 ms ; 512 Hz => 1.953125 ms.
variables_of_interest : tvb.simulator.monitors.Monitor.variables_of_interest = NArray(label=’Model variables to watch’, dtype=int64, default=None, dim_names=(), ndim=None, required=False)
Indices of model’s variables of interest (VOI) that this monitor should record. Note that the indices should start at zero, so that if a model offers VOIs V, W and V+W, and W is selected, and this monitor should record W, then the correct index is 0.

gid : tvb.basic.neotraits._core.HasTraits.gid = Attr(field_type=<class ‘uuid.UUID’>, default=None, required=True)

config_for_sim(simulator)[source]
record(step, state)[source]
sample(step, state)[source]
class tvb.simulator.monitors.Projection(**kwargs)[source]

Bases: tvb.simulator.monitors.Monitor

Base class monitor providing lead field suppport.

region_mapping : tvb.simulator.monitors.Projection.region_mapping = Attr(field_type=<class ‘tvb.datatypes.region_mapping.RegionMapping’>, default=None, required=False)
A region mapping specifies how vertices of a surface correspond to given regions in the connectivity. For iEEG/EEG/MEG monitors, this must be specified when performing a region simulation but is optional for a surface simulation.
obsnoise : tvb.simulator.monitors.Projection.obsnoise = Attr(field_type=<class ‘tvb.simulator.noise.Noise’>, default=<tvb.simulator.noise.Additive object at 0x7f71ae9e5d90>, required=False)
The monitor’s noise source. It incorporates its own instance of Numpy’s RandomState.
period : tvb.simulator.monitors.Monitor.period = Float(field_type=<class ‘float’>, default=0.9765625, required=True)
Sampling period in milliseconds, must be an integral multiple of integration-step size. As a guide: 2048 Hz => 0.48828125 ms ; 1024 Hz => 0.9765625 ms ; 512 Hz => 1.953125 ms.
variables_of_interest : tvb.simulator.monitors.Monitor.variables_of_interest = NArray(label=’Model variables to watch’, dtype=int64, default=None, dim_names=(), ndim=None, required=False)
Indices of model’s variables of interest (VOI) that this monitor should record. Note that the indices should start at zero, so that if a model offers VOIs V, W and V+W, and W is selected, and this monitor should record W, then the correct index is 0.

gid : tvb.basic.neotraits._core.HasTraits.gid = Attr(field_type=<class ‘uuid.UUID’>, default=None, required=True)

analytic(loc, ori)[source]

Construct analytic or default set of spatial filters for simulation.

config_for_sim(simulator)[source]

Configure projection matrix monitor for given simulation.

configure(*args, **kwargs)[source]
classmethod from_file(sensors_fname, projection_fname, rm_f_name='regionMapping_16k_76.txt', period=0.9765625, **kwds)[source]

Build Projection-based monitor from sensors and projection files, and any extra keyword arguments are passed to the monitor class constructor.

gain[source]
obsnoise

An Attr declares the following about the attribute it describes: * the type * a default value shared by all instances * if the value might be missing * documentation It will resolve to attributes on the instance.

static oriented_gain(gain, orient)[source]

Apply orientations to gain matrix.

region_mapping

An Attr declares the following about the attribute it describes: * the type * a default value shared by all instances * if the value might be missing * documentation It will resolve to attributes on the instance.

rmap[source]

Normalize obtaining reg map vector over various possibilities.

sample(step, state)[source]

Record state, returning sample at sampling frequency / period.

class tvb.simulator.monitors.Raw(**kwargs)[source]

Bases: tvb.simulator.monitors.Monitor

A monitor that records the output raw data from a tvb simulation: It collects:

  • all state variables and modes from class :Model:
  • all nodes of a region or surface based
  • all the integration time steps

period : tvb.simulator.monitors.Raw.period = Float(field_type=<class ‘float’>, default=0.0, required=True)

variables_of_interest : tvb.simulator.monitors.Raw.variables_of_interest = NArray(label=’Raw Monitor sees all!!! Resistance is futile...’, dtype=int64, default=None, dim_names=(), ndim=None, required=False)

gid : tvb.basic.neotraits._core.HasTraits.gid = Attr(field_type=<class ‘uuid.UUID’>, default=None, required=True)

config_for_sim(simulator)[source]
period

Declares a float. This is different from Attr(field_type=float). The former enforces float subtypes. This allows any type that can be safely cast to the declared float type according to numpy rules.

Reading and writing this attribute is slower than a plain python attribute. In performance sensitive code you might want to use plain python attributes or even better local variables.

sample(step, state)[source]
variables_of_interest

Declares a numpy array. dtype enforces the dtype. The default dtype is float32. An optional symbolic shape can be given, as a tuple of Dim attributes from the owning class. The shape will be enforced, but no broadcasting will be done. domain declares what values are allowed in this array. It can be any object that can be checked for membership Defaults are checked if they are in the declared domain. For performance reasons this does not happen on every attribute set.

class tvb.simulator.monitors.SpatialAverage(**kwargs)[source]

Bases: tvb.simulator.monitors.Monitor

Monitors the averaged value for the models variable of interest over sets of nodes – defined by spatial_mask. This is primarily intended for use with surface simulations, with a default behaviour, when no spatial_mask is specified, of using surface.region_mapping in order to reduce a surface simulation back to a single average timeseries for each region in the associated Connectivity. However, any vector of length nodes containing integers, from a set contiguous from zero, specifying the new grouping to which each node belongs should work.

Additionally, this monitor temporally sub-samples the simulation every istep integration steps.

spatial_mask : tvb.simulator.monitors.SpatialAverage.spatial_mask = NArray(label=’An index mask of nodes into areas’, dtype=int64, default=None, dim_names=(), ndim=None, required=False)
A vector of length==nodes that assigns an index to each node specifying the “region” to which it belongs. The default usage is for mapping a surface based simulation back to the regions used in its Long-range Connectivity.
default_mask : tvb.simulator.monitors.SpatialAverage.default_mask = Attr(field_type=<class ‘str’>, default=’hemispheres’, required=True)
Fallback in case spatial mask is none and no surface providedto use either connectivity hemispheres or cortical attributes.
period : tvb.simulator.monitors.Monitor.period = Float(field_type=<class ‘float’>, default=0.9765625, required=True)
Sampling period in milliseconds, must be an integral multiple of integration-step size. As a guide: 2048 Hz => 0.48828125 ms ; 1024 Hz => 0.9765625 ms ; 512 Hz => 1.953125 ms.
variables_of_interest : tvb.simulator.monitors.Monitor.variables_of_interest = NArray(label=’Model variables to watch’, dtype=int64, default=None, dim_names=(), ndim=None, required=False)
Indices of model’s variables of interest (VOI) that this monitor should record. Note that the indices should start at zero, so that if a model offers VOIs V, W and V+W, and W is selected, and this monitor should record W, then the correct index is 0.

gid : tvb.basic.neotraits._core.HasTraits.gid = Attr(field_type=<class ‘uuid.UUID’>, default=None, required=True)

config_for_sim(simulator)[source]
create_time_series(connectivity=None, surface=None, region_map=None, region_volume_map=None)[source]
default_mask

An Attr declares the following about the attribute it describes: * the type * a default value shared by all instances * if the value might be missing * documentation It will resolve to attributes on the instance.

sample(step, state)[source]
spatial_mask

Declares a numpy array. dtype enforces the dtype. The default dtype is float32. An optional symbolic shape can be given, as a tuple of Dim attributes from the owning class. The shape will be enforced, but no broadcasting will be done. domain declares what values are allowed in this array. It can be any object that can be checked for membership Defaults are checked if they are in the declared domain. For performance reasons this does not happen on every attribute set.

class tvb.simulator.monitors.SubSample(**kwargs)[source]

Bases: tvb.simulator.monitors.Monitor

Sub-samples or decimates the solution in time.
period : tvb.simulator.monitors.Monitor.period = Float(field_type=<class ‘float’>, default=0.9765625, required=True)
Sampling period in milliseconds, must be an integral multiple of integration-step size. As a guide: 2048 Hz => 0.48828125 ms ; 1024 Hz => 0.9765625 ms ; 512 Hz => 1.953125 ms.
variables_of_interest : tvb.simulator.monitors.Monitor.variables_of_interest = NArray(label=’Model variables to watch’, dtype=int64, default=None, dim_names=(), ndim=None, required=False)
Indices of model’s variables of interest (VOI) that this monitor should record. Note that the indices should start at zero, so that if a model offers VOIs V, W and V+W, and W is selected, and this monitor should record W, then the correct index is 0.

gid : tvb.basic.neotraits._core.HasTraits.gid = Attr(field_type=<class ‘uuid.UUID’>, default=None, required=True)

sample(step, state)[source]
class tvb.simulator.monitors.TemporalAverage(**kwargs)[source]

Bases: tvb.simulator.monitors.Monitor

Monitors the averaged value for the model’s variable/s of interest over all the nodes at each sampling period. Time steps that are not modulo istep are stored temporarily in the _stock attribute and then that temporary store is averaged and returned when time step is modulo istep.
period : tvb.simulator.monitors.Monitor.period = Float(field_type=<class ‘float’>, default=0.9765625, required=True)
Sampling period in milliseconds, must be an integral multiple of integration-step size. As a guide: 2048 Hz => 0.48828125 ms ; 1024 Hz => 0.9765625 ms ; 512 Hz => 1.953125 ms.
variables_of_interest : tvb.simulator.monitors.Monitor.variables_of_interest = NArray(label=’Model variables to watch’, dtype=int64, default=None, dim_names=(), ndim=None, required=False)
Indices of model’s variables of interest (VOI) that this monitor should record. Note that the indices should start at zero, so that if a model offers VOIs V, W and V+W, and W is selected, and this monitor should record W, then the correct index is 0.

gid : tvb.basic.neotraits._core.HasTraits.gid = Attr(field_type=<class ‘uuid.UUID’>, default=None, required=True)

config_for_sim(simulator)[source]
sample(step, state)[source]

Records if integration step corresponds to sampling period, Otherwise just update the monitor’s stock. When the step corresponds to the sample period, the _stock is averaged over time for return.

class tvb.simulator.monitors.iEEG(**kwargs)[source]

Bases: tvb.simulator.monitors.Projection

Forward solution for intracranial EEG (not ECoG!).

projection : tvb.simulator.monitors.iEEG.projection = Attr(field_type=<class ‘tvb.datatypes.projections.ProjectionSurfaceSEEG’>, default=None, required=True)
Projection matrix to apply to sources.

sigma : tvb.simulator.monitors.iEEG.sigma = Float(field_type=<class ‘float’>, default=1.0, required=True)

sensors : tvb.simulator.monitors.iEEG.sensors = Attr(field_type=<class ‘tvb.datatypes.sensors.SensorsInternal’>, default=None, required=True)
The set of SEEG sensors for which the forward solution will be calculated.
region_mapping : tvb.simulator.monitors.Projection.region_mapping = Attr(field_type=<class ‘tvb.datatypes.region_mapping.RegionMapping’>, default=None, required=False)
A region mapping specifies how vertices of a surface correspond to given regions in the connectivity. For iEEG/EEG/MEG monitors, this must be specified when performing a region simulation but is optional for a surface simulation.
obsnoise : tvb.simulator.monitors.Projection.obsnoise = Attr(field_type=<class ‘tvb.simulator.noise.Noise’>, default=<tvb.simulator.noise.Additive object at 0x7f71ae9e5d90>, required=False)
The monitor’s noise source. It incorporates its own instance of Numpy’s RandomState.
period : tvb.simulator.monitors.Monitor.period = Float(field_type=<class ‘float’>, default=0.9765625, required=True)
Sampling period in milliseconds, must be an integral multiple of integration-step size. As a guide: 2048 Hz => 0.48828125 ms ; 1024 Hz => 0.9765625 ms ; 512 Hz => 1.953125 ms.
variables_of_interest : tvb.simulator.monitors.Monitor.variables_of_interest = NArray(label=’Model variables to watch’, dtype=int64, default=None, dim_names=(), ndim=None, required=False)
Indices of model’s variables of interest (VOI) that this monitor should record. Note that the indices should start at zero, so that if a model offers VOIs V, W and V+W, and W is selected, and this monitor should record W, then the correct index is 0.

gid : tvb.basic.neotraits._core.HasTraits.gid = Attr(field_type=<class ‘uuid.UUID’>, default=None, required=True)

analytic(loc, ori)[source]

Compute the projection matrix – simple distance weight for now. Equation 12 from sarvas1987basic (point dipole in homogeneous space):

V(r) = 1/(4*pi*sigma)*Q*(r-r_0)/|r-r_0|^3
create_time_series(connectivity=None, surface=None, region_map=None, region_volume_map=None)[source]
classmethod from_file(sensors_fname='seeg_588.txt', projection_fname='projection_seeg_588_surface_16k.npy', **kwargs)[source]
projection

An Attr declares the following about the attribute it describes: * the type * a default value shared by all instances * if the value might be missing * documentation It will resolve to attributes on the instance.

sensors

An Attr declares the following about the attribute it describes: * the type * a default value shared by all instances * if the value might be missing * documentation It will resolve to attributes on the instance.

sigma

Declares a float. This is different from Attr(field_type=float). The former enforces float subtypes. This allows any type that can be safely cast to the declared float type according to numpy rules.

Reading and writing this attribute is slower than a plain python attribute. In performance sensitive code you might want to use plain python attributes or even better local variables.

tvb.simulator.monitors.numpy_add_at()

at(a, indices, b=None)

Performs unbuffered in place operation on operand ‘a’ for elements specified by ‘indices’. For addition ufunc, this method is equivalent to a[indices] += b, except that results are accumulated for elements that are indexed more than once. For example, a[[0,0]] += 1 will only increment the first element once because of buffering, whereas add.at(a, [0,0], 1) will increment the first element twice.

New in version 1.8.0.

a : array_like
The array to perform in place operation on.
indices : array_like or tuple
Array like index object or slice object for indexing into first operand. If first operand has multiple dimensions, indices can be a tuple of array like index objects or slice objects.
b : array_like
Second operand for ufuncs requiring two operands. Operand must be broadcastable over first operand after indexing or slicing.

Set items 0 and 1 to their negative values:

>>> a = np.array([1, 2, 3, 4])
>>> np.negative.at(a, [0, 1])
>>> a
array([-1, -2,  3,  4])

Increment items 0 and 1, and increment item 2 twice:

>>> a = np.array([1, 2, 3, 4])
>>> np.add.at(a, [0, 1, 2, 2], 1)
>>> a
array([2, 3, 5, 4])

Add items 0 and 1 in first array to second array, and store results in first array:

>>> a = np.array([1, 2, 3, 4])
>>> b = np.array([1, 2])
>>> np.add.at(a, [0, 1], b)
>>> a
array([2, 4, 3, 4])