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

Extraction deformation field after 3D registration. #273

Open
shloveya opened this issue Mar 6, 2024 · 0 comments
Open

Extraction deformation field after 3D registration. #273

shloveya opened this issue Mar 6, 2024 · 0 comments

Comments

@shloveya
Copy link

shloveya commented Mar 6, 2024

Hi,
I recently tried to make a 3D image registration (x,y,z) by using ITKElastix
(Reference: Example3 and Example5)
reason
For some reasons, I should get a deformation field in a specific z index. (to perform the same registration in different images)
In 2D registration, I easily get the deformation by using

#Load another image for same registration
moving_image_transformix = itk.imread("C:/python/Second_moving_object.tif", itk.F) transformix_object = itk.TransformixFilter.New(moving_image_transformix) transformix_object.SetTransformParameterObject(result_transform_parameters) transformix_object.UpdateLargestPossibleRegion()
#Perform 2nd registration
result_image_transformix = transformix_object.GetOutput()

By using this code, I can visualize the deformation field by using
deformation_field = itk.transformix_deformation_field(moving_image, result_transform_parameters) deformation_field.shape deformation_field = np.asarray(deformation_field).astype(np.float32) fig, axs = plt.subplots(1,2, sharey=True, figsize=[10,10]) plt.figsize=[10,10] axs[0].imshow(deformation_field[:,:,1]) axs[0].set_title('Deformation Field X', fontsize=30) axs[1].imshow(deformation_field[:,:,0]) axs[1].set_title('Deformation Field Y', fontsize=30)

I used the same code in 3D registration adding information of the z index.
(At this time, the shape of the deformation field was (46, 512, 512, 3)

#I extract the deformation field at z:10

deformation_field_ar = np.asarray(deformation_field).astype(np.float32)
DF_dimension = deformation_field.shape
print(DF_dimension)
fig, axs = plt.subplots(1,3, sharey=True, figsize=[10,10])
plt.figsize=[10,10]
axs[0].imshow(deformation_field[10,:,:,2])
axs[0].set_title('Deformation Field X', fontsize=10)
axs[1].imshow(deformation_field[10,:,:,1])
axs[1].set_title('Deformation Field Y', fontsize=10)
axs[2].imshow(deformation_field[10,:,:,0])
axs[2].set_title('Deformation Field Z', fontsize=10)
deformation_field_ar = np.asarray(deformation_field).astype(np.float32)
DF_dimension = deformation_field.shape
print(DF_dimension)
fig, axs = plt.subplots(1,3, sharey=True, figsize=[10,10])
plt.figsize=[10,10]
axs[0].imshow(deformation_field[10,:,:,2])
axs[0].set_title('Deformation Field X', fontsize=10)
axs[1].imshow(deformation_field[10,:,:,1])
axs[1].set_title('Deformation Field Y', fontsize=10)
axs[2].imshow(deformation_field[10,:,:,0])
axs[2].set_title('Deformation Field Z', fontsize=10)

z10 deform

But when I changed the deformation field at z 20, the Z-field did not change.

deformation_field_ar = np.asarray(deformation_field).astype(np.float32)
DF_dimension = deformation_field.shape
print(DF_dimension)
fig, axs = plt.subplots(1,3, sharey=True, figsize=[10,10])
plt.figsize=[10,10]
axs[0].imshow(deformation_field[20,:,:,2])
axs[0].set_title('Deformation Field X', fontsize=10)
axs[1].imshow(deformation_field[20,:,:,1])
axs[1].set_title('Deformation Field Y', fontsize=10)
axs[2].imshow(deformation_field[20,:,:,0])
axs[2].set_title('Deformation Field Z', fontsize=10)

z20 deform

I think the deformation field of Z should have a different dimension (because of dimension of z is smaller than x or y).

Could someone please help me?

Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant