-
Notifications
You must be signed in to change notification settings - Fork 8
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
Add median filtering function #85
Conversation
Hi @cgohlke! I opened this PR to start the discussion of a couple of thing related to the filtering methods, before I continue working on this:
|
I removed the |
Good to see you getting familiar with Cython. I think that 20% is not worth the implementation/maintenance overhead, but that can probably be improved. The huge advantage of ndimage's implementation is that it works with any-dimensional arrays, for example of 3D phasors. The
In general, use
Try cython-lint. It's in the project's dev requirements but not used in CI yet.
Exactly, and that is probably a huge opportunity for optimizing the Cython function: Move the In general, how about adding (or replacing with) a function taking phasor coordinates as input for convenience, something like
|
Great suggestions @cgohlke, I will look a little bit more into the algorithms but these are all good ideas. I will fall on SciPy's for cases we can't handle yet. I will look into the iterations, I didn't think of including it in the Cython function but it makes a lot of sense. I will let you know when it's ready again for review, but thanks already for all the suggestions! |
I realize that this will not be that trivial with the default algorithm. |
Don't spend too much time on it though. I think we agree that the purpose of the median filter functionality in the PhasorPy library is not to provide yet another |
It's probably enough for to update the introduction tutorial. I noticed that the Cython code works on |
You are right, I was testing that. If it uses Maybe for now it's better to work only with float since I can't think of now of cases where int is going to be used. Let me know if you believe this is the best option and I will make the changes. |
The issue with using |
… to use `scipy.ndimage.median_filter` instead of previous cython implementation. Added tests for `phasor_filter` function. Updated `tutorials/phasorpy_introduction.py` to reflect changes in `utils` module.
…to median_filter
Hi @cgohlke, I have been researching as we talked with the cython implementation of the median filter and tested moving the iteration inside the cython function for memory and execution efficency, but It didn't have much of an impact in performance, mainly compared to scipy's and skimage filters, so I rolled back and made a new implementation using scipy's median filter instead. I think it's the best approach for now as it is already very efficent and maybe it's not worth spending time now trying to improve this to only have a very minor impact. I used scipy's instead of skimage's filtering function because skimage actually uses scipy's and altough it seems to be more efficent with large images, I tested and actually were quite similar. I think scipy is a little more personalizable with the parameters and also can handle more than 3D, which may be of use in the case of multidimensional phasors. As you may see, I am having some error when building the cibuildwheel because it doesn't seem to have scipy installed, although it is already listed as a dependence. Do you know what can be the problem? |
Scipy is in the development dependencies. Add it to the install dependencies in Line 22 in fee878e
|
A few general thoughts:
|
Thanks @cgohlke for all your comments, I will go through them and let you know when it is ready for review.
I agree, this is something we can discuss in the next meeting as I believe is a big change that should be done (if we agree to do it) before our first release.
This is a very good issue you raised. It is also something I was thinking about in the thresholding function implementation also. Maybe this is something we can discuss in it's corresponding PR, but I was thinking of masking below the threshold as Regarding the filtering, how do you think it should handle
Maybe we can discuss this or @schutyb and @lmalacrida can give some insight into this. I am inclined to the first alternative, but I don't know what is usually done in phasor processing in this case. |
Good question. What does Using |
…ation for `phasor_filter`.
It seems that the topic of Considering this I think we have to discuss if implementing our filter makes sense to be able to control what happens to |
Description
This PR adds the function
phasor_filter
inutils
module. The only supported method at the moment is the median filtering function which usesscipy.ndimage.median_filter
function.The
phasor_filter
function was implemented in a way to allow easy addition of new methods for filtering (i.e. the wavelet filter, gaussian, etc)This PR partly addresses some functionality to be added in #21
Release note
Summarize the changes in the code block below to be included in the
release notes:
Checklist