Git Product home page Git Product logo

jdsp's Introduction

Logo Logo

Build Status codecov Maven Central javadoc jitpack License: MIT DOI

JDSP is a library of signal processing tools aimed at providing functionalities as available in MATLAB or in scipy-signal package for Python. The goal is to provide easy-to-use APIs for performing complex operation on signals eliminating the necessity of understanding the low-level complexities in the processing pipeline.

Quick Start


To get the latest stable release of JDSP:

Gradle

implementation 'com.github.psambit9791:jdsp:3.0.0'

Maven

<dependency>
  <groupId>com.github.psambit9791</groupId>
  <artifactId>jdsp</artifactId>
  <version>3.0.0</version>
</dependency>

For the latest development version of JDSP:

Github

git clone --single-branch --branch master https://github.com/psambit9791/jdsp.git

JitPack

You can use JitPack to use the development version on your application; use this link for reference.

Documentation

See the Wiki for an introduction to the general use of JDSP.

See the javadocs for more detailed documentation.


Citation

If you are using this software in your research, please use the following citation:

@software{sambit_paul_2024_10448582,
  author       = {Sambit Paul},
  title        = {psambit9791/jdsp: v3.0.0 (January 1, 2024)},
  month        = jan,
  year         = 2024,
  publisher    = {Zenodo},
  version      = {v3.0.0},
  doi          = {10.5281/zenodo.10448582},
  url          = {https://doi.org/10.5281/zenodo.10448582}
}

Usage

Class Type Description
com.github.psambit9791.jdsp.filter.Butterworth IIR Filter Implements Butterworth Filter for low-pass, high-pass, band-pass and band-stop operation
com.github.psambit9791.jdsp.filter.Chebyshev IIR Filter Implements Chebyshev Filter (Type 1 and Type 2) for low-pass, high-pass, band-pass and band-stop operation
com.github.psambit9791.jdsp.filter.Bessel IIR Filter Implements Bessel Filter for low-pass, high-pass, band-pass and band-stop operation
com.github.psambit9791.jdsp.filter.FIRWin1 FIR Filter Implements a windowed FIR filter for low-pass, high-pass, band-pass and band-stop operation
com.github.psambit9791.jdsp.filter.FIRWin2 FIR Filter Implements a windowed FIR filter (with gain) for low-pass, high-pass, band-pass and band-stop operation
com.github.psambit9791.jdsp.filter.FIRLS FIR Filter Implements an FIR filter which has the closest frequency response as desired optimised using Least Squares Minimization
com.github.psambit9791.jdsp.filter.Median Kernel-based Filter Implements Median Filter for smoothing while maintaining the sharp edges
com.github.psambit9791.jdsp.filter.Savgol Kernel-based Filter Implements Savitzky–Golay Filter for smoothing using Savitzky–Golay coefficients
com.github.psambit9791.jdsp.filter.Wiener Kernel-based Filter Implements Wiener Filter for the sharpening operation
com.github.psambit9791.jdsp.filter.adaptive.AP Adaptive Filter Implements Affine Projection Adaptive filter
com.github.psambit9791.jdsp.filter.adaptive.GNGD Adaptive Filter Implements Generalised Normalised Gradient Descent Adaptive Filter Adaptive filter
com.github.psambit9791.jdsp.filter.adaptive.LMS Adaptive Filter Implements Least Mean Squares Adaptive filter
com.github.psambit9791.jdsp.filter.adaptive.NLMS Adaptive Filter Implements Normalised Least Mean Squares Adaptive filter
com.github.psambit9791.jdsp.filter.adaptive.RLS Adaptive Filter Implements Reduced Least Squares Adaptive filter
com.github.psambit9791.jdsp.filter.adaptive.SSLMS Adaptive Filter Implements Sign-Sign Least Mean Squares Adaptive filter
com.github.psambit9791.jdsp.filter.adaptive.NSSLMS Adaptive Filter Implements Normalised Sign-Sign Least Mean Squares Adaptive filter
com.github.psambit9791.jdsp.signal.Convolution Signal Operation Implements the convolve() and convolve1d() operation
com.github.psambit9791.jdsp.signal.CrossCorrelation Signal Operation Implements the cross-correlation operation
com.github.psambit9791.jdsp.signal.Deconvolution Signal Operation Implements the deconvolution operation for valid and full mode convolved signals
com.github.psambit9791.jdsp.signal.Detrend Signal Operation Implements the detrend operation to remove trends from a signal
com.github.psambit9791.jdsp.signal.Smooth Signal Operation Implements convolutional smoothing with rectangular and triangular window
com.github.psambit9791.jdsp.signal.Decimate Signal Operation Implements the decimation operation to downsample a signal after applying an anti-aliasing filter
com.github.psambit9791.jdsp.signal.Resample Signal Operation Implements the resampling operation to change the number of samples in a signal using Fourier method
com.github.psambit9791.jdsp.signal.Generate Signal Operation Helps to generate different waves and wavelets
com.github.psambit9791.jdsp.signal.peaks.FindPeak Peak Detection Identifies peaks in the signal
com.github.psambit9791.jdsp.signal.peaks.Peak Peak Detection Calculates peak properties and allows filtering with them
com.github.psambit9791.jdsp.signal.peaks.Spike Peak Detection Calculates spike properties and allows filtering with them
com.github.psambit9791.jdsp.transform.DiscreteFourier Transformation Applies the Discrete Fourier Transform on a signal
com.github.psambit9791.jdsp.transform.InverseDiscreteFourier Transformation Applies the Inverse Discrete Fourier Transform on a sequence and returns the original signal
com.github.psambit9791.jdsp.transform.FastFourier Transformation Applies the Fast Fourier Transform on a signal
com.github.psambit9791.jdsp.transform.InverseFastFourier Transformation Applies the Inverse Fast Fourier Transform on a sequence and returns the original signal
com.github.psambit9791.jdsp.transform.DiscreteSine Transformation Applies the Discrete Sine Transform on a signal
com.github.psambit9791.jdsp.transform.InverseDiscreteSine Transformation Applies the Inverse Discrete Sine Transform on a sequence and returns the original signal
com.github.psambit9791.jdsp.transform.FastSine Transformation Applies the Fast Sine Transform on a signal
com.github.psambit9791.jdsp.transform.InverseFastSine Transformation Applies the Inverse Fast Sine Transform on a sequence and returns the original signal
com.github.psambit9791.jdsp.transform.DiscreteCosine Transformation Applies the Discrete Cosine Transform on a signal
com.github.psambit9791.jdsp.transform.InverseDiscreteCosine Transformation Applies the Inverse Discrete Cosine Transform on a sequence and returns the original signal
com.github.psambit9791.jdsp.transform.FastCosine Transformation Applies the Fast Cosine Transform on a signal
com.github.psambit9791.jdsp.transform.InverseFastCosine Transformation Applies the Inverse Fast Cosine Transform on a sequence and returns the original signal
com.github.psambit9791.jdsp.transform.Hilbert Transformation Applies the Hilbert Transform on a signal and provides functions to return amplitude, phase and frequency information
com.github.psambit9791.jdsp.transform.PCA Transformation Applies Principal Component Analysis on a multi-channel signal and returns a low-dimensional signal
com.github.psambit9791.jdsp.transform.ICA Transformation Performs Independent Component Analysis on a multi-channel signal and returns the recovered source signals
com.github.psambit9791.jdsp.transform.ContinuousWavelet Transformation Applies the Wavelet Transform on a signal with one of Paul, Ricker or Morlet wavelet
com.github.psambit9791.jdsp.transform.InverseContinuousWavelet Transformation Applies the Inverse Wavelet Transform on a sequence transformed using CWT and returns the original signal
com.github.psambit9791.jdsp.transform.ShortTimeFourier Transformation Applies the Short Time Fourier Transform on a signal
com.github.psambit9791.jdsp.transform.InverseShortTimeFourier Transformation Applies the Inverse Short Time Fourier Transform on a sequence transformed using STFT and returns the original signal
com.github.psambit9791.jdsp.speech.Silence Speech Provides methods to detect periods of silence in an audio
com.github.psambit9791.jdsp.windows.Boxcar Windowing Generates a Boxcar (Rectangular) Window
com.github.psambit9791.jdsp.windows.GeneralCosine Windowing Generates a General Cosine Window with provided weights
com.github.psambit9791.jdsp.windows.Hamming Windowing Generates a Hamming Window
com.github.psambit9791.jdsp.windows.Hanning Windowing Generates a Hanning Window
com.github.psambit9791.jdsp.windows.Blackman Windowing Generates a Blackman Window
com.github.psambit9791.jdsp.windows.BlackmanHarris Windowing Generates a Blackman-Harris Window
com.github.psambit9791.jdsp.windows.Poisson Windowing Generates a Poisson (Exponential) Window
com.github.psambit9791.jdsp.windows.Gaussian Windowing Generates a Gaussian Window
com.github.psambit9791.jdsp.windows.FlatTop Windowing Generates a Flat Top Window
com.github.psambit9791.jdsp.windows.Nuttall Windowing Generates a Nuttall Window
com.github.psambit9791.jdsp.windows.Triangular Windowing Generates a Triangular Window
com.github.psambit9791.jdsp.windows.Tukey Windowing Generates a Tukey Window
com.github.psambit9791.jdsp.windows.Bartlett Windowing Generates a Bartlett Window
com.github.psambit9791.jdsp.windows.BartlettHann Windowing Generates a Bartlett-Hann Window
com.github.psambit9791.jdsp.windows.Bohman Windowing Generates a Bohman Window
com.github.psambit9791.jdsp.windows.Kaiser Windowing Generates a Kaiser Window
com.github.psambit9791.jdsp.splines.AkimaSpline Splines Provides methods to construct an Akima Spline
com.github.psambit9791.jdsp.splines.BSpline Splines Provides methods to construct an B-Spline
com.github.psambit9791.jdsp.splines.QuadraticSpline Splines Provides methods to construct an Quadratic B-Spline
com.github.psambit9791.jdsp.splines.CubicSpline Splines Provides methods to construct an Cubic B-Spline
com.github.psambit9791.jdsp.io.Wav Input/Output Provides methods to read from and write to WAV files
com.github.psambit9791.jdsp.io.Csv Input/Output Provides methods to read from and write to CSV files
com.github.psambit9791.jdsp.misc.UtilMethods Miscellaneous Provides Numpy style utility functions, details in Wiki
com.github.psambit9791.jdsp.misc.Plotting Miscellaneous Enables plotting of different signals and points using line and scatter plots
com.github.psambit9791.jdsp.misc.Polynomial Miscellaneous Provides methods for operating with polynomial functions
com.github.psambit9791.jdsp.misc.Random Miscellaneous Provides methods to create random numbers as samples or multi-dimensional arrays

Supporting JDSP

JDSP is an open source project.
You can help by becoming a sponsor on Patreon or doing a one time donation on PayPal.
You can also show your appreciation on Ko-Fi.

Become a Patron Donate on Paypal Support on Kofi


License

This project is licensed under the MIT License - see the LICENSE file for details.
You are free to use, modify and distribute this software, as long as the copyright header is left intact.

jdsp's People

Contributors

psambit9791 avatar sibovg avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

jdsp's Issues

Add Kaiser Window

Adding Kaiser Window to the list of available Windows - Will be useful for building FIR filter.

Feature Request: Zero-padding for DFT

It would be a fairly simple implementation, since a zero padding method already exists in the utils methods, but having zero padding implemented in the dtf-method of DiscreteFourier would be handy.

IDFT should support onlyPositive array.

IDFT right now supports only transforming array with same length as the signal. But a fully functional IDFT also needs to support transforming the half length sequences which are used as outputs from DFT of real-valued signals. This can be done because, for real valued signals, the second half is the mirrored complex conjugate of the first half.

This support needs to be added to the InverseDiscreteFourier class.

Gradle and VSCode

I was trying to add jdsp to my project but it didn't work.

This is my gradle file:

/*
 * This file was generated by the Gradle 'init' task.
 *
 * This generated file contains a sample Java application project to get you started.
 * For more details take a look at the 'Building Java & JVM projects' chapter in the Gradle
 * User Manual available at https://docs.gradle.org/7.3/userguide/building_java_projects.html
 */

plugins {
    // Apply the application plugin to add support for building a CLI application in Java.
    application
}

repositories {
    // Use Maven Central for resolving dependencies.
    mavenCentral()
    maven(url = "https://oss.sonatype.org/content/repositories/snapshots")
    maven(url = "https://oss.sonatype.org/service/local/staging/deploy/maven2/")
}

dependencies {
    // Use JUnit Jupiter for testing.
    testImplementation("org.junit.jupiter:junit-jupiter:5.7.2")

    // This dependency is used by the application.
    implementation("com.google.guava:guava:30.1.1-jre")
    implementation("tech.tablesaw:tablesaw-core:0.43.1")
    implementation("com.github.psambit9791:jdsp:1.0.0")
    implementation(fileTree(mapOf("dir" to "libs", "include" to listOf("*.jar"))))
}

application {
    // Define the main class for the application.
    mainClass.set("javagradlecage.App")
}

tasks.named<Test>("test") {
    // Use JUnit Platform for unit tests.
    useJUnitPlatform()
}

I'm not even getting any errors. Just nothing happens.

I tried adding the jar file too, but same result. If I add the jar and try to build grade it at least tells me that they are duplicates.

Am I missing something? I basically did the same with other dependencies (e.g. tablesaw) and they work fine.

Auto-correlation

Hello,

I want to calculate signal's Auto-Correction in Android.
So, I used this library using gradle.

I saw this issue was fixed but still I can not use Cross-Correlation which takes only the signal as argument

so, how can i use ?

Zero-phase digital filtering

This is a great library, now I translate matlab program to java code, there is a filtfilt() method in matlab, it's Zero-phase digital filtering, is it supported in your library?
thanks

Rounding error in UtilMethods.round()

The round() method under UtilMethods always gives the output in Ceil mode of rounding.

double d1 = 7.40241449;
double d2 = -14.39767505;

System.out.println(UtilMethods.round(d1, 1));
System.out.println(UtilMethods.round(d2, 1));

Outputs: 7.5 , -14.3

Expected: 7.4 , -14.4

smooth cause phase shift

The smooth result is different from matlab.

There are 100 point smooth result in jdsp and matlab.

Red line is jdsp's result ; Green line is matlab's smooth result.

The Jdsp's smooth result is faster 50 pionts( half of the smooth window ).

smooth_jdsp_vs_matlab

data files are :

data_Files.zip

Decimate incorrect for nondivisible factors

Problems occurring for values of factors for which the sampling frequency is not divisible by the factor. Array length is less by 1.

OUTPUT:

array lengths differed, expected.length=32 actual.length=31; arrays first differed at element [31];
Expected :-0.494
Actual :end of array

at com.onyx.jdsp.TestDecimate.DecimateWithZeroPhaseTest(TestDecimate.java:102)
Caused by: java.lang.AssertionError: expected:<-0.494> but was:
at org.junit.Assert.failNotEquals(Assert.java:835)

Savitzky Golay Filter Java implementation there is a difference from python

When we use Savitzky Golay Filte to smooth data, we found that the result after Java processing is inconsistent with Python. Inconsistent intervals appear at the edges,so we checked the source code of both。When the mode selects constant, python does edge processing on the data, but Java does not.
Excuse me, will the code be updated in the future to keep it consistent?

image

image

Filtering Peaks by multiple properties

Is there a way to filter peaks by multiple properties (as done in scipy)?

Example in scipy:

find_peaks(x, distance=20, height=(50, None)

jDSP currently allows filtering by only one metric (i.e. find* methods return int[], and they cannot be filtered further). Unless I'm missing something

Duplicate class SafeThrowable or StackTraceWriter

Hi
I tried to use the jDSP 0.5.0 library in an Android projet.
I added the dependencies :
implementation('com.github.psambit9791:jdsp:0.5.0')
But I had the following error :

Duplicate class org.apache.maven.surefire.report.SafeThrowable found in modules 
jetified-common-java5-2.19.1 (org.apache.maven.surefire:common-java5:2.19.1) and 
jetified-surefire-api-2.19.1 (org.apache.maven.surefire:surefire-api:2.19.1)
Duplicate class org.apache.maven.surefire.report.StackTraceWriter found in modules 
jetified-common-java5-2.19.1 (org.apache.maven.surefire:common-java5:2.19.1) and
jetified-surefire-api-2.19.1 (org.apache.maven.surefire:surefire-api:2.19.1)

I tried to exclude the dependencies with the following gradle configurations :

    implementation('com.github.psambit9791:jdsp:0.5.0') {
        exclude group: 'org.apache.maven.surefire', module: 'common-java5'
    }

or

    implementation('com.github.psambit9791:jdsp:0.5.0') {
        exclude group: 'org.apache.maven.surefire', module: 'surefire-api'
    }

But I add the following error :

Execution failed for task ':mylibrary:mergeDebugAndroidTestJavaResource'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
   > More than one file was found with OS independent path 'META-INF/DEPENDENCIES'.

Could you please help me to solve this problem ?
Best regards,
Franck

What are new features of version 2.0.0?

Hello,

I saw on JDSP's website that there is a new version of JDSP available. Would you please tell me what are the newest features available on this version that distinguishes it from version 1.0.0? I didn't see such a description on the website and so I am curious. Also, does the new version have a feature to provide the actual frequency values when doing FFTs? One of my previous challenges as a newbie to the DSP world was manually calculating the "x-axis" values that correspond to the plot/graph of the DFT from my data.

Thanks and it's really exciting to see the newest version of JDSP available. I can't wait to use the new features and please keep this amazing project going.

LM

problem with stream usage in FIRWin1.java when used in andriod api below 24

Hi Thanks for your jdsp library , i could actually develop a hamiltion segmentator for ecg processing with it.
But when i tried to integrate with andriod API below 24 i am getting this error
java.lang.NoSuchMethodError: No static method stream([D)Ljava/util/stream/DoubleStream; in class Ljava/util/Arrays; or its super classes (declaration of 'java.util.Arrays' appears in /system/framework/core-libart.jar)
at com.github.psambit9791.jdsp.filter.FIRWin1.computeCoefficients(FIRWin1.java:270)
at com.piccolomed.smartpicc.ecg.PeakDetector.apply_fir_filter(PeakDetector.java:651)
at com.piccolomed.smartpicc.ecg.PeakDetector.apply_fir_filter_filtfilt(PeakDetector.java:657)
at com.piccolomed.smartpicc.ecg.PeakDetector.getPeaks(PeakDetector.java:29)

i am currently using version 0.8.0 of you library, it seems stream are not supported in older versions of android.
is there any other alternative

Feature request: Implement LMS adaptive filtering + other adaptive filters

Adaptive filtering is often used for signal noise reduction and some other cool DSP applications. The most often used one is the Least Mean Square (LMS) adaptive filter.

A very good adaptive filtering library in Python is padasip. It also has some code documentation on how the algorithm should work, both in code and on a documentation page.

Other potential good source: explanation of MATLAB LMS adaptive filtering implementation

Issue with findPlateauSize()

Identified bug with findPlateauSize()
The function seems to accept the peak indices in stead of the actual peaks.

Use case question

Would you please tell me if by calculating the "only positive absolute values" from JDSP when doing the Fourier transform, if this is sufficient, for a physical system I have that is oscillating back and forth, to obtain the constituent frequencies of oscillations in my system?

The code I'm using to calculate the only positive absolute values is below:

_Fourier ft = new DiscreteFourier(signal); // OR _Fourier ft = new FastFourier(signal); ft.transform(); boolean onlyPositive = true; double[] out = ft.getMagnitude(onlyPositive);

Thanks.

LM

FFT Request Performance Enhancement

Hello,
Currently the performance of the Discrete Fourier in Java is sub-par, is it possible to integrate the FFTW if it is installed on the system to use it as it is backed by C? It runs in milliseconds compared to minutes on Java when running a 1 million point signal

Thanks in advance

Real-Time "Processor" Adapter for Transformation

It would be great to have an adapter class ("Processor") to wrap, for example, the ShortTimeFourier class and provide a more real-time streaming interface. There are examples of this style in "Digital Audio with Java" by Craig A Lindley.
The wrapper would mean that the full input signal would not need to be loaded into memory, but could be streamed through the processor.
We could use it for real-time sound affects such as pitch shifting/tempo changing (there is another suggestion for time-based pitch shifting/tempo changing using WSOLA - #18).
I am not sure if older phones/tablets have enough processing power for this, but it would be great to try!

DFT output for positive mirror not correct length

The full DFT output should be of length equal to the signal length. The mirrored (only positive) length should be equal to (length of signal)/2 + 1. But the mirrored output length is computed as (length of signal)/2.

Using bandpass and bandstop filters for time series data

Hi dear JDSP author,
I have been using using JDSP library for filtering time series data from sensor. Currently I am filtering 33 samples from a sensor in one double array and get perfect results. I am using same filter instance to filter similar sensor data from 3 other sensors. However, when i receive new data samples the results are incorrect after using filters.
What would be the ideal way to apply same filter to multiple sample from multiple sensors? Thanks in advance for your suggestion. Here is my current implementation.

Salman

Build error due to org.apache.maven Duplicate

Hello,

I have experienced the exact same issue as issue #5 but I am not able to solve the issue.

After following the steps, I am getting the following error:

`A problem occurred evaluating project ':app'.

Could not find method com.github.psambit9791:jdsp:2.0.1() for arguments [build_8b7glpftwjyi9ocz81v2e7e82$_run_closure2$_closure9@1fa01953] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.

  • Try:

Run with --info or --debug option to get more log output.
Run with --scan to get full insights.

  • Exception is:
    org.gradle.api.GradleScriptException: A problem occurred evaluating project ':app'.
    at org.gradle.groovy.scripts.internal.DefaultScriptRunnerFactory$ScriptRunnerImpl.run(DefaultScriptRunnerFactory.java:93)
    at org.gradle.configuration.DefaultScriptPluginFactory$ScriptPluginImpl.lambda$apply$0(DefaultScriptPluginFactory.java:133)
    at org.gradle.configuration.ProjectScriptTarget.addConfiguration(ProjectScriptTarget.java:79)
    at org.gradle.configuration.DefaultScriptPluginFactory$ScriptPluginImpl.apply(DefaultScriptPluginFactory.java:136)
    at org.gradle.configuration.BuildOperationScriptPlugin$1.run(BuildOperationScriptPlugin.java:65)
    at org.gradle.internal.operations.DefaultBuildOperationRunner$1.execute(DefaultBuildOperationRunner.java:29)
    at org.gradle.internal.operations.DefaultBuildOperationRunner$1.execute(DefaultBuildOperationRunner.java:26)
    at org.gradle.internal.operations.DefaultBuildOperationRunner$2.execute(DefaultBuildOperationRunner.java:66)
    at org.gradle.internal.operations.DefaultBuildOperationRunner$2.execute(DefaultBuildOperationRunner.java:59)
    at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:157)
    ...
    at org.gradle.groovy.scripts.BasicScript$ScriptDynamicObject.tryInvokeMethod(BasicScript.java:135)
    at org.gradle.internal.metaobject.AbstractDynamicObject.invokeMethod(AbstractDynamicObject.java:163)
    at org.gradle.groovy.scripts.BasicScript.invokeMethod(BasicScript.java:84)
    at build_8b7glpftwjyi9ocz81v2e7e82.run(C:\Users\tushar.rain\AndroidStudioProjects\FFT\app\build.gradle:41)
    at org.gradle.groovy.scripts.internal.DefaultScriptRunnerFactory$ScriptRunnerImpl.run(DefaultScriptRunnerFactory.java:91)
    ... 177 more`

Kindly help in resolving the issue.
Thanks

Dependency resolution error

There seem to be a dependency issue in 0.4.0. I am trying to build with Gradle from Andoid Studio and get the following error, when adding jDSP as a dependency

Duplicate class org.apache.maven.surefire.report.SafeThrowable found in modules jetified-common-java5-2.19.1.jar (org.apache.maven.surefire:common-java5:2.19.1) and jetified-surefire-api-2.19.1.jar (org.apache.maven.surefire:surefire-api:2.19.1)
Duplicate class org.apache.maven.surefire.report.StackTraceWriter found in modules jetified-common-java5-2.19.1.jar (org.apache.maven.surefire:common-java5:2.19.1) and jetified-surefire-api-2.19.1.jar (org.apache.maven.surefire:surefire-api:2.19.1)

Hilbert Transform gives incorrect outputs

For signals which have large number of values close to 0, like a Gaussian pulse, the instantaneous phase is incorrect. Comparisons made against scipy.hilbert() and their method of calculating phase and frequency.

signal
The signal for which the issue was identified

issue
The issue as visualised

Feature request: Return phase in DFT

Right now, the DFT transform can return both the complex valued result and the magnitude of that result. Would also be helpful to include a return function for the phase of the result.

Feature Request: be able to reuse filter states for filtering data in batches, or have ability to initialize filter states for IIR filters

As currently written and as an example, when we call Butterworth.lowPassFilter() method a new filter is initialized and used to filter the data. This works correctly and as expected when all data is already available ahead of time.

In same cases (using a continuous sampling data acquisition task) we may want to collect a batch of data, filter that batch, and then display the filtered data. We may want to do this over and over again as new batches of data is collected. If we use the filters in this cases, a new filter is created and initialized each time we call the .lowPassFilter() method, which will incorrectly show discontinuous jumps in the filtered and displayed data from batch to batch.

I am proposing to have a "BatchFilter" or reusable filter, where the same filter is persisted and reused, as opposed to creating a new filter for every filter operation. I think this should hopefully be straightforward, as you could just store uk.me.berndporr.iirj.Butterworth() filter as a field in your ButterWorth class and reused that filter for each filter operation, instead of initializing and using a new one with each filter operation.

Power Spectral Density Capability

Hello,

Would you please tell me if it would be possible for JDSP to have a new feature to calculate the power spectral density of a random signal (I've been told that it is inappropriate to do FFT on random signals)? If it is a trivial thing that the user can do by just writing some loop and doing some simple math on the FFT results instead, please let me know that this is the case as I'd like to be able to implement power spectral density capabilities in my workflows to handle a more diverse set of signals. Thanks.

LM

Providing Signal Data Question

If I have data in the form of x,y coordinates, how do I get this data into JDSP? I noticed that data input into, say, a low pass filter is in the form of a 1-D array of type double which is essentially a list of one set of numbers not two. Should the numbers in the 1-D array be in pairs as in [x1, y1, x2, y2, x3, y3, etc...]?

Cannot use jdsp with java modular project

The jdsp library currently cannot be used with java modular projects because jdsp is an unnamed module. This can be fixed by converting it into an automatic module.

This can be done by adding an automatic module name attribute to your jar manifest with the following line:

Automatic-Module-Name: com.github.psambit9791:jdsp

Why is there no abstract base class or interface for filters etc?

Hi there,

When using filters in my own code it is a bit cumbersome, that there is not an interface or such for it. So you cannot do something like:

		HashMap<String, Filter> filterHashMap = new HashMap<>();
		for(String filterName : filterHashMap){
			Filter myFilter = filterHashMap.get(filterName);
			// Do things with each filter
		}

Are there any plans to change this?

Cheers,
Martin

findpeakproblem

When I use your library jdsp for peak detection on android phone,It takes long time and can not get the result.
The data can be downloaded at https://drive.google.com/file/d/112almsqRELM5sE82I9QIfHjgazAOjLcT/view?usp=sharing
The code as follows:
readWavObj = new WAV();
readWavObj1 = new WAV();
try {
readWavObj.readWAV(Environment.getExternalStorageDirectory().getAbsolutePath() + "/" + "audio/" + "singal.wav");
originSignal = readWavObj.getData("double");
readWavObj1.readWAV(Environment.getExternalStorageDirectory().getAbsolutePath() + "/" + "reference.wav");
originrefSingal = readWavObj1.getData("double");
} catch (WavFileException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
//covert 1-D array
double[] Singal = utilAcObj.getArray(originSignal);
double[] refSingal = utilAcObj.getArray(originrefSingal);

                        String mode = "valid"; //Can be "valid", "same"
                        CrossCorrelation cc = new CrossCorrelation(Singal, refSingal);
                        double[] zout = cc.crossCorrelate(mode);
                        FindPeak fp = new FindPeak(zout);
                       Peak out = fp.detectPeaks();
                       int[] peaks = out.getPeaks();

bandPassFilter should fail if lowCutOff>highCutOff?

If you run any Frequency filter and have lowCutOff>highCutOff, then you do not get an error. In fact this happens:

double centreFreq = (highCutoff + lowCutoff)/2.0;
double width = Math.abs(highCutoff - lowCutoff);

So what happens here is lowCutOff and highCutOff are implicitly inverted. I think this is not desired?

Citing JDSP in Publications

Would you please tell me how you would like to have JDSP cited/bibliographed in peer-review publications whose work uses JDSP? Thanks.

LM

Auto-Correlation

I want to calculate signal's Auto-Correction. In matlib, I can use xcorr() function to do this. But this this lib, I can not find a function like this. (Cross-Correction can do this?)

FFT plot question

Hello,

Would you please tell me if in the figure below if the very first/leftmost data point that starts over 12,000 units on the Y-axis is some sort of artifact that is almost always produced by taking the FFT? I am almost consistently getting this very tall first data point of the FFT spectrum from all my data sets so I couldn't help but wonder if my data is telling me something or if all FFT plots always start out looking like this from the FFT math under the hood. I mean, the very first tall data point is not a distinct peak for me to confidently state (with my present limited knowledge) that it is indeed a frequency in my oscillation data, but I would like to know if there is some physical meaning behind such an "incomplete" peak/"incomplete" frequency that begins my FFT plot. Here is the image in question:
ALA771_Phi_AngleFrequencies

This is in contrast with this next FFT plot whose first point instead does not simply slope down but it actually is part of a distinct peak whose maxima is formed by the second FFT plot data point:
ASN188_Phi_AngleFrequencies

Therefore, do I have a strong low frequency according to the first graph? Also, do I have a strong low frequency according to the second graph? If it means anything, the X-axis values shown above are presently just the ennumerated indices of the arrays that contained the data as I am still working on "translating" the array index values to actual frequency values. Thanks.

LM

Interpreting FFT symmetry

Hello,

The image below is the FFT plot of my data and it is showing symmetry (I did not change the values printed on the x axis to reflect the frequency of the original time domain, but the shown FFT plot below is assuredly of transformed data). Would you please tell me if such symmetry is indicative of raw data that is too noisy or lacking of any discernible constituent sinusoids (my raw data does actually have a nice bandwidth - fixed y max and fixed x max - throughout the collected data oscillations)? I've been looking at FFT plots of a more "textbook" like quality and those plots give nice and discernible/distinct peaks that don't have symmetry in their profile and those ideal peaks shoot up from the x axis as opposed to my profile which looks like raw data itself (such idealized "textbook" data tends to be of the waveform from a guitar or violin string just to point out what I've been looking at). Thanks for any direction or tips you can provide.

LM

FFT_data

Plotting output is inconsistent with peak detection indices

Hello,

I plotted the data in the file named "Freq_ANGLE_PER_NUM_29_theta.txt" (shown below)
Freq_angles_plot

and then I obtained the DFT for that same data and plotted it (shown below)
Freq_DFT_plot

I also stored this DFT output data in the file named "Freq_theta_Num_29_FrequencyValues.txt" (I included index/predictibly increasing numbers as part of this data, but they are not provided from the JDSP code).

I then wanted to find out where the peaks were and so I used the following code on the DFT version of my data:
FindPeak dftFp = new FindPeak(xOut);
Peak middleMan = dftFp.detectPeaks();
int[] peaks = middleMan.getPeaks();
//System.out.println(peaks.length + "\n");
System.out.println("Residue: " + counter);

The results from this peak-determining code indicated that the very first peak/maximum was located at the x-axis value of '1' when the plot by contrast seems to show that the very first peak is instead located the x-axis value of '2.'

I stored the location results of all peaks in the file named "Freq_theta_Num_29AllTransformPeaks.txt"

Am I reading/interpreting the output data incorrectly (all data files referenced to in this message are attached
Freq_ANGLE_PER_NUM_29_theta.txt

Freq_theta_Num_29_FrequencyValues.txt

Freq_theta_Num_29AllTransformPeaks.txt
)? Why does the plot seem to indicate the peak is at one position, but the peak-detecting analysis with the library declares the peak is at another?

Thanks.

LM

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.