resample the registered moving image

Hello

I want to resample the registered moving image, set the angle to and the translation amount remains unchanged, but I’m not sure if I’m right. Should I set the conversion parameter to (0,0,0,0,0) or (0,0,0, x, y, z)? x, y, z are the translation values.
Thanks.

Hello @TJH123456,

Really not recommended to set the values via the generic SetParameters method as it relies on the user remembering the parameter order. Better to use dedicated, transform specific, methods such as tx.SetRotation(angleX=0.0, angleY=0.0, angleZ=0.0).

If you still want to use SetParameters then you will have to use [0,0,0,x,y,z], as these overwrite the existing values.

Thank you for your answer. But I seem to find that when I use (0,0,0, x, y, z) for resampling, the image will be translated. I wonder if the software will use the registered movting image and conversion parameters as the coordinate origin. If so, it will be very bad. Here’s my code. I hope you can help me to confirm whether the code is correct.

Thank you for your answer. But I seem to find that when I use (0,0,0, x, y, z) for resampling, the image will be translated. I wonder if the software will use the registered movting image and conversion parameters as the coordinate origin. If so, it will be very bad. Here’s my code. I hope you can help me to confirm whether the code is correct.

The problem is with your use of the Resample function. You are using a version that receives a single image, and uses that as both the source and destination grid, this isn’t what you want. You should use the version that receives two images, with the image1=moving_image and referenceImage=fixed_image from your prior registration.

Yes, because I think that I am resampling the registered moving image, I think it is OK to set the parameters in the TFM file and import it into img1 for resampling. However, I found that the set translation parameters (x, y, z) will affect the resampled image and cause it to shift horizontally. The left side is the image before resampling, and the right side is the image after resampling. Theoretically, when I set the angle to 0, there should not be such a big difference, because its angle is very small (less than 0.05 °), so I wonder whether the setting of translation amount affects the resampling.

Hello @TJH123456,

From your image it appears that the original volume is translated primarily in the z direction. You set the resampling transformation so that it only involved translation, rotation zeroed out, so not clear why you think the resulting image isn’t consistent with that.

Please read the resampling section in this read-the-docs page, and the portion on resampling in this Jupyter notebook. Hopefully these will clarify how resampling works and how to set the resampling grid to fit your needs.

Because what I want is to set its angle to 0, without involving translation. But from the image I sent, it obviously involves translation. I also understand that changing the angle will lead to image transformation, but its angle is very small and should not have such a big change. I’m very troubled, and I don’t understand why.

I get it now. As you said, it should be use the [version that receives two images], with the image1=moving_image and referenceImage=fixed_image from your prior registration.This is the right solution. Thank you very much!

1 Like