InsightSoftwareConsortium / InsightSoftwareConsortium/ITKElastix
Extraction deformation field after 3D registration.
- Dominant language
- Python
- Stars
- 281
- Forks
- 29
- Avg merge
- 16h 28m
- Merged PRs (30d)
- 8
Description
Hi,
I recently tried to make a 3D image registration (x,y,z) by using ITKElastix
(Reference: [Example3](https://github.com/InsightSoftwareConsortium/ITKElastix/blob/main/examples/ITK_Example03_Masked_3D_Registration.ipynb) and [Example5](https://github.com/InsightSoftwareConsortium/ITKElastix/blob/main/examples/ITK_Example05_PointRegistration.ipynb))
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)
```

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)
```

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.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.