xform is designed to operate on a variety of data types, especially
objects encapsulating neurons.
xform depends on two specialised
These are user visible any contain some useful documentation, but should only
be required for expert use; in almost all circumstances, you should use only
xform.character is designed to work with files on disk.
Presently it is restricted to images, although other datatypes may be
supported in future.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
xform(x, reg, ...) ## Default S3 method: xform(x, reg, na.action = c("warn", "none", "drop", "error"), ...) ## S3 method for class 'character' xform(x, reg, ...) ## S3 method for class 'list' xform(x, reg, FallBackToAffine = TRUE, na.action = "error", ...) ## S3 method for class 'shape3d' xform(x, reg, FallBackToAffine = TRUE, na.action = "error", ...) ## S3 method for class 'neuron' xform(x, reg, FallBackToAffine = TRUE, na.action = "error", ...) ## S3 method for class 'data.frame' xform(x, reg, subset = NULL, ...) ## S3 method for class 'dotprops' xform(x, reg, FallBackToAffine = TRUE, ...) ## S3 method for class 'neuronlist' xform(x, reg, subset = NULL, ..., OmitFailures = NA, VectoriseRegistrations = FALSE, TransformDFCoords = TRUE)
an object to transform
A registration defined by a matrix, a function, a
additional arguments passed to methods and eventually to
How to handle NAs. NB drop may not work for some classes.
Whether to use an affine transform when a cmtk warping transformation fails.
Whether to omit neurons for which
If the metadata
Methods are provided for some specialised S3 classes. Further
methods can of course be constructed for user-defined S3 classes. However
this will probably not be necessary if the
`xyzmatrix<-` generics are suitably overloaded and the S3
object inherits from
Note that given the behaviour of the
xyzmatrix functions, the
xform.data.frame method will transform the x,y,z or X,Y,Z columns of
a data.frame if the data.frame has more than 3 columns, erroring out if no
such unique columns exist.
TODO get this to work for matrices with more than 3 columns by working on xyzmatrix definition.
xform.dotprops method, dotprops tangent vectors will
be recalculated from scratch after the points have been transformed (even
though the tangent vectors could in theory be transformed more or less
correctly). When there are multiple transformations,
xform will take
care to carry out all transformations before recalculating the vectors.
xform.neuronlist, if you want to apply a different
registration to each object in the neuronlist
x, then you should use
x's attached data.frame contains columns called x,y,z or X,Y,Z
then these are assumed to be coordinates and also transformed when
TransformDFCoords=TRUE (the default). This provides a mechanism for
transforming the soma positions of
neuronlist objects containing
dotprops objects (which do not otherwise store the soma position).
Note that if transformation fails, a warning will be issued and the points
will be replaced with
reg is a character vector, xform's specialised downstream
functions will check to see if it defines a path to one (or more)
registrations on disk. These can be of two classes
reglist objects saved in R's
RDS format (see
readRDS) which can contain any sequence of registrations
supported by nat.
If the path does indeed point to a CMTK registration, this method will hand
xformimages.cmtkreg. In this
case, the character vector may optionally have an attribute, 'swap', a
logical vector of the same length indicating whether the transformation
direction should be swapped. At the moment only CMTK registration files are
reg is a character vector of length >=1 defining a sequence of
registration files on disk they should proceed from sample to reference.
reg is a function, it should have a signature like
myfun(x,), ... where the
... must be provided in
order to swallow any arguments passed from higher level functions that are
not relevant to this particular transformation function.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
## Not run: kc1=kcs20[] kc1.default=xform(kc1,function(x,...) x) stopifnot(isTRUE(all.equal(kc1,kc1.default))) kc1.5=xform(kc1,function(x,...) x, k=5) stopifnot(isTRUE(all.equal(kc1.5,kc1.default))) kc1.20=xform(kc1,function(x,...) x, k=20) stopifnot(!isTRUE(all.equal(kc1,kc1.20))) # apply two registrations converting sample->IS2->JFRC2 reg_seq=c("IS2_sample.list", "JFRC2_IS2.list") xform(kc1, reg_seq) # apply two registrations, swapping the direction of the second one # i.e. sample -> IS2 -> FCWB reg_seq=structure(c("IS2_sample.list", "IS2_FCWB.list"), swap=c(FALSE, TRUE)) xform(kc1, reg_seq) ## End(Not run) ## Not run: # apply reg1 to Cell07PNs[], reg2 to Cell07PNs[] etc regs=c(reg1, reg2, reg3) nx=xform(Cell07PNs[1:3], reg=regs, VectoriseRegistrations=TRUE) ## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.