junyuchen245 / TransMorph_Transformer_for_Medical_Image_Registration

TransMorph: Transformer for Unsupervised Medical Image Registration (PyTorch)
MIT License
442 stars 75 forks source link

Hi @HBB0517 and @M figure but I used something like #61

Open wysjn999 opened 1 year ago

wysjn999 commented 1 year ago
          Hi @HBB0517 and @Mobbyjj, this does not necessarily reproduce the same exact figure but I used something like
import nibabel as nib
flow_image = nib.Nifti1Image(flow.permute(2, 3, 4, 0, 1).cpu().numpy(), affine, header)
nib.save(flow_image, fn) # fn: output filename

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.

_Originally posted by @kvttt in https://github.com/junyuchen245/TransMorph_Transformer_for_Medical_Image_Registration/issues/56#issuecomment-1611917090_

wysjn999 commented 1 year ago

Hi, I was wondering where can I find these affine and header,thank you,Can you give me a link