Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Filtering Peaks by multiple properties #8

Closed
d-lowl opened this issue Oct 13, 2020 · 4 comments
Closed

Filtering Peaks by multiple properties #8

d-lowl opened this issue Oct 13, 2020 · 4 comments
Assignees
Labels
enhancement New feature or request

Comments

@d-lowl
Copy link

d-lowl commented Oct 13, 2020

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

@psambit9791 psambit9791 self-assigned this Oct 13, 2020
@psambit9791 psambit9791 added the enhancement New feature or request label Oct 13, 2020
@psambit9791 psambit9791 added this to Issues ❌ in Features List Oct 13, 2020
@psambit9791
Copy link
Owner

psambit9791 commented Oct 13, 2020

At the moment, the Peak class only allows filtering by one metric at a time.
I am planning to add the functionality of filtering by multiple parameters using a piping structure and this should be available in the next release.

@psambit9791 psambit9791 moved this from Issues ❌ to In progress ⏳ in Features List Oct 26, 2020
@psambit9791
Copy link
Owner

This functionality has been added in commit f6e0abb

The process to do this as of now is as follows:

FindPeak fp = new FindPeak(signal);
Peak out = fp.detectPeaks();
int[] peaks = out.getPeaks();
int[] filteredPeaks = out.filterByHeight(peaks, 0.5, "lower");
filteredPeaks = out.filterByPeakDistance(filteredPeaks, 150);
filteredPeaks = out.filterByWidth(filteredPeaks, 20 ,"lower");

The output peaks can now be passed into the <filterByProperty()> functions alongside the arguments.
Calling the functions without peaks will return the result of filtering on all the detected peaks.

This will be released as PATCH release - v0.5.1 accounting for the fact that this is an essential feature for Peak Filtering


The pipelining of filtering properties will be added in next release. (v0.6.0)

@psambit9791 psambit9791 moved this from In progress ⏳ to Done ✔️ in Features List Oct 31, 2020
@psambit9791
Copy link
Owner

Update to filtering method in v0.5.1

With the addition of the feature of filtering from a specific list of peaks, some new updates have also been made in the way the functions are called.

Unlike before, filtering for a lower or upper threshold does not require passing "lower" or "upper" as argument. In stead you can now pass null. All the filterBy*() methods are now structured as filterBy*(peaks, lower_threshold, upper_threshold) and you can pass null as an argument to ignore it.

So, code from #8 (comment) will now be written as follows:

FindPeak fp = new FindPeak(signal);
Peak out = fp.detectPeaks();
int[] peaks = out.getPeaks();
int[] filteredPeaks = out.filterByHeight(peaks, 0.5, null);
filteredPeaks = out.filterByPeakDistance(filteredPeaks, 150);
filteredPeaks = out.filterByWidth(filteredPeaks, 20.0 , null);

@d-lowl
Copy link
Author

d-lowl commented Nov 12, 2020

Awesome. Cheers! I'll have a look.

@psambit9791 psambit9791 moved this from Done ✔️ to Fixed in Features List Dec 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Features List
  
Fixed
Development

No branches or pull requests

2 participants