Skip to content

Instantly share code, notes, and snippets.

@satra
Created July 21, 2011 00:50
Show Gist options
  • Save satra/1096274 to your computer and use it in GitHub Desktop.
Save satra/1096274 to your computer and use it in GitHub Desktop.
combining bbregister, fsl and ants to warp functional images

ANTS : http://picsl.upenn.edu/ANTS/ c3d : http://www.itksnap.org/pmwiki/pmwiki.php?n=Convert3D.Convert3D

export PATH=/software/ANTS-dev:$PATH

c3d_affine_tool -ref [A] -src [B] bbreg.mat -fsl2ras -oitk fsl2antsAffine.txt

WarpImageMultiTransform 3 [B] [C] -R [D] [A_Warp].nii.gz [A_Affine].txt fsl2antsAffine.txt
  • A = your structural brain/orig.mgz, but converted to nii. you should already have this in your ANTS output
  • B = con/t/z image that you want to warp
  • bbreg.mat = when your bbregister node has out_fsl_file = True
  • C = warped con/t/z image
  • D = ANTS template or other template to which you computed the ANTS warp (unless you have another affine transform see note below)
  • A_Warp = should equal the Warp fields from running ANTS, they should be called sth_Warp[xyz]vec.nii.gz. you simply need to provide sth_Warp.nii.gz
  • A_Affine = there should also be an affine transform in the place where ANTS was run.

Note

if you also have an affine transform using flirt for your own template to MNI space and you did not use the MNI spaced template as your target

c3d_affine_tool -ref [E] -src [D] flirt.mat -fsl2ras -oitk fsl2antsTemplateAffine.txt

WarpImageMultiTransform 3 [B] [C] -R [E] fsl2antsTemplateAffine.txt [A_Warp].nii.gz [A_Affine].txt fsl2antsAffine.txt
  • E = template in MNI space after flirting
@anbai106
Copy link

@satra @9999sotelom

Hi,

I have a similar use case:

I applied a rigid+deformable transformation for my b0 image to map it on my T1 image.

Now I want to transfer the warp image in ANTS format into FSL format???

I know I can do the inverse using c3d to transfer FSL format into ANTS, but it works only for affine registration, not for non-linear registration.

Do you have any ideas?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment