Skip to content

to_multiscale with Methods.ITK_LABEL_GAUSSIAN throws error for certain data types #79

@ahnsws

Description

@ahnsws

Hello, we would like to use to_multiscale to generate downscaled pyramids of label arrays. Unfortunately, it looks like the ITK_LABEL_GAUSSIAN method only works for certain data types. Please see the snippet below:

import dask.array as da
import numpy as np
from multiscale_spatial_image import to_multiscale, Methods
from spatial_image import to_spatial_image, SpatialImage


def try_multiscale_label():
    """
    types:
    - int8   failed -> itk.support.extras.TemplateTypeError: itk.Image is not wrapped for input type `itk.SC, int`.
    - int16  worked, but max val not big enough
    - int32  failed -> itk.support.extras.TemplateTypeError: itk.BinShrinkImageFilter is not wrapped for input type `None`.
    - int64  failed -> itk.support.extras.TemplateTypeError: itk.Image is not wrapped for input type `itk.SL, int`.

    - uint8  worked, but max val not big enough
    - uint16 worked, but max val not big enough
    - uint32 failed -> itk.support.extras.TemplateTypeError: itk.BinShrinkImageFilter is not wrapped for input type `None`.
    - uint64 failed -> itk.support.extras.TemplateTypeError: itk.BinShrinkImageFilter is not wrapped for input type `None`.
    """
    labels_arr: da.Array = da.zeros(shape=(100, 100), dtype=np.uint64)
    labels_arr[:50, :50] = 1

    labels: SpatialImage = to_spatial_image(labels_arr, dims=("y", "x"))
    to_multiscale(
        labels,
        scale_factors=[dict(y=2, x=2)],
        method=Methods.ITK_LABEL_GAUSSIAN,
    )


if __name__ == "__main__":
    try_multiscale_label()

For int8, int32, int64, uint32, and uint64, there is an error thrown, and it seems like this will take me into the weeds a bit. If you have any suggestions on how to approach fixing this I am all ears.

Edit: the dependencies for the above snippet are:

python==3.10.12
multiscale-spatial-image==0.11.2
dask==2023.8.0
numpy==1.25.2
zarr==2.16.0
itk==5.3.0

Thank you,
Seb

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions