Open marivas-MRI opened 3 years ago
see ?antsApplyTransforms
Before asking I have tried to follow the instructions and again I have not been able to do it correctly. Could you help me please?
Thank you and excuse me for this kind of questions.
Best,
If you type ?antsApplyTransforms
, you'll see an example that you should try to reproduce before asking about your specific example.
Here's what I do:
First the registration:
ImageA_into_ImageB_reg<-antsRegistration(ImageB, ImageA, typeofTransform = "SyNRA")
First, note that the resulting object: ImageA_into_ImageB_reg itself CONTAINS ImageA transformed into ImageB already. If you enter the name of this object by itself on R's commandline, you get something like:
> ImageA_into_ImageB_reg
$warpedmovout
antsImage
Pixel Type : float
Components Per Pixel: 1
Dimensions : 218x209x255
Voxel Spacing : 0.75x0.75x0.75
Origin : 6.75 6.75 -3.75
Direction : -1 0 0 0 -1 0 0 0 1
$warpedfixout
antsImage
Pixel Type : float
Components Per Pixel: 1
Dimensions : 218x209x255
Voxel Spacing : 0.75x0.75x0.75
Origin : 6.75 6.75 -3.75
Direction : -1 0 0 0 -1 0 0 0 1
$fwdtransforms
[1] "/var/folders/mk/9_clkwx513df94kdv85c25m80000gn/T//RtmpV5JKx3/file8134589d25581Warp.nii.gz"
[2] "/var/folders/mk/9_clkwx513df94kdv85c25m80000gn/T//RtmpV5JKx3/file8134589d25580GenericAffine.mat"
$invtransforms
[1] "/var/folders/mk/9_clkwx513df94kdv85c25m80000gn/T//RtmpV5JKx3/file8134589d25580GenericAffine.mat"
[2] "/var/folders/mk/9_clkwx513df94kdv85c25m80000gn/T//RtmpV5JKx3/file8134589d25581InverseWarp.nii.gz"
$prev_transforms
character(0)
In other words, ImageA_into_ImageB_reg$warpedmovout is (in this case) ImageA warped into ImageB. You can check this by doing:
plot(ImageA_into_ImageB_reg$warpedmovout)
(Similarly ImageA_into_ImageB_reg$warpedfixout is ImageB warped into ImageA)
However, these are created using (I believe) linear interpolation. If you want to use a different kind of interpretation, you'd use antsApplyTransforms, and specify a particular type of interpolation. For example:
ImageA_in_ImageB_nearestNeighbor_interpolation_image<-antsApplyTransforms(ImageB, ImageA, transformlist = ImageA_into_ImageB_reg$fwdtransforms, interpolator = "nearestNeighbor")
This would apply nearest-neighbor interpolation to the transform.
I believe this is correct...
-Tom
Hi,
I have two images (A.nii, B.nii). After perform SyN registration from A.nii to B.nii, I obtained the C0GenericAffine.mat, C1InverseWarp.nii.gz and the C1Warp.nii.gz files.
Now my goal is to apply the registration fields obtained in registration A.nii ---> B.nii to the A.nii image. For that purpose I am trying to use the antsApplyTransforms using this command:
antsApplyTransforms ('B.nii', 'A.nii', transformlist = "C0GenericAffine.mat", interpolator = 'nearestNeighbor', imagetype = 0, whichtoinvert = FALSE, compose = NA, verbose = FALSE)
and the output is
[1] 1
I am very new using ANTsR tools, can anyone suggest to me the correct command to apply the deformation fields to the A.nii image??
Thanks for your help.
Best regards,