.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "_examples\sqi\plot_sample_02.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note Click :ref:`here ` to download the full example code .. rst-class:: sphx-glr-example-title .. _sphx_glr__examples_sqi_plot_sample_02.py: Sample 02 ==================== This examples computes the three most basic standard SQIs (kurtosis, skewness and entropy). In addition, it shows the code and explains it in different sections. This is similar to jupyter notebook. It is just an example. .. warning:: The ``dtw`` module seems to be loaded even though we are not really using it. Instead, load it only when required. .. GENERATED FROM PYTHON SOURCE LINES 17-20 Main ---- .. GENERATED FROM PYTHON SOURCE LINES 22-24 First, lets import the required libraries .. GENERATED FROM PYTHON SOURCE LINES 24-36 .. code-block:: default :lineno-start: 25 # Libraries generic import numpy as np import pandas as pd # Libraries specific from vital_sqi.sqi.standard_sqi import perfusion_sqi from vital_sqi.sqi.standard_sqi import kurtosis_sqi from vital_sqi.sqi.standard_sqi import skewness_sqi from vital_sqi.sqi.standard_sqi import entropy_sqi from vital_sqi.sqi.standard_sqi import signal_to_noise_sqi .. GENERATED FROM PYTHON SOURCE LINES 37-39 Lets create the sinusoide .. GENERATED FROM PYTHON SOURCE LINES 39-46 .. code-block:: default :lineno-start: 40 # Create samples x = np.linspace(-10*np.pi, 10*np.pi, 201) # Create signal signal = np.sin(x) .. GENERATED FROM PYTHON SOURCE LINES 47-49 Lets compute the SQIs .. GENERATED FROM PYTHON SOURCE LINES 49-55 .. code-block:: default :lineno-start: 50 # Loop computing sqis k = kurtosis_sqi(signal) s = skewness_sqi(signal) e = entropy_sqi(signal) .. GENERATED FROM PYTHON SOURCE LINES 56-58 Lets display the result .. GENERATED FROM PYTHON SOURCE LINES 58-69 .. code-block:: default :lineno-start: 59 # Create Series result = pd.Series( data=[k, s, e], index=['kurtosis', 'skewness', 'entropy'] ) # Show print("\nResult:") print(result) .. rst-class:: sphx-glr-script-out Out: .. code-block:: none Result: kurtosis -1.492500e+00 skewness -1.605493e-16 entropy 4.997679e+00 dtype: float64 .. GENERATED FROM PYTHON SOURCE LINES 70-75 Plot ---- Lets plot something so it shows a thumbicon .. GENERATED FROM PYTHON SOURCE LINES 75-86 .. code-block:: default :lineno-start: 76 # --------------- # Create plot # --------------- # Library import matplotlib.pyplot as plt # Plot plt.plot(x, signal) # Show plt.show() .. image:: /_examples/sqi/images/sphx_glr_plot_sample_02_001.png :alt: plot sample 02 :class: sphx-glr-single-img .. rst-class:: sphx-glr-timing **Total running time of the script:** ( 0 minutes 0.062 seconds) .. _sphx_glr_download__examples_sqi_plot_sample_02.py: .. only :: html .. container:: sphx-glr-footer :class: sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_sample_02.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_sample_02.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_