-
-
Notifications
You must be signed in to change notification settings - Fork 53
Description
Currently, if you run map_coordinates with the keyword argument prefilter=True, the results do not exactly match the equivalent results from scipy. See this docstring comment by Marvin:
dask-image/dask_image/ndinterp/_map_coordinates.py
Lines 186 to 190 in 9992f3f
| Warning: prefilter is True by default in | |
| `scipy.ndimage.map_coordinates`. Prefiltering here is performed on a | |
| chunk-by-chunk basis, which may lead to different results than | |
| `scipy.ndimage.map_coordinates` in case of chunked input arrays | |
| and order > 1. |
As a hacky workaround, currently we have prefilter=False as the default in dask-image, but this is not ideal behaviour. It's not great because that does not match the default behaviour of the scipy.ndimage.map_coordinates function.
What if
dask_image.ndinterp.map_coordinatesdid this automatically, e.g. usingdask_image.ndinterp.spline_filterautomatically ifprefilter=True?
I think once this release is out, it would be worth investigating properly implementingprefilter=Trueusing dask-image'sspline_filteras you noted, so that prefilter could actually default to True here.
I think that's a great idea. Then we would get identical results from the scipy and dask-image map_coordinates functions when prefilter=True.
Rough approach:
- In the
dask_image.ndinterp.map_coordinatesfunction, add an initial step - if theprefilterkwarg is True, then add a step manually prefiltering the array using thedask_image.ndinterp.spline_filterfunction. - Then change the default kwargs
a. Set prefilter to False in theoutput = da.map_blocks(_map_single_coordinates_array_chunk, ... prefilter=False)part (since the input arrays are already pre-filtered with the dask-image spline interpolation
prefilter=prefilter,
b. Set prefilter to True in the outer dask-image map_coordinates function signature (in order to match the scipy map_coordinates implementation) - Add a test for this, ensuring the results from scipy's map_coordinates match the dask-image map_coordinates results when prefilter=True. Probably you could extend the existing test with pytest input parameters, instead of having to write an entirely new test.