Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

reroot method added #172

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ S3method(nsoma,neuron)
S3method(nsoma,neuronlist)
S3method(plot3d,catmaidneuron)
S3method(print,catmaid_connection)
S3method(reroot,catmaidneuron)
S3method(soma,neuron)
S3method(soma,neuronlist)
S3method(somaid,neuron)
Expand Down
6 changes: 6 additions & 0 deletions R/catmaid_nat.R
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,12 @@ summary.catmaidneuron<-function(object, ...) {
df
}

#' @export
reroot.catmaidneuron<-function(object, ...) {
n = NextMethod()
copy_tags_connectors(n, object)
}

#' Copy the tag / connector info from a catmaid neuron to a new neuron
#' @description This function is intended primarily for developer use as a way
#' to copy over connector/tag information typically contained in CATMAID
Expand Down
10 changes: 10 additions & 0 deletions tests/testthat/test-nat.R
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,13 @@ test_that("Ops.catmaidneuron behaves", {
t(t(xyzmatrix(connectors(AV4b1)))*c(2,3,4)))
expect_equal((AV4b1*2)/2, AV4b1)
})

test_that("reroot.catmaidneuron works", {
data(AV4b1)
soma <- list(id=2712463, idx=126)
rAV4b1 <- reroot(AV4b1, pointno = soma$id)
# check if new soma has correct index
expect_equal(rAV4b1$StartPoint, soma$idx)
# old soma is no longer without parent
expect_true(rAV4b1$d[AV4b1$StartPoint, "Parent"] != -1)
})