ANTsX / ANTsR

R interface to the ANTs biomedical image processing library
https://antsx.github.io/ANTsR
Apache License 2.0
128 stars 35 forks source link

WISH: Add antsApplyTransformsToPoints to ANTsR #45

Closed zarquon42b closed 9 years ago

zarquon42b commented 9 years ago

Hi, as I am mostly dealing with Volume and surface data, I momentarily am using a wrapper called antsTransformPoints* (it is an S3 function) calling the command line tool antsApplyTransformsToPoints to apply the transforms to point sets. It takes care of IJK to RAS transform and works on matrices and meshes of class "mesh3d". Would it be a big issue to implement this in ANTsR?

*) vert2points used from Morpho is simply

vert2points  <- function (mesh) {
    out <- t(mesh$vb[1:3, ])
    return(out)
}

Best Stefan

stnava commented 9 years ago

I am in agreement about this and put it on the to do list. On Apr 22, 2015 9:18 AM, "Stefan Schlager" notifications@github.com wrote:

Hi, as I am mostly dealing with Volume and surface data, I momentarily am using a wrapper called antsTransformPoints* https://github.com/zarquon42b/RANTs/blob/master/R/newAntsExample.r#L45 (it is an S3 function) calling the command line tool antsApplyTransformsToPoints to apply the transforms to point sets. It takes care of IJK to RAS transform and works on matrices and meshes of class "mesh3d". Would it be a big issue to implement this in ANTsR?

*) vert2points used from Morpho is simply

vert2points <- function (mesh) { out <- t(mesh$vb[1:3, ]) return(out) }

Best Stefan

— Reply to this email directly or view it on GitHub https://github.com/stnava/ANTsR/issues/45.

jefferis commented 9 years ago

Incidentally, @zarquon42b, have you looked at my NeuroAnatomy Toolbox which needs to handle similar kinds of functionality (transforming points, surfaces, linesets and also volumes) – presently only for the CMTK registration suite but I hope to provide ANTs support (via ANTsR) in due course.

For example there is an xform generic to handle transformation of 3d data using registrations, with methods for a few specific cases. The generics for objects are essentially all the same, see:

https://github.com/jefferis/nat/blob/master/R/xform.R#L63-L78

and rely on two helper functions, xyzmatrix and xyzmatrix<- which are used to get and set vertex information for a variety of types with 3d vertices. For rgl::mesh3d objects (which have a base class shape3d), I have done this via

# get
xyzmatrix.shape3d<-function(x, ...){
  cbind(x$vb[1, ]/x$vb[4, ], x$vb[2, ]/x$vb[4, ], x$vb[3, ]/x$vb[4, ])
}

# set
`xyzmatrix<-.shape3d`<-function(x, value){
  x$vb=t(cbind(value, 1))
  x
}

I would be interested to see if we can learn anything from our respective implementations.

Best wishes,

Greg.

zarquon42b commented 9 years ago

Hi @jefferis , thanks for the tips, I only had a peak at your package but will look closer. Up until now my own work is mostly based on 3d-point sets (landmarks) and triangular meshes. I have implemented a simple way to compute rigid, affine, similarity and tps deforms for meshes/points based on landmark transforms in computeTransform and applyTransform, as well as some elastic and non-elastic icp in my inofficial package mesheR.

Best Stefan

stnava commented 9 years ago

this is now added to antsr ... the behavior is consistent with the chicken example ... i am leaving this issue open in case there is further discussion wrt IJK to RAS or other cases. the basic idea of aatxtp is to transform the first d coordinates and carry along any other information beyond dimension d.

stnava commented 9 years ago

@zarquon42b - added a more detailed example here that may help clarify transformation standards https://github.com/stnava/ANTsR/commit/334b52f8e1c837a1532da692ec645a37a08c0646

stnava commented 9 years ago

assuming this is working well .... so closing.