Comments (15)
Are you referring to a 2D signal here? Like an image?
There are different kinds of signals with multiple channels - for example, accelerometers have x, y and z axes but all of those are captured independently with respect to time.
Grayscale images have x and y data but they are interdependent and does not have a temporal information within.
from jdsp.
The data input I'm working with is in the form of collected x,y and z position data points as a function of time. I have a text file that lists each trio of x,y,z coordinates on its own line down the file without the time (though I can add the time manually to each line if it's necessary to have the time as part of the data for JDSP to process it). Can this type of data be processed for filtering?
from jdsp.
Time is not an essential parameter. You will need each axis to be in a separate array however.
So all you x data, y data and z data need to be in their individual arrays.
Each of these arrays will have to be passed as an argument to the Filter object.
from jdsp.
Wonderful. So then how would this look incorporated into the sample code below? How exactly do I put my 3 arrays in the filter object once I have them?
// My arrays:
double [] xArray = double[100];
double [] yArray = double[100];
double [] zArray = double[100];
// Sample code for Butterworth filter:
int Fs = 100; //Sampling Frequency in Hz
int order = 4; //order of the filter
int cutOff = 9; //Cut-off Frequency
Butterworth flt = new Butterworth(signal, Fs); //signal is of type double[]
double[] result = flt.lowPassFilter(order, cutOff); //get the result after filtering
from jdsp.
Simply replace signal
in Butterworth flt = new Butterworth(signal, Fs);
with your respective arrays: xArray
, yArray
and zArray
. As of now, you will need to create three different objects for each signal, but that will change with the upcoming release.
Currently your implementation will look like this:
int Fs = 100; //Sampling Frequency in Hz
int order = 4; //order of the filter
int cutOff = 9; //Cut-off Frequency
Butterworth fltX = new Butterworth(xArray, Fs);
double[] resultX = fltX.lowPassFilter(order, cutOff);
Butterworth fltY = new Butterworth(yArray, Fs);
double[] resultY = fltY.lowPassFilter(order, cutOff);
Butterworth fltZ = new Butterworth(zArray, Fs);
double[] resultZ = fltZ.lowPassFilter(order, cutOff);
from jdsp.
Sounds good. So at that point with the resultX, resultY and resultZ arrays, I must plot/graph each array separately? My understanding then is that each array's contents is basically it's own dependent variable, so if I want to plot them, what should I provide to my plotting program for each array's independent variable? Should I provide the original data's time collection values for plotting those three arrays individually (my apologies if my question is a bit elementary, but I am new to signal processing)? Thanks.
from jdsp.
Depends on what you are using to plot.
The plotting utility in JDSP can be used as shown here.
The following example will plot all your outputs in a single figure.
- You can initialise a plot like this:
int width = 600;
int height = 500;
String title = "Filtered Output";
String x_axis = "Time";
String y_axis = "Signal";
Plotting fig = new Plotting(width, height, title, x_axis, y_axis);
fig.initialisePlot();
- Then add the data you want, in your case it will be as follows:
If you don't have a time array, you can also ignore it.
fig.addSignal("X axis", time, resultX, false);
fig.addSignal("Y axis", time, resultY, false);
fig.addSignal("Z axis", time, resultZ, false);
- To display:
fig.plot();
- Or, if you want to save the plot:
fig.saveAsPng(outputFileName);
from jdsp.
I'll give this a try. Thanks again.
from jdsp.
I just wanted to say thanks for all your help with using JDSP. This is an amazing piece of software.
My follow up question is the following: given that I now have individual plots for x vs time, y vs time and z vs time, which all look like signals (they each kind of resemble stock market price plots), what kind of signal processing exercise do you recommend for this kind of data and are there any physical interpretations of such a signal processing exercise from this "position vs time" data? If it means anything, I also observed bell curve-shaped distributions of the various x, y and z values (don't know if they're specifically normal distributions though). Thanks again.
from jdsp.
The kind of signal processing technique you use on this data is entirely dependent on what you're trying to achieve from this. You need to go through your problem statement and understand what the best course of action would be to solve the problem.
You may want to move to the frequency domain for further analysis which requires you to use the FFT. However, as I mentioned before, this is highly reliant on what your problem statement is.
from jdsp.
That sounds good and it does make sense. I'll start with analyzing frequency to begin with.
Looking at the Fourier transforms on the JDSP website, I noticed that the sample code,
_Fourier ft = new DiscreteFourier(signal); // OR _Fourier ft = new FastFourier(signal); ft.transform(); boolean onlyPositive = true; double[] out = fft.getMagnitude(onlyPositive);
declares a _Fourier object called "ft" but the output method of getMagnitude is applied to "fft." Was that supposed to be "ft" instead of "fft" or did something else need to be declared/defined earlier?
Also, I noticed that there is a PCA class to do PCA analysis. In the PCA section of the JDSP webpage, the example is for a tri-component data set composed of X, Y and Z much like my own data. However, I see that there is input for only one signal variable named "signal." Would you please tell me, how should the "signal" variable (I assume a 1-D array of type double) be structured to accomodate X, Y and Z? Similarly, the output signal (called "newSignal") is shown to be a 2-D array, but the provided plot of the PCA output signal appears to be for one dimensional data (a standard Y vs X plot). Below is the PCA code I refer to:
int dimensions = 1; PCA p1 = new PCA(signal, dimensions); p1.fit(); double[][] newSignal = p1.transform(signal); //Returns the reduced signal
Thank you again for helping me with using JDSP and understanding signal processing concepts (I am reading on my own to try to catch up to speed).
from jdsp.
Thanks for pointing that out - it should be ft
on the website.
For PCA, it is a 2D signal where Dimension 1 holds the samples and Dimension 2 holds the channels.
For example:
double[][] signal = {{0.38, 0.53}, {0.80, 0.86}, {0.11, 0.88}, {0.72, 0.87}, {0.37, 0.52}};
which implies the signal has 2 channels and 5 samples.
For the output, since PCA does not always imply the output to have only one dimension (you can use PCA to reduce from 3 to 2 dimensions as well), the output is in 2D. In this example, it is just that we are choosing to reduce to 1 dimension. For plotting, the 2D output array has been flattened.
from jdsp.
Closing the issue since the queries seem to have been addressed,
from jdsp.
Awesome. Thanks again for all your help and again, I just want to say that this is a wonderful library you've made here.
from jdsp.
from jdsp.
Related Issues (20)
- Plotting output is inconsistent with peak detection indices HOT 12
- Feature request: for Independent Components Analysis (ICA) algorithm for multi-channel signal analysis HOT 2
- "Generate" do not generate correct number of samples
- smooth cause phase shift HOT 6
- Using bandpass and bandstop filters for time series data HOT 2
- Use case question HOT 1
- Citing JDSP in Publications HOT 2
- Feature request: for multiplicative scatter correction HOT 1
- Savitzky Golay Filter Java implementation there is a difference from python HOT 12
- Build error due to org.apache.maven Duplicate HOT 23
- Java 19+ SIMD support ? HOT 1
- Real-Time "Processor" Adapter for Transformation HOT 1
- Power Spectral Density Capability HOT 1
- Input data dimensions and window dimensions don't match HOT 1
- The documentation page is not working HOT 2
- Result of Butterworth Bandpass and Bandstop Inconsistent with Python Scipy Library HOT 2
- Feature request : first order low pass filter HOT 2
- UtilMethods.diff throws java.lang.NegativeArraySizeException: -1 HOT 1
- Welch or Multitaper-like bandpower analysis
- Question regarding Phython Scipy Import Signal.Welch HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jdsp.