Skip to content

Commit

Permalink
Merge branch 'master' into so_fix
Browse files Browse the repository at this point in the history
  • Loading branch information
dokato committed Jun 2, 2021
2 parents 0f5dfe3 + c203a26 commit 0d77b02
Show file tree
Hide file tree
Showing 14 changed files with 38 additions and 9 deletions.
3 changes: 2 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ Authors@R: c(
person("Gregory","Jefferis", email="jefferis@gmail.com",
role = c("aut", "cre"), comment = c(ORCID = "0000-0002-0587-9355")),
person("James", "Manton", role = c("aut"), comment = c(ORCID = "0000-0001-9260-3156")),
person("Sridhar", "Jagannathan", role = c("aut"), comment = c(ORCID = "0000-0002-2078-1145"))
person("Sridhar", "Jagannathan", role = c("aut"), comment = c(ORCID = "0000-0002-2078-1145")),
person("Dominik", "Krzeminski", role = c("ctb"), comment = c(ORCID = "0000-0003-4568-0583"))
)
URL: https://github.com/natverse/nat, https://natverse.github.io
BugReports: https://github.com/natverse/nat/issues
Expand Down
2 changes: 2 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ S3method("xyzmatrix<-",default)
S3method("xyzmatrix<-",dotprops)
S3method("xyzmatrix<-",hxsurf)
S3method("xyzmatrix<-",igraph)
S3method("xyzmatrix<-",mesh3d)
S3method("xyzmatrix<-",neuron)
S3method("xyzmatrix<-",neuronlist)
S3method("xyzmatrix<-",shape3d)
Expand Down Expand Up @@ -184,6 +185,7 @@ S3method(xform,data.frame)
S3method(xform,default)
S3method(xform,dotprops)
S3method(xform,list)
S3method(xform,mesh3d)
S3method(xform,neuron)
S3method(xform,neuronlist)
S3method(xform,shape3d)
Expand Down
3 changes: 3 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ Some new features and bug fixes. Thanks to @PostPreAndCleft and @artxz for repor
* Fix bug `pan3d()` not found (#447)
* Added support for multi material binary Amira surface files while fixing
"Bad triangle numbers" error in `read.hxsurf()` (#445)
* Add `xform()` and `xyzmatrix<-()` methods for `mesh3d` objects
* Don't clean `mesh3d` objects read from ply files by default
* `summary.neuron` now prints number of subtrees (#462, @dokato)

# nat 1.10.2

Expand Down
4 changes: 2 additions & 2 deletions R/dotprops.R
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ dotprops.neuronlist<-function(x, ..., OmitFailures=NA) {
#' @param resample When finite, a new length to which all segmented edges will
#' be resampled. See \code{\link{resample.neuron}}.
#' @param topo flag that says whether or not to add topological features
#' (inverted Strahler's Order and distance from soma)
#' (reversed Strahler Order and distance from soma)
#' @rdname dotprops
dotprops.neuron<-function(x, Labels=NULL, resample=NA, topo=FALSE, ...) {
if(is.finite(resample)) x=resample(x, stepsize = resample)
Expand Down Expand Up @@ -212,7 +212,7 @@ get_distance_to_soma <- function(n) {
#' behaviour for different classes of input object, \code{TRUE} always uses
#' labels when an incoming object has them and \code{FALSE} never uses labels.
#' @param na.rm Whether to remove \code{NA} points (default FALSE)
#' @param topo_features topological features of each dotprop
#' @param topo_features topological features of each dotprops
#' @importFrom nabor knn
#' @references The dotprops format is essentially identical to that developed
#' in:
Expand Down
7 changes: 5 additions & 2 deletions R/neuron-mesh.R
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
# internal function
# read a mesh representing a neuron and return a mesh3d object
read.neuron.mesh <- function(x, ...) {
read.neuron.mesh <- function(x, updateNormals=FALSE, clean=FALSE, ...) {
ext=tools::file_ext(x)

if(ext=="ply") {
if(!requireNamespace('Rvcg', quietly = TRUE))
stop("Please install suggested library Rvcg to read .ply files!")
Rvcg::vcgPlyRead(x, updateNormals=F, ...)
m=Rvcg::vcgPlyRead(x, updateNormals=updateNormals, clean=clean, ...)
if(!inherits(m, 'shape3d'))
class(m)=union(class(m), 'shape3d')
m
} else if(ext=="obj") {
if(!requireNamespace('readobj', quietly = TRUE))
stop("Please install suggested library readobj to read .obj files!")
Expand Down
5 changes: 4 additions & 1 deletion R/summary.R
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ summary.neuronlist<-function(object, ..., include.attached.dataframe=FALSE) {
#'
#' \item{cable.length}
#'
#' \item{nTrees}
#'
#' }
#' @export
#' @examples
Expand All @@ -50,7 +52,8 @@ summary.neuron<-function(object, ...) {
segments=object$NumSegs,
branchpoints=length(object$BranchPoints),
endpoints=length(object$EndPoints),
cable.length=total_cable(object))
cable.length=total_cable(object),
nTrees=ifelse("nTrees" %in% names(object), object$nTrees, 1))
}

#' @export
Expand Down
9 changes: 9 additions & 0 deletions R/xform.R
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,10 @@ xform.list<-function(x, reg, FallBackToAffine=TRUE, na.action='error', ...){
#' @rdname xform
xform.shape3d<-xform.list

#' @export
#' @rdname xform
xform.mesh3d<-xform.list

#' @export
#' @rdname xform
xform.neuron<-xform.list
Expand Down Expand Up @@ -512,6 +516,11 @@ xyzmatrix.mesh3d<-function(x, ...){
x
}

#' @export
#' @rdname xyzmatrix
`xyzmatrix<-.mesh3d`<-`xyzmatrix<-.shape3d`


#' @export
#' @rdname xyzmatrix
`xyzmatrix<-.neuronlist`<-function(x, value){
Expand Down
4 changes: 2 additions & 2 deletions man/dotprops.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions man/summary.neuron.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions man/xform.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions man/xyzmatrix.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion tests/testthat/test-summary.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ context("summary")

test_that("summary.neuronlist behaves", {
expect_is(s <- summary(Cell07PNs), 'data.frame')
expect_equal_to_reference(s, file = 'testdata/summary_cell07pns.rda', tolerance=1e-3)
expect_equal_to_reference(s, file = 'testdata/summary_cell07pns.rds', tolerance=1e-3)
expect_is(summary(kcs20, veclength=1.2), 'data.frame')
})

Expand Down
Binary file removed tests/testthat/testdata/summary_cell07pns.rda
Binary file not shown.
Binary file added tests/testthat/testdata/summary_cell07pns.rds
Binary file not shown.

0 comments on commit 0d77b02

Please sign in to comment.