junyuchen245 / TransMorph_Transformer_for_Medical_Image_Registration

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

How to visualise the flow field #56

Open Mobbyjj opened 1 year ago

Mobbyjj commented 1 year ago

Thank you for providing the codes for Transmorph and complementary files about the comparison studies. I wonder how the flow field in the manuscript is drawn. Could you provide the visualisation codes or any links about this? Thanks. Picture 1

HBB0517 commented 1 year ago

i also want to konw .if you have solution,plz tell me .Thank you very much.

kvttt 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.

Mobbyjj commented 1 year ago

Hi @kvttt, thanks for your reply. I have also seen such code like saving it into the header of a nii or as the transformation mha file in SimpleITK.

Specifically, I just wonder what 'programs' you have mentioned that can draw the colorbar in the second figure (I guess it can be implemented using matplotlib?) . Of course feel free to raise another program with references that has similar visualisation performance.

Cheers!

shy922 commented 1 year ago

Hi @kvttt, thanks for your reply. I have also seen such code like saving it into the header of a nii or as the transformation mha file in SimpleITK.

Specifically, I just wonder what 'programs' you have mentioned that can draw the colorbar in the second figure (I guess it can be implemented using matplotlib?) . Of course feel free to raise another program with references that has similar visualisation performance.

Cheers!

Can you communicate with me? My qq is 1135451439

Mobbyjj commented 1 year ago

I got similar solutions from the optical flow visualisation and hope this can help. [https://github.com/tomrunia/OpticalFlow_Visualization].

HHHuan12138 commented 6 months ago

I got similar solutions from the optical flow visualisation and hope this can help. [https://github.com/tomrunia/OpticalFlow_Visualization].

Hello May I add your qq contact information to communicate with you