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(x[, alpha, base, normalize, ...])

Entropy \(H(X)\)

mutual_info(x, y[, base, is_discrete, bins, ...])

Mututal Information \(I(X;Y)\)

entropy_joint(x, y[, base, is_discrete, ...])

Joint Entropy \(H(X,Y)\)

entropy_cond(x, y[, base, is_discrete, ...])

Conditional Entropy \(H(X|Y)\)

entropy_cross(x, y[, base, is_discrete, ...])

Cross Entropy \(H_{xy}(X,Y)\)

entropy_kld(x, y[, base, is_discrete, bins, ...])

Cross Entropy Kullback–Leibler divergence \(H_{kl}(X,Y)\)

entropy_sample(x, m, r)

Sample Entropy \(SampEn(X)\) or \(H_{se}(X)\)

entropy_approx(x, m, r)

Approximate Entropy \(ApproxEn(X)\) or \(H_{ae}(X)\)

entropy_spectral(x, fs[, method, alpha, ...])

Spectral Entropy \(H_f(X)\)

entropy_svd(x[, order, delay, base, normalize])

Singular Value Decomposition Entropy \(H_{\Sigma}(X)\)

entropy_permutation(x[, order, delay, base, ...])

Permutation Entropy \(H_{\pi}(X)\)

Information Theory - Advanced

spkit.core

dispersion_entropy(x[, classes, scale, ...])

Dispersion Entropy of signal \(H_{de}(X)\)

dispersion_entropy_multiscale_refined(x[, ...])

Multiscale refined Dispersion Entropy of signal \(H_{de}(X)\)

entropy_differential(x[, is_multidim, ...])

Differential Entropy \(H_{\partial}(X)\)

entropy_diff_cond_self(X[, present_first])

Self-Conditional Entropy \(H_{\partial}(X_{i+1}|X_i)\)

entropy_diff_cond(X, Y[, present_first])

Conditional Entropy \(H_{\partial}(X_{i+1}|X_i,Y_i)\)

entropy_diff_joint(X, Y)

Differential Joint Entropy \(H_{\partial}(X,Y)\)

entropy_diff_joint_cond(X, Y[, present_first])

Joint-Conditional Entropy \(H_{\partial}(X_{i+1},Y_{i+1}|X_i,Y_i)\)

mutual_info_diff_self(X[, present_first])

Self Mutual Information \(I_{\partial}(X_{i+1}; X_i)\)

mutual_info_diff(X, Y[, present_first])

Mutual Information \(I_{\partial}(X_{i+1}; X_i, Y_i)\)

transfer_entropy(X, Y[, present_first])

Transfer Entropy \(TE_{X->Y}\)

transfer_entropy_cond(X, Y, Z[, present_first])

Conditional Transfer Entopry Or Partial Transfer Entropy \(TE_{X->Y | Z}\)

partial_transfer_entropy(X, Y, Z[, ...])

Partial Transfer Entropy Or Conditional Transfer Entopry \(TE_{X->Y | Z}\)

entropy_granger_causality(X, Y[, ...])

Granger Causality based on Differential Entropy \(GC_{X->Y}, GC_{Y->X}, GC_{X.Y}\)

Filtering - Signal Processing

spkit.core.processing

filter_X(X[, fs, band, btype, order, ftype, ...])

Spectral filtering using Buttorworth

filterDC(X[, alpha, return_background, ...])

Filter out DC component using IIR filter

filterDC_sGolay(X[, window_length, ...])

Filter out DC component using Savitzky-Golay filter

filter_smooth_gauss(X[, window_length, ...])

Smoothing filter using Gaussian Kernel and 1d-ConvFB

filter_smooth_mollifier(X[, window_length, ...])

Smoothing filter using Mollifier kernel and 1d-ConvFB

filter_smooth_sGolay(X[, window_length, ...])

Smoothing filter using Savitzky-Golay filter

filter_with_kernel(X, kernel[, iterations, mode])

Smoothing/Sharpening using given kernel and 1d-ConvFB

filter_powerline(X[, fs, powerline])

Remove Powerline interefences

filtering_pipeline(X, fs[, trim, iir_alpha, ...])

Filtering Pipeline

graph_filter_dist(X, V[, d, ftype, ...])

Graph Filtering with (Proximity)

graph_filter_adj(X, AdjM[, V, ftype, ...])

Graph Filtering with Adjacency Matrix

spatial_filter_adj(X, AdjM[, V, ftype, ...])

Spatial Filter with Adjacency Matrix: AdjM

spatial_filter_dist(X, V[, r, ftype, ...])

Spatial Filter with Distance (Proximity)

conv1d_fft(x, y)

1D Convolution using FFT

conv1d_fb(x, kernel[, iterations, mode, ...])

1D Forward-Backward-Convolution (ConvFB)

conv1d_nan(x, kernel[, denormalise_ker, ...])

1D Convolution with NaN values

conv2d_nan(x, kernel[, boundary, fillvalue, ...])

2D Convolution with NaN values

Analysis & Sythesis Models

spkit.core.advnace_techniques

dft_analysis(x[, window, N, scaling_dB, ...])

Discrete Fourier Transform: Analysis (DFT)

dft_synthesis(mX, pX[, M, scaling_dB, window])

Discrete Fourier Transform: Synthesis (iDFT)

stft_analysis(x, winlen[, window, nfft, ...])

Short-Time Fourier Transform Analysis Model

stft_synthesis(mXt, pXt, winlen, overlap)

Short-Time Fourier Transform Synthesis Model

sineModel_analysis(x, fs, winlen[, overlap, ...])

Analysis of a signal x using the sinusoidal model

sineModel_synthesis(fXt, mXt, pXt, fs, overlap)

Synthesis of signal x using the Sinusoidal Model

frft(x[, alpha, method, verbose])

Fractional Fourier Transform

ifrft(x[, alpha, method, verbose])

Inverse Fractional Fourier Transform

ffrft(x, alpha)

Fast Fractional Fourier Transform

iffrft(x, alpha)

Inverse Fast Fractional Fourier Transform

Wavelet Analysis

spkit.core : DWT

wavelet_filtering(x[, wv, threshold, ...])

Wavelet Filtering

wavelet_filtering_win(x[, winsize, wv, ...])

Wavelet Filtering window-wise

periodogram(x[, fs, show_plot, method, win, ...])

Computing Periodogram

wpa_coeff(x[, wv, mode, maxlevel, ...])

Wavelet Packet Decomposition

wpa_coeff_win(x[, winsize, overlap, wv, ...])

Wavelet Packet Decomposition - window-wise

wpa_plot(x[, winsize, overlap, ...])

WPA Window-wise Plot

wavelet_decomposed_signals(x[, wv, L, WPD, ...])

Decomposing signal into signals of wavelet components

spkit.cwt: CWT

ScalogramCWT(x, t[, wType, fs, PlotPSD, ...])

Scalogram using Continues Wavelet Transform

WavePSD(x, t[, wType, PlotW, PlotPSD, dFFT, ...])

Wavelet Power Spectral Density

GaussWave(t, f, f0, Q[, t0])

Gaussian Wavelet

MorlateWave(t[, f, sig])

Morlate Wavelet

GaborWave(t[, f, f0, a, t0])

Gabor Wavelet

PoissonWave(t[, f, n, method])

Poisson Wavelet

cMaxicanHatWave(t, f[, f0, a])

Complex Maxican Hat Wavelet

ShannonWave(t, f[, f0, fw])

Complex Shannon Wavelet

compare_cwt_example(x, t[, fs, sLog])

Compare different CWT Functions

Ramanujan Methods

spkit.core

ramanujan_filter(x[, Pmax, Rcq, Rav, Th, ...])

Ramanujan Filter Banks for Estimation and Tracking of Periodicity

ramanujan_filter_prange(x[, Pmin, Pmax, ...])

Ramanujan Filter Banks for Estimation and Tracking of Periodicity with given range.

regularised_period_estimation(x, Pmax[, ...])

Computing strength of periods

create_dictionary(Nmax, rowSize[, method])

Creating Dictionary for RFB

RFB_example_1([period, SNR, seed])

Example 1 for Ramanujan Filter Bank

RFB_example_2([periods, signal_length, SNR, ...])

Example 2 for Ramanujan Filter Bank

Simulate Signals

create_signal_1d([n, seed, circular, ...])

Generate 1D arbitary signal

create_signal_2d([n, seed, sg_winlen, ...])

Generate 2D arbitary signal/image patch

EEG Signal Processing

spkit.eeg

ATAR(X[, wv, winsize, thr_method, OptMode, ...])

ATAR - Automatic and Tunable Artifact Removal Algorithm

ATAR_1Ch(x[, wv, winsize, thr_method, ...])

ATAR : Automatic and Tunable Artifact Removal Algorithm (single channel)

ATAR_mCh(X[, wv, winsize, thr_method, ...])

ATAR: - Automatic and Tunable Artifact Removal Algorithm

ICA_filtering(X[, winsize, ICA_method, ...])

Aftifact Removal using ICA

rhythmic_powers(X[, fs, fBands, Sum, Mean, ...])

Compute powers of different Rhythms of EEG Signal

rhythmic_powers_win(X[, winsize, overlap, ...])

Rhythmic powers-window-wise

s1020_get_epos2d(ch_names[, style, ...])

Get 2D projection points for given channel using 10-20 System

s1010_get_epos2d(ch_names[, case_sensitive, ...])

Get 2D projection points for given channel using 10-10 System

s1005_get_epos2d(ch_names[, case_sensitive, ...])

Get 2D projection points for given channel using 10-05 System

topomap(data[, pos, ch_names, res, Zi, ...])

Display Topographical Map of EEG, with given values

gen_ssfi(PX, pos[, res, NormalizeEachBand, ...])

Generating Spatio-Spectral Feature Image (SSFI)

TopoMap_Zi(pos, data[, Zi, res, showplot, ...])

Display Topographical Map of EEG, with given values

MEA - Multi-Electrode Array

spkit.mea

analyse_mea_file(file_name, stim_fhz[, fs, ...])

A Complete Analysis of a MEA recording

get_stim_loc(X[, fs, ch, fhz, N, method, ...])

Get Stimulus Locations in given multi-channel

find_bad_channels_idx(X[, fs, thr, ...])

Identify the Bad Channels of MEA based on stimuli

align_cycles(X, stim_loc[, fs, ...])

Align Cycles

activation_time_loc(X[, fs, t_range, ...])

Compute Activation Time of multi-channel signals

activation_repol_time_loc(X[, fs, at_range, ...])

Computing Activation and Repolarisation Time together

extract_egm(X, act_loc[, fs, dur_from_loc, ...])

Extract EGMs (Electrograms) from each channel

egm_features(x, act_loc[, fs, ...])

Feature Extraction from a single EGM

mea_feature_map(features, ch_labels[, ...])

Displaying Feature values of MEA channels in a MEA Grid

compute_cv(Ax, Ax_bad[, eD, esp, cv_pad, ...])

Compute Conduction Velocity

arrange_mea_grid(features, ch_labels[, ...])

Arranging features into MEA-Grid Matrix: Feature Matrix

unarrange_mea_grid(M, ch_labels)

Reverse the operation of 'arrange_mea_grid'

plot_mea_grid(X, ch_labels[, fs, ...])

Plot MEA Grid 8x8: Visualisation of EGM/Signal in MEA Grid Form

mat_1_show(A[, fmt, vmin, vmax, cmap, ...])

Display a single Feature Matrix of MEA

mat_list_show(A[, fmt, vmin, vmax, cmap, ...])

Display multiple Feature Matrix of MEA

Signal Analysis and Processing

sinc_interp(x)

Sinc interpolation

gaussian_kernel(window_length[, ...])

Gaussian Kernel

friedrichs_mollifier_kernel(window_size[, ...])

Mollifier: Kurt Otto Friedrichs

denorm_kernel(kernel[, mode, keep_scale, esp])

De-normalise 1d/2d Kernel

periodogram(x[, fs, show_plot, method, win, ...])

Computing Periodogram

bin_width(x[, method])

Compute bin width for histogram, using different methods

hist_plot(x[, norm, bins, show])

Plot histogram with optimal number of bins (FD).

mean_minSE(x, y[, W, show, compare_mse, ...])

Mean of Minimum Squared Error (MMSE) under temporal shift

minMSE(x, y[, W, show])

Minimum Mean Squared Error under temporal shift

is_power2(n)

Check if num is power of two

plotJointEntropyXY(x, y[, Venn, DistPlot, ...])

Analyse Entropy-Venn Diagrams of X and Y

show_farmulas()

Usuful Formulas

New Methods

signal_diff(x[, method, sg_window, ...])

Derivative of a signal

simplify_signal(x, fs, winlen, overlap[, N, ...])

Simplify a signal with Sinasodal Model

elbow_knee_point(x[, dx, plot, show, ...])

Finding Elbow-knee point of a curve

total_variation(x[, normalise, method])

Total Variation of a signal

total_variation_win(x[, winlen, overlap, method])

Total Variation of a signal window-wise

fill_nans_1d(x[, pkind])

Fill nan values with interpolation/exterpolation for 1D

fill_nans_2d(X[, pkind, filter_size, ...])

Fill nan values with interpolation/exterpolation for 2D

add_noise(x[, snr_db, return_noise])

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(x[, fs, method, ...])

Get Activation Time based on Gradient

get_repolarisation_time(x, fs, at_loc[, ...])

Get Repolarisation Time based on Gradient

peak_detection(mX, thr)

Detect spectral peaks

peak_interp(mX, pX, ploc)

Interpolate peak using parabolic interpolation

f0_detection(x, fs, winlen[, nfft, overlap, ...])

Fundamental frequency detection using TWM

sinc_dirichlet(x, N)

Generate the main lobe of a sinc function

blackman_lobe(x[, N])

Main lobe of a Blackman-Harris window

sine_tracking(pfreq, pmag, pphase, tfreq[, ...])

Tracking sinusoids from one frame to the next

sinetracks_cleaning(tfreq[, minTrackLength])

Delete short fragments of a collection of sinusoidal tracks

sine_spectrum(ipfreq, ipmag, ipphase, N, fs)

Generate a spectrum from a series of sine values

TWM_f0(pfreq, pmag[, f0min, f0max, f0_pre, ...])

Two-Way Mismatch algorithm

TWM_algo(pfreq, pmag, f0c[, verbose])

Two-way mismatch algorithm for f0 detection

Phase, Angles, Dominent Frequencies

phase_map(X[, add_sig])

Phase Mapping of multi channel signals X

clean_phase(xp[, w, thr, low, high])

Cleaning Phase

phase_map_reconstruction(X[, add_sig, ...])

Phase Mapping and Amplitude Equalization

dominent_freq(X, fs[, method, window, ...])

Dominent Frequency Analysis

dominent_freq_win(X, fs[, win_len, overlap, ...])

Dominent Frequency Analysis Window-wise

agg_angles(thetas[, agg])

Aggregating Angles (Directional Arrows) (thetas)

show_compass(Ax_theta[, Ax_bad, arr_agg, ...])

Display Compass with Arrows and aggregated Arrow

direction_flow_map(X_theta[, X, upsample, ...])

Displaying Directional flow map of a 2D grid

Machine Learning

spkit.ml

LogisticRegression([alpha, lambd, polyfit, ...])

Logistic Regression

NaiveBayes()

Gaussian Naive Bayes classifier.

DecisionTree([min_samples_split, ...])

Super class of RegressionTree and ClassificationTree.

ClassificationTree([min_samples_split, ...])

Classification Tree

RegressionTree([min_samples_split, ...])

Regression Tree

Sample Data & Simulate

spkit.data

Sample of real data/signal

data.eeg_sample_14ch([fname])

Load 14 channel EEG sample recording of 16 second duration.

data.eeg_sample_1ch([ch, xtype])

Load a single channel EEG sample recording of 16 second duration.

data.eeg_sample_artifact([fname])

Load 14 channel EEG sample recording of 16 second duration with artifacts and processed.

data.ecg_sample_12leads([sample])

Load 12 lead ECG sample.

data.ecg_sample([sample])

Load sample(s) of ECG sampled at high rate

data.optical_sample([sample, species])

Load sample(s) of optical mapping signals

data.ppg_sample([sample])

Load sample(s) of PPG signals

data.gsr_sample([sample])

Load sample(s) of Galvanic Skin Response (GSR) or

data.eda_sample([sample])

Load sample(s) of Electrodermal activity (EDA)

data.egm_sample([sample])

Load sample(s) of Electrograms and ECG

data.primitive_polynomials([fname])

List of Primitive Polynomials as dictionary

Simulation of Data

For Machine Learning

data.linear([N, m, b, s, return_para])

Generate a 2-class dataset separated by a linear boundary

data.gaussian([N, ndist, means, sigmas, ...])

Generate a 2-class dataset from a mixture of gaussians

data.moons([N, s, d, angle, return_para])

Generate a 2-class dataset from two "moon" distributions

data.sinusoidal([N, s, return_para])

Generate a 2-class dataset separated by a sinusoidal line

data.spiral([N, s, wrappings, m, return_para])

Generate a 2-class dataset of spirals

data.create_dataset([N, Dtype, noise, ...])

Sample a 2D dataset from different distributions

data.mclass_gauss([N, nClasses, var, ...])

Generate Multi-class gaussian samples

For Signal Processing

create_signal_1d([n, seed, circular, ...])

Generate 1D arbitary signal

create_signal_2d([n, seed, sg_winlen, ...])

Generate 2D arbitary signal/image patch

Matrix Decomposition

ICA([n_components, max_pca_components, ...])

Independent Component Analysis

PCA([n_components, apply_whitening, tol])

Principle Component Analysis

SVD(X[, full])

Singular Value Decomposition,

Statististics

spkit.stats

quick_stats(x[, show, return_table, name])

Quick Statistics, excluding np.nan values

outliers(x[, method, k, include_lower, ...])

Statistical Outliers

get_stats(x[, detail_level, name, esp, add_esp])

Statistics of a given sequence x, excluding NaN values

test_2groups(x1, x2[, paired, alpha, ...])

Test two groups

test_groups(x[, axis, alpha, title, ...])

Test multiple groups: One-way Anova

plot_groups_boxes(x[, lines, xlabels, ylab, ...])

Boxplot for Groups data

Read/Write Files I/O

spkit.io

read_hdf(file_name[, fs, max_volt, ...])

Reading HDF File

read_surf(file_name)

Read Surf File .surf file geenrated by tools including vertices and faces

read_bdf(file_name[, verbose, readSignal, ...])

Read EDF/BDF File

read_vtk(file_name[, V_name, F_name, ...])

Read VTK File

write_vtk(filename, vertices, faces)

Writes .vtk file format for the Paraview (Kitware (c)) visualisation software.

Utilities

spkit.utils

ProgBar_JL(i, N[, title, style, L, ...])

Progress Bar : Utilities - Compatible with JupyterLab/Jupyter-Notebook

ProgBar(i, N[, title, style, L, ...])

Progress Bar : Utilities

pretty_print(List[, n, sep, show_index, ...])

Print list : in pretty way

view_hierarchical_order(file_obj[, sep, ...])

View nested dictionary type objects as hierarchical tree-order

utils.txcolors()

Utilities for coloring text

utils.bcolors()

Utilities for coloring text

Geometrical functions [UNDER DEVELOPMENT]

spkit.geometry

car2spar(X)

Cartesian to Spherical Coordinates

spar2car(S)

Spherical to CartesianCoordinates

get_adjacency_matrix_depth(V, F[, depth, ...])

Create Adjacency Matrix based on Trianglution Connection Depth

get_adjacency_matrix_dist(V[, dist, ...])

Create Adjacency Matrix based on Euclidean distance

get_adjacency_matrix_kNN(V[, K, ...])

Create Adjacency Index Matrix based on Euclidean distance kNN

node2C_to_adjacency_matrix(node2C[, M])

From node2C to Adjacency Matrix

get_neibours(V, p[, N])

Get N Neibours of point p

get_optimal_projection(X, p[, d, plot])

Optimal Projection

get_plane(X[, lamd, n])

Get Plane passing through (3D) points X

get_PCA(X[, whiting])

Get PCA

opt_project(X, p[, plot])

Optimal Projection

plot_proj(Xp, Xp1, Xp1c, Xp2, p)

Plot Projections

dir_vectors(V, AdjM[, verbose])

Directional Vectors

area_tri(p1, p2, p3)

Compute Area of a triangle in d-dimension

get_circle([r, n])

Get a circle of radius r with n points

get_circular_grid([n, al, rl, rmax])

Get a circular grid

get_square([n, r])

Get a uniform square grid of n by n points between -r to r

get_square_grid([n, vl, hl, r])

Get a square grid of n by n points between -r to r

get_sphare([n1, n2, r, r2, r3, phi_rang, ...])

Get a sphare

get_ellipsoid([n1, n2, rx, ry, rz, ...])

Get a ellipsoid

lin_inter(x1, x2, y1, y2, xt)

linear Inpeterpolation

surface_reconstruction(V[, shift_mean, ...])

Surface Recosntruction

surface_plot_mayavi(V, F, X[, D, ...])

3D Surface Plot using Mayavi

getTriFaces_V2(V[, plot, npoint_rotate, ...])

Get Triangulation Faces of given Vertices V

getTriFaces(V[, plot])

Get Triangulation Faces of given Vertices V

rotation_matrix([theta])

3 Rotational Matrices of Theta

divide_space(X, D[, V, lamda, plot, n])

Divide space point of X, by plane passing from D

get_center(X)

Get center of points

TriAng(F[, V])

Triangulation Class (Graph)

Inter2DPlane(xy_loc[, res])

Interpolation of 2D Plane

TO BE DEPRECATED

Wavelet Analysis

WPA_temporal(x[, winsize, overlap, wv, ...])

Wavelet Packet Decomposition - window-wise

WPA_plot(x[, winsize, overlap, ...])

WPA Window-wise - Plot

Wavelet_decompositions(x[, wv, L, ...])

Decomposing signal into wavelet components

Ramanujan Methods

RFB(x[, Pmax, Rcq, Rav, Th, Penalty, ...])

Ramanujan Filter Banks for Estimation and Tracking of Periodicity

RFB_prange(x[, Pmin, Pmax, skip, Rcq, Rav, ...])

Ramanujan Filter Banks for Estimation and Tracking of Periodicity with given range.

Create_Dictionary(Nmax, rowSize[, method])

Creating Dictionary for RFB

PeriodStrength(x, Pmax[, method, lambd, L, ...])

Computing strength of periods

EEG Signal Processing

display_topo_RGB(IR[, kersize, interpolation])

RGB Image show of Topographic Maps.

RhythmicDecomposition(E[, fs, order, ...])

Compute powers of different Rhythms of EEG Signal

TopoMap(pos, data[, res, showplot, axes, ...])

Topographical Map for given the data point and 2D projection points,

showTOPO(Zi, pos, ch_names[, axes, vmin, ...])

Topographical Map for given the data point and 2D projection points,

Gen_SSFI(X[, pos, res, NormalizeEachBand, ...])

Generating Spatio-Spectral Feature Image (SSFI)

Statistics

getStats(x[, detail_level, return_names])

Quick Statistics of a given sequence x, excluding NaN values

getQuickStats(x)

OutLiers(x[, method, k, include_lower, ...])

Identyfying outliers

IO Utilities

read_surf_file(file_name)

Read Surf File

Data

data.linear_data(*args, **kwargs)

Linear Data