ndinterp methods fails with ResourceBackedDaskArray from aicsimageio
Hi there,
I want to use ndinterp.affine_transform on images loaded with aicsimageio/nd2. For some image formats (e.g. .nd2) aicsimageio returns a ResourceBackedDaskAray which is an instance of da.Array.
However the type check for da.core.Array fails.
img = AICSImage("image.nd2")
affine_transform(img.dask_data, matrix)
ValueError: Array is already a dask array. Use 'asarray' or 'rechunk' instead.
Cheers, Chris
Hi @sommerc, thanks for posting this issue 🙏
This is the line behind the type check you mentioned:
type(image) == da.core.Array
We should probably look into whether this is the right way to perform this check. Would you be aware of a check that ResourceBackedDaskArrays passes?
Hi @m-albert,
thanks for your quick reply! I am not an expert on dask, but
isinstance(image, da.core.Array) is True for image of type ResourceBackedDaskArray
and should not do any harm.
C
Thanks! Probably we should be using isinstance in dask_image.ndinterp to also support dask array sublcasses, as your example clearly motivates.
Would you be interested in creating a PR for this @sommerc ?
Yes, then it would also match the check inside da.from_array()
Would you be interested in creating a PR
Absolutely, I'll create on tomorrow.
Thanks a lot!