where flow is the output flow field from the model. affine and header are the affine and header matrices from the target image .nii file. permute(2, 3, 4, 0, 1) is performed to transpose the flow field such that the order of dimensions agrees with nifti convention. Finally, the output .nii file can be opened in ITK-Snap or similar programs to visualize the flow field.
where
flow
is the output flow field from the model.affine
andheader
are the affine and header matrices from the target image .nii file.permute(2, 3, 4, 0, 1)
is performed to transpose the flow field such that the order of dimensions agrees with nifti convention. Finally, the output .nii file can be opened in ITK-Snap or similar programs to visualize the flow field._Originally posted by @kvttt in https://github.com/junyuchen245/TransMorph_Transformer_for_Medical_Image_Registration/issues/56#issuecomment-1611917090_