-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
MRG: Add polyphase resampling #5136
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
Conversation
Codecov Report
@@ Coverage Diff @@
## master #5136 +/- ##
==========================================
+ Coverage 88.13% 88.13% +<.01%
==========================================
Files 358 358
Lines 65784 65843 +59
Branches 11191 11204 +13
==========================================
+ Hits 57976 58031 +55
- Misses 4983 4987 +4
Partials 2825 2825 |
|
I am not against this feature but i'd like to be sure it brings something useful on some settings. Faster? more accurate? |
|
See PR description about assumptions, integer values, and primes. Do you want code examples? |
|
yes. What is in the impact on a final ERP/ERF for example?
is it significantly faster? I imagine it does not change the results
of an ERF/ERP study no?
|
|
It depends on options. By default Getting |
mne/cuda.py
Outdated
| else: | ||
| assert method == 'poly' | ||
| from scipy.signal import resample_poly | ||
| y = resample_poly(x, new_len, x.size, window=W) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't it make sense to make functions out of all three of these?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry I meant to put "what do you mean" here. The triaging needs to be done somewhere and this is the first level where mode actually matters (e.g. upstream callers pad before and remove padding after the same way regardless of method, etc.). So I don't see a split elsewhere being cleaner
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah you must mean move the other two bits into functions. I guess we could, you think it should be more readable?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes.
Also, looking at this .... the function is called fft_resample. That would be a bit misleading, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes but probably not worth the effort to rename
|
Can't we add the benefits/drawbacks to the docs of the resample method? |
|
What do you mean?
… |
Something like that? Or at least a reference to a section of the docs explaining it. |
|
@jona-sassenhagen can you see if the documentation is better now? |
|
Yes, and I think factoring out the fft resampling into a function looks better, too. So there are no expected differences in quality? Otherwise, that should also probably be documented. If not, lgtm |
|
There can be slight differences in behavior in some cases, e.g. https://docs.scipy.org/doc/scipy-0.18.1/reference/generated/scipy.signal.resample_poly.html But for our data I doubt it would make much difference, especially with a non-zero |
|
@jona-sassenhagen okay for you? |
|
Sure. |
|
Shall I merge? Or do you indeed want to wait for .17? |
|
please don't merge.
give me time to test and look
I am doing the 0.16 release now.
|
|
great! |
|
@agramfort 0.16.1 has been on PyPI since at least yesterday - is this intentional? |
|
yes I screwed up 0.16 so we are already at 0.16.1
I just sent the announcement email
|
|
Rebase and merge right? |
|
Anything standing in the way of merging this? |
|
(I mean, besides for the merge conflict etc of course :D) |
|
sorry this is not high on my todo list now. However if I can make a comment I think we should have method="auto" that defaults to fft or poly depending on what will be more efficient. Otherwise people will not discover this option. |
|
Since the assumptions of the two methods (and resulting properties like ringing) are not equivalent for all signals between the two methods, I would not be comfortable switching between them automatically :( We could always kill this PR and let experts use polyphase manually by getting data and using |
|
I am just uneasy to add more complex code for stuff that already work and
will only benefit to a tiny fraction of people.
|
|
Okay let's leave it out for now at least then |
scipy.signal.resample_polyhas been in SciPy since 0.18. Time to expose it.Originally I was going to make it the new default -- it does not assume signal periodicity (an implicit assumption of FFT-based resampling) and could be faster for integer sample rate changes (especially if the signal of interest has a non-easily-factorable number of samples so the FFT/IFFT will be slow). But given how long we've been using
fftand the fact thatsampleandsomatouse wacky non-integral sample rates, I guess we can leave it asfft.