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

Got the same results when using ants.image_similarity with different types #479

Closed
Mo-Junyang opened this issue Jun 25, 2023 · 6 comments · Fixed by #480
Closed

Got the same results when using ants.image_similarity with different types #479

Mo-Junyang opened this issue Jun 25, 2023 · 6 comments · Fixed by #480

Comments

@Mo-Junyang
Copy link

Mo-Junyang commented Jun 25, 2023

I am using ants.image_similarity to calculate the histogram mutual information and the Neighborhood cross correlation

import ants

x = ants.image_read(ants.get_ants_data('r16'))
y = ants.image_read(ants.get_ants_data('r30'))

mi_metric = ants.image_similarity(fixed_image=x,
                                  moving_image=y,
                                  metric_type="JointHistogramMutualInformation",)

cc_metric = ants.image_similarity(fixed_image=x,
                                  moving_image=y,
                                  metric_type="ANTsNeighborhoodCorrelation",)

but got two same results, cc_metric = mi_metric. Should they be the same? Is there anything wrong between these two metric_type?

BTW, is this function corresponding to MeasureImageSimilarity in ANTs?

@Mo-Junyang Mo-Junyang changed the title Got the same results when using ants.image_similarity Got the same results when using ants.image_similarity with different types Jun 25, 2023
@cookpa
Copy link
Member

cookpa commented Jun 25, 2023

I think you might be seeing 'JointHistogramMutualInformation' for both cases.

The underlying library function compares the metric_type to the different options by the "==" operator. This might be getting confused by different encoding of Python and C++ strings.

ANTsImageToImageMetric< MetricBaseType > create_ants_metric(std::string pixeltype,

I'm not sure of the best solution but will look into it.

The function appears to not call the ANTs MeasureImageSimilarity program directly, but it might produce the same results nonetheless because it evaluates the same metrics.

@Mo-Junyang
Copy link
Author

I think you might be seeing 'JointHistogramMutualInformation' for both cases.

The underlying library function compares the metric_type to the different options by the "==" operator. This might be getting confused by different encoding of Python and C++ strings.

ANTsImageToImageMetric< MetricBaseType > create_ants_metric(std::string pixeltype,

I'm not sure of the best solution but will look into it.

The function appears to not call the ANTs MeasureImageSimilarity program directly, but it might produce the same results nonetheless because it evaluates the same metrics.

If you figure out how to get the 'ANTsNeighborhoodCorrelation' metric, please let me know, thank you so much!

@cookpa
Copy link
Member

cookpa commented Jun 26, 2023

Looks like it's not string encoding because pybind11 takes care of that

https://pybind11.readthedocs.io/en/stable/advanced/cast/strings.html

The weird thing is other metric return different values, MeanSquares, Correlation, MattesMutualInformation are all unique. But ANTsNeighborhoodCorrelation is wrong somehow

@cookpa
Copy link
Member

cookpa commented Jun 26, 2023

It's a typo!

Try "ANTSNeighborhoodCorrelation" not "ANTsNeighborhoodCorrelation". I'll work on making this not silently fail

@cookpa
Copy link
Member

cookpa commented Jun 26, 2023

Actually ANTSNeighborhoodCorrelation won't work, but I'll fix that

@Mo-Junyang
Copy link
Author

@cookpa I am looking forward to it. Thanks again for your help!

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 a pull request may close this issue.

2 participants