How to save the output of StrainImageFilter (Tensor) with ITK?

1 How to save the output of StrainImageFilter (Tensor)?

Hello!

I am trying to save the output of the examples/numpy_to_strain.py
(on the ITKStrain repo). I tried the naïve itk.imwrite, but I got
the following issue. The data which I have is 3D, but the same happens
with 2D (except for the [itk.F,3],3):

┌────
│ itk.imwrite(strain_image, “/tmp/t.vtk”)
└────

┌────
│ File “/home/edgar/.local/lib/python3.10/site-packages/itk/support/template_class.py”, line 529, in getitem
│ raise itk.TemplateTypeError(self, key)
│ itk.support.extras.TemplateTypeError: itk.ImageFileWriter is not wrapped for input type itk.Image[itk.SymmetricSecondRankTensor[itk.F,3],3].

│ To limit the size of the package, only a limited number of
│ types are available in ITK Python. To print the supported
│ types, run the following command in your python environment:

│ itk.ImageFileWriter.GetTypes()

│ Possible solutions:
│ * If you are an application user:
│ ** Convert your input image into a supported format (see below).
│ ** Contact developer to report the issue.
│ * If you are an application developer, force input images to be
│ loaded in a supported pixel type.

│ e.g.: instance = itk.ImageFileWriter[itk.Image[itk.ULL,2]].New(my_input)
└────

(removed content: the supported types)

These could be related

| mumps | 5.5.1-2 |
| scotch | 7.0.1-1 |
| petsc | 3.18.5-2 |
| hypre | 2.27.0.23.g31e8cd64f-1 |
| cblas | 3.11.0-2 |
| liblas | 1.8.1.r128+gded46373-5 |
| openblas | 0.3.21-4 |
| xtensor-blas | 0.20.0-1 |
| Python | 3.10.10 |
| itk | 5.3.0 |
| itk-core | 5.3.0 |
| itk-elastix | 0.15.0 |
| itk-filtering | 5.3.0 |
| itk-io | 5.3.0 |
| itk-meshtopolydata | 0.10.0 |
| itk-minimalpathextraction | 1.2.4 |
| itk-numerics | 5.3.0 |
| itk-registration | 5.3.0 |
| itk-segmentation | 5.3.0 |
| itk-strain | 0.4.0 |
| itk-tubetk | 1.3.4 |
| itkwidgets | 0.32.5 |
| numpy | 1.24.2 |
| Pillow | 9.4.0 |
| scipy | 1.10.1 |

(ITK from pip)

Thank you!

@Tom_Birdsong Did you encounter a need to write strain images?

Thanks @dzenanz . I solved it like this:

    import pyvista as pv


    test = pv.UniformGrid()
    test.origin = deformation_field.GetOrigin()
    test.spacing = deformation_field.GetSpacing()
    test.dimensions = deformation_field.shape[::-1][1:]
    test.point_data["strain"] = strain_array.reshape(
      np.prod(strain_array.shape[:-1]), 6)
    test.save("/tmp/itk_strain_with_pyvista.vti")