# this file defines the class 'antsMatrix' and its associated methods
# C++ type used to represent an element of the matrix pointer to the actual image of C++ type 'itk::image<
# pixeltype , dimension >::Pointer'
setClass(Class = "antsMatrix", representation(elementtype = "character", pointer = "externalptr"))
setMethod(f = "initialize", signature(.Object = "antsMatrix"), definition = function(.Object, elementtype) {
.Call("antsMatrix", elementtype, PACKAGE = "itkImageR")
})
setMethod(f = "as.data.frame", signature(x = "antsMatrix"), definition = function(x) {
lst <- .Call("antsMatrix_asList", x, PACKAGE = "itkImageR")
names(lst)[1:(length(lst) - 1)] <- lst[length(lst)]
lst[[length(lst)]] <- NULL
return(as.data.frame(lst))
})
setMethod(f = "as.list", signature(x = "antsMatrix"), definition = function(x) {
lst <- .Call("antsMatrix_asList", x, PACKAGE = "itkImageR")
names(lst)[1:(length(lst) - 1)] <- lst[length(lst)]
lst[[length(lst)]] <- NULL
return(lst)
})
setGeneric(name = "as.antsMatrix", def = function(object, ...) standardGeneric("as.antsMatrix"))
setMethod(f = "as.antsMatrix", signature(object = "list"), definition = function(object, elementtype) {
return(.Call("antsMatrix_asantsMatrix", object, elementtype, PACKAGE = "itkImageR"))
})
setMethod(f = "as.antsMatrix", signature(object = "data.frame"), definition = function(object, elementtype) {
return(.Call("antsMatrix_asantsMatrix", as.list(object), elementtype, PACKAGE = "itkImageR"))
})
setMethod(f = "as.list", signature(x = "antsMatrix"), definition = function(x) {
lst <- .Call("antsMatrix_asList", x, PACKAGE = "itkImageR")
names(lst)[1:(length(lst) - 1)] <- lst[length(lst)]
lst[[length(lst)]] <- NULL
return(lst)
})
as.list.antsMatrix <- function(x, row.names = NULL, optional = FALSE, ...) {
lst <- .Call("antsMatrix_asList", x, PACKAGE = "itkImageR")
names(lst)[1:(length(lst))] <- lst[length(lst)]
lst[[length(lst)]] <- NULL
return(lst)
}
setAs("antsMatrix", "list", function(from) {
as.list.antsMatrix(from)
})
as.data.frame.antsMatrix <- function(x, row.names = NULL, optional = FALSE, ...) {
lst <- .Call("antsMatrix_asList", x, PACKAGE = "itkImageR")
names(lst)[1:(length(lst))] <- lst[length(lst)]
lst[[length(lst)]] <- NULL
as.data.frame(lst)
}
setAs("antsMatrix", "data.frame", function(from) {
as.data.frame.antsMatrix(from)
})
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.