From 3dca5d798bfaf353daf838a6a43e945cf5f76e50 Mon Sep 17 00:00:00 2001 From: Nikesh Bajaj Date: Tue, 4 Apr 2023 23:37:18 +0100 Subject: [PATCH] 0.0.9.6 Updating 0.0.9.6 release --- README.md | 338 ++++++++++------------------------------------- Version | 2 +- requirements.txt | 6 +- setup.py | 125 +++++++++++------- 4 files changed, 152 insertions(+), 319 deletions(-) diff --git a/README.md b/README.md index 2de94ef..cd4af27 100644 --- a/README.md +++ b/README.md @@ -28,82 +28,11 @@ DOI --> - [![Join the chat at https://gitter.im/spkitpy/community](https://badges.gitter.im/spkitpy/community.svg)](https://gitter.im/spkitpy/community?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) - - -## **[New Documentation](https://spkit.github.io/guide)** - - ----- -### For more updated documentation check github or [Documentation](https://spkit.readthedocs.io/) -## Table of contents -- [**New Updates**](#new-updates) -- [**Installation**](#installation) -- [**Function list: Signal Processing & ML**](#functions-list) -- [**Examples with Notebooks**](#examples) - - [**Scalogram CWT**](https://github.com/Nikeshbajaj/spkit#scalogram-cwt) - - [**Information Theory**](#information-theory) - - [**Machine Learning**](#machine-learning) - -[Logistic Regression](#logistic-regression---view-in-notebook) - -[Naive Bayes](#naive-bayes---view-in-notebook) - -[Decision Trees](#decision-trees---view-in-notebook) - - [**Independent Component Analysis**](#independent-component-analysis) - - [**Linear Feedback Shift Register**](#linear-feedback-shift-register) -- [**Cite as**](#cite-as) ------ - -## New Updates - -**Version: 0.0.9.3** - -Following functionaliets are added in 0.0.9.3 version -* **ATAR Algorithm for EEG Artifact removal** [Automatic and Tunable Artifact Removal Algorithm for EEG from artical](https://www.sciencedirect.com/science/article/pii/S1746809419302058) -* **ICA based artifact removal algorith** -* **Basic filtering, wavelet filtering, EEG signal processing techniques** -* **spectral, sample, aproximate and svd entropy functions** -

- - -

- -**Version: 0.0.9.2** -* **Added Scalogram with CWT functions** -

- -

- -**Version: 0.0.9.1** -* **Fixed the Import Error with python 2.7** -* **Logistic Regression with multiclass** -* **Updated Examples with 0.0.9 version [View Notebooks](https://nbviewer.jupyter.org/github/Nikeshbajaj/Notebooks/tree/master/spkit/0.0.9/ML/Trees/) | Run all the examples with [![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/Nikeshbajaj/Notebooks/master?urlpath=lab/tree/spkit/0.0.9/ML/Trees)** - - -#### New Updates:: Decision Tree [View Notebooks](https://nbviewer.jupyter.org/github/Nikeshbajaj/Notebooks/tree/master/spkit_ML/DecisionTree/) - -**Version: 0.0.7** -* **Analysing the performance measure of trained tree at different depth - with ONE-TIME Training ONLY** -* **Optimize the depth of tree** -* **Shrink the trained tree with optimal depth** -* **Plot the Learning Curve** -* **Classification: Compute the probability and counts of label at a leaf for given example sample** -* **Regression: Compute the standard deviation and number of training samples at a leaf for given example sample** - -

- - -

- - -* **Version: 0.0.6**: Works with catogorical features without converting them into binary vector -* **Version: 0.0.5**: Toy examples to understand the effect of incresing max_depth of Decision Tree -

- - -

## Installation -**Requirement**: numpy, matplotlib, scipy.stats, scikit-learn +**Requirement**: numpy, matplotlib, scipy.stats, scikit-learn, seaborn ### with pip @@ -111,13 +40,6 @@ Following functionaliets are added in 0.0.9.3 version pip install spkit ``` -### with conda - -``` -conda install -c nikeshbajaj spkit -``` - - ### update with pip ``` @@ -125,34 +47,55 @@ pip install spkit --upgrade ``` -### Build from the source -Download the repository or clone it with git, after cd in directory build it from source with +# New in 0.0.9.5: +## MEA Processing Toolkit + * sp.mea +## Geometrical Functions + * sp.gemetry +## More on signal processing + * sp.core +## Statistics + * sp.stats -``` -python setup.py install -``` -# Functions list -## Signal Processing Techniques -### **Information Theory functions** + +# For updated list of contents and documentation check [github](https://GitHub.com/nikeshbajaj/spkit) or [Documentation](https://spkit.readthedocs.io/) + +# List of all functions +# Signal Processing Techniques +## **Information Theory functions** **for real valued signals** -* Entropy : Shannon entropy, Rényi entropy of order α, Collision entropy, Spectral Entropy, Approximate Entropy, Sample Entropy -* Joint entropy -* Conditional entropy -* Mutual Information -* Cross entropy -* Kullback–Leibler divergence -* Computation of optimal bin size for histogram using FD-rule + * Entropy + * Shannon entropy + * Rényi entropy of order α, Collision entropy, + * Joint entropy + * Conditional entropy + * Mutual Information + * Cross entropy + * Kullback–Leibler divergence + * Spectral Entropy + * Approximate Entropy + * Sample Entropy + * Permutation Entropy + * SVD Entropy + * Plot histogram with optimal bin size +* Computation of optimal bin size for histogram using FD-rule +* Compute bin_width with various statistical measures +* Plot Venn Diagram- joint distribuation and normalized entropy values + +## **Dispersion Entropy** --**for time series (physiological signals)** +* **Dispersion Entropy** (Advanced) - for time series signal + * Dispersion Entropy + * Dispersion Entropy - multiscale + * Dispersion Entropy - multiscale - refined -### **Matrix Decomposition** + +## **Matrix Decomposition** * SVD * ICA using InfoMax, Extended-InfoMax, FastICA & **Picard** -### **Linear Feedback Shift Register** -* pylfsr - -### **Continuase Wavelet Transform** +## **Continuase Wavelet Transform** * Gauss wavelet * Morlet wavelet * Gabor wavelet @@ -160,203 +103,62 @@ python setup.py install * Maxican wavelet * Shannon wavelet -### **Discrete Wavelet Transform** +## **Discrete Wavelet Transform** * Wavelet filtering * Wavelet Packet Analysis and Filtering -### **Basic Filtering** +## **Basic Filtering** * Removing DC/ Smoothing for multi-channel signals * Bandpass/Lowpass/Highpass/Bandreject filtering for multi-channel signals ## Biomedical Signal Processing + +### MEA Processing Toolkit + **Artifact Removal Algorithm** * **ATAR Algorithm** [Automatic and Tunable Artifact Removal Algorithm for EEG from artical](https://www.sciencedirect.com/science/article/pii/S1746809419302058) * **ICA based Algorith** -## Machine Learning models - with visualizations -* Logistic Regression -* Naive Bayes -* Decision Trees -* DeepNet (to be updated) +## Analysis and Synthesis Models +* **DFT Analysis & Synthesis** +* **STFT Analysis & Synthesis** +* **Sinasodal Model - Analysis & Synthesis** + - to decompose a signal into sinasodal wave tracks +* **f0 detection** +## Ramanajum Methods for period estimation +* **Period estimation for a short length sequence using Ramanujam Filters Banks (RFB)** +* **Minizing sparsity of periods** -# Examples -## Scalogram CWT +## Fractional Fourier Transform +* **Fractional Fourier Transform** +* **Fast Fractional Fourier Transform** -``` -import numpy as np -import matplotlib.pyplot as plt -import spkit as sp -from spkit.cwt import ScalogramCWT -from spkit.cwt import compare_cwt_example - -x,fs = sp.load_data.eegSample_1ch() -t = np.arange(len(x))/fs -print(x.shape, t.shape) -compare_cwt_example(x,t,fs=fs) -``` -

- -

- -``` -f0 = np.linspace(0.1,10,100) -Q = np.linspace(0.1,5,100) -XW,S = ScalogramCWT(x,t,fs=fs,wType='Gauss',PlotPSD=True,f0=f0,Q=Q) -``` -

- -

-## Information Theory -### [View in notebook](https://nbviewer.jupyter.org/github/Nikeshbajaj/Notebooks/blob/master/spkit_InfoTheory/1_Entropy_Example.ipynb) - -``` -import numpy as np -import matplotlib.pyplot as plt -import spkit as sp - -x = np.random.rand(10000) -y = np.random.randn(10000) - -#Shannan entropy -H_x= sp.entropy(x,alpha=1) -H_y= sp.entropy(y,alpha=1) - -#Rényi entropy -Hr_x= sp.entropy(x,alpha=2) -Hr_y= sp.entropy(y,alpha=2) - -H_xy= sp.entropy_joint(x,y) - -H_x1y= sp.entropy_cond(x,y) -H_y1x= sp.entropy_cond(y,x) - -I_xy = sp.mutual_Info(x,y) - -H_xy_cross= sp.entropy_cross(x,y) - -D_xy= sp.entropy_kld(x,y) - - -print('Shannan entropy') -print('Entropy of x: H(x) = ',H_x) -print('Entropy of y: H(y) = ',H_y) -print('-') -print('Rényi entropy') -print('Entropy of x: H(x) = ',Hr_x) -print('Entropy of y: H(y) = ',Hr_y) -print('-') -print('Mutual Information I(x,y) = ',I_xy) -print('Joint Entropy H(x,y) = ',H_xy) -print('Conditional Entropy of : H(x|y) = ',H_x1y) -print('Conditional Entropy of : H(y|x) = ',H_y1x) -print('-') -print('Cross Entropy of : H(x,y) = :',H_xy_cross) -print('Kullback–Leibler divergence : Dkl(x,y) = :',D_xy) - - - -plt.figure(figsize=(12,5)) -plt.subplot(121) -sp.HistPlot(x,show=False) - -plt.subplot(122) -sp.HistPlot(y,show=False) -plt.show() -``` - -## Independent Component Analysis -### [View in notebook](https://nbviewer.jupyter.org/github/Nikeshbajaj/Notebooks/blob/master/spkit_SP/1_EEG_ICA_Example_spkit.ipynb) -``` -from spkit import ICA -from spkit.data import load_data -X,ch_names = load_data.eegSample() - -x = X[128*10:128*12,:] -t = np.arange(x.shape[0])/128.0 - -ica = ICA(n_components=14,method='fastica') -ica.fit(x.T) -s1 = ica.transform(x.T) - -ica = ICA(n_components=14,method='infomax') -ica.fit(x.T) -s2 = ica.transform(x.T) - -ica = ICA(n_components=14,method='picard') -ica.fit(x.T) -s3 = ica.transform(x.T) - -ica = ICA(n_components=14,method='extended-infomax') -ica.fit(x.T) -s4 = ica.transform(x.T) -``` - -## Machine Learning -### [Logistic Regression](https://nbviewer.jupyter.org/github/Nikeshbajaj/Notebooks/blob/master/spkit_ML/LogisticRegression/1_LogisticRegression_examples_spkit.ipynb) - *View in notebook* -

- -### [Naive Bayes](https://nbviewer.jupyter.org/github/Nikeshbajaj/Notebooks/blob/master/spkit_ML/NaiveBayes/1_NaiveBayes_example_spkit.ipynb) - *View in notebook* -

- -### [Decision Trees](https://nbviewer.jupyter.org/github/Nikeshbajaj/Notebooks/blob/master/spkit_ML/DecisionTree/1_Tree_ClassificationRegression_spkitV0.0.5.ipynb) - *View in notebook* - -[**[jupyter-notebooks]**](https://nbviewer.jupyter.org/github/Nikeshbajaj/Notebooks/tree/master/spkit/0.0.9/ML/Trees/) | **[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/Nikeshbajaj/Notebooks/master?urlpath=lab/tree/spkit/0.0.9/ML/Trees)** -

- - -

+## Machine Learning models - with visualizations +* Logistic Regression +* Naive Bayes +* Decision Trees +* DeepNet (to be updated) -#### Plottng tree while training +## **Linear Feedback Shift Register** +* pylfsr -

-[**view in repository **](https://github.com/Nikeshbajaj/Notebooks/tree/master/spkit_ML/DecisionTree) -## Linear Feedback Shift Register -

- -

-``` -import numpy as np -from spkit.pylfsr import LFSR -## Example 1 ## 5 bit LFSR with x^5 + x^2 + 1 -L = LFSR() -L.info() -L.next() -L.runKCycle(10) -L.runFullCycle() -L.info() -tempseq = L.runKCycle(10000) # generate 10000 bits from current state -``` -______________________________________ # Cite As ``` -@misc{spkit@2019, - author = {Bajaj,Nikesh and Requena Carrión, Jesús}, - title = {{SpKit: Signal Processing Toolkit}}, - url = {https://spkit.github.io}, - version = {0.0.9.3}, - year={2021}, - note ={version 0.9.3, \url{https://spkit.github.io}}, - howpublished = {\url{https://github.com/Nikeshbajaj/spkit}}, - publisher={Python package, Github} -} - - - @software{nikesh_bajaj_2021_4710694, author = {Nikesh Bajaj}, - title = {Nikeshbajaj/spkit: 0.0.9.2}, + title = {Nikeshbajaj/spkit: 0.0.9.4}, month = apr, - year = 2021, + year = 2022, publisher = {Zenodo}, - version = {0.0.9.2}, + version = {0.0.9.4}, doi = {10.5281/zenodo.4710694}, url = {https://doi.org/10.5281/zenodo.4710694} } @@ -366,5 +168,5 @@ ______________________________________ * **Nikesh Bajaj** * http://nikeshbajaj.in * n.bajaj[AT]qmul.ac.uk, n.bajaj[AT]imperial[dot]ac[dot]uk -### PhD Student: Queen Mary University of London +### Imperial College London ______________________________________ diff --git a/Version b/Version index d2a6a24..4c7210e 100644 --- a/Version +++ b/Version @@ -1 +1 @@ -0.0.9.5 +0.0.9.6 \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index 1fb9344..0c9a301 100644 --- a/requirements.txt +++ b/requirements.txt @@ -3,12 +3,10 @@ pandas scipy scikit-learn python-picard -matplotlib>1.3 +matplotlib PyWavelets -phyaat pylfsr -pyedflib h5py seaborn joblib -pickle +phyaat \ No newline at end of file diff --git a/setup.py b/setup.py index 6c2ff62..2eab879 100644 --- a/setup.py +++ b/setup.py @@ -1,6 +1,17 @@ import setuptools import os +DISTNAME = 'spkit' +DESCRIPTION = "SpKit: Signal Processing ToolKit" +MAINTAINER = "Nikesh Bajaj" +MAINTAINER_EMAIL = "nikkeshbajaj@gmail.com" +AUTHER = "Nikesh Bajaj" +AUTHER_EMAIL = "nikkeshbajaj@gmail.com" +URL = 'https://spkit.github.io' +LICENSE = 'BSD-3-Clause' +GITHUB_URL= 'https://github.com/Nikeshbajaj/spkit' + + with open("README.md", "r") as fh: long_description = fh.read() @@ -14,51 +25,73 @@ version = urllib.request.urlopen(Vpath).read().strip().decode("utf-8") -setuptools.setup( - name="spkit", - version= version, - author="Nikesh Bajaj", - author_email="nikkeshbajaj@gmail.com", - description="SpKit: Signal Processing toolkit | Nikesh Bajaj |", - long_description=long_description, - long_description_content_type="text/markdown", - url="https://spkit.github.io", - download_url = 'https://github.com/Nikeshbajaj/spkit/tarball/' + version, - packages=setuptools.find_packages(), - license = 'MIT', - keywords = 'Signal processing machine-learning entropy Rényi Kullback–Leibler divergence mutual information decision-tree logistic-regression naive-bayes LFSR ICA EEG-signal-processing ATAR', - classifiers=[ - "Programming Language :: Python :: 2", - "Programming Language :: Python :: 2.7", - "Programming Language :: Python :: 3", - 'Programming Language :: Python :: 3.5', - 'Programming Language :: Python :: 3.6', - 'Programming Language :: Python :: 3.7', - 'Natural Language :: English', - "License :: OSI Approved :: MIT License", - "Operating System :: OS Independent", - 'Development Status :: 5 - Production/Stable', - 'Topic :: Scientific/Engineering :: Artificial Intelligence', - 'Topic :: Scientific/Engineering :: Information Analysis', - 'Topic :: Software Development :: Libraries :: Python Modules', - 'Topic :: Multimedia', - 'Topic :: Multimedia :: Sound/Audio :: Analysis', - 'Topic :: Multimedia :: Sound/Audio :: Speech', - 'Topic :: Scientific/Engineering :: Image Processing', - 'Topic :: Scientific/Engineering :: Visualization', +def parse_requirements_file(fname): + requirements = list() + with open(fname, 'r') as fid: + for line in fid: + req = line.strip() + if req.startswith('#'): + continue + # strip end-of-line comments + req = req.split('#', maxsplit=1)[0].strip() + requirements.append(req) + return requirements + +if __name__ == "__main__": + if os.path.exists('MANIFEST'): + os.remove('MANIFEST') + + install_requires = parse_requirements_file('requirements.txt') + + setuptools.setup( + name=DISTNAME, + version= version, + author=AUTHER, + author_email = AUTHER_EMAIL, + maintainer=MAINTAINER, + maintainer_email=MAINTAINER_EMAIL, + description=DESCRIPTION, + long_description=long_description, + long_description_content_type="text/markdown", + url=URL, + download_url = 'https://github.com/Nikeshbajaj/spkit/tarball/' + version, + packages=setuptools.find_packages(), + license = 'MIT', + keywords = 'Signal processing machine-learning entropy Rényi Kullback–Leibler divergence mutual information decision-tree logistic-regression naive-bayes LFSR ICA EEG-signal-processing ATAR', + classifiers=[ + "Programming Language :: Python :: 3", + 'Programming Language :: Python :: 3.5', + 'Programming Language :: Python :: 3.6', + 'Programming Language :: Python :: 3.7', + 'Natural Language :: English', + "License :: OSI Approved :: MIT License", + "Operating System :: OS Independent", + 'Development Status :: 5 - Production/Stable', + 'Topic :: Scientific/Engineering :: Artificial Intelligence', + 'Topic :: Scientific/Engineering :: Information Analysis', + 'Topic :: Software Development :: Libraries :: Python Modules', + 'Topic :: Multimedia', + 'Topic :: Multimedia :: Sound/Audio :: Analysis', + 'Topic :: Multimedia :: Sound/Audio :: Speech', + 'Topic :: Scientific/Engineering :: Image Processing', + 'Topic :: Scientific/Engineering :: Visualization', - 'Intended Audience :: Developers', - 'Intended Audience :: Science/Research', - 'Intended Audience :: Education', + 'Intended Audience :: Developers', + 'Intended Audience :: Science/Research', + 'Intended Audience :: Education', - 'Development Status :: 5 - Production/Stable', - ], - project_urls={ - 'Documentation': 'https://spkit.readthedocs.io/', - 'Say Thanks!': 'https://github.com/Nikeshbajaj', - 'Source': 'https://github.com/Nikeshbajaj/spkit', - 'Tracker': 'https://github.com/Nikeshbajaj/spkit/issues', - }, - include_package_data=True, - install_requires=['numpy','matplotlib','scipy','scikit-learn','python-picard'] -) + 'Development Status :: 5 - Production/Stable', + ], + project_urls={ + 'Documentation': 'https://spkit.readthedocs.io/', + 'Say Thanks!': 'https://github.com/Nikeshbajaj', + 'Source': 'https://github.com/Nikeshbajaj/spkit', + 'Tracker': 'https://github.com/Nikeshbajaj/spkit/issues', + }, + + platforms='any', + python_requires='>=3.5', + install_requires = install_requires, + setup_requires=["numpy>1.8","setuptools>=45", "setuptools_scm>=6.2"], + include_package_data=True, + )