visbrain.objects.TimeFrequencyObj¶
- class visbrain.objects.TimeFrequencyObj(name, data=None, sf=1.0, method='fourier', nperseg=256, f_min=1.0, f_max=160.0, f_step=1.0, baseline=None, norm=None, n_window=None, overlap=0.0, window=None, c_parameter=20, cmap='viridis', clim=None, vmin=None, under='gray', vmax=None, over='red', interpolation='nearest', max_pts=-1, parent=None, transform=None, verbose=None, **kw)[source][source]¶
Compute the time-frequency map (or spectrogram).
The time-frequency decomposition can be assessed using :
The fourier transform
Morlet’s wavelet
Multi-taper
- Parameters:
- namestring | None
Name of the time-frequency object.
- dataarray_like
Array of data of shape (N,)
- sffloat | 1.
The sampling frequency.
- method{‘fourier’, ‘wavelet’, ‘multitaper’}
The method to use to compute the time-frequency decomposition.
- npersegint | 256
Length of each segment. Argument pass to the scipy.signal.spectrogram function (for ‘fourier’ and ‘multitaper’ method).
- overlapfloat | 0.
Overlap between segments. Must be between 0. and 1.
- f_minfloat | 1.
Minimum frequency (for ‘wavelet’ method).
- f_maxfloat | 160.
Maximum frequency (for ‘wavelet’ method).
- f_stepfloat | 2.
Frequency step between two consecutive frequencies (for ‘wavelet’ method).
- baselinearray_like | None
Baseline period (for ‘wavelet’ method).
- normint | None
The normalization type (for ‘wavelet’ method).. See the normalization function.
- n_windowint | None
If this parameter is an integer, the time-frequency map is going to be averaged into smaller windows (for ‘wavelet’ method).
- window{‘flat’, ‘hanning’, ‘hamming’, ‘bartlett’, ‘blackman’}
Windowing method for averaging. By default, ‘flat’ is used for Wavelet and ‘hamming’ for Fourier.
- c_parameterint | 20
Parameter ‘c’ described in doi:10.1155/2011/980805 (for ‘multitaper’ method)
- climtuple | None
Colorbar limits. If None, clim=(data.min(), data.max())
- cmapstring | None
Colormap name.
- vminfloat | None
Minimum threshold of the colorbar.
- understring/tuple/array_like | None
Color for values under vmin.
- vmaxfloat | None
Maximum threshold of the colorbar.
- overstring/tuple/array_like | None
Color for values over vmax.
- interpolationstring | ‘nearest’
Interpolation method for the image. See vispy.scene.visuals.Image for availables interpolation methods.
- max_ptsint | -1
Maximum number of points of the image along the x or y axis. This parameter is essentially used to solve OpenGL issues with very large images.
- transformVisPy.visuals.transforms | None
VisPy transformation to set to the parent node.
- parentVisPy.parent | None
Markers object parent.
- verbosestring
Verbosity level.
- kwdict | {}
Optional arguments are used to control the colorbar (See
ColorbarObj
).
Notes
List of supported shortcuts :
s : save the figure
<delete> : reset camera
Examples
>>> import numpy as np >>> from visbrain.objects import TimeFrequencyObj >>> n, sf = 512, 256 # number of time-points and sampling frequency >>> time = np.arange(n) / sf # time vector >>> data = np.sin(2 * np.pi * 25. * time) + np.random.rand(n) >>> tf = TimeFrequencyObj('tf', data, sf) >>> tf.preview(axis=True)
Methods
__init__
(name[, data, sf, method, nperseg, ...])Init.
animate
([step, interval, iterations])Animate the object.
copy
()Get a copy of the object.
Tree description.
preview
([bgcolor, axis, xyz, show, obj, ...])Previsualize the result.
record_animation
(name[, n_pic, bgcolor])Record an animated object and save as a *.gif file.
render
()Render the canvas.
screenshot
(saveas[, print_size, dpi, unit, ...])Take a screeshot of the scene.
set_data
(data[, sf, method, nperseg, f_min, ...])Compute TF and set data to the ImageObj.
set_shortcuts_to_canvas
(canvas)Set shortcuts to a VisbrainCanvas.
to_dict
()Return a dictionary of all colorbar args.
to_kwargs
([addisminmax])Return a dictionary for input arguments.
update
()Fonction to run when an update is needed.
update_from_dict
(kwargs)Update attributes from a dictionary.