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
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.

Parameters

aarray_like

The array to perform in place operation on.

indicesarray_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.

barray_like

Second operand for ufuncs requiring two operands. Operand must be broadcastable over first operand after indexing or slicing.

Examples

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])
class tvb.simulator.monitors.Monitor(**kwargs)[source]

Bases: HasTraits

Traited class [tvb.simulator.monitors.Monitor]

Abstract base class for monitor implementations.

Attributes declared

periodtvb.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_interesttvb.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)

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.

variables_of_interest

Declares a numpy array. dtype enforces the dtype. The default dtype is float64. 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.

istep = None
dt = None
voi = None
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.

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.

abstract sample(step, state)[source]

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

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

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

Bases: Monitor

Traited class [tvb.simulator.monitors.Raw]

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

Attributes declared

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)

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.

variables_of_interest

Declares a numpy array. dtype enforces the dtype. The default dtype is float64. 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.

sample(step, state)[source]

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

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

Bases: Raw

Traited class [tvb.simulator.monitors.RawVoi]

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

  • selected state variables of all modes from class :Model:

  • all nodes of a region or surface based

  • all the integration time steps

Attributes declared

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)

sample(step, state)[source]

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

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

Bases: Monitor

Traited class [tvb.simulator.monitors.SubSample]

Sub-samples or decimates the solution in time.

Attributes declared

periodtvb.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_interesttvb.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]

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

class tvb.simulator.monitors.DefaultMasks(value)[source]

Bases: TVBEnum

An enumeration.

CORTICAL = 'cortical'
HEMISPHERES = 'hemispheres'
REGION_MAPPING = 'region_mapping'
class tvb.simulator.monitors.SpatialAverage(**kwargs)[source]

Bases: Monitor

Traited class [tvb.simulator.monitors.SpatialAverage]

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.

Attributes declared

spatial_masktvb.simulator.monitors.SpatialAverage.spatial_mask = NArray(label=’Spatial Mask’, 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_masktvb.simulator.monitors.SpatialAverage.default_mask = EnumAttr(field_type=<enum ‘DefaultMasks’>, default=<DefaultMasks.CORTICAL: ‘cortical’>, required=False)

Fallback in case spatial mask is none and no surface providedto use either connectivity hemispheres or cortical attributes.

periodtvb.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_interesttvb.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)

spatial_mask

Declares a numpy array. dtype enforces the dtype. The default dtype is float64. 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.

default_mask
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.

sample(step, state)[source]

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

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

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

Bases: Monitor

Traited class [tvb.simulator.monitors.GlobalAverage]

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.

Attributes declared

periodtvb.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_interesttvb.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]

Records if integration step corresponds to sampling period.

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

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

Bases: Monitor

Traited class [tvb.simulator.monitors.TemporalAverage]

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.

Attributes declared

periodtvb.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_interesttvb.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]

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.AfferentCoupling(**kwargs)[source]

Bases: RawVoi

Traited class [tvb.simulator.monitors.AfferentCoupling]

A monitor that records the variables_of_interest from node_coupling data from a tvb simulation for all the integration time steps.

Attributes declared

variables_of_interest : tvb.simulator.monitors.AfferentCoupling.variables_of_interest = NArray(label=’Indices of coupling variables to record’, dtype=int64, default=None, dim_names=(), ndim=None, required=False)

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

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

variables_of_interest

Declares a numpy array. dtype enforces the dtype. The default dtype is float64. 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.

sample(step, node_coupling)[source]

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

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

Bases: AfferentCoupling, TemporalAverage

Traited class [tvb.simulator.monitors.AfferentCouplingTemporalAverage]

Monitors the averaged value for the model’s coupling 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.

Attributes declared

variables_of_interest : tvb.simulator.monitors.AfferentCoupling.variables_of_interest = NArray(label=’Indices of coupling variables to record’, dtype=int64, default=None, dim_names=(), ndim=None, required=False)

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

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

sample(step, node_coupling)[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.Projection(**kwargs)[source]

Bases: Monitor

Traited class [tvb.simulator.monitors.Projection]

Base class monitor providing lead field support.

Attributes declared

region_mappingtvb.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.

obsnoisetvb.simulator.monitors.Projection.obsnoise = Attr(field_type=<class ‘tvb.simulator.noise.Noise’>, default=<class ‘tvb.simulator.noise.Additive’>, required=False)

The monitor’s noise source. It incorporates its own instance of Numpy’s RandomState.

periodtvb.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_interesttvb.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)

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.

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.

classmethod projection_class()[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.

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]

Ensures that invariant of the class are satisfied. Override to compute uninitialized state of the class.

sample(step, state)[source]

Record state, returning sample at sampling frequency / period.

property gain
property rmap

Normalize obtaining reg map vector over various possibilities.

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

Bases: Projection

Traited class [tvb.simulator.monitors.EEG]

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.

Attributes declared

projectiontvb.simulator.monitors.EEG.projection = Attr(field_type=<class ‘tvb.datatypes.projections.ProjectionSurfaceEEG’>, default=None, required=True)

Projection matrix to apply to sources.

referencetvb.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.

sensorstvb.simulator.monitors.EEG.sensors = Attr(field_type=<class ‘tvb.datatypes.sensors.SensorsEEG’>, default=None, required=True)

Sensors to use for this EEG monitor

sigmatvb.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_mappingtvb.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.

obsnoisetvb.simulator.monitors.Projection.obsnoise = Attr(field_type=<class ‘tvb.simulator.noise.Noise’>, default=<class ‘tvb.simulator.noise.Additive’>, required=False)

The monitor’s noise source. It incorporates its own instance of Numpy’s RandomState.

periodtvb.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_interesttvb.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)

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.

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.

classmethod from_file(sensors_fname='eeg_brainstorm_65.txt', projection_fname='projection_eeg_65_surface_16k.npy', **kwargs)[source]

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

config_for_sim(simulator)[source]

Configure projection matrix monitor for given simulation.

analytic(loc, ori)[source]

Equation 12 of [Sarvas_1987]

sample(step, state)[source]

Record state, returning sample at sampling frequency / period.

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

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

Bases: Projection

Traited class [tvb.simulator.monitors.MEG]

Forward solution monitor for magnetoencephalography (MEG).

Attributes declared

projectiontvb.simulator.monitors.MEG.projection = Attr(field_type=<class ‘tvb.datatypes.projections.ProjectionSurfaceMEG’>, default=None, required=True)

Projection matrix to apply to sources.

sensorstvb.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_mappingtvb.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.

obsnoisetvb.simulator.monitors.Projection.obsnoise = Attr(field_type=<class ‘tvb.simulator.noise.Noise’>, default=<class ‘tvb.simulator.noise.Additive’>, required=False)

The monitor’s noise source. It incorporates its own instance of Numpy’s RandomState.

periodtvb.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_interesttvb.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)

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.

classmethod from_file(sensors_fname='meg_brainstorm_276.txt', projection_fname='projection_meg_276_surface_16k.npy', **kwargs)[source]

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

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]

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

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

Bases: Projection

Traited class [tvb.simulator.monitors.iEEG]

Forward solution for intracranial EEG (not ECoG!).

Attributes declared

projectiontvb.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)

sensorstvb.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_mappingtvb.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.

obsnoisetvb.simulator.monitors.Projection.obsnoise = Attr(field_type=<class ‘tvb.simulator.noise.Noise’>, default=<class ‘tvb.simulator.noise.Additive’>, required=False)

The monitor’s noise source. It incorporates its own instance of Numpy’s RandomState.

periodtvb.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_interesttvb.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)

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.

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.

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.

classmethod from_file(sensors_fname='seeg_588.txt', projection_fname='projection_seeg_588_surface_16k.npy', **kwargs)[source]

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

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]

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

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

Bases: Monitor

Traited class [tvb.simulator.monitors.Bold]

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

Attributes declared

periodtvb.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_kerneltvb.simulator.monitors.Bold.hrf_kernel = Attr(field_type=<class ‘tvb.datatypes.equations.HRFKernelEquation’>, default=<tvb.datatypes.equations.FirstOrderVolterra object at 0x7f222a160c10>, required=True)

A tvb.datatypes.equation object which describe the haemodynamic response function used to compute the BOLD signal.

hrf_lengthtvb.simulator.monitors.Bold.hrf_length = Float(field_type=<class ‘float’>, default=20000.0, required=True)

Duration of the hrf kernel

variables_of_interesttvb.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)

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.

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.

hemodynamic_response_function = None
compute_hrf()[source]

Compute the hemodynamic response function.

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.

sample(step, state)[source]

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

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

Bases: Bold

Traited class [tvb.simulator.monitors.BoldRegionROI]

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.

Attributes declared

periodtvb.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_kerneltvb.simulator.monitors.Bold.hrf_kernel = Attr(field_type=<class ‘tvb.datatypes.equations.HRFKernelEquation’>, default=<tvb.datatypes.equations.FirstOrderVolterra object at 0x7f222a160c10>, required=True)

A tvb.datatypes.equation object which describe the haemodynamic response function used to compute the BOLD signal.

hrf_lengthtvb.simulator.monitors.Bold.hrf_length = Float(field_type=<class ‘float’>, default=20000.0, required=True)

Duration of the hrf kernel

variables_of_interesttvb.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.

sample(step, state)[source]

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

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

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

Bases: Monitor

Traited class [tvb.simulator.monitors.ProgressLogger]

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

Attributes declared

periodtvb.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_interesttvb.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.

record(step, state)[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.