.. 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_binned_amplitude.py: ==================================== Bin amplitude according to the phase ==================================== This example illustrate how to bin the amplitude according to the phase. .. image:: /auto_examples/misc/images/sphx_glr_plot_binned_amplitude_001.png :class: sphx-glr-single-img .. code-block:: default from tensorpac.signals import pac_signals_tort from tensorpac.utils import BinAmplitude import matplotlib.pyplot as plt # 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=2, n_epochs=n_epochs, dpha=10, damp=10, sf=sf, n_times=n_times) plt.figure(figsize=(14, 5)) plt.subplot(121) b_obj = BinAmplitude(data, sf, f_pha=[9, 11], f_amp=[90, 110], n_jobs=1, n_bins=18) ax = b_obj.plot(color='red', alpha=.5, unit='deg') plt.ylim(0, 180) plt.title("Binned amplitude (phase=[9, 11])") plt.subplot(122) b_obj = BinAmplitude(data, sf, f_pha=[2, 4], f_amp=[90, 110], n_jobs=1, n_bins=18) ax = b_obj.plot(color='blue', alpha=.5, unit='deg') plt.ylim(0, 180) plt.title("Binned amplitude (phase=[2, 4])") b_obj.show() .. rst-class:: sphx-glr-timing **Total running time of the script:** ( 0 minutes 0.523 seconds) .. _sphx_glr_download_auto_examples_misc_plot_binned_amplitude.py: .. only :: html .. container:: sphx-glr-footer :class: sphx-glr-footer-example .. container:: sphx-glr-download :download:`Download Python source code: plot_binned_amplitude.py ` .. container:: sphx-glr-download :download:`Download Jupyter notebook: plot_binned_amplitude.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_