I did a registration in two steps, Affine -> B-Spline, and now I want to know what is the correspondent index in the new space for a given index in the original space. Here is the code I’m using:
#Receiving the voxel coordinates
print("Please, insert the voxel coordinates (X, Y, Z): ")
voxel = [int(x) for x in input().split()]
physical_voxel = moving_volume.TransformIndexToPhysicalPoint(voxel)
print(physical_voxel)
#Applying the transformation
transformed_point = BS_transformation.TransformPoint(Affine_transformation.TransformPoint(physical_voxel))
print(transformed_point)
fixed_index = Fixed_volume.TransformPhysicalPointToIndex(transformed_point)
print(fixed_index)
label = fixed_atlas.GetPixel(fixed_index)
Voxel is the index in the original space.
The problem is: I do not get the correct index in the registered space but for me everything is right. So, How to solve this?
Thanks for your reply Matt. What do you mean by “Reverse the volumes”? Do you mean assume that the coordinates VOXEL are in the fixed_volume space and change Fixed_volume by Moving_volume? Or do you mean by creating an inverse transformation?
Matt, I’ve made the changes you said, but I’m getting some errors. Here is the code I’m using:
#Receiving the voxel coordinates
print("Please, insert the voxel coordinates (X, Y, Z): ")
voxel = [int(x) for x in input().split()]
physical_voxel = fixed_volume.TransformIndexToPhysicalPoint(voxel)
print(physical_voxel)
#Applying the transformation
transformed_point = BS_result.TransformPoint(Affine_result.TransformPoint(physical_voxel))
print(transformed_point)
fixed_index = moving_volume.TransformPhysicalPointToIndex(transformed_point)
print(fixed_index)
label = fixed_volume.GetPixel(fixed_index)
print(label)
When I test with the entry (192, 160, 58), I get the fixed_index (81, 127, -13) which cause an error. Is my code right or I didn’t understand what you said?
Look at this issue in the bug tracker, and its soon-to-be-proposed fix. It should be instructive on what you might be doing wrong in the registration, and how to fix it.
Side note: voxel coordinates entered are IJK, not XYZ as your message indicates.