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:
|
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.
@astrofrog suggests
What if dask_image.ndinterp.map_coordinates did this automatically, e.g. using dask_image.ndinterp.spline_filter automatically if prefilter=True?
I think once this release is out, it would be worth investigating properly implementing prefilter=True using dask-image's spline_filter as 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_coordinates function, add an initial step - if the prefilter kwarg is True, then add a step manually prefiltering the array using the dask_image.ndinterp.spline_filter function.
- Then change the default kwargs
a. Set prefilter to False in the output = 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
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.
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
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.
@astrofrog suggests
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:
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.a. Set prefilter to False in the
output = da.map_blocks(_map_single_coordinates_array_chunk, ... prefilter=False)part (since the input arrays are already pre-filtered with the dask-image spline interpolationdask-image/dask_image/ndinterp/_map_coordinates.py
Line 238 in 9992f3f
b. Set prefilter to True in the outer dask-image map_coordinates function signature (in order to match the scipy map_coordinates implementation)