Skip to content
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

ENH: Add DASK_GAUSSIAN scaling and fix ITK_GAUSSIAN #40

Merged
merged 2 commits into from
May 16, 2022

Conversation

tbirdso
Copy link
Collaborator

@tbirdso tbirdso commented May 12, 2022

Changes:

  • Adds DASK_GAUSSIAN scaling option which combines dask_image Gaussian
    blurring with ITK's ResampleImageFilter for downsampling
  • Resolves issue in ITK_GAUSSIAN where kernel radius was improperly calculated from local metadata,
    resulting in severely different images from DASK_GAUSSIAN blurring results
  • Adds tests and updates baseline testing data

Note that Gaussian kernels with same sigma value are still generated slightly differently between ITK and dask_image, so baseline image magnitudes differ by a small amount.

@tbirdso tbirdso requested a review from thewtex May 12, 2022 17:17
@tbirdso
Copy link
Collaborator Author

tbirdso commented May 12, 2022

Example output for comparison

gaussian-output

Changes:
- Adds `DASK_GAUSSIAN` scaling option which combines dask_image Gaussian
  blurring with ITK's ResampleImageFilter for downsampling
- Resolves issue in ITK_GAUSSIAN where kernel radius was improperly set
  from local block metadata,
  resulting severely different images from DASK_GAUSSIAN blurring
  results
- Adds tests and update baseline images
@tbirdso tbirdso marked this pull request as ready for review May 12, 2022 18:11
Copy link
Contributor

@thewtex thewtex left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tbirdso awesome!!

Can we use something from dask-image for the resampling so we do not have the itk dependency for this method? E.g. affine_transform, map_coordinates

@jakirkham @GenevieveBuckley

The `DASK_GAUSSIAN` method previously relied on ITK for calculating
output metadata at each scale and resampling after dask_image blurring.
This commit updates the `DASK_GAUSSIAN` procedure to manually compute
output metadata without ITK and to use the dask_image `affine_transform`
method for downsampling.
@tbirdso
Copy link
Collaborator Author

tbirdso commented May 16, 2022

@thewtex Please see updated changes substituting dask_image.ndinterp.affine_transform in place of itk.resample_image_filter for downsampling. Note that we were also relying on ITK for generating output metadata at each scale with itk.BinShrinkImageFilter, I have pulled out that logic for getting the output spacing and origin along each dimension, though without support for image direction at the moment.

Does MultiscaleSpatialImage contain image direction metadata? It does not look like direction information is being propagated to each scale in any of the existing to_multiscale methods.

Copy link
Contributor

@thewtex thewtex left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tbirdso beautiful!! ✨

@thewtex thewtex merged commit 58f6436 into spatial-image:main May 16, 2022
@jakirkham
Copy link

That's really cool to see. Thanks for sharing and working on this Matt and Tom! 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants