The Virtual Brain Project

Previous topic

Phase-Plane Interactive

Next topic

Timeseries Interactive

This Page

Power-Spectra Interactive

Class diagram for tvb.simulator.power_spectra_interactive

An interactive power spectra plot generated from a TVB TimeSeries datatype.


#Load the demo data
import numpy
data = numpy.load("demos/demo_data_region_16s_2048Hz.npy")
period = 0.00048828125 #NOTE: Providing period in seconds

#Create a tvb TimeSeries object
import tvb.datatypes.time_series
tsr = tvb.datatypes.time_series.TimeSeriesRegion() = data
tsr.sample_period = period

#Create and launch the interactive visualiser
import tvb.simulator.power_spectra_interactive as ps_int
psi = ps_int.PowerSpectraInteractive(time_series=tsr)
class tvb.simulator.plot.power_spectra_interactive.PowerSpectraInteractive(**kwargs)[source]

The graphical interface for visualising the power-spectra (FFT) of a timeseries provide controls for setting:

  • which state-variable and mode to display [sets]
  • log or linear scaling for the power or frequency axis [binary]
  • sementation lenth [set]
  • windowing function [set]
  • power normalisation [binary] (emphasise relative frequency contribution)
  • show std or sem [binary]
time_series : tvb.simulator.plot.power_spectra_interactive.PowerSpectraInteractive.time_series = Attr(field_type=<class ‘tvb.datatypes.time_series.TimeSeries’>, default=None, required=True)
The timeseries to which the FFT is to be applied.
first_n : tvb.simulator.plot.power_spectra_interactive.PowerSpectraInteractive.first_n = Int(field_type=<class ‘int’>, default=-1, required=True)
Primarily intended for displaying the first N components of a surface PCA timeseries. Defaults to -1, meaning it’ll display all of ‘space’ (ie, regions or vertices or channels). In other words, for Region or M/EEG timeseries you can ignore this, but, for a surface timeseries it really must be set.

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


Add a radio button to the figure for selecting which mode of the model should be displayed.


Add a radio button to chose whether or not the power of all spectra shouold be normalised to 1.


Generate radio selector buttons to set which state variable is displayed.


Generate radio selector buttons to set the windowing function.


Generate radio selector buttons to set the window length is seconds.


Add a radio button to the figure for selecting which scaling the x-axes should use.


Add a radio button to the figure for selecting which scaling the y-axes should use.


Calculate FFT using current state of the window_length, window_function,


Seperate configure cause ttraits be busted...


Create the figure and time-series axes.


Declares an integer This is different from Attr(field_type=int). The former enforces int subtypes This allows all integer types, including numpy ones that can be safely cast to the declared type according to numpy rules


Plot the power spectra.


Generate the interactive power-spectra figure.


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.


Update the visualised mode based on radio button selection.


Update whether to normalise based on radio button selection.


Clear the axes and redraw the power-spectra.


Update state variable being plotted based on radio buttton selection.


Update windowing function based on the radio button selection.


Update timeseries window length based on the selected value.


Update the FFT axes’ xscale to either log or linear based on radio button selection.


Update the FFT axes’ yscale to either log or linear based on radio button selection.