Ok, so I had this same problem. This thread slightly helped, but I want to make explicit what helped me fix the problem
In R, when you run: antsApplyTransforms()
it provides the example warpedimg<-antsApplyTransforms( fixed=img1 , moving=img2 , transformlist=list("my0GenericAffine.mat","my1Warp.nii.gz") )
But, when I use list() to create the transformlist I get that error. Error in file.exists(transformlist[i]) : invalid 'file' argument
FYI, translist=list("my0GenericAffine.mat","my1Warp.nii.gz")
typeof(translist)
[1] "list")
However, when I create the transform list this way: translist<-"my1Warp.nii.gz"
translist[2]<-"my0GenericAffine.mat"
FYI typeof(translist)
[1] "character"
and call warpedimg<-antsApplyTransforms(fixed=img1, moving=img2, transformlist=translist)
it works fine.
Hope that helps someone else.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi,
I'm having trouble passing two files (one affine transformation and one
warp file) to ANTsR to apply serial transformations, my command is:
outimg <- antsApplyTransforms( fixed=t1 , moving=t2 ,
transformlist=list("path/to/file.mat",
"/path/to/file/file-reg1Warp.nii.gz"))
The error that I get is:
Error in file.exists(transformlist[i]) : invalid 'file' argument
However outside of R the above files work good with antsApplyTransforms.
Any input is greatly appreciated.
All the best,
Arman
here is an example from ?antsRegistration
fi<-antsImageRead( getANTsRData('r16') ,2)
mi<-antsImageRead( getANTsRData('r64') ,2)
mytx<-antsRegistration(fixed=fi , moving=mi , typeofTransform =
c("SyN"), outprefix=paste(tempdir(),"/Z",sep=''))
mywarpedimage<-antsApplyTransforms(fixed=fi,moving=mi,transformlist=mytx$fwdtransforms)
what is different about your case and this one?
this one works fine .... here is the representation:
[2]
"/var/folders/jc/_ktt55mn2ddcd8bcf88jrf0h0000gn/T//RtmpqFUVbB/Z0GenericAffine.mat"
brian
On Sat, Nov 9, 2013 at 9:19 AM, Arman armaneshaghi@users.sf.net wrote:
Thanks Brian! I was a bit ignorant
Sent from a mobile device, please excuse my brevity/misspellings.
On Nov 9, 2013, at 6:48 PM, "stnava" stnava@users.sf.net wrote:
Ok, so I had this same problem. This thread slightly helped, but I want to make explicit what helped me fix the problem
In R, when you run:
antsApplyTransforms()it provides the example
warpedimg<-antsApplyTransforms( fixed=img1 , moving=img2 , transformlist=list("my0GenericAffine.mat","my1Warp.nii.gz") )But, when I use
list()to create thetransformlistI get that error.Error in file.exists(transformlist[i]) : invalid 'file' argumentFYI,
translist=list("my0GenericAffine.mat","my1Warp.nii.gz") typeof(translist) [1] "list")However, when I create the transform list this way:
translist<-"my1Warp.nii.gz" translist[2]<-"my0GenericAffine.mat"FYI
typeof(translist) [1] "character"and call
warpedimg<-antsApplyTransforms(fixed=img1, moving=img2, transformlist=translist)it works fine.
Hope that helps someone else.