Calculate temporal cross correlation coefficients (Pearson’s coefficient) on a TimeSeries datatype and return a graph.CorrelationCoefficients dataype. The correlation matrix is widely used to represent functional connectivity (FC).
Compute the nodepairwise pearson correlation coefficient of the given input 4D TimeSeries datatype.
Return a CrossCorrelation datatype, whose values of are between 1 and 1, inclusive.
See: http://docs.scipy.org/doc/numpy/reference/generated/numpy.corrcoef.html
traits on this class:
 t_end (\(t_{end}\))
End time point (ms)default: 1000.0 t_start (\(t_{start}\))
Time start point (ms). By default it uses the default Monitor sample period. The starting time point of a time series is not zero, but the monitor’s sample period.default: 0.9765625 time_series (Time Series)
The timeseries for which the cross correlation matrices are calculated.default: None
Calculate temporal cross correlation on a TimeSeries datatype and return a temporal_correlations.CrossCorrelation dataype.
Compute the nodepairwise crosscorrelation of the given input 4D TimeSeries DataType.
Return a CrossCorrelation DataType. It contains the crosscorrelation sequences for all possible combinations of the nodes.
See: http://www.scipy.org/doc/api_docs/SciPy.signal.signaltools.html#correlate
traits on this class:
 time_series (Time Series)
The timeseries for which the cross correlation sequences are calculated.default: None
Adapter that uses the traits module to generate interfaces for ... Analyzer.
The present class will do the following actions:
the time series is divided in time window of fixed length and with an overlapping of fixed length. The datapoints within each window, centered at time ti, are used to calculate FC(ti) as Pearson correlation. The ij element of the FCD matrix is calculated as the Pearson correlation between FC(ti) and FC(tj) in a vector
(length of time during which FC matrix are high correlated).
The algorithm can produce 2 kind of results:
– fcs calculated over the epochs of stability (excluded the first one = artifact, due to initial conditions) – 3 eigenvectors, associated to the 3 largest eigenvalues, of the fcs are extracted
– fc over the all time series is calculated – 3 first eigenvectors, associated to the 3 largest eigenvalues, of the fcs are extracted
fcd matrix whose values are between 1 and 1, inclusive.
(Value=1.1 for time not belonging to epochs of stability identified with spectral embedding algorithm) in case 2: fcd matrix segmented identical to the fcd matrix not segmented
dictionary containing the eigenvectors.
dictionary containing the eigenvalues
connectivity associated to the TimeSeriesRegions
traits on this class:
 sp (Spanning between two consecutive sliding window (ms))
Spanning= (time windows length)(overlapping between two consecutive time window). FCD matrix is calculated in the following way: the time series is divided in time window of fixed length and with an overlapping of fixed length. The datapoints within each window, centered at time ti, are used to calculate FC(ti) as Pearson Correlation. The ij element of the FCD matrix is calculated as the Pearson correlation between FC(ti) and FC(tj) arranged in a vectordefault: 2000 sw (Sliding window length (ms))
Length of the time window used to divided the time series. FCD matrix is calculated in the following way: the time series is divided in time window of fixed length and with an overlapping of fixed length. The datapoints within each window, centered at time ti, are used to calculate FC(ti) as Pearson correlation. The ij element of the FCD matrix is calculated as the Pearson Correlation between FC(ti) and FC(tj) arranged in a vector.default: 120000 time_series (Time Series)
The timeseries for which the fcd matrices are calculated.default: None
Calculate an FFT on a TimeSeries DataType and return a FourierSpectrum DataType.
A class for calculating the FFT of a TimeSeries object of TVB and returning a FourierSpectrum object. A segment length and windowing function can be optionally specified. By default the time series is segmented into 1 second blocks and no windowing function is applied.
traits on this class:
 detrend (Detrending)
Detrending is not always appropriate. Default is True, False means no detrending is performed on the time seriesdefault: True segment_length (Segment(window) length (ms))
The TimeSeries can be segmented into equally sized blocks (overlapping if necessary). The segment length determines the frequency resolution of the resulting power spectra – longer windows produce finer frequency resolution.default: 1000.0 time_series (Time Series)
The TimeSeries to which the FFT is to be applied.default: None window_function (Windowing function)
Windowing functions can be applied before the FFT is performed. Default is None, possibilities are: ‘hamming’; ‘bartlett’; ‘blackman’; and ‘hanning’. See, numpy.<function_name>.default: None
Implementation of differet BOLD signal models. Four different models are distinguished:
Classical means that the coefficients used to compute the BOLD signal are derived as described in [Obata2004] . Revised coefficients are defined in [Stephan2007]
References:
[Stephan2007]  Stephan KE, Weiskopf N, Drysdale PM, Robinson PA, Friston KJ (2007) Comparing hemodynamic models with DCM. NeuroImage 38: 387401. 
[Obata2004]  Obata, T.; Liu, T. T.; Miller, K. L.; Luh, W. M.; Wong, E. C.; Frank, L. R. & Buxton, R. B. (2004) Discrepancies between BOLD and flow dynamics in primary and supplementary motor areas: application of the balloon model to the interpretation of BOLD transients. Neuroimage, 21:144153 
A class for calculating the simulated BOLD signal given a TimeSeries object of TVB and returning another TimeSeries object.
The haemodynamic model parameters based on constants for a 1.5 T scanner.
traits on this class:
 E0 (\(E_0\))
BOLD parameter. Resting oxygen extraction fraction.default: 0.4 RBM (Revised BOLD Model)
Select classical vs revised BOLD model (CBM or RBM). Coefficients k1, k2 and k3 will be derived accordingly.default: True TE (\(TE\))
BOLD parameter. Echo Timedefault: 0.04 V0 (\(V_0\))
BOLD parameter. Resting blood volume fraction.default: 4.0 alpha (\(\tau_f\))
Balloon model parameter. Stiffness parameter. Grubb’s exponent.default: 0.32 bold_model (Select BOLD model equations)
Select the set of equations for the BOLD model.default: [‘nonlinear’] dt (\(dt\))
The integration time step size for the balloon model (s). If none is provided, by default, the TimeSeries sample period is used.default: 0.002 epsilon (\(\epsilon\))
BOLD parameter. Ratio of intra and extravascular signals. In principle this parameter could be derived from empirical data and spatialized.default: [ 0.5]range: low = 0.5 ; high = 2.0 integrator (Integration scheme)
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 balloon model state variables.default: <class ‘tvb.simulator.integrators.HeunDeterministic’> neural_input_transformation (Neural input transformation)
This represents the operation to perform on the statevariable(s) of the model used to generate the input TimeSeries. none takes the first statevariable as neural input; `` abs_diff`` is the absolute value of the derivative (first order difference) of the first state variable; sum: sum all the statevariables of the input TimeSeries.default: [‘none’] nu_0 (\(\nu_0\))
BOLD parameter. Frequency offset at the outer surface of magnetized vessels (Hz).default: 40.3 r_0 (\(r_0\))
BOLD parameter. Slope r0 of intravascular relaxation rate (Hz). Only used for revised coefficients.default: 25.0 tau_f (\(\tau_f\))
Balloon model parameter. Time of flowdependent elimination or feedback regulation (s). The average time blood take to traverse the venous compartment. It is the ratio of resting blood volume (V0) to resting blood flow (F0).default: 0.41 tau_o (\(\tau_o\))
Balloon model parameter. Haemodynamic transit time (s). The average time blood take to traverse the venous compartment. It is the ratio of resting blood volume (V0) to resting blood flow (F0).default: 0.98 tau_s (\(\tau_s\))
Balloon model parameter. Time of signal decay (s)default: 0.65 time_series (Time Series)
The timeseries that represents the input neural activitydefault: None
Useful graph analyses.
Node betweenness centrality is the fraction of all shortest paths in the network that contain a given node. Nodes with high values of betweenness centrality participate in a large number of shortest paths.
Parameters:  A – binary (directed/undirected) connection matrix (array) 

Returns:  BC: a vector representing node between centrality vector. 
Notes:
Betweenness centrality may be normalised to the range [0,1] as BC/[(N1)(N2)], where N is the number of nodes in the network.
Original Mika Rubinov, UNSW/U Cambridge, 20072012  From BCT 20121204
Reference: [1] Kintali (2008) arXiv:0809.1906v2 [cs.DS] (generalization to directed and disconnected graphs)
Author: Paula Sanz Leon
Compute the inverse shortest path lengths of G.
Parameters:  G – binary undirected connection matrix 

Returns:  D: matrix of inverse distances 
Computes global efficiency or local efficiency of a connectivity matrix. The global efficiency is the average of inverse shortest path length, and is inversely related to the characteristic path length.
The local efficiency is the global efficiency computed on the neighborhood of the node, and is related to the clustering coefficient.
Parameters: 


Returns: 

References: [1] Latora and Marchiori (2001) Phys Rev Lett 87:198701.
Note
Algorithm: algebraic path count
Note
Original: Mika Rubinov, UNSW, 20082010  From BCT 20121204
Note
Tested with Numpy 1.7
Warning
tested against Matlab version... needs indexing improvement
Example:
>>> import numpy.random
>>> A = np.random.rand(5, 5)
>>> E = efficiency_bin(A)
>>> E.shape == (1, )
>>> True
If you want to compute the local efficiency for every node in the network:
>>> E = efficiency_bin(A, compute_local_efficiency=True)
>>> E.shape == (5, 1)
>>> True
Author: Paula Sanz Leon
Get connected components sizes. Returns the size of the largest component of an undirected graph specified by the binary and undirected connection matrix A.
Parameters:  A – array  binary undirected (BU) connectivity matrix. 

Returns: 

Raises:  Value Error  If A is not square. 
Warning
Requires NetworkX
Author: Paula Sanz Leon
A strategy to lesion a connectivity matrix.
A single node is removed at each step until the network is reduced to only 2 nodes. This method represents a structural failure analysis and it should be run several times with different random sequences.
Parameters: 


Returns: 

References: Alstott et al. (2009).
Author: Paula Sanz Leon
A strategy to lesion a connectivity matrix.
A single node is removed at each step until the network is reduced to only 2 nodes. At each step different graph metrics are computed (degree, strength and betweenness centrality). The single node with the highest degree, strength or centrality is removed.
Parameters: 


Returns: 

See also: sequential_random_deletion, localized_area_deletion
References: Alstott et al. (2009).
Author: Paula Sanz Leon
Perform Independent Component Analysis on a TimeSeries Object and returns an IndependentComponents datatype.
Takes a TimeSeries datatype (x) and returns the unmixed temporal sources (S) and the estimated mixing matrix (A).
Math:  x = A S 

ICA takes timepoints as observations and nodes as variables.
It uses the FastICA algorithm implemented in the scikitlearn toolkit, and its intended usage is as a blind source separation method.
traits on this class:
 n_components (Number of principal components to unmix.)
Number of principal components to unmix.default: None time_series (Time Series)
The timeseries to which the ICA is to be applied.default: None
This module implements information theoretic analyses.
TODO: Fix docstring of sampen TODO: Convert sampen to a traited class
Computes (quadratic) sample entropy of a given input signal y, with embedding dimension n, and a match tolerance of r (ref 2). If an array of scale factors, taus, are given, the signal will be coarsened by each factor and a corresponding entropy will be computed (ref 1). If no value for r is given, it will be set to 0.15*y.std().
Currently, the implementation is lazy and expects or coerces scale factors to integer values.
With qse=True (default) the probability p is normalized for the value of r, giving the quadratic sample entropy, such that results from different values of r can be meaningfully compared (ref 2).
To check that algorithm is working, look at ref 1, fig 1, and run
>>> sampen(randn(3*10000), r=.15, taus=r_[1:20], qse=False, m=2)
Filler analyzer: Takes a TimeSeries object and returns a Float.
Return the Kuramoto synchronization index.
Useful metric for a parameter analysis when the collective brain dynamics represent coupled oscillatory processes.
The order parameters are \(r\) and \(Psi\).
The first is the phase coherence of the population of oscillators (KSI) and the second is the average phase.
When \(r=0\) means 0 coherence among oscillators.
Input: TimeSeries DataType
Output: Float
This is a crude indicator of synchronization among nodes over the entire network.
#NOTE: For the time being it is meant to be another global metric. However, it should be consider to have a sort of TimeSeriesDatatype for this analyzer.
traits on this class:
 segment (Segmentation factor)
Divide the input timeseries into discrete equally sized sequences and use the last segment to compute the metric. It is only used when the start point is larger than the timeseries length.default: 4 start_point (Start point (ms))
The start point determines how many points of the TimeSeries will be discarded before computing the metric. By default it drops the first 500 ms.default: 500.0 time_series (Time Series)
The TimeSeries for which the metric(s) will be computed.default: None
Filler analyzer: Takes a TimeSeries object and returns two Floats.
These metrics are described and used in:
Hellyer et al. The Control of Global Brain Dynamics: Opposing Actions of Frontoparietal Control and Default Mode Networks on Attention. The Journal of Neuroscience, January 8, 2014, 34(2):451– 461
Proxy of spatial coherence (V):
Proxy metastability (M): the variability in spatial coherence of the signal globally or locally (within a network) over time.
Proxy synchrony (S) : the reciprocal of mean spatial variance across time.
Subtract the mean timeseries and compute.
Input: TimeSeries DataType
Output: Float, Float
The two metrics given by this analyzers are a proxy for metastability and synchrony. The underlying dynamical model used in the article was the Kuramoto model.
traits on this class:
 segment (Segmentation factor)
Divide the input timeseries into discrete equally sized sequences and use the last segment to compute the metric. It is only used when the start point is larger than the timeseries length.default: 4 start_point (Start point (ms))
The start point determines how many points of the TimeSeries will be discarded before computing the metric. By default it drops the first 500 ms.default: 500.0 time_series (Time Series)
The TimeSeries for which the metric(s) will be computed.default: None
Filler analyzer: Takes a TimeSeries object and returns a Float.
Zerocentres all the timeseries and then calculates the variance over all data points.
Input: TimeSeries DataType
Output: Float
This is a crude indicator of “excitability” or oscillation amplitude of the models over the entire network.
traits on this class:
 segment (Segmentation factor)
Divide the input timeseries into discrete equally sized sequences and use the last segment to compute the metric. It is only used when the start point is larger than the timeseries length.default: 4 start_point (Start point (ms))
The start point determines how many points of the TimeSeries will be discarded before computing the metric. By default it drops the first 500 ms.default: 500.0 time_series (Time Series)
The TimeSeries for which the metric(s) will be computed.default: None
Filler analyzer: Takes a TimeSeries object and returns a Float.
Zerocentres all the timeseries, calculates the variance for each node timeseries and returns the variance of the node variances.
Input: TimeSeries DataType
Output: Float
This is a crude indicator of how different the “excitability” of the model is from node to node.
traits on this class:
 segment (Segmentation factor)
Divide the input timeseries into discrete equally sized sequences and use the last segment to compute the metric. It is only used when the start point is larger than the timeseries length.default: 4 start_point (Start point (ms))
The start point determines how many points of the TimeSeries will be discarded before computing the metric. By default it drops the first 500 ms.default: 500.0 time_series (Time Series)
The TimeSeries for which the metric(s) will be computed.default: None
This is a base class for all metrics on timeSeries dataTypes. Metric means an algorithm computing a single value for an entire TimeSeries.
traits on this class:
 segment (Segmentation factor)
Divide the input timeseries into discrete equally sized sequences and use the last segment to compute the metric. It is only used when the start point is larger than the timeseries length.default: 4 start_point (Start point (ms))
The start point determines how many points of the TimeSeries will be discarded before computing the metric. By default it drops the first 500 ms.default: 500.0 time_series (Time Series)
The TimeSeries for which the metric(s) will be computed.default: None
Compute cross coherence between all nodes in a time series.
Adapter for crosscoherence algorithm(s) traits on this class:
 nfft (Datapoints per block)
Should be a power of 2...default: 256 time_series (Time Series)
The timeseries to which the FFT is to be applied.default: None
Calculate the cross spectrum and complex coherence on a TimeSeries datatype and return a ComplexCoherence datatype.
A class for calculating the FFT of a TimeSeries and returning a ComplexCoherenceSpectrum datatype.
[Freyer_2012]  Freyer, F.; Reinacher, M.; Nolte, G.; Dinse, H. R. and Ritter, P. Repetitive tactile stimulation changes restingstate functional connectivityimplications for treatment of sensorimotor decline. Front Hum Neurosci, Bernstein Focus State Dependencies of Learning and Bernstein Center for Computational Neuroscience Berlin, Germany., 2012, 6, 144 
Input: originally the input could be 2D (tpts x nodes/channels), and it was possible to give a 3D array (e.g., tpspt x nodes/cahnnels x trials) via the segment_length attribute. Current TVB implementation can handle 4D or 2D TimeSeries datatypes. Be warned: the 4D TimeSeries will be averaged and squeezed.
Output: (main arrays)  the crossspectrum  the complex coherence, from which the imaginary part can be extracted
By default the time series is segmented into 1 second epoch blocks and 0.5 second 50% overlapping segments to which a Hanning function is applied.
traits on this class:
 average_segments (Average across segments)
Flag. If True, compute the mean Cross Spectrum across segments.default: True detrend_ts (Detrend time series)
Flag. If True removes linear trend along the time dimension before applying FFT.default: False epoch_length (Epoch length [ms])
In general for lengthy EEG recordings (~30 min), the timeseries are divided into equally sized segments (~ 2040s). These contain the event that is to be characterized by means of the cross coherence. Additionally each epoch block will be further divided into segments to which the FFT will be applied.default: 1000.0 max_freq (Maximum frequency)
Maximum frequency points (e.g. 32., 64., 128.) represented in the output. Default is segment_length / 2 + 1.default: 1024.0 npat (dummy variable)
This attribute appears to be related to an input projection matrix... Which is not yet implementeddefault: 1.0 segment_length (Segment length [ms])
The timeseries can be segmented into equally sized blocks (overlapping if necessary). The segment length determines the frequency resolution of the resulting power spectra – longer windows produce finer frequency resolution.default: 500.0 segment_shift (Segment shift [ms])
Time length by which neighboring segments are shifted. e.g. segment shift = segment_length / 2 means 50% overlapping segments.default: 250.0 subtract_epoch_average (Subtract average across epochs)
Flag. If True and if the number of epochs is > 1, you can optionally subtract the mean across epochs before computing the complex coherence.default: True time_series (Time Series)
The timeseries for which the CrossCoherence and ComplexCoherence is to be computed.default: None window_function (Windowing function)
Windowing functions can be applied before the FFT is performed. Default is hanning, possibilities are: ‘hamming’; ‘bartlett’; ‘blackman’; and ‘hanning’. See, numpy.<function_name>.default: hanning zeropad (Zeropadding)
Adds n zeros at the end of each segment and at the end of window_function. It is not yet functional.default: 0
Calculate a ... on a .. datatype and return a ...
Compute the temporal covariance of nodes in a TimeSeries dataType. A nodes x nodes matrix is returned for each (statevariable, mode).
traits on this class:
 time_series (Time Series)
The timeseries to which the NodeCovariance is to be applied.default: None
Perform Principal Component Analysis (PCA) on a TimeSeries datatype and return a PrincipalComponents datatype.
Return principal component weights and the fraction of the variance that they explain.
PCA takes timepoints as observations and nodes as variables.
traits on this class:
 time_series (Time Series)
The timeseries to which the PCA is to be applied. NOTE: The TimeSeries must be longer(more timepoints) than the number of nodes – Mostly a problem for surface timesseries, which, if sampled at 1024Hz, would need to be greater than 16 seconds long.default: None
Calculate a wavelet transform on a TimeSeries datatype and return a WaveletSpectrum datatype.
A class for calculating the wavelet transform of a TimeSeries object of TVB and returning a WaveletSpectrum object. The sampling period and frequency range of the result can be specified. The mother wavelet can also be specified... (So far, only Morlet.)
[TBetal_1996]  C. TallonBaudry et al, Stimulus Specificity of PhaseLocked and NonPhaseLocked 40 Hz Visual Responses in Human., J Neurosci 16(13):42404249, 1996. 
[Mallat_1999]  S. Mallat, A wavelet tour of signal processing., book, Academic Press, 1999. 
traits on this class:
 frequencies (Frequency range of result (kHz).)
The frequency resolution and range returned. Requested frequencies are converted internally into appropriate scales.default: Range(bound=False, value=None) mother (Wavelet function)
The mother wavelet function used in the transform. Default is ‘morlet’, possibilities are: ‘morlet’...default: morlet normalisation (Normalisation)
The type of normalisation for the resulting wavet spectrum. Default is ‘energy’, options are: ‘energy’; ‘gabor’.default: energy q_ratio (Qratio)
NFC. Must be greater than 5. Ratios of the center frequencies to bandwidths.default: 5.0 sample_period (Sample period of result (ms))
The sampling period of the computed wavelet spectrum. NOTE: This should be an integral multiple of the of the sampling period of the source time series, otherwise the actual resulting sample period will be the first correct value below that requested.default: 7.8125 time_series (Time Series)
The timeseries to which the wavelet is to be applied.default: None