Extracting displacement fields from rigid registration

Thank you, Dženan. I initially got this error:

RuntimeError: /pkg/insight-toolkit/src/insight-toolkit/Modules/Core/Common/src/itkProcessObject.cxx:1339:
ITK ERROR: TransformToDisplacementFieldFilter(0x55578b3cac50): Input Transform is required but not set.

Then, I used this instead:

displ_filt.SetTransform(registr_transform)
displ_filt.Update()
displ_field_out = displ_filt.GetOutput()

To save to a file, I naïvely used this:

displ_writer = itk.ImageFileWriter.New(
    Input=displ_field_out, FileName=displ_field_vtk)
displ_writer.Update()

that produces:

RuntimeError: /pkg/insight-toolkit/src/insight-toolkit/Modules/IO/ImageBase/include/itkImageFileWriter.hxx:245:
ITK ERROR: ImageFileWriter(0x555788553d50): Largest possible region does not fully contain requested paste IO regionPaste IO region: ImageIORegion (0x7ffd35280600)
  Dimension: 3
  Index: 0 0 0
  Size: 0 0 0
Largest possible region: ImageRegion (0x7ffd35280760)
  Dimension: 3
  Index: [0, 0, 0]
  Size: [0, 0, 0]

I tried other approaches, but I’m sure that expanding on my mistakes is of no use :stuck_out_tongue: . How do I save the results? (is what I did to get them the right way?). Thank you again :slight_smile: .