API Reference¶
This is the function and class objects reference of spkit. This the most up-to-date documentation of spkit functions/classes/modules. We are set out to write a comprehensive User Guide and we are continuously updating it, however, it might be missing the full details of functions. Please refer to each function here at API Reference, where the docstring of each function and class have been written with most of the information with examples.
Entropy Funtions¶
spkit.core
¶
spkit.core
: core module
|
Entropy \(H(X)\) |
|
Mututal Information \(I(X;Y)\) |
|
Joint Entropy \(H(X,Y)\) |
|
Conditional Entropy \(H(X|Y)\) |
|
Cross Entropy \(H_{xy}(X,Y)\) |
|
Cross Entropy Kullback–Leibler divergence \(H_{kl}(X,Y)\) |
|
Sample Entropy \(SampEn(X)\) or \(H_{se}(X)\) |
|
Approximate Entropy \(ApproxEn(X)\) or \(H_{ae}(X)\) |
|
Spectral Entropy \(H_f(X)\) |
|
Singular Value Decomposition Entropy \(H_{\Sigma}(X)\) |
|
Permutation Entropy \(H_{\pi}(X)\) |
Information Theory - Advanced¶
spkit.core
¶
|
Dispersion Entropy of signal \(H_{de}(X)\) |
|
Multiscale refined Dispersion Entropy of signal \(H_{de}(X)\) |
|
Differential Entropy \(H_{\partial}(X)\) |
|
Self-Conditional Entropy \(H_{\partial}(X_{i+1}|X_i)\) |
|
Conditional Entropy \(H_{\partial}(X_{i+1}|X_i,Y_i)\) |
|
Differential Joint Entropy \(H_{\partial}(X,Y)\) |
|
Joint-Conditional Entropy \(H_{\partial}(X_{i+1},Y_{i+1}|X_i,Y_i)\) |
|
Self Mutual Information \(I_{\partial}(X_{i+1}; X_i)\) |
|
Mutual Information \(I_{\partial}(X_{i+1}; X_i, Y_i)\) |
|
Transfer Entropy \(TE_{X->Y}\) |
|
Conditional Transfer Entopry Or Partial Transfer Entropy \(TE_{X->Y | Z}\) |
|
Partial Transfer Entropy Or Conditional Transfer Entopry \(TE_{X->Y | Z}\) |
|
Granger Causality based on Differential Entropy \(GC_{X->Y}, GC_{Y->X}, GC_{X.Y}\) |
Filtering - Signal Processing¶
spkit.core.processing
¶
|
Spectral filtering using Buttorworth |
|
Filter out DC component using IIR filter |
|
Filter out DC component using Savitzky-Golay filter |
|
Smoothing filter using Gaussian Kernel and 1d-ConvFB |
|
Smoothing filter using Mollifier kernel and 1d-ConvFB |
|
Smoothing filter using Savitzky-Golay filter |
|
Smoothing/Sharpening using given kernel and 1d-ConvFB |
|
Remove Powerline interefences |
|
Filtering Pipeline |
|
Graph Filtering with (Proximity) |
|
Graph Filtering with Adjacency Matrix |
|
Spatial Filter with Adjacency Matrix: AdjM |
|
Spatial Filter with Distance (Proximity) |
|
1D Convolution using FFT |
|
1D Forward-Backward-Convolution (ConvFB) |
|
1D Convolution with NaN values |
|
2D Convolution with NaN values |
Analysis & Sythesis Models¶
spkit.core.advnace_techniques
¶
|
Discrete Fourier Transform: Analysis (DFT) |
|
Discrete Fourier Transform: Synthesis (iDFT) |
|
Short-Time Fourier Transform Analysis Model |
|
Short-Time Fourier Transform Synthesis Model |
|
Analysis of a signal x using the sinusoidal model |
|
Synthesis of signal x using the Sinusoidal Model |
|
Fractional Fourier Transform |
|
Inverse Fractional Fourier Transform |
|
Fast Fractional Fourier Transform |
|
Inverse Fast Fractional Fourier Transform |
Wavelet Analysis¶
spkit.core
: DWT¶
|
Wavelet Filtering |
|
Wavelet Filtering window-wise |
|
Computing Periodogram |
|
Wavelet Packet Decomposition |
|
Wavelet Packet Decomposition - window-wise |
|
WPA Window-wise Plot |
|
Decomposing signal into signals of wavelet components |
spkit.cwt
: CWT¶
|
Scalogram using Continues Wavelet Transform |
|
Wavelet Power Spectral Density |
|
Gaussian Wavelet |
|
Morlate Wavelet |
|
Gabor Wavelet |
|
Poisson Wavelet |
|
Complex Maxican Hat Wavelet |
|
Complex Shannon Wavelet |
|
Compare different CWT Functions |
Ramanujan Methods¶
spkit.core
¶
|
Ramanujan Filter Banks for Estimation and Tracking of Periodicity |
|
Ramanujan Filter Banks for Estimation and Tracking of Periodicity with given range. |
|
Computing strength of periods |
|
Creating Dictionary for RFB |
|
Example 1 for Ramanujan Filter Bank |
|
Example 2 for Ramanujan Filter Bank |
Simulate Signals¶
|
Generate 1D arbitary signal |
|
Generate 2D arbitary signal/image patch |
EEG Signal Processing¶
spkit.eeg
¶
|
ATAR - Automatic and Tunable Artifact Removal Algorithm |
|
ATAR : Automatic and Tunable Artifact Removal Algorithm (single channel) |
|
ATAR: - Automatic and Tunable Artifact Removal Algorithm |
|
Aftifact Removal using ICA |
|
Compute powers of different Rhythms of EEG Signal |
|
Rhythmic powers-window-wise |
|
Get 2D projection points for given channel using 10-20 System |
|
Get 2D projection points for given channel using 10-10 System |
|
Get 2D projection points for given channel using 10-05 System |
|
Display Topographical Map of EEG, with given values |
|
Generating Spatio-Spectral Feature Image (SSFI) |
|
Display Topographical Map of EEG, with given values |
MEA - Multi-Electrode Array¶
spkit.mea
¶
|
A Complete Analysis of a MEA recording |
|
Get Stimulus Locations in given multi-channel |
|
Identify the Bad Channels of MEA based on stimuli |
|
Align Cycles |
|
Compute Activation Time of multi-channel signals |
|
Computing Activation and Repolarisation Time together |
|
Extract EGMs (Electrograms) from each channel |
|
Feature Extraction from a single EGM |
|
Displaying Feature values of MEA channels in a MEA Grid |
|
Compute Conduction Velocity |
|
Arranging features into MEA-Grid Matrix: Feature Matrix |
|
Reverse the operation of 'arrange_mea_grid' |
|
Plot MEA Grid 8x8: Visualisation of EGM/Signal in MEA Grid Form |
|
Display a single Feature Matrix of MEA |
|
Display multiple Feature Matrix of MEA |
Signal Analysis and Processing¶
|
Sinc interpolation |
|
Gaussian Kernel |
|
Mollifier: Kurt Otto Friedrichs |
|
De-normalise 1d/2d Kernel |
|
Computing Periodogram |
|
Compute bin width for histogram, using different methods |
|
Plot histogram with optimal number of bins (FD). |
|
Mean of Minimum Squared Error (MMSE) under temporal shift |
|
Minimum Mean Squared Error under temporal shift |
|
Check if num is power of two |
|
Analyse Entropy-Venn Diagrams of X and Y |
Usuful Formulas |
New Methods¶
|
Derivative of a signal |
|
Simplify a signal with Sinasodal Model |
|
Finding Elbow-knee point of a curve |
|
Total Variation of a signal |
|
Total Variation of a signal window-wise |
|
Fill nan values with interpolation/exterpolation for 1D |
|
Fill nan values with interpolation/exterpolation for 2D |
|
Add Gaussian Noise to Signal |
Signal Transformations/Mapping¶
spkit.core
¶
Mu_law
(x[, Mu, companding])μ-Law for companding and expanding (Non-linear mapping)
A_law
(x[, A, companding])A-Law for companding and expanding (Non-linear mapping)
cdf_mapping
(x)CDF: Cumulative Distribution Function Mapping (Non-linear mapping)
quantize_signal
(x[, n_levels, A, Mu, ...])Quantize signal into discreet levels
quantize_FD
(x[, scale, min_bins, ...])Discretize (quantize) input signal x using optimal bin-width (FD)
low_resolution
(x, scale)Reducing the time-resolution of signal \(x\)
signal_delayed_space
(x[, emb_dim, delay])Create N-dimensional signal space
create_multidim_space_signal
(x[, emb_dim, delay])Create N-dimensional signal space
TD_Embed
(x[, order, delay])Time delay Embedding Matrix
Event Analysis¶
|
Get Activation Time based on Gradient |
|
Get Repolarisation Time based on Gradient |
|
Detect spectral peaks |
|
Interpolate peak using parabolic interpolation |
|
Fundamental frequency detection using TWM |
|
Generate the main lobe of a sinc function |
|
Main lobe of a Blackman-Harris window |
|
Tracking sinusoids from one frame to the next |
|
Delete short fragments of a collection of sinusoidal tracks |
|
Generate a spectrum from a series of sine values |
|
Two-Way Mismatch algorithm |
|
Two-way mismatch algorithm for f0 detection |
Phase, Angles, Dominent Frequencies¶
|
Phase Mapping of multi channel signals X |
|
Cleaning Phase |
|
Phase Mapping and Amplitude Equalization |
|
Dominent Frequency Analysis |
|
Dominent Frequency Analysis Window-wise |
|
Aggregating Angles (Directional Arrows) (thetas) |
|
Display Compass with Arrows and aggregated Arrow |
|
Displaying Directional flow map of a 2D grid |
Machine Learning¶
spkit.ml
¶
|
Logistic Regression |
Gaussian Naive Bayes classifier. |
|
|
Super class of RegressionTree and ClassificationTree. |
|
Classification Tree |
|
Regression Tree |
Sample Data & Simulate¶
spkit.data
¶
Sample of real data/signal¶
|
Load 14 channel EEG sample recording of 16 second duration. |
|
Load a single channel EEG sample recording of 16 second duration. |
|
Load 14 channel EEG sample recording of 16 second duration with artifacts and processed. |
|
Load 12 lead ECG sample. |
|
Load sample(s) of ECG sampled at high rate |
|
Load sample(s) of optical mapping signals |
|
Load sample(s) of PPG signals |
|
Load sample(s) of Galvanic Skin Response (GSR) or |
|
Load sample(s) of Electrodermal activity (EDA) |
|
Load sample(s) of Electrograms and ECG |
|
List of Primitive Polynomials as dictionary |
Simulation of Data¶
For Machine Learning¶
|
Generate a 2-class dataset separated by a linear boundary |
|
Generate a 2-class dataset from a mixture of gaussians |
|
Generate a 2-class dataset from two "moon" distributions |
|
Generate a 2-class dataset separated by a sinusoidal line |
|
Generate a 2-class dataset of spirals |
|
Sample a 2D dataset from different distributions |
|
Generate Multi-class gaussian samples |
For Signal Processing¶
|
Generate 1D arbitary signal |
|
Generate 2D arbitary signal/image patch |
Matrix Decomposition¶
|
Independent Component Analysis |
|
Principle Component Analysis |
|
Singular Value Decomposition, |
Statististics¶
spkit.stats
¶
|
Quick Statistics, excluding np.nan values |
|
Statistical Outliers |
|
Statistics of a given sequence x, excluding NaN values |
|
Test two groups |
|
Test multiple groups: One-way Anova |
|
Boxplot for Groups data |
Read/Write Files I/O¶
spkit.io
¶
|
Reading HDF File |
|
Read Surf File .surf file geenrated by tools including vertices and faces |
|
Read EDF/BDF File |
|
Read VTK File |
|
Writes .vtk file format for the Paraview (Kitware (c)) visualisation software. |
Utilities¶
spkit.utils
¶
|
Progress Bar : Utilities - Compatible with JupyterLab/Jupyter-Notebook |
|
Progress Bar : Utilities |
|
Print list : in pretty way |
|
View nested dictionary type objects as hierarchical tree-order |
Utilities for coloring text |
|
Utilities for coloring text |
Geometrical functions [UNDER DEVELOPMENT]¶
spkit.geometry
¶
|
Cartesian to Spherical Coordinates |
|
Spherical to CartesianCoordinates |
|
Create Adjacency Matrix based on Trianglution Connection Depth |
|
Create Adjacency Matrix based on Euclidean distance |
|
Create Adjacency Index Matrix based on Euclidean distance kNN |
|
From node2C to Adjacency Matrix |
|
Get N Neibours of point p |
|
Optimal Projection |
|
Get Plane passing through (3D) points X |
|
Get PCA |
|
Optimal Projection |
|
Plot Projections |
|
Directional Vectors |
|
Compute Area of a triangle in d-dimension |
|
Get a circle of radius r with n points |
|
Get a circular grid |
|
Get a uniform square grid of n by n points between -r to r |
|
Get a square grid of n by n points between -r to r |
|
Get a sphare |
|
Get a ellipsoid |
|
linear Inpeterpolation |
|
Surface Recosntruction |
|
3D Surface Plot using Mayavi |
|
Get Triangulation Faces of given Vertices V |
|
Get Triangulation Faces of given Vertices V |
|
3 Rotational Matrices of Theta |
|
Divide space point of X, by plane passing from D |
|
Get center of points |
|
Triangulation Class (Graph) |
|
Interpolation of 2D Plane |
TO BE DEPRECATED¶
Wavelet Analysis¶
|
Wavelet Packet Decomposition - window-wise |
|
WPA Window-wise - Plot |
|
Decomposing signal into wavelet components |
Ramanujan Methods¶
|
Ramanujan Filter Banks for Estimation and Tracking of Periodicity |
|
Ramanujan Filter Banks for Estimation and Tracking of Periodicity with given range. |
|
Creating Dictionary for RFB |
|
Computing strength of periods |
EEG Signal Processing¶
|
RGB Image show of Topographic Maps. |
|
Compute powers of different Rhythms of EEG Signal |
|
Topographical Map for given the data point and 2D projection points, |
|
Topographical Map for given the data point and 2D projection points, |
|
Generating Spatio-Spectral Feature Image (SSFI) |
Statistics¶
|
Quick Statistics of a given sequence x, excluding NaN values |
|
Identyfying outliers |
IO Utilities¶
|
Read Surf File |
Data¶
|
Linear Data |