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

manipulate annotations from ngscene #57

Open
jefferis opened this issue Dec 29, 2020 · 1 comment
Open

manipulate annotations from ngscene #57

jefferis opened this issue Dec 29, 2020 · 1 comment

Comments

@jefferis
Copy link
Collaborator

  • Ideally would allow annotations to set and retrieved using the same interface as the csv in the neuroglancer interface i.e. with a data.frame intermediate
  • some columns may need to be compound
@jefferis
Copy link
Collaborator Author

jefferis commented Jan 2, 2021

There was some WIP code. Currently looks like:

decode_annotes <- function(x) {
  if(inherits(x, 'nglayers')) {
    ann=x[[1]]
  } else {
    sc=ngl_decode_scene(x)
    type <- NULL # for R CMD check
    ann=ngl_layers(sc, type=='annotation')[[1]]
  }

  if(!isTRUE(ann$tool=='annotatePoint'))
    stop("Only point annotations can be converted to a dataframe",
         " but you can still process them manually!\n",
         "See ?")
  process_segs <- function(x) {
    if(is.null(x)) x="0"
    if(length(x)>1) x=paste(x, collapse = ", ")
    x
  }
  l = lapply(ann$annotations, function(p)
    tibble::tibble(
      x = p$point[1],
      y = p$point[2],
      z = p$point[3],
      type = p$type,
      segments = process_segs(p$segments),
      id = p$id
    ))
  df=dplyr::bind_rows(l)
  df
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant