-
-
Notifications
You must be signed in to change notification settings - Fork 381
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
Issue with Point Set Metrics in antsRegistration #1335
Comments
The points are defined in the physical space of the images, so they are not independent of the fixed and moving images. The points must be defined in ITK coordinates (LPS, like DICOM). You can load your images into ITK-SNAP and then see whether your points are sensible (Tools -> Layer Inspector, select Info tab). |
Thanks @cookpa, I was using RAS coordinates. I mapped my coordinates to LPS and checked with itk-snap that they were sensible for my images. I am still seeing the same issue though, with the metricValue staying constant. |
Here is a minimal example of the issue: https://drive.google.com/drive/folders/1aMS0gJFQsDZU9AKWKaTnrpxaLhqffa6z?usp=sharing Running Gives:
|
Have you looked at this example repository? |
@ntustison Yes, I did. Correct me if I'm wrong, but I don't think that repository has an example of registering point sets specified as space delimited .txt files. E.g. |
You're right but you can convert those labeled images to .csv point set files using |
@ntustison is there a minimum number of points for the metric to work effectively? The files above only have two points |
I hadn't noticed that. Thanks for pointing that out. Two points should work, I think, but I wouldn't use it as a case for debugging. |
This is a minimal example, I tried with up to 6 point correspondences with the same issue. |
I confirmed that the following commands reproduce the issue with the "points" data in the chicken repository:
|
In my suggestion above, my assumption was that you'd do a bit more digging on your end. The original chicken example works so the key question is "at what stage in making it more like your problem does it not work?" For example, is it the ICP metric? Is it the .txt conversion? We're busy with our own projects, etc. and so we rely on users to do as much as they can before we take on doing the investigation ourselves. |
Thanks @ntustison, I can definitely offer some more details (and I appreciate the continued help, I know this is a side-project). I have dug into this for a couple of days but I'm trying not to present too much information at once. Here are some things I've noticed:
My conclusion from this is that the *.txt landmark point metric losses are not being used to update the transformation parameters internally. It is unclear to me why this would be the case. The original chicken example works because it uses *.nii.gz files with "landmark disks", but I have not been able to find a working example with *.txt landmark points. If we can figure this out together I would be happy to contribute some documentation and examples for running registration with *.txt landmark points. |
Also relevant: The same problem was touched on in this thread but never resolved. |
I don't know what "landmark disks" are but the input data structure of the point set metric is the same for images as it is for .txt files. |
By "landmark disks" I just mean that e.g. Maybe a good place to start debugging this is a simpler example: what is the expected behavior of registration with only ICP metric?
This results in a segfault for me:
Does ANTs need the header info in NIFTI files to run registration? |
I think you need to have an image metric. It's needed to define physical space of the inputs and outputs. I'm not familiar with all the point set data types, but a text file is definitely not enough to initialize the registration. In any case, I don't see how you could solve for a dense warp field from a handful of distant points. It might be more theoretically reasonable to define an affine transform with points only, but I don't know if You could try using Mattes with a small weight to approximate a solution that relies more on the point set metric. |
Thanks @cookpa. So I think we can safely assume So then we have two other (possibly related) issues:
|
I believe I wrote it such that one could specify a mask to provide the necessary physical domain without having to use an image-specific metric. Also, you might want to explore this issue using |
Good to know about the mask. I'll look into this when I get time and see about updating the tutorials and documentation |
The mask comment helps a lot. The following command fixes the issue with the segfault from here: Now the registration appears to be working for the |
I generated a binary mask image in the same physical space as Next I tried adding I expected to get a similar result to the previous command, but instead the The same issue occurs when using So the problem is independent of the input types passed to |
I see what you're saying, the metric values don't seem to change. I will look more into this when I get time. Is there a reason you're using |
Thanks @cookpa, I spent some time last week going through the source code but could not find where the issue was coming from. One more note that might be useful for debugging: the issue does not appear when using affine or rigid registration (I managed to get that to work), but does appear for all deformable transformation models.
|
For testing purposes, I would use "BSplineSyN" as it's much more appropriate framework for both voxel and landmark contributions. |
I've not made any breakthroughs here but as we've been dealing with metric scales issues lately, I began to wonder if the scales estimation might also be relevant to this issue. I noticed scales are set by the first metric. It might not be the only time the first metric is important, but I thought it might be a lead to explain why the ordering of metrics matters in the experiments above ANTs/Examples/itkantsRegistrationHelper.hxx Lines 1315 to 1321 in ec91afc
|
Thank you all for the great work on this package! I am trying to use landmark points to guide the registration of some abdominal MR volumes and have encountered an unexpected issue. Here is the command I am trying to run:
antsRegistration -d 3 --metric ICP[fixed.txt,moving.txt,1] --metric MI[fixed.nii,moving.nii,1] --transform SyN[0.1,0,0] --shrink-factors 4x2x1 --smoothing-sigmas 3x1x0 --convergence [1000x100x100,1e-4,4] -v
The two volumes are already affine registered. I've attached my
fixed.txt
andmoving.txt
files (you should be able to reproduce with anyfixed.nii
andmoving.nii
volumes).The issue with the command above is that the metricValue never decreases and the result of the registration is an identity transformation. When the
--transform
is changed to any other deformable transformation method (e.g. Exponential) I get a segmentation fault.ANTs version 2.3.5, compiled from source on Ubuntu 20.04. I've reproduced the issue on a separate machine as well.
I appreciate the help.
moving.txt
fixed.txt
The text was updated successfully, but these errors were encountered: