Saving Transform Information to DICOM » History » Version 4
Peter Qian, 31/08/2021 03:24 PM
1 | 1 | Peter Qian | h1. Saving Transform Information to DICOM |
---|---|---|---|
2 | |||
3 | Documentation to describe how the Transform Information is saved into a DICOM file. |
||
4 | |||
5 | After a fixed and moving image are successfully co-registered, the function |
||
6 | <pre><code class="python"> |
||
7 | def register_images(image_1, image_2): |
||
8 | </code></pre> |
||
9 | |||
10 | Will produce the moving image(translated) and SITK.CompositeTransform object. The SITK.CompositeTransform will contain a number of transforms in a queue. |
||
11 | |||
12 | As of the time of development, it can be only observed that Euler3DTransform and Versor3DRigidTransform transform objects are stored into the SITK.CompositeTransform object. |
||
13 | |||
14 | <pre><code class="python"> |
||
15 | def create_fused_model(old_images, new_image) |
||
16 | </code></pre> |
||
17 | 2 | Peter Qian | |
18 | 3 | Peter Qian | The function below calls for all the transforms in the SITK.CompositeTransform object and reduces all the transform objects into a singular transform object. This singular transform object is constructed in a SITK.AffineTransform. One thing to mention is that the function only assumes that there is only an Euler3DTransform and Versor3DRigidTransform in the SITK.CompositeTransform. Information regarding to "SITK Spatial Transformations":https://github.com/InsightSoftwareConsortium/SimpleITK-Notebooks/blob/master/Python/22_Transforms.ipynb. |
19 | 2 | Peter Qian | |
20 | <pre><code class="python"> |
||
21 | def convert_composite_to_affine_transform(composite_transform) |
||
22 | </code></pre> |
||
23 | |||
24 | 4 | Peter Qian | To construct a matrix that complies with DICOM standards, the 3x3 matrix within the SITK.AffineTransform object is calculated to a 4x4 matrix with the function. (It has been checked that with the retrieval of the matrix and only collecting elements up to the 3rd column and row. The last column represents the translation (or offset) vector. The conversion of the matrix can be found "here":https://discourse.itk.org/t/express-affinetransform-as-single-4x4-matrix/3193. |
25 | 2 | Peter Qian | |
26 | <pre><code class="python"> |
||
27 | def convert_combined_affine_to_matrix(combined_affine) |
||
28 | </code></pre> |
||
29 | |||
30 | 3 | Peter Qian | The 4x4 is then written to a transform.dcm via the function, adhering to DICOM standards. The Spatial Registration Object is constructed and implemented by following the tree list pattern as shown in "here":https://dicom.innolitics.com/ciods/spatial-registration/spatial-registration/00700308/00700309/0070030a/300600c6. |
31 | 2 | Peter Qian | |
32 | <pre><code class="python"> |
||
33 | def write_transform_to_dcm(affine_matrix) |
||
34 | </code></pre> |