Inheritance diagram for nitime.analysis:
This module implements an analysis interface between between time-series objects implemented in the timeseries module and the algorithms provided in the algorithms library and other algorithms.
The general pattern of use of Analyzer objects is that they an object is initialized with a TimeSeries object as input. Depending on the analysis methods implemented in the particular analysis object, additional inputs may also be required.
The methods of the object are then implemented as instances of OneTimeProperty, which means that they are only calculated when they are needed and then cached for further use.
Analyzer objects are generally implemented inheriting the desc.ResetMixin(), which means that they have a reset() method. This method resets the object to its initialized state, in which none of the OneTimeProperty methods have been calculated. This allows to change parameter settings of the object and recalculating the quantities in these methods with the new parameter setting.
Bases: nitime.descriptors.ResetMixin
Analyzer that implements the default data flow.
All analyzers inherit from this class at least have to * implement a __init__ function to set parameters * define the ‘output’ property
Set the input of the analyzer, if you want to reuse the analyzer with a different input than the original
Bases: nitime.analysis.BaseAnalyzer
Analyzer object for coherence/coherency analysis
| Parameters : | input: TimeSeries object :
method: dict, optional, :
unwrap_phases: bool, optional :
|
|---|
Examples
>>> t1 = ts.TimeSeries(data = np.arange(0,1024,1).reshape(2,512),sampling_rate=np.pi)
>>> c1 = CoherenceAnalyzer(t1)
>>> c1.method['Fs']
3.14159265359 Hz
>>> c1.method['this_method']
'welch'
>>> c1.coherency[0,1]
array([ 0.9499+0.j , 0.9495-0.0332j, 0.8696-0.4571j, 0.8918-0.3848j,
0.9099-0.3191j, 0.9217-0.2679j, 0.9294-0.2285j, 0.9346-0.1977j,
0.9382-0.1732j, 0.9407-0.1533j, 0.9426-0.1367j, 0.9441-0.1226j,
0.9452-0.1106j, 0.9460-0.1001j, 0.9467-0.0908j, 0.9473-0.0826j,
0.9477-0.0752j, 0.9481-0.0684j, 0.9484-0.0623j, 0.9487-0.0566j,
0.9489-0.0513j, 0.9491-0.0465j, 0.9492-0.0419j, 0.9494-0.0376j,
0.9495-0.0336j, 0.9496-0.0298j, 0.9497-0.0263j, 0.9497-0.0232j,
0.9498-0.0205j, 0.9498-0.0187j, 0.9498-0.0188j, 0.9497-0.0266j,
1.0000+0.j ])
>>> c1.phase[0,1]
array([ 0. , -0.035 , -0.4839, -0.4073, -0.3373, -0.2828, -0.241 ,
-0.2085, -0.1826, -0.1615, -0.144 , -0.1292, -0.1164, -0.1054,
-0.0956, -0.0869, -0.0791, -0.072 , -0.0656, -0.0596, -0.0541,
-0.0489, -0.0441, -0.0396, -0.0353, -0.0314, -0.0277, -0.0244,
-0.0216, -0.0197, -0.0198, -0.028 , 0. ])
The coherence between the different channels in the input TimeSeries object
The partial coherence between data[i] and data[j], given data[k], as a function of frequency band
The standard output for this kind of analyzer is the coherency
The delay in seconds between the two time series
The central frequencies in the bands
The frequency-dependent phase relationship between all the pairwise combinations of time-series in the data
The spectra of each of the channels and cross-spectra between different channles in the input TimeSeries object
Bases: nitime.analysis.BaseAnalyzer
Analyzer object for correlation analysis. Has the same API as the CoherenceAnalyzer
| Parameters : | input: TimeSeries object :
|
|---|
Examples
>>> t1 = ts.TimeSeries(data = np.sin(np.arange(0,10*np.pi,10*np.pi/100)).reshape(2,50),sampling_rate=np.pi)
>>> c1 = CorrelationAnalyzer(t1)
>>> c1 = CorrelationAnalyzer(t1)
>>> c1.corrcoef
array([[ 1., -1.],
[-1., 1.]])
>>> c1.xcorr.sampling_rate
3.1415926536 Hz
>>> c1.xcorr.t0
-15.915494309150001 s
The correlation coefficient between every pairwise combination of time-series contained in the object
The cross-correlation between every pairwise combination time-series in the object. Uses np.correlation(‘full’).
| Returns : | TimeSeries: the time-dependent cross-correlation, with zero-lag : at time=0 : |
|---|
The cross-correlation between every pairwise combination time-series in the object, where the zero lag correlation is normalized to be equal to the correlation coefficient between the time-series
| Returns : | TimeSeries: A TimeSeries object :
|
|---|
Bases: nitime.descriptors.ResetMixin
A class for performing filtering operations on time-series and producing the filtered versions of the time-series
Filte the time-series by a boxcar filter. The low pass filter is implemented by convolving with a boxcar function of the right length and amplitude and the high-pass filter is implemented by subtracting a low-pass version (as above) from the signal
Filter the time-series by passing it to the Fourier domain and null out the frequency bands outside of the range [lb,ub]
Bases: nitime.analysis.BaseAnalyzer
Analyzer class for extracting the Hilbert transform
Constructor function for the Hilbert analyzer class.
| Parameters : | input: TimeSeries : |
|---|
The natural output for this analyzer is the analytic signal
Bases: nitime.analysis.BaseAnalyzer
Analyzer for multi-taper coherence analysis, including jack-knife estimate of confidence interval
Initializer function for the MTCoherenceAnalyzer
| Parameters : | input: TimeSeries object : bandwidth: float, :
alpha: float, default =0.05 :
adaptive: bool, default to True :
|
|---|
The size of the 1-alpha confidence interval
Bases: nitime.analysis.BaseAnalyzer
Analyzer class for extracting the (complex) Morlet wavelet transform
Constructor function for the Hilbert analyzer class.
| Parameters : | freqs: list or float :
sd: list or float :
sd_rel: float :
f_min: float :
f_max: float :
nfreqs: int :
log_spacing: bool :
log_morlet: bool :
|
|---|
The natural output for this analyzer is the analytic signal
Bases: nitime.analysis.BaseAnalyzer
A class for performing normalization operations on time-series and producing the renormalized versions of the time-series
Constructor function for the Normalization analyzer class.
| Parameters : | input: TimeSeries object : |
|---|
Bases: nitime.analysis.BaseAnalyzer
Calculate SNR for a response to repetitions of the same stimulus, according to [Borst1999] (Figure 2) and [Hsu2004].
| [Hsu2004] | Hsu A, Borst A and Theunissen, FE (2004) Quantifying |
variability in neural responses ans its application for the validation of model predictions. Network: Comput Neural Syst 15:91-109
| [Borst1999] | Borst A and Theunissen FE (1999) Information theory and |
neural coding. Nat Neurosci 2:947-957
Initializer for the multi_taper_SNR object
| Parameters : | input: TimeSeries object : bandwidth: float, :
adaptive: bool, default to False :
low_bias : bool, default to False
|
|---|
The correlation between all combinations of trials
| Returns : | (r,e) : tuple
|
|---|
Bases: nitime.analysis.BaseAnalyzer
This analyzer takes two time-series. The first is designated as a time-series of seeds. The other is designated as a time-series of targets. The analyzer performs a coherence analysis between each of the channels in the seed time-series and all of the channels in the target time-series.
The constructor for the SeedCoherenceAnalyzer
| Parameters : | seed_time_series: a time-series object : target_time_series: a time-series object : lb,ub: float,optional, default: lb=0, ub=None (max frequency) :
prefer_speed_over_memory: Boolean, optional, default=True :
|
|---|
The coherence between each of the channels of the seed time series and all the channels of the target time-series.
The delay in seconds between the two time series
Get the central frequencies for the frequency bands, given the method of estimating the spectrum
The frequency-band dependent relative phase between the two time-series
Bases: nitime.analysis.BaseAnalyzer
This analyzer is intended for analysis of large sets of data, in which possibly only a subset of combinations of time-series needs to be compared. The constructor for this class receives as input not only a time-series object, but also a list of tuples with index combinations (i,j) for the combinations. Importantly, this class implements only the mlab csd function and cannot use other methods of spectral estimation
The constructor for the SparseCoherenceAnalyzer
| Parameters : | time_series: a time-series object : ij: a list of tuples, each containing a pair of indices. :
lb,ub: float,optional, default: lb=0, ub=None (max frequency) :
prefer_speed_over_memory: Boolean, optional, default=True :
method: optional, dict : The method for spectral estimation (see :func:`algorithms.get_spectra`) : |
|---|
Caches the fft windows required by the other methods of the SparseCoherenceAnalyzer. Calculate only once and reuse
The coherence values for the output
The default behavior is to calculate the cache, extract it and then output the coherency
The delay in seconds between the two time series
Get the central frequencies for the frequency bands, given the method of estimating the spectrum
The frequency-band dependent phases of the spectra of each of the time -series i,j in the analyzer
The frequency-band dependent relative phase between the two time-series
get the spectrum for the collection of time-series in this analyzer
Bases: nitime.analysis.BaseAnalyzer
Analyzer object for spectral analysis
The initialization of the
| Parameters : | input: time-series objects : method: dict optional, see :func:`algorithms.get_spectra` for : specification of the spectral analysis method : |
|---|
Examples
>>> t1 = ts.TimeSeries(data = np.arange(0,1024,1).reshape(2,512),
... sampling_rate=np.pi)
>>> s1 = SpectralAnalyzer(t1)
>>> s1.method['this_method']
'welch'
>>> s1.method['Fs']
3.14159265359 Hz
>>> f,s = s1.psd
>>> f
array([ 0. , 0.0491, 0.0982, 0.1473, 0.1963, 0.2454, 0.2945,
0.3436, 0.3927, 0.4418, 0.4909, 0.54 , 0.589 , 0.6381,
0.6872, 0.7363, 0.7854, 0.8345, 0.8836, 0.9327, 0.9817,
1.0308, 1.0799, 1.129 , 1.1781, 1.2272, 1.2763, 1.3254,
1.3744, 1.4235, 1.4726, 1.5217, 1.5708])
>>> s[0,0]
1128276.92538360...
This outputs both the PSD and the CSD calculated using algorithms.get_spectra().
| Returns : | (f,s): tuple :
|
|---|
This is the spectrum estimated as the FFT of the time-series
| Returns : | (f,spectrum): f is an array with the frequencies and spectrum is the : complex-valued FFT. : |
|---|
The standard output for this analyzer is a tuple f,s, where: f is the frequency bands associated with the discrete spectral components and s is the PSD calculated using mlab.psd().
This is the spectrum estimated as the FFT of the time-series
| Returns : | (f,spectrum): f is an array with the frequencies and spectrum is the : complex-valued FFT. : |
|---|
Signal and noise as defined in Borst and Theunissen 1999, Figure 2
| Parameters : | response: nitime TimeSeries object :
|
|---|