Skip to content

learn2reg_nlst_paired_lung_ct.ipynb keypoints warping #2021

Description

@coolteemf

Hi,
I'm working on a new registration method, and decided to use learn2reg_nlst_paired_lung_ct.ipynb as a base.
However, the conversion from keypoints from voxel coordinates to warping coordinates in the range [-1, 1] seems incorrect to me.
It is done like this (in the forward function):

offset = torch.as_tensor(fixed_image.shape[-3:]).to(fixed_keypoints.device) / 2
offset = offset[None][None]
ddf_keypoints = torch.flip((fixed_keypoints - offset) / offset, (-1,))

But in the Warp class of Monai, the conversion is done like this:

for i, dim in enumerate(grid.shape[1:-1]):
    grid[..., i] = grid[..., i] * 2 / (dim - 1) - 1
index_ordering: list[int] = list(range(spatial_dims - 1, -1, -1))
grid = grid[..., index_ordering]  # z, y, x -> x, y, z

Which seems correct to me, since voxel coordinates should max out at dim - 1 for indexing.

The two are almost equivalent, except that in the notebook, image.shape is used and not image.shape - 1, so I think the notebook is wrong.
Feel free to correct me if I'm wrong, because I'm lacking info on what exactly are those keypoints and how they were obtained.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

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