Note
Click here to download the full example code
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.
Main¶
First, lets import the required libraries
25 # Libraries generic
26 import numpy as np
27 import pandas as pd
28
29 # Libraries specific
30 from vital_sqi.sqi.standard_sqi import perfusion_sqi
31 from vital_sqi.sqi.standard_sqi import kurtosis_sqi
32 from vital_sqi.sqi.standard_sqi import skewness_sqi
33 from vital_sqi.sqi.standard_sqi import entropy_sqi
34 from vital_sqi.sqi.standard_sqi import signal_to_noise_sqi
Lets create the sinusoide
40 # Create samples
41 x = np.linspace(-10*np.pi, 10*np.pi, 201)
42
43 # Create signal
44 signal = np.sin(x)
Lets compute the SQIs
50 # Loop computing sqis
51 k = kurtosis_sqi(signal)
52 s = skewness_sqi(signal)
53 e = entropy_sqi(signal)
Lets display the result
59 # Create Series
60 result = pd.Series(
61 data=[k, s, e],
62 index=['kurtosis', 'skewness', 'entropy']
63 )
64
65 # Show
66 print("\nResult:")
67 print(result)
Out:
Result:
kurtosis -1.492500e+00
skewness -1.636973e-16
entropy 4.997679e+00
dtype: float64
Plot¶
Lets plot something so it shows a thumbicon
76 # ---------------
77 # Create plot
78 # ---------------
79 # Library
80 import matplotlib.pyplot as plt
81
82 # Plot
83 plt.plot(x, signal)
84
85 # Show
86 plt.show()
Total running time of the script: ( 0 minutes 0.097 seconds)