Simulator

Class diagram for tvb.simulator.simulator

This is the main module of the simulator. It defines the Simulator class which brings together all the structural and dynamic components necessary to define a simulation and the method for running the simulation.

class tvb.simulator.simulator.Simulator(**kwargs)[source]

Traited class [tvb.simulator.simulator.Simulator]

A Simulator assembles components required to perform simulations.

Attributes declared

connectivitytvb.simulator.simulator.Simulator.connectivity = Attr(field_type=<class ‘tvb.datatypes.connectivity.Connectivity’>, default=None, required=True)

A tvb.datatypes.Connectivity object which contains the structural long-range connectivity data (i.e., white-matter tracts). In combination with the Long-range coupling function it defines the inter-regional connections. These couplings undergo a time delay via signal propagation with a propagation speed of Conduction Speed

conduction_speedtvb.simulator.simulator.Simulator.conduction_speed = Float(field_type=<class ‘float’>, default=3.0, required=False)

Conduction speed for Long-range connectivity (mm/ms)

couplingtvb.simulator.simulator.Simulator.coupling = Attr(field_type=<class ‘tvb.simulator.coupling.Coupling’>, default=<class ‘tvb.simulator.coupling.Linear’>, required=True)

The coupling function is applied to the activity propagated between regions by the Long-range connectivity before it enters the local dynamic equations of the Model. Its primary purpose is to ‘rescale’ the incoming activity to a level appropriate to Model.

surfacetvb.simulator.simulator.Simulator.surface = Attr(field_type=<class ‘tvb.datatypes.cortex.Cortex’>, default=None, required=False)

By default, a Cortex object which represents the cortical surface defined by points in the 3D physical space and their neighborhood relationship. In the current TVB version, when setting up a surface-based simulation, the option to configure the spatial spread of the Local Connectivity is available.

stimulustvb.simulator.simulator.Simulator.stimulus = Attr(field_type=<class ‘tvb.datatypes.patterns.SpatioTemporalPattern’>, default=None, required=False)

A Spatiotemporal stimulus can be defined at the region or surface level. It’s composed of spatial and temporal components. For region defined stimuli the spatial component is just the strength with which the temporal component is applied to each region. For surface defined stimuli, a (spatial) function, with finite-support, is used to define the strength of the stimuli on the surface centred around one or more focal points. In the current version of TVB, stimuli are applied to the first state variable of the Local dynamic model.

modeltvb.simulator.simulator.Simulator.model = Attr(field_type=<class ‘tvb.simulator.models.base.Model’>, default=<class ‘tvb.simulator.models.oscillator.Generic2dOscillator’>, required=True)

A tvb.simulator.Model object which describe the local dynamic equations, their parameters, and, to some extent, where connectivity (local and long-range) enters and which state-variables the Monitors monitor. By default the ‘Generic2dOscillator’ model is used. Read the Scientific documentation to learn more about this model.

integratortvb.simulator.simulator.Simulator.integrator = Attr(field_type=<class ‘tvb.simulator.integrators.Integrator’>, default=<class ‘tvb.simulator.integrators.HeunDeterministic’>, required=True)

A tvb.simulator.Integrator object which is an integration scheme with supporting attributes such as integration step size and noise specification for stochastic methods. It is used to compute the time courses of the model state variables.

initial_conditionstvb.simulator.simulator.Simulator.initial_conditions = NArray(label=’Initial Conditions’, dtype=float64, default=None, dim_names=(), ndim=None, required=False)

Initial conditions from which the simulation will begin. By default, random initial conditions are provided. Needs to be the same shape as simulator ‘history’, ie, initial history function which defines the minimal initial state of the network with time delays before time t=0. If the number of time points in the provided array is insufficient the array will be padded with random values based on the ‘state_variables_range’ attribute.

monitorstvb.simulator.simulator.Simulator.monitors = List(of=<class ‘tvb.simulator.monitors.Monitor’>, default=(<tvb.simulator.monitors.TemporalAverage object at 0x7fe869ad4c40>,), required=True)

A tvb.simulator.Monitor or a list of tvb.simulator.Monitor objects that ‘know’ how to record relevant data from the simulation. Two main types exist: 1) simple, spatial and temporal, reductions (subsets or averages); 2) physiological measurements, such as EEG, MEG and fMRI. By default the Model’s specified variables_of_interest are returned, temporally down-sampled from the raw integration rate to a sample rate of 1024Hz.

simulation_lengthtvb.simulator.simulator.Simulator.simulation_length = Float(field_type=<class ‘float’>, default=1000.0, required=True)

The length of a simulation (default in milliseconds).

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

TYPES_TO_DEEPCOPY = (<class 'numpy.random.mtrand.RandomState'>, <class 'scipy.sparse._csc.csc_matrix'>, <class 'scipy.sparse._base.spmatrix'>, <class 'list'>, <class 'tuple'>)
backend = <tvb.simulator.backend.ref.ReferenceBackend object>
calls = 0
conduction_speed

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.

configure(full_configure=True)[source]

Configure simulator and its components.

The first step of configuration is to run the configure methods of all the Simulator’s components, ie its traited attributes.

Configuration of a Simulator primarily consists of calculating the attributes, etc, which depend on the combinations of the Simulator’s traited attributes (keyword args).

Converts delays from physical time units into integration steps and updates attributes that depend on combinations of the 6 inputs.

Returns

sim: Simulator

The configured Simulator instance.

configure_integration_for_model()[source]
connectivity

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.

coupling

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.

current_step = 0
duplicate()
gid

gid identifies a specific instance of the hastraits it is used by serializers as an identifier. For non-datatype HasTraits this is less usefull but still provides a unique id for example for a model configuration

property good_history_shape

Returns expected history shape.

history: SparseHistory = None
initial_conditions

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.

integrate_next_step = None
integrator

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.

property is_surface_simulation
memory_requirement()[source]

Return an estimated of the memory requirements (Bytes) for this simulator’s current configuration.

model: Model

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.

monitors

The attribute is a list of values. Choices and type are reinterpreted as applying not to the list but to the elements of it

number_of_nodes = None
preconfigure()[source]

Configure just the basic fields, so that memory can be estimated.

run(**kwds)[source]

Convenience method to call the simulator with **kwds and collect output data.

runtime(simulation_length)[source]

Return an estimated run time (seconds) for the simulator’s current configuration and a specified simulation length.

set_title()
simulation_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.

stimulus

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.

storage_requirement()[source]

Return an estimated storage requirement (Bytes) for the simulator’s current configuration and a specified simulation length.

summary_info() Dict[str, str]

A more structured __str__ A 2 column table represented as a dict of str->str The default __str__ and html representations of this object are derived from this table. Override this method and return such a table filled with instance information that informs the user about your instance

surface: Cortex

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.

tag(tag_name: str, tag_value: str | None = None) None

Add a tag to this trait instance. The tags are for user to recognize and categorize the instances They should never influence the behaviour of the program :param tag_name: an arbitrary tag :param tag_value: an optional tag value

tags

a generic collections of tags. The trait system is not using them nor should any other code. They should not alter behaviour They should describe the instance for the user

validate()

Check that the internal invariants of this class are satisfied. Not meant to ensure that that is the case. Use configure for that. The default configure calls this before it returns. It complains about missing required attrs Can be overridden in subclasses