Menu

antsApplyTrsnforms inside R

Help
Arman
2013-11-09
2016-01-03
  • Arman

    Arman - 2013-11-09

    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

     
    • stnava

      stnava - 2013-11-09

      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:

      mytx$fwdtransforms
      [1]
      "/var/folders/jc/_ktt55mn2ddcd8bcf88jrf0h0000gn/T//RtmpqFUVbB/Z1Warp.nii.gz"

      [2]
      "/var/folders/jc/_ktt55mn2ddcd8bcf88jrf0h0000gn/T//RtmpqFUVbB/Z0GenericAffine.mat"

      typeof(mytx$fwdtransforms)
      [1] "character"
      mytx$fwdtransforms[[1]]
      [1]
      "/var/folders/jc/_ktt55mn2ddcd8bcf88jrf0h0000gn/T//RtmpqFUVbB/Z1Warp.nii.gz"
      mytx$fwdtransforms[[2]]
      [1]
      "/var/folders/jc/_ktt55mn2ddcd8bcf88jrf0h0000gn/T//RtmpqFUVbB/Z0GenericAffine.mat"

      brian

      On Sat, Nov 9, 2013 at 9:19 AM, Arman armaneshaghi@users.sf.net wrote:

      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


      antsApplyTrsnforms inside Rhttp://sourceforge.net/p/advants/discussion/840261/thread/1187f990/?limit=25#e7be

      Sent from sourceforge.net because you indicated interest in
      https://sourceforge.net/p/advants/discussion/840261/

      To unsubscribe from further messages, please visit
      https://sourceforge.net/auth/subscriptions/

       
      • Arman

        Arman - 2013-11-09

        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:

        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:

        mytx$fwdtransforms
        [1]
        "/var/folders/jc/_ktt55mn2ddcd8bcf88jrf0h0000gn/T//RtmpqFUVbB/Z1Warp.nii.gz"

        [2]
        "/var/folders/jc/_ktt55mn2ddcd8bcf88jrf0h0000gn/T//RtmpqFUVbB/Z0GenericAffine.mat"

        typeof(mytx$fwdtransforms)
        [1] "character"
        mytx$fwdtransforms[[1]]
        [1]
        "/var/folders/jc/_ktt55mn2ddcd8bcf88jrf0h0000gn/T//RtmpqFUVbB/Z1Warp.nii.gz"
        mytx$fwdtransforms[[2]]
        [1]
        "/var/folders/jc/_ktt55mn2ddcd8bcf88jrf0h0000gn/T//RtmpqFUVbB/Z0GenericAffine.mat"

        brian

        On Sat, Nov 9, 2013 at 9:19 AM, Arman armaneshaghi@users.sf.net wrote:

        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

        antsApplyTrsnforms inside Rhttp://sourceforge.net/p/advants/discussion/840261/thread/1187f990/?limit=25#e7be

        Sent from sourceforge.net because you indicated interest in
        https://sourceforge.net/p/advants/discussion/840261/

        To unsubscribe from further messages, please visit
        https://sourceforge.net/auth/subscriptions/

        antsApplyTrsnforms inside R

        Sent from sourceforge.net because you indicated interest in https://sourceforge.net/p/advants/discussion/840261/

        To unsubscribe from further messages, please visit https://sourceforge.net/auth/subscriptions/

         
  • Bryson Reynolds

    Bryson Reynolds - 2016-01-03

    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.

     
MongoDB Logo MongoDB