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

Feature Idea/Request: HistogramMatch in antsRegistration using mask if provided #368

Open
gdevenyi opened this issue Oct 14, 2016 · 14 comments
Labels
wouldbenice Nice ideas not under development (pull requests welcome)

Comments

@gdevenyi
Copy link
Contributor

For the histogram matching code, done for each stage of registration, it may be beneficial to histogram match images using masks (if provided)

See https://github.com/stnava/ANTs/blob/master/Examples/itkantsRegistrationHelper.hxx#L113-L128

It looks like the mask isn't currently passed into the preprocessing call, so that would need to be modified.

I'm looking into this but if someone is inspired (and more skilled at C++) you're also welcome to try to implement.

@ntustison ntustison added the wouldbenice Nice ideas not under development (pull requests welcome) label May 3, 2017
@devDonnn
Copy link

devDonnn commented Apr 3, 2024

Hi guys. Has this feature already been implemented at any point since its inception?

@gdevenyi
Copy link
Contributor Author

gdevenyi commented Apr 3, 2024

Nope

@cookpa
Copy link
Member

cookpa commented Apr 3, 2024

I believe the masks are only used to restrict metric computation. Preprocessing, including smoothing, winsorization, histogram matching, happen over the entire image domain.

If we were to change this, I would vote that we only do so if a mask is defined for both the fixed and the moving image.

@ntustison
Copy link
Member

Perhaps it's a momentary brain lag but why can't something like this preprocessing step be done prior to the antsRegistration call?

@cookpa
Copy link
Member

cookpa commented Apr 3, 2024

ImageMath 3 matched.nii.gz HistogramMatch SourceImage ReferenceImage {NumberBins-Default=255} {NumberPoints-Default=64} {useThresholdAtMeanIntensity=false}

Note the registration uses NumberPoints=12.

I've only used this once or twice and the results didn't look great, however that doesn't necessarily imply it doesn't enable better registration.

@devDonnn
Copy link

devDonnn commented Apr 3, 2024

@ntustison If so, shoudn't the

--use-histogram-matching

flag be removed? At least in all the applications I have encountered there is no use of this flag unless it supports masks. Even 'minor' changes in the size of the background between two images can distort the quantiles matching approach. Also, from https://itk.org/Doxygen/html/classitk_1_1HistogramMatchingImageFilter.html:

The algorithm works best if background pixels are excluded from both the source and reference histograms.

@ntustison
Copy link
Member

It's there for legacy reasons. But, yes, if I were to start development from scratch, I would not include it.

@gdevenyi
Copy link
Contributor Author

gdevenyi commented Apr 3, 2024

In the meantime I have been indeed doing this step on my own, using minc_nuyl, because ImageMath also doesn't support masks.

@cookpa
Copy link
Member

cookpa commented Apr 3, 2024

In the meantime I have been indeed doing this step on my own, using minc_nuyl, because ImageMath also doesn't support masks.

I can fix that

@cookpa
Copy link
Member

cookpa commented Apr 3, 2024

Also, ThresholdAtMeanIntensityOn() is a crude form of masking, which antsRegistration does, but I think it would be worthwhile to enable explicit masks in ImageMath.

@stnava
Copy link
Member

stnava commented Apr 3, 2024

just for historical context, these parameter choices were based on empirical data generated by Lydia Ng and Luis Ibanez.

  • demons registration ( classic style )
  • some old school T1w MRI with crude labels
  • parameter search over different hist matching parameters

so has little to do with ants approaches. was intended for use with demons metric.

@cookpa
Copy link
Member

cookpa commented Apr 12, 2024

OK, so I looked into this a bit more. I don't think the ITK filter can be easily modified in a backwards compatible way to support masks. It could possibly be a subclass, where the histograms would be populated with all voxels inside the masks.

The registration uses the threshold at mean intensity, which should exclude background but might still result in different tissue types contributing to the histograms.

Both the antsMultivariateTemplateConstruction2.sh and antsCorticalThickness.sh use histogram matching, definitely something to reconsider as we update those pipelines.

@ntustison
Copy link
Member

So I implemented the inverse operation for data augmentation here. Using the internals of that program, I'm pretty sure I could implement Nyul's version with arbitrary masking. Let me look a bit more and I'll try putting something together.

@ntustison
Copy link
Member

ANTsX/ANTsPy#607

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wouldbenice Nice ideas not under development (pull requests welcome)
Projects
None yet
Development

No branches or pull requests

5 participants