.. note:: :class: sphx-glr-download-link-note Click :ref:`here ` to download the full example code .. rst-class:: sphx-glr-example-title .. _sphx_glr_auto_examples_misc_plot_psd.py: ================================================= Compute and plot the Power Spectrum Density (PSD) ================================================= This example illustrate how to compute and plot the Power Spectrum Density (PSD) of an electrophysiological dataset. The PSD should be used to check that there is the presence of a clear peak, espacially for frequency phase. .. image:: /auto_examples/misc/images/sphx_glr_plot_psd_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out Out: .. code-block:: none /home/circleci/project/tensorpac/utils.py:208: MatplotlibDeprecationWarning: The 'basex' parameter of __init__() has been renamed 'base' since Matplotlib 3.3; support for the old name will be dropped two minor releases later. plt.xscale('log', basex=10) | .. code-block:: default from tensorpac.utils import PSD from tensorpac.signals import pac_signals_tort # Dataset of signals artificially coupled between 10hz and 100hz : n_epochs = 20 n_times = 4000 sf = 512. # sampling frequency # Create artificially coupled signals using Tort method : data, time = pac_signals_tort(f_pha=10, f_amp=100, noise=4, n_epochs=n_epochs, dpha=10, damp=10, sf=sf, n_times=n_times) # compute the PSD psd = PSD(data, sf) # plot the mean PSD across trials between [5, 150]Hz with a 95th confidence # interval. Also, use a log x-scale ax = psd.plot(confidence=95, f_min=5, f_max=150, log=True, grid=True) # finally display the figure psd.show() .. rst-class:: sphx-glr-timing **Total running time of the script:** ( 0 minutes 0.290 seconds) .. _sphx_glr_download_auto_examples_misc_plot_psd.py: .. only :: html .. container:: sphx-glr-footer :class: sphx-glr-footer-example .. container:: sphx-glr-download :download:`Download Python source code: plot_psd.py ` .. container:: sphx-glr-download :download:`Download Jupyter notebook: plot_psd.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_