Skip to content

Commit

Permalink
fixes to banc_updateids
Browse files Browse the repository at this point in the history
  • Loading branch information
alexanderbates committed Aug 15, 2024
1 parent ac9ce62 commit c20dd0e
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 4 deletions.
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ export(banc_segid_from_cellid)
export(banc_set_token)
export(banc_side_view)
export(banc_to_JRC2018F)
export(banc_updateids)
export(banc_upload_mesh)
export(banc_view)
export(banc_vnc_side_view)
Expand Down
1 change: 1 addition & 0 deletions R/ggplot2.R
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#' @param filename Optional. If provided, the plot will be saved to this file. If NULL (default), the plot will be displayed but not saved.
#' @param width Numeric. The width of the output plot in inches. Default is 16.
#' @param height Numeric. The height of the output plot in inches. Default is 16.
#' @param alpha Vector of alpha values for neurons 1, 2 and 3. If a single value, applied to all.
#'
#' @return If filename is NULL, the function returns a ggplot object. If filename is provided, the function saves the plot and returns invisibly.
#'
Expand Down
16 changes: 13 additions & 3 deletions R/ids.R
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ banc_leaves <- function(x, integer64=TRUE, ...) {
#' @examples
#' \dontrun{
#' # a point from neuroglancer, should map to 648518346498932033
#' banc_xyz2id(cbind(34495, 82783, 1954), rawcoords=TRUE)
#' banc_xyz2id(cbind(438976,985856,215955), rawcoords=FALSE)
#' }
banc_xyz2id <- function(xyz,
rawcoords=FALSE,
Expand Down Expand Up @@ -111,7 +111,6 @@ banc_islatest <- function(x, timestamp=NULL, ...) {
with_banc(flywire_islatest(x=x, timestamp = timestamp, ...))
}


#' Find the latest id for a banc root id
#'
#' @inheritParams fafbseg::flywire_latestid
Expand All @@ -128,6 +127,17 @@ banc_latestid <- function(rootid, sample=1000L, cloudvolume.url=NULL, Verbose=FA
with_banc(fafbseg::flywire_latestid(rootid=rootid, sample = sample, Verbose=Verbose, ...))
}

#' @export
#' @rdname banc_latestid
banc_updateids <- function(rootid, ...){
old <- !banc_islatest(rootid, ...)
old[is.na(old)] <- TRUE
#cat("latest/outdated: ",table(old))
updated <- banc_latestid(x[old], ...)
rootid[old] <- updated
rootid
}

#' Return a vector of banc root ids from diverse inputs
#'
#' @param x A data.frame, URL or vector of ids
Expand All @@ -141,7 +151,7 @@ banc_latestid <- function(rootid, sample=1000L, cloudvolume.url=NULL, Verbose=FA
#' banc_ids(data.frame(rootid="648518346474360770"))
banc_ids <- function(x, integer64=NA) {
if(is.data.frame(x)) {
colstocheck=c("rootid", "id", "pre_id", "post_id")
colstocheck=c("rootid", "id", "pre_id", "post_id", "root_id")
for(col in colstocheck) {
if(col %in% colnames(x))
return(banc_ids(x[[col]], integer64 = integer64))
Expand Down
3 changes: 3 additions & 0 deletions man/banc_latestid.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/banc_neuron_comparison_plot.Rd

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

2 changes: 1 addition & 1 deletion man/banc_xyz2id.Rd

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

0 comments on commit c20dd0e

Please sign in to comment.