In [1]:
%pylab nbagg
import os
from tvb.simulator.lab import *
Populating the interactive namespace from numpy and matplotlib
   INFO  log level set to INFO

Exploring longer time series

The scripting interface has two interactive tools for looking at the TimeSeries generated in simulations. This tutorial shows an example of their use, using a demo dataset for region time-series.

These are mainly of use for longer simulations, of at least a few seconds.

Example data

As a simple set of example data, we will use a linear stochastic model with the default connectivity:

In [2]:
sim = simulator.Simulator(
    connectivity=connectivity.Connectivity(load_default=True, speed=1.0),

(time, data), =

plot(time/1e3, data[:, 0, :, 0], 'k', alpha=0.1);
xlabel('Time (s)')
WARNING  File 'hemispheres' not found in ZIP.
<matplotlib.text.Text at 0x1af5db70>

Create a TimeSeriesRegion Datatype

Because we just stored our simulation as a simple array, we need to turn it into one of TVB's TimeSeries datatypes, which is what the two plotting tools operate on, in this case we'll use TimeSeriesRegion.

In [4]:
tsr = time_series.TimeSeriesRegion(
    sample_period=sim.monitors[0].period / 1e3,

Create And Launch A TimeSeriesInteractive

Our typical approach throughout these tutorials has been to to simply plot our time-series using PyLab's plot() function. This is fine as a quick way to look at the small amounts of data we'd been producing, but is insufficient for longer, more meaningful, time-series, such as we get when trying to runs simulations aimed at generating time-series comparable to experimental data.

TimeSeriesInteractive is a tool for looking at these longer time-series. It's still relatively simple, but it adds a number of useful features. The time-series are plotted in the main central panel with a constant vertical offset, the label for each channel or region displayed down the left hand side. Along the bottom are three basic controls: on the left there is a slider that allows the length of the window to be changed (in physical units); in the middle a set of buttons exist to step forward and backward through the time-series at different speeds (at the top of the window there is an indicator showing where you are in the time-series); and on the right the vertical spacing, or offset between time series can be set, this has the effect of scaling the time-series' amplitudes.

In [5]:
#Create and launch the interactive visualiser
import tvb.simulator.plot.timeseries_interactive as ts_int
tsi = ts_int.TimeSeriesInteractive(time_series=tsr)
Time-series name
Time-series typeTimeSeriesRegion
Dimensions['Time', 'State Variable', 'Region', 'Mode']
Region MappingNone
Sample period0.01
Region Mapping VolumeNone
Time unitss
Source ConnectivityConnectivity 76