tensorpac.utils.ITC¶
-
class
tensorpac.utils.
ITC
(x, sf, f_pha=[2, 4], dcomplex='hilbert', cycle=3, width=7, edges=None, n_jobs=-1, verbose=None)[source]¶ Compute the Inter-Trials Coherence (ITC).
The Inter-Trials Coherence (ITC) is a measure of phase consistency over trials for a single recording site (electrode / sensor etc.).
- Parameters
- xarray_like
Array of data of shape (n_epochs, n_times)
- sffloat
The sampling frequency
- f_phatuple, list | [2, 4]
List of two floats describing the frequency bounds for extracting the phase
- dcomplex{‘wavelet’, ‘hilbert’}
Method for the complex definition. Use either ‘hilbert’ or ‘wavelet’.
- cycletuple | 3
Control the number of cycles for filtering the phase (only if dcomplex is ‘hilbert’).
- widthint | 7
Width of the Morlet’s wavelet.
- edgesint | None
Number of samples to discard to avoid edge effects due to filtering
-
__init__
(x, sf, f_pha=[2, 4], dcomplex='hilbert', cycle=3, width=7, edges=None, n_jobs=-1, verbose=None)[source]¶ Init.
Methods
__init__
(x, sf[, f_pha, dcomplex, cycle, …])Init.
filter
(sf, x[, ftype, keepfilt, edges, n_jobs])Filt the data in the specified frequency bands.
pacplot
(pac, xvec, yvec[, xlabel, ylabel, …])Main plotting pac function.
plot
([times])Plot the Inter-Trials Coherence.
savefig
(filename[, dpi])Save the figure.
show
()Show the figure.
Attributes
Get the cycle value.
Get the dcomplex value.
Vector of amplitudes of shape (n_amp, 2).
Vector of phases of shape (n_pha, 2).
Get the itc value.
Get the width value.
Vector of phases of shape (n_pha,) use for plotting.
Vector of amplitudes of shape (n_amp,) use for plotting.
-
filter
(sf, x, ftype='phase', keepfilt=False, edges=None, n_jobs=-1)¶ Filt the data in the specified frequency bands.
- Parameters
- sffloat
The sampling frequency.
- xarray_like
Array of data of shape (n_epochs, n_times)
- ftype{‘phase’, ‘amplitude’}
Specify if you want to extract phase (‘phase’) or the amplitude (‘amplitude’).
- n_jobsint | -1
Number of jobs to compute PAC in parallel. For very large data, set this parameter to 1 in order to prevent large memory usage.
- keepfiltbool | False
Specify if you only want the filtered data (True). This parameter is only available with dcomplex=’hilbert’ and not wavelet.
- edgesint | None
Number of samples to discard to avoid edge effects due to filtering
- Returns
- xfiltarray_like
The filtered data of shape (n_freqs, n_epochs, n_times)
-
pacplot
(pac, xvec, yvec, xlabel='', ylabel='', cblabel='', title='', fz_labels=12, fz_title=13, fz_cblabel=12, cmap='viridis', vmin=None, vmax=None, under=None, over=None, bad=None, pvalues=None, p=0.05, interp=None, rmaxis=False, dpaxis=False, plotas='imshow', ncontours=5, levels=None, levelcmap='Reds', polar=False, colorbar=True, y=1.02, subplot=111)¶ Main plotting pac function.
This method can be used to plot any 2D array.
- Parameters
- pacarray_like
A 2D array.
- xvecarray_like
The vector to use for the x-axis.
- yvecarray_like
The vector to use for the y-axis.
- xlabelstring | ‘’
Label for the x-axis.
- ylabelstring | ‘’
Label for the y-axis.
- cblabelstring | ‘’
Label for the colorbar.
- titlestring | ‘’
Title of the plot.
- fz_labelsfloat | 12
Font size of the y- and x-labels
- fz_titlefloat | 13
Font size of the title
- fz_cblabelfloat | 12
Font size of the colorbar label
- yfloat | 1.02
Title location.
- cmapstring | ‘viridis’
Name of one Matplotlib’s colomap.
- vminfloat | None
Threshold under which set the color to the uner parameter.
- vmaxfloat | None
Threshold over which set the color in the over parameter.
- understring | ‘gray’
Color for values under the vmin parameter.
- overstring | ‘red’
Color for values over the vmax parameter.
- badstring | None
Color for non-significant values.
- pvaluesarray_like | None
P-values to use for masking PAC values. The shape of this parameter must be the same as the shape as pac.
- pfloat | .05
If pvalues is pass, use this threshold for masking non-significant PAC.
- interptuple | None
Tuple for controlling the 2D interpolation. For example, (.1, .1) will multiply the number of row and columns by 10.
- rmaxisbool | False
Remove unecessary axis.
- dpaxisbool | False
Despine axis.
- plotas{‘imshow’, ‘contour’, ‘pcolor’}
Choose how to display the comodulogram, either using imshow (‘imshow’) or contours (‘contour’). If you choose ‘contour’, use the ncontours parameter for controlling the number of contours.
- ncontoursint | 5
Number of contours if plotas is ‘contour’.
- levelslist | None
Add significency levels. This parameter must be a sorted list of p-values to use as levels.
- levelcmapstring | Reds
Colormap of signifiency levels.
- Returns
- gca: axes
The current matplotlib axes.
-
plot
(times=None, **kw)[source]¶ Plot the Inter-Trials Coherence.
- Parameters
- timesarray_like | None
Custom time vector to use
- kwdict | {}
Additional inputs are either pass to the matplotlib.pyplot.plot function if a single phase band is used, otherwise to the matplotlib.pyplot.pcolormesh function
- Returns
- axMatplotlib axis
The matplotlib axis that contains the figure
-
savefig
(filename, dpi=600)¶ Save the figure.
- Parameters
- filenamestring
The name of the figure to save.
- dpiint | 600
DPI of the figure.
-
property
cycle
¶ Get the cycle value.
-
property
dcomplex
¶ Get the dcomplex value.
-
property
f_amp
¶ Vector of amplitudes of shape (n_amp, 2).
-
property
f_pha
¶ Vector of phases of shape (n_pha, 2).
-
property
itc
¶ Get the itc value.
-
property
width
¶ Get the width value.
-
property
xvec
¶ Vector of phases of shape (n_pha,) use for plotting.
-
property
yvec
¶ Vector of amplitudes of shape (n_amp,) use for plotting.