Skip to content
Merged
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
2 changes: 1 addition & 1 deletion .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ jobs:
needs: check

- name: Build CMTK
if: ${{matrix.config.os != 'windows-latest'}}
if: ${{matrix.config.os == 'macos-latest'}}
run: sh ./build-cmtk.sh
env:
CC: clang
Expand Down
2 changes: 0 additions & 2 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -402,8 +402,6 @@ importFrom(igraph,"V<-")
importFrom(igraph,E)
importFrom(igraph,V)
importFrom(igraph,add_edges)
importFrom(igraph,as.directed)
importFrom(igraph,as.undirected)
importFrom(igraph,as_edgelist)
importFrom(igraph,bfs)
importFrom(igraph,decompose)
Expand Down
2 changes: 1 addition & 1 deletion R/alphashape3d.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#' \code{triang} entry in \bold{Value} section of
#' \code{\link[alphashape3d]{ashape3d}} docs for details.)
#' @return a \code{\link[rgl]{mesh3d}} object which can be plotted and
#' manipulated using \code{\link{rgl}} and \code{nat} packages.
#' manipulated using \code{rgl} and \code{nat} packages.
#' @export
#'
#' @name as.mesh3d
Expand Down
35 changes: 18 additions & 17 deletions R/cmtk-reformat.R
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ cmtk.targetvolume.default <- function(target, ...) {
}

#' Reformat an image with a CMTK registration using the reformatx tool
#'
#'
#' @details Note that if you are reformatting a mask then you will need to
#' change the interpolation to "nn", since interpolating between e.g. mask
#' levels 72 and 74 with 73 may have unintended consequences. Presently we
Expand All @@ -97,37 +97,38 @@ cmtk.targetvolume.default <- function(target, ...) {
#' @param registrations One or more CMTK format registrations on disk
#' @param output The path to the output image (defaults to
#' \code{"<targetstem>_<floatingstem>.nrrd"})
#' @param mask Whether to treat target as a binary mask (only reformatting
#' @param mask Whether to treat target as a binary mask (only reformatting
#' positive voxels)
#' @param interpolation What interpolation scheme to use for output image
#' @param interpolation What interpolation scheme to use for output image
#' (defaults to linear - see details)
#' @param dryrun Just print command
#' @param Verbose Whether to show cmtk status messages and be verbose about file
#' update checks. Sets command line \code{--verbose} option.
#' @param MakeLock Whether to use a lock file to allow simple parallelisation
#' (see \code{makelock})
#' @param OverWrite Whether to OverWrite an existing output file. One of
#' c("no","update","yes"). When OverWrite='update'
#' \code{\link{RunCmdForNewerInput}} is used to determine if the output is
#' older than any of the input files.
#' @param filesToIgnoreModTimes Input files whose modification time should not
#' @param MakeLock Whether to use a lock file to allow simple parallelisation
#' (see \code{\link[nat.utils]{makelock}})
#' @param OverWrite Whether to OverWrite an existing output file. One of
#' c("no","update","yes"). When OverWrite='update'
#' \code{\link[nat.utils]{RunCmdForNewerInput}} is used to determine if the
#' output is older than any of the input files.
#' @param filesToIgnoreModTimes Input files whose modification time should not
#' be checked when determining if new output is required.
#' @param ... additional arguments passed to CMTK \code{reformatx} after
#' @param ... additional arguments passed to CMTK \code{reformatx} after
#' processing by \code{\link{cmtk.call}}.
#' @inheritParams cmtk.targetvolume
#' @inheritParams xformimage.cmtkreg
#' @importFrom nat.utils makelock removelock RunCmdForNewerInput
#' @seealso \code{\link{cmtk.bindir}, \link{cmtk.call}, \link{makelock},
#' \link{RunCmdForNewerInput}}
#' @seealso \code{\link{cmtk.bindir}}, \code{\link{cmtk.call}},
#' \code{\link[nat.utils]{makelock}},
#' \code{\link[nat.utils]{RunCmdForNewerInput}}
#' @export
#' @return the path to the output image (whether or not it was re-created afresh)
#' or \code{NA_character_} if no output was possible.
#' @return the path to the output image (whether or not it was re-created
#' afresh) or \code{NA_character_} if no output was possible.
#' @examples
#' \dontrun{
#' cmtk.reformatx('myimage.nrrd', target='template.nrrd',
#' registrations='template_myimage.list')
#'
#' # get full listing of command line options
#'
#' # get full listing of command line options
#' system(cmtk.call('reformatx', help=TRUE))
#' }
cmtk.reformatx<-function(floating, registrations, output, target, mask=FALSE,
Expand Down
4 changes: 2 additions & 2 deletions R/graph-nodes.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
#' friends. It is conceived of as slightly lower level and end users would
#' normally use the \code{rootpoints} methods.
#'
#' \code{graph.nodes} should work for any \code{\link{igraph}} object
#' \code{graph.nodes} should work for any \code{\link[igraph]{igraph}} object
#' (including \code{\link{ngraph}} objects, which inherit from \code{igraph}).
#' However the graph must be directed in order to return a root point
#' @param x An \code{\link{ngraph}} or raw \code{\link{igraph}} object
#' @param x An \code{\link{ngraph}} or raw \code{\link[igraph]{igraph}} object
#' @param type one of root, end (which includes root) or branch
#' @param original.ids Use named attribute to return original vertex ids (when
#' available). Set to FALSE when this is not desired.
Expand Down
2 changes: 1 addition & 1 deletion R/im3d.R
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ boundingbox.character<-function(x, ...) {
#' \code{\link{xyzmatrix}} method is defined including \code{matrix} or
#' \code{data.frame} objects describing 3D points as well as specialised
#' classes such as \code{\link{neuron}}, \code{\link{neuronlist}}, \code{rgl}
#' \code{\link{mesh3d}} objects.
#' \code{\link[rgl]{mesh3d}} objects.
#'
#' @export
#' @rdname boundingbox
Expand Down
28 changes: 17 additions & 11 deletions R/interactive.R
Original file line number Diff line number Diff line change
Expand Up @@ -100,20 +100,26 @@ correct_root <- function(someneuronlist, brain = NULL){
#' @description Generate a mesh3d model based on points contained in a
#' neuronlist or neuron object, or another object that consists of 3D points.
#'
#' @param x a neuronlist or neuron object, or another object that consists of 3D points
#' @param x a neuronlist or neuron object, or another object that consists of 3D
#' points
#' @param substrate whether to make the model based on the 3D location of
#' connectors, neuron cable or both. Connectors are pre-synapse locations,
#' e.g. the pre-synapses of a \code{catmaidneuron} from the R package \code{catmaid})
#' connectors, neuron cable or both. Connectors are pre-synapse locations,
#' e.g. the pre-synapses of a \code{catmaidneuron} from the R package
#' \code{catmaid})
#' @param alpha a single value or vector of values for alpha, fed to
#' \code{alphashape3d::ashape3d}. Selection is subsequently interactive.
#' @param auto.selection logical, whether or not to try and remove points based on interactively
#' choosing simple values for clustering.
#' @details Interactive function that allows a users to select points in 3D space from neuronlist/neuron objects,
#' or another object that is coercible in 3D points using \code{\link{xyzmatrix}}. Points can first be automatically chosen, by
#' selecting an integer number of nearest neighbours to find for each point using \code{nabor::\link{knn}}, and then a
#' maximum distance at which nodes can be part of a cluster. Next, \code{\link{select_points}} is used to manually pick desired 3D
#' points. Lastly, \code{alphashape3d::ashape3d} is used to create an alphashape around these points. The user can trial different values for
#' alpha until they get their desired result.
#' @param auto.selection logical, whether or not to try and remove points based
#' on interactively choosing simple values for clustering.
#' @details Interactive function that allows a users to select points in 3D
#' space from neuronlist/neuron objects, or another object that is coercible
#' in 3D points using \code{\link{xyzmatrix}}. Points can first be
#' automatically chosen, by selecting an integer number of nearest neighbours
#' to find for each point using \code{nabor::\link[nabor]{knn}}, and then a
#' maximum distance at which nodes can be part of a cluster. Next,
#' \code{\link{select_points}} is used to manually pick desired 3D points.
#' Lastly, \code{alphashape3d::ashape3d} is used to create an alphashape
#' around these points. The user can trial different values for alpha until
#' they get their desired result.
#' @examples
#' \dontrun{
#' # Make a model based off of fly olfactory projection neuron arbours
Expand Down
6 changes: 3 additions & 3 deletions R/nat-package.R
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
#'
#' \code{neuron} objects containing connected trees can be converted to
#' \code{\link{ngraph}} objects, a lightweight wrapper around the
#' \code{\link{igraph}} library's \code{\link[igraph]{graph}} class that
#' \code{\link[igraph]{igraph}} library's \code{\link[igraph]{graph}} class that
#' preserves 3D coordinate information. This allows neurons to be manipulated
#' based on their graph structure, e.g. by finding all nodes upstream (closer
#' to the root) or downstream of a given node. The \code{\link{as.neuron}}
Expand All @@ -47,7 +47,7 @@
#' \code{\link{plot3d.neuronlist}} and \code{\link{subset.neuronlist}}).
#' Interactive 3D selection of neurons in a neuronlist is also possible using
#' \code{\link{find.neuron}} (which makes use of \code{rgl}'s
#' \code{\link{select3d}} function.
#' \code{\link[rgl]{select3d}} function.
#'
#' \code{neuronlist} objects also provide additional functionality to
#' streamline arithmetic (e.g. scaling all the points in all neurons see
Expand Down Expand Up @@ -165,7 +165,7 @@
#' @seealso \code{\link{neuron}}, \code{\link{dotprops}},
#' \code{\link{neuronlist}}, \code{\link{nlapply}}, \code{\link[nat]{plot3d}},
#' \code{\link{xform}}, \code{\link{im3d}}, \code{\link{read.hxsurf}},
#' \code{\link{rgl}} which is used for visualisation,
#' \code{\link[rgl]{rgl}} which is used for visualisation,
#' \code{\link{fileformats}}, \code{\link{read.neurons}}, \code{\link{cmtk}}.
#' @keywords package
#' @import rgl graphics grDevices utils
Expand Down
6 changes: 3 additions & 3 deletions R/ndigest.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
#' machine on which the digest is being computed.
#' @param x Object for which a normalised digest will be computed.
#' @param ... Additional arguments passed to methods and then on to
#' \code{\link{digest}}
#' \code{\link[digest]{digest}}
#' @return A character string containing the digest of the supplied object
#' computed by \code{\link{digest}}.
#' computed by \code{\link[digest]{digest}}.
#' @export
#' @importFrom digest digest
#' @seealso \code{\link{digest}}
#' @seealso \code{\link[digest]{digest}}
ndigest<-function(x, ...) UseMethod('ndigest')

#' @details \code{ndigest.neuronlistfh} only considers the \code{keyfilemap} and
Expand Down
3 changes: 1 addition & 2 deletions R/neuron-io-amira.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# read neurons in the format produced by Amira skeletonize plugin
#' @importFrom igraph as.undirected
read.neuron.hxskel<-function(file, ...){
ndata=read.amiramesh(file)
required_fields=c("Coordinates", "NeighbourCount", "Radii", "NeighbourList")
Expand Down Expand Up @@ -40,7 +39,7 @@ read.neuron.hxskel<-function(file, ...){
doubleg=ngraph(el, d$PointNo, directed=TRUE)
# TODO see if we can make appropriate directed graph rather than converting
# to undirected.
ug=as.undirected(doubleg, mode='collapse')
ug=as_undirected_nat(doubleg, mode='collapse')
if(!inherits(ug,'ngraph')) class(ug)=c("ngraph",class(ug))
n=as.neuron(ug, vertexData=d, origin=Origin, InputFileName=file, ... )
n
Expand Down
36 changes: 18 additions & 18 deletions R/neuron-plot.R
Original file line number Diff line number Diff line change
Expand Up @@ -254,19 +254,20 @@ NULL
#' Note that sometimes (parts of) objects seem to disappear after panning and
#' zooming. See help for \code{\link{pan3d}}.
#'
#' \code{\link{rgl}} and \code{\link[plotly:plot_ly]{plotly}} have quite
#' \code{\link[rgl]{rgl}} and \code{\link[plotly:plot_ly]{plotly}} have quite
#' different models for how to handle the active plot. \code{nopen3d} and
#' \code{\link{nclear3d}} allow you to treat them more similarly. Use them
#' wherever you use the rgl \code{clear3d} and \code{open3d} commands and your
#' could she be able to run with both \bold{plotly} or \bold{rgl} as the
#' wherever you use the rgl \code{\link[rgl]{clear3d}} and
#' \code{\link[rgl]{open3d}} commands and your
#' code should be able to run with both \bold{plotly} or \bold{rgl} as the
#' \code{plotengine}.
#'
#' @param bgcol background colour
#' @param FOV field of view
#' @param ... additional options passed to open3d
#' @return current rgl device
#' @export
#' @seealso \code{\link{open3d},\link{pan3d}}, \code{\link{nclear3d}}
#' @seealso \code{\link[rgl]{open3d}, \link{pan3d}}, \code{\link{nclear3d}}
nopen3d<- function(bgcol='white', FOV=0, ...){
res=open3d(mouseMode=c("trackball", "user", "zoom", "pull"), FOV=FOV, ...)
bg3d(col=bgcol)
Expand All @@ -282,7 +283,7 @@ nopen3d<- function(bgcol='white', FOV=0, ...){
#' @param extramat An optional extra transformation matrix to be applied after
#' the one implied by the viewpoint argument.
#' @param ... additional arguments passed to \code{\link[rgl]{par3d}}
#' @seealso \code{\link{nopen3d}}, \code{\link{view3d}}
#' @seealso \code{\link{nopen3d}}, \code{\link[rgl]{view3d}}
#' @export
#' @importFrom rgl rotationMatrix scaleMatrix par3d
#' @examples
Expand Down Expand Up @@ -319,17 +320,17 @@ nview3d <- function(viewpoint=c("frontal", "anterior", "dorsal", "ventral",
}

#' Some useful extensions / changes to rgl defaults
#'
#'
#' Set up pan call back for current rgl device
#'
#'
#' Copied verbatim from ?rgl.setMouseCallbacks for rgl version 0.92.892 Mouse
#' button 2 is right and button 3 is middle (accessed by Meta/Alt key)
#'
#' Note that sometimes (parts of) objects seem to disappear after panning and
#' zooming. The example in \code{\link{rgl.setMouseCallbacks}} from which this
#' is copied includes a note that "this doesn't play well with rescaling"
#'
#' Note that sometimes (parts of) objects seem to disappear after panning and
#' zooming. The example in \code{\link[rgl]{rgl.setMouseCallbacks}} from which
#' this is copied includes a note that "this doesn't play well with rescaling"
#' @param button Integer from 1 to 3 indicating mouse button
#' @seealso \code{\link{rgl.setMouseCallbacks}}
#' @seealso \code{\link[rgl]{rgl.setMouseCallbacks}}
#' @author Duncan Murdoch
#' @export
#' @examples
Expand Down Expand Up @@ -599,7 +600,7 @@ plot3d.boundingbox <- function(x, col='black',

#' Clear the rgl or plotly 3D scene
#'
#' @details \code{\link{rgl}} and \code{\link[plotly:plot_ly]{plotly}} have
#' @details \code{\link[rgl]{rgl}} and \code{\link[plotly:plot_ly]{plotly}} have
#' quite different models for how to handle the active plot. \code{nclear3d}
#' and \code{\link{nopen3d}} allow you to treat them more similarly. Use them
#' wherever you use the rgl \code{clear3d} and \code{open3d} commands and your
Expand Down Expand Up @@ -649,12 +650,11 @@ check_plotengine <- function(plotengine) {
#' Plot 3d representation of neuron (ngraph) with directed edges
#'
#' @param x A \code{\link{ngraph}} object
#' @param type They type of arrows (lines by default, see \code{\link{arrow3d}}
#' for details).
#' @param type They type of arrows (lines by default, see
#' \code{\link[rgl]{arrow3d}} for details).
#' @param soma radius of soma (or \code{FALSE} to suppress plotting)
#' @param labels Whether to label nodes/all points with their raw index (not
#' id)
#' @param ... Additional arguments passed to \code{\link{arrow3d}}
#' @param labels Whether to label nodes/all points with their raw index (not id)
#' @param ... Additional arguments passed to \code{\link[rgl]{arrow3d}}
#'
#' @export
#'
Expand Down
6 changes: 4 additions & 2 deletions R/neuron.R
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,16 @@
#' plot(as.neuron(gstem))
#'
#' # but if you had an undirected graph
#' ug=igraph::as.undirected(gstem)
#' if(utils::packageVersion('igraph')>='2.1.0') {
#' ug=igraph::as_undirected(gstem)
#' # you get a warning because there is no explicit origin for the graph
#' as.neuron(ug)
#'
#' # If you need finer control of the conversion process
#' gstem2=as.ngraph(ug, root = 10)
#' plot(gstem2)
#' plot(as.neuron(gstem2))
#' }
neuron<-function(d, NumPoints=nrow(d), StartPoint, BranchPoints=integer(), EndPoints,
SegList, SubTrees=NULL, InputFileName=NULL, NeuronName=NULL, ...,
MD5=TRUE){get
Expand Down Expand Up @@ -208,7 +210,7 @@ normalise_swc<-function(x, requiredColumns=c('PointNo','Label','X','Y','Z','W','
#' @export
#' @importFrom igraph V V<- vcount decompose
#' @rdname neuron
#' @seealso \code{\link{dfs}, \link{as.seglist}}
#' @seealso \code{\link[igraph]{dfs}, \link{as.seglist}}
as.neuron.ngraph<-function(x, vertexData=NULL, origin=NULL, Verbose=FALSE, ...){
# translate origin into raw vertex id if necessary
if(length(origin)){
Expand Down
11 changes: 6 additions & 5 deletions R/neuronlist.R
Original file line number Diff line number Diff line change
Expand Up @@ -396,13 +396,14 @@ as.data.frame.neuronlist<-function(x, row.names = names(x), optional = FALSE, ..
#' overridden for the current session by setting the value of
#' \code{options(nat.progressbar)} (see examples). Values of \code{T} and
#' \code{F} are aliases for 'text' and 'none', respectively.
#'
#'
#' @section Progress bar: There are currently two supported approaches to
#' defining progress bars for \code{nlapply}. The default (when
#' \code{progress="auto"}) now uses a progress bar built using
#' \code{\link{progress_bar}} from the progress package, which can be highly
#' customised. The alternative is to use the progress bars distributed
#' directly with the \code{plyr} package such as \code{\link{progress_text}}.
#' \code{\link[progress]{progress_bar}} from the progress package, which can
#' be highly customised. The alternative is to use the progress bars
#' distributed directly with the \code{plyr} package such as
#' \code{\link[plyr]{progress_text}}.
#'
#' In either case the value of the \code{.progress} argument must be a
#' character vector which names a function. According to \code{plyr}'s
Expand Down Expand Up @@ -526,7 +527,7 @@ nlapply<-function (X, FUN, ..., subset=NULL, OmitFailures=NA,
#' @export
#' @rdname nlapply
#' @description \code{progress_natprogress} provides a progress bar compatible
#' with the \code{progress::\link{progress_bar}}.
#' with the \code{progress::\link[progress]{progress_bar}}.
progress_natprogress <- function(...) {
pb <- NULL
list(
Expand Down
Loading
Loading