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

Interchanged pre and pos prefixes in peak_detection function #53

Draft
wants to merge 1 commit into
base: dev
Choose a base branch
from

Conversation

jimearruti
Copy link
Collaborator

@jimearruti jimearruti commented Feb 11, 2022

The prefixes were mixed up, as described in the linked issue. Now the filters are centered in the correct sample.

@jimearruti jimearruti linked an issue Feb 11, 2022 that may be closed by this pull request
@jimearruti jimearruti requested a review from mrocamora February 11, 2022 16:37
Copy link
Owner

@mrocamora mrocamora left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's intriguing.

The code in librosa does exactly the same:

https://librosa.org/doc/latest/_modules/librosa/util/utils.html#peak_pick

As well as the code in madmom:

https://github.com/CPJKU/madmom/blob/main/madmom/features/onsets.py

Are they wrong? What do you think?

@jimearruti
Copy link
Collaborator Author

jimearruti commented Feb 11, 2022

The result of both operations is then used as the origin parameter when calling sp.ndimage.filters.maximum_filter.

According to the documentation:
origin: int or sequence, optional
Controls the placement of the filter on the input array’s pixels. A value of 0 (the default) centers the filter over the pixel, with positive values shifting the filter to the left, and negative ones to the right.

I had read this before the PR but the direction of the shift had confused me. Reading this again (and drawing some examples for different windows) I now think it was okay before the change, and librosa and madmom are right.

What made you think they were interchanged? Maybe I'm missing something.

@mrocamora
Copy link
Owner

Look at the plot of the moving average and moving maximum thresholds in the onset detection demo notebook. They clearly extend longer to the future despite the fact that pre is greater than pos. Why is this happening? I thought the parameters were interchanged, but it is not clear to me now.

@jimearruti
Copy link
Collaborator Author

Yep, the plot indeed shows what you said, and is fixed if we interchange the prefixes. It's weird. Maybe we can talk it through in our next meeting, to make sure we're not missing anything.

@jimearruti jimearruti marked this pull request as draft February 24, 2022 19:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

peak detection parameter names mixed-up
2 participants