diff --git a/.Rbuildignore b/.Rbuildignore index d55d7be9..fc4d4fef 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -9,3 +9,9 @@ travisbuildchildren.sh ^build-cmtk.sh$ ^build_docs.r$ ^vignettes/.*pdf$ +^\.httr-oauth$ +^spare$ +^CRAN-RELEASE$ +^.github$ +^codecov\.yml$ +^CRAN-SUBMISSION$ diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml new file mode 100644 index 00000000..f253a277 --- /dev/null +++ b/.github/workflows/R-CMD-check.yaml @@ -0,0 +1,91 @@ +#on: push +on: + push: + branches: + - main + - master + pull_request: + branches: + - main + - master + +name: R-CMD-check + +jobs: + R-CMD-check: + runs-on: ${{ matrix.config.os }} + + name: ${{ matrix.config.os }} (${{ matrix.config.r }}) + + strategy: + fail-fast: false + matrix: + config: + #- {os: windows-latest, r: 'release', rglusenull: "true"} + - {os: macOS-latest, r: 'release', rglusenull: "true"} + - {os: ubuntu-20.04, r: 'release', rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest", rglusenull: "true", codecov: "true"} + #- {os: ubuntu-20.04, r: 'devel', rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"} + + env: + R_REMOTES_NO_ERRORS_FROM_WARNINGS: true + RSPM: ${{ matrix.config.rspm }} + GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} + RGL_USE_NULL: ${{ matrix.config.rglusenull }} + + steps: + - uses: actions/checkout@v2 + + - uses: r-lib/actions/setup-r@master + with: + r-version: ${{ matrix.config.r }} + + - uses: r-lib/actions/setup-pandoc@master + + - name: Query dependencies + run: Rscript -e "install.packages('remotes')" -e "saveRDS(remotes::dev_package_deps(dependencies = TRUE), 'depends.Rds', version = 2)" + + - name: Cache R packages + if: runner.os != 'Windows' + uses: actions/cache@v1 + with: + path: ${{ env.R_LIBS_USER }} + key: ${{ runner.os }}-r-${{ matrix.config.r }}-${{ hashFiles('depends.Rds') }} + restore-keys: ${{ runner.os }}-r-${{ matrix.config.r }}- + + - name: Install system dependencies + if: runner.os == 'Linux' + env: + RHUB_PLATFORM: linux-x86_64-ubuntu-gcc + run: | + Rscript -e "remotes::install_github('r-hub/sysreqs')" + sysreqs=$(Rscript -e "cat(sysreqs::sysreq_commands('DESCRIPTION'))") + sudo -s eval "$sysreqs" + + - name: Install Covr + run: Rscript -e "remotes::install_github('r-lib/covr')" + + - name: Build CMTK + run: sh ./build-cmtk.sh + env: + MAKEFLAGS: "-j2" + + - name: Install dependencies + run: Rscript -e "library(remotes)" -e "update(readRDS('depends.Rds'))" -e "remotes::install_cran('rcmdcheck')" + + - name: Install manual dependencies + run: Rscript -e "remotes::install_github('natverse/natcpp')" + + - name: Check + run: Rscript -e "rcmdcheck::rcmdcheck(args = c('--no-manual', '--as-cran'), error_on = 'error', check_dir = 'check')" + + - name: Upload check results + if: failure() + uses: actions/upload-artifact@master + with: + name: ${{ runner.os }}-r${{ matrix.config.r }}-results + path: check + + - name: Test coverage + if: matrix.config.codecov + run: | + Rscript -e 'covr::codecov(token = "${{secrets.CODECOV_TOKEN}}")' diff --git a/.gitignore b/.gitignore index 119a0f20..e60ede94 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,6 @@ inst/doc *.Rout docs/figs/*.pdf +tests/testthat/Rplots.pdf +.httr-oauth +spare diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index f88525d6..00000000 --- a/.travis.yml +++ /dev/null @@ -1,30 +0,0 @@ -# R for travis: see documentation at https://docs.travis-ci.com/user/languages/r - -language: R -sudo: false -dist: trusty -cache: - packages: true - directories: - - $HOME/usr/local - -r_github_packages: - - jimhester/covr - -env: - global: - - secure: U5L4JHPa5/mpcDjL60XZVDXtT/nQe4lyhCG6pIj7dF8N6iLRO/vh0ChPxZsBhunKaNMnu59MEqn9nvp09kodV7DzW1nNV+UVi2ZtXpAFejHOK6T4d31vGShCnoM5BkTeMp7exX8yfKWw3Zw0JY47sHTLFihYbwUFqsus0aqT0hIK - -before_install: - - bash build-cmtk.sh - -before_script: - - export PATH=$PATH:$HOME/usr/local/bin - - "export DISPLAY=:99.0" - - "sh -e /etc/init.d/xvfb start" - - sleep 3 # give xvfb some time to start - -after_success: - - Rscript -e 'devtools::install();nat::cmtk.mat2dof(version=TRUE)' - - Rscript -e 'library(covr);coveralls(exlusions="R/zzz.R")' - - bash travisbuildchildren.sh diff --git a/DESCRIPTION b/DESCRIPTION index 0440188d..043ef258 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,13 +1,15 @@ Package: nat Type: Package Title: NeuroAnatomy Toolbox for Analysis of 3D Image Data -Version: 1.8.12 +Version: 1.8.25 Authors@R: c( - person("Gregory", "Jefferis", , "jefferis@gmail.com", role = c("aut", "cre")), - person("James", "Manton", role = c("aut")) + 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("Dominik", "Krzeminski", role = c("ctb"), comment = c(ORCID = "0000-0003-4568-0583")) ) -URL: https://github.com/jefferis/nat, http://jefferislab.org -BugReports: https://github.com/jefferis/nat/issues +URL: https://github.com/natverse/nat, https://natverse.org/ +BugReports: https://github.com/natverse/nat/issues Description: NeuroAnatomy Toolbox (nat) enables analysis and visualisation of 3D biological image data, especially traced neurons. Reads and writes 3D images in NRRD and 'Amira' AmiraMesh formats and reads surfaces in 'Amira' hxsurf @@ -24,9 +26,9 @@ Depends: rgl (>= 0.98.1) Imports: nabor, - igraph (>= 0.7.1), + igraph (>= 1.3.0), methods, - filehash, + filehash (>= 2.3), digest, nat.utils (>= 0.4.2), plyr, @@ -38,8 +40,10 @@ Suggests: XML, knitr, rmarkdown, + markdown, MASS, - alphashape3d + alphashape3d, + webshot2 License: GPL-3 LazyData: yes Collate: @@ -84,5 +88,6 @@ Collate: 'xformimage.R' 'xformpoints.R' 'zzz.R' -RoxygenNote: 6.0.1 +RoxygenNote: 7.3.2 +Encoding: UTF-8 VignetteBuilder: knitr diff --git a/NAMESPACE b/NAMESPACE index eb9224b4..827203f3 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -19,6 +19,8 @@ S3method("[<-",neuronlist) S3method("[[",neuronlistfh) S3method("boundingbox<-",default) S3method("data.frame<-",neuronlist) +S3method("materials<-",default) +S3method("materials<-",hxsurf) S3method("xyzmatrix<-",default) S3method("xyzmatrix<-",dotprops) S3method("xyzmatrix<-",hxsurf) @@ -26,6 +28,7 @@ S3method("xyzmatrix<-",igraph) S3method("xyzmatrix<-",neuron) S3method("xyzmatrix<-",neuronlist) S3method("xyzmatrix<-",shape3d) +S3method(PotentialSynapses,dotprops) S3method(all.equal,dotprops) S3method(all.equal,im3d) S3method(all.equal,neuron) @@ -42,6 +45,7 @@ S3method(as.mesh3d,hxsurf) S3method(as.neuron,data.frame) S3method(as.neuron,default) S3method(as.neuron,igraph) +S3method(as.neuron,morphml_cell) S3method(as.neuron,neuron) S3method(as.neuron,ngraph) S3method(as.neuronlist,default) @@ -49,6 +53,7 @@ S3method(as.neuronlist,neuronlistfh) S3method(as.neuronlistfh,neuronlist) S3method(as.ngraph,data.frame) S3method(as.ngraph,igraph) +S3method(as.ngraph,morphml_cell) S3method(as.ngraph,neuron) S3method(as.ngraph,ngraph) S3method(as.seglist,default) @@ -67,6 +72,7 @@ S3method(branchpoints,igraph) S3method(branchpoints,neuron) S3method(c,neuronlist) S3method(c,reglist) +S3method(cmtk.targetvolume,character) S3method(cmtk.targetvolume,default) S3method(cmtk.targetvolume,im3d) S3method(cmtk.targetvolume,list) @@ -107,6 +113,7 @@ S3method(ndigest,neuron) S3method(ndigest,neuronlistfh) S3method(nvertices,default) S3method(nvertices,dotprops) +S3method(nvertices,igraph) S3method(nvertices,neuron) S3method(nvertices,neuronlist) S3method(plot,neuron) @@ -320,24 +327,22 @@ importFrom(digest,digest) importFrom(igraph,"V<-") importFrom(igraph,E) importFrom(igraph,V) -importFrom(igraph,add.edges) -importFrom(igraph,as.directed) -importFrom(igraph,as.undirected) -importFrom(igraph,decompose.graph) +importFrom(igraph,add_edges) +importFrom(igraph,bfs) +importFrom(igraph,decompose) importFrom(igraph,degree) -importFrom(igraph,delete.vertices) +importFrom(igraph,delete_vertices) +importFrom(igraph,dfs) importFrom(igraph,diameter) -importFrom(igraph,get.diameter) -importFrom(igraph,get.shortest.paths) -importFrom(igraph,get.vertex.attribute) -importFrom(igraph,graph.bfs) -importFrom(igraph,graph.dfs) -importFrom(igraph,graph.empty) -importFrom(igraph,is.connected) -importFrom(igraph,is.directed) +importFrom(igraph,distances) +importFrom(igraph,get_diameter) +importFrom(igraph,is_connected) +importFrom(igraph,is_directed) +importFrom(igraph,make_empty_graph) importFrom(igraph,neighborhood) -importFrom(igraph,shortest.paths) +importFrom(igraph,shortest_paths) importFrom(igraph,vcount) +importFrom(igraph,vertex_attr) importFrom(methods,is) importFrom(nabor,knn) importFrom(nat.utils,RunCmdForNewerInput) diff --git a/NEWS b/NEWS index e4db6ffe..0556bc99 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,79 @@ +nat 1.8.25 +========== + +* docs: fix links to external packages as requested by CRAN +* workaround for renamed igraph functions (in v2.1.0) +* workaround for swc files being omitted from tar during check + +nat 1.8.24 +========== + +* workaround for a small regression in igraph 2.0.1 dfs function +* test error reported by CRAN (BDR) +* replace deprecated igraph functions +* add nvertices.igraph method + +nat 1.8.23 +========== + +* fix bug in handling of numeric versions in . r-devel now refuses to compare a +number with a numeric_version +* reported by CRAN (Kurt Hornik, who also kindly pointed out the precise error) + +nat 1.8.22 +========== + +* version bump owing to package archival + +nat 1.8.21 +========== + +* tweaks to the news file format picked up on cran linux pretest + (but strangely not win-devel etc) + +nat 1.8.20 +========== + +* replace deprected rgl functions +* update igraph test for compatability + +nat 1.8.18 +========== + +* Fix errors in `neurons-intro` vignette when pandoc is missing + +nat 1.8.17 +========== + +* Suggest webshot2 to cope with changes in rgl snapshot behaviour (at the request of BDR for CRAN) +* Fix URLs + +nat 1.8.16 +========== + +* Fix further failing URLs from CRAN pre-test + +nat 1.8.15 +========== + +* Fix failing test on CRAN for R 4.1 (thanks to KH, #444). + +nat 1.8.14 +========== + +* Fix failing test on CRAN when Rvcg unavailable (thanks to BDR). + +nat 1.8.13 +========== + +* backports a few urgent fixes to the 1.8 branch +* Fix very slow loading of neurons in neuronlistfh() objects. + Apparently due to a change in behaviour in R 3.6.0 (#402). + Thanks to Shanice Bailey and Lisa Marin for the bug report. +* Fix ndigest check error on CRAN (#411) +* also updates URLs to point to nat's new home organisation on GitHub +https://github.com/natverse. + nat 1.8.12 ========== * Speed up (2-3x) summary.neuron(list) by faster calculation of total cable @@ -8,7 +84,7 @@ nat 1.8.12 nat 1.8.11 ========== -Fixes + * pointsinside fails for points >1e5 from mesh (#354) * as.neuron should work for an igraph made from an ngraph (#356) this is helpful if you e.g. delete nodes/edges from an ngraph object @@ -61,9 +137,8 @@ nat 1.8.8 nat 1.8.7 ========= -This release includes some bug fixes and significantly improved online package -documentation visible at http://jefferis.github.io/nat/ including two vignettes. - +* This release includes some bug fixes and significantly improved online package +documentation visible at http://natverse.github.io/nat/ including two vignettes: * Teach xform and friends to transform soma positions (#206) * Copy attributes (including templatebrains) of neuronlists when subsetting (#310) * Fix error in read.amiramesh for RLE encoded files. (#317) @@ -79,8 +154,7 @@ nat 1.8.6 nat 1.8.5 ========= -The main feature of this release is improved support for nat+CMTK on Windows. - +* The main feature of this release is improved support for nat+CMTK on Windows. * teach voxdims.character to get voxel dimensions straight from image file on disk enhancement (#303) * teach coord2ind to accept nat.templatebrains objects for imdims (#302) @@ -88,619 +162,3 @@ The main feature of this release is improved support for nat+CMTK on Windows. * fix bug reading amira surfaces when Color precedes Id (#305) * cmtk.reformatx needs to use system2 (#301) * Don't use shell features on Windows (#295) - -nat 1.8.4 -========= -* fix build failures with testthat >=0.12 (#293) -* ensure that nat still works with igraph <1.0 (#298) -* fix read.hxsurf failure when a region is not listed in the Parameters section (#291) -* Protect find.neuron from trying to filter with a neuronlist (#299) -* Fix simplification of reglist containing one cmtkreg (#297) -* Don't lose swap attribute when >1 cmtk registrations in reglist (#296) -* Documentation improvements for neurons and file formats - -nat 1.8.3 -========= -* nat now handles compound registrations via reglist objects (#286). - These can contain homogeneous affine, CMTK registrations (in disk or in memory) - and R functions (which can be used to wrap arbitrary registration types not - directly supported by nat). NB xformimage.reglist will currently only work for - CMTK compatible registrations. -* add mask(.im3d) function to zero out parts of an image (#285) - Looks after im3d attributes and material name to integer pixel level mapping. -* add read.ngraph.swc which can be used to read even malformed SWC files (such - as those containing cycles) (#282). - This is exposed by giving read.neuron an argument class, which can be set to - 'ngraph' instead of 'neuron'. - Inspired by https://github.com/BigNeuron/BigNeuron-Wiki/wiki/BigNeuron-Imperial-College-London-Hackathon-Discussion-Notes -* add prune_edges to delete by specifying neuron edges rather than vertices (#280) -* Give give spine an invert option (#279) using prune_edges -* Teach spine to return point ids (#278) -* fix bug in pointsinside for distant points (#290) -* fix subsetting neuronlists with a single column data.frame drops column name - (#276) -* Fix invert option of subset/prune_vertices returns an error with igraph::dfs - points (#288) -* Fix fileformats(, rval='info') to return a well-formatted data.frame -* The idiom neuronlist[,] will never drop columns (since it is a useful shortcut - for as.data.frame(neuronlist)) (#277) - -nat 1.8.2 -========= -* roll back rgl NULL mode changes from 1.8.0 in favour of less invasive approach - of marking the majority of rgl based plotting examples as donttest (#274) - -nat 1.8.1 -========= -* fix non-canonical URLs to CRAN packages (thanks to Uwe Ligges) - -nat 1.8.0 -========= -This is tagged as a major release because of a change in behaviour that (by -default) suppresses interactive rgl windows when running in batch -(non-interactive) mode. See ?nat "rgl Package" section for details. - -* nat will only activate an rgl display in interactive mode, otherwise - defaulting to rgl's NULL mode display. This should help run nat in batch mode - situations including knitr runs, the CRAN build server etc. (#272) -* Add summary.neuron(list) functions to calculate tree statistics such as number - of nodes and cable length for neurons/neuronlists (#269) -* Automate progress bar in nlapply - this will always show in interactive mode - when there are more than 10 neurons being processed. (#271) -* Fix bug in c.neuronlist when combining more than 2 neuronlists (#270) -* Fix bug in read.neuronlistfh on Windows (#268) -* Fix bug when constructing an ngraph with a single node (#267) -* Fix bug in `[<-.neuronlist` when assigning a whole data.frame using (#256) -* Fix bug in bounding box with input = "bounds" (#273) -* Documentation improvements (especiall package overview - see ?nat) - -nat 1.7.2 -========= -* new function subset.neuron can keep/remove individual vertices from a neuron - based on internal variables such as position, width, vertex number etc while - still producing a valid neuron with an appropriate graph structure (#261) -* this depends on a new low level function prune_vertices that can remove - specified vertices -* this has also enabled the prune.neuron method to be defined for the first time - enabling pruning by spatial proximity () -* teach mirror to work with image data (#265) and enable better handling of the - mirrorAxisSize by allowing this to be supplied as a bounding box (#254) -* teach as.im3d.matrix to use an im3d object to specify the desired space (#263) - This enables for example a set or tracings to be turned into volume data that - exactly matches a specific template brain. -* fix bug: seglengths fails for neurons with multiple trees bug (#257) -* fix bug: xformpoint.cmtkreg fails for in memory registration lists (#259) - -nat 1.7.1 -========= -* new functions strahler_order and prune_strahler to calculate the Strahler - order of points in a neuron and to remove lower order (terminal) branches. -* fix is.cmtkreg for non-existent files (and better handling of status messages) -* export segmentgraph function for end users -* enable segmentgraph to return segment ids - -nat 1.7.0 -========= -* implement extraction/replacement of the data.frame attached to a neuronlist - using the [ operator (#217) -* fix xform of image data (#143, #199) -* implement handling of inverted (swapped i.e. reference to sample) - registrations in xform(image) (#199) -* normalise handling of registration sequences and inversion in - xform/image/points (all 3 expect reg to be in sample to ref order and for any - individual registration to be marked with swap=T if it is ref->sample) -* read.nrrd no longer returns an im3d (use read.im3d) (#238) -* teach write.nrrd to handle more diverse inputs (including #242) -* add reading of detached nrrds (#236, #237) -* add ability to write detached nrrds -* add ability to make a detached nrrd from a compatible amira file on disk (#243) -* new function is.im3d -* fix cmtk.targetvolume for templatebrain objects (#241) -* fix cmtk.targetvolume for --target-grid specification (#240) -* fix names for [.neuronlistfh with null df (#250) -* plot.neuron can cope with some NA coordinates -* teach plot.neuron(list) to cope with NA points (#247) -* boundingbox has an na.rm argument (#246) -* teach droplevels.neuronlist to use extra arg (#249) -* teach plot.neuron to plot soma (#245) -* fix cmtk.call for numeric args (#235) -* set read.hxsurf RegionChoice="both" by default -* document return values of cmtk.statistics in more detail (#252) -* support for igraph 1.0 (#248) - -nat 1.6.6 -========= -* Fixes description capitalisation/quoting for CRAN -* Adds ability to write dotprops neuron objects to SWC format (#233) -* fixes bug in xyzmatrix.neuron for single point neurons (#234) -* likewise for xyzmatrix.default for 1-row >3-col matrices - -nat 1.6.5 -========= -* add xyzmatrix get/set methods for class mesh3d along with xform.shape3d. This - should enable rgl::mesh3d objects (used in a number of other packages) to be - transformed using CMTK registrations. -* add tail.neuronlist -* add as.data.frame.neuronlist for convenient generation of a data.frame from a - neuronlist -* add help topics for generics subset and plot3d so that e.g. ?subset will give - the option to see our documentation as well as base docs. -* subset.hxsurf drops unused vertices by default -* add sample surface object of mushroom body -* teach cmtk.statistics to handle imagetype == 'label' (#221) -* plot.neuronlist sets axes based on boundingbox of all plotted neurons, not just - the first neuron (#223) -* plot.neuron(,AxisDirections) argument is re-implemented (#224) -* don't warn when read.neuronlistfh changes the directory location on disk (#157) -* remove superimposed plots in mirror example (hope this will fix build on - macosx snowleopard) -* teach read.neurons to OmitFailures when reading in a neuronlistfh object. -* fix handling of default colours in plot.neuronlist and plot3d.neuronlist (#230) -* fix plot3d.neuronlist returns one element per neuron -* fix bug in xformpoints.cmtkreg when some points could not be transformed - - now give NAs as expected (#227) -* fix bug when xform(na.action='drop') dropped dimensions when only 1 valid - point resulted (#228) -* teach xyz.matrix<- to work for bare 3 column matrices (i.e. without colnames) -* fix bug in xformimage where input image was not being passed on when - transforming with a matrix. -* read.hxsurf can accept RegionChoices='both' (see ?read.hxsurf) -* fix: unary -.neuronlist behaves -* docs: numerous minor doc/example improvements -* dev: improvements in test coverage (up to 84%) catching numerous small bugs in - the process. - -nat 1.6.4 -========= -* Edits to package description for CRAN - -nat 1.6.3 -========= -* fix invalid url in README.md noticed by r-devel/BDR - -nat 1.6.2 -========= -* add as.im3d.matrix which allows conversion of a Nx3 matrix of coordinates into - a volume representation -* add ability to use a neuron's StartPoint in the spine function that finds the - longest path (aka backbone or spine) of a neuron -* fix xformimage's handling of in-memory registrations -* fix bug in read.hxsurf docs -* dev: add coveralls code coverage support -* dev: fix use of require in package code (a new note from r-devel) -* dev: fix a cmtk-dependent test that was not guarded against cmtk's absence - -nat 1.6.1 -========= -* add ability to transform images (specified as path to a file) -* register image file formats to use with read/write.im3d -* register amira types including linesets, surfaces and landmarks -* add ability to read neurons from remote url -* add support for applying multiple registrations in xform.neuronlist, as well - as vectorisation (where each registration is applied to a different object) - -nat 1.6.0 -========= -* Add support for reading NeuroML and Fiji Simple Neurite Tracer neurons -* recognise SWC neurons by content (rather than just file extension) -* can write a set of neurons to a zip archive (?write.neurons) -* getformatreader returns name of identified format -* Give find.soma and find.neuron invert arguments -* internal function normalise_swc sets sensible defaults for column values (and - these can be overridden from some user functions). -* fix resample.neuron so that it keeps all subtrees and handles width and labels -* fix seglist2swc when receiving flat seglist -* ngraph attaches vertex data to each point and now includes diameter -* fix is.nrrd for raw input -* fix node colours in plot3d.neuron when WithAllPoints=TRUE - -nat 1.5.14 -========== -* add nlscan function to review a set of neurons, optionally selecting a subset -* add find.soma function to select neurons whose cell bodies fall within an rgl - seelection box (thanks to Ben Sutcliffe). -* add setdiff, intersect and union generics with implementations for neuronlist - objects (note this is done in more or less identical fashion to generics - defined in the dplyr package). -* give write.neurons a format argument to make it more obvious that this is an - option rather than pointing people to the write.neuron docs (suggestion from - Ben Sutcliffe) -* teach as.neuronlist to handle inputs with empty (rather than NULL names) -* simplify calculation of inertia in dotprops -* minor doc fixes and clarifications - -nat 1.5.13 -========== -* mat2dof output gets descriptive rownames -* ndigest.neuronlistfh only uses 2 key fields (keyfilemap and df) -* fix bug in locating cmtk when only the cmtk wrapper script is in the path - (spotted on neurodebian with /usr/bin/cmtk) -* fix bug in compound registrations when CMTK <3.2.2 -* fix rgl import errors on r-devel -* switch from RANN to nabor package for finding nearest neighbours -* dev: update help to roxygen2 4.0.2 - -nat 1.5.12 -========== -* fix bug in updating neuronlistfh objects from remote url -* nlapply now has options for progress bars and parallelisation by using the - plyr package under the hood. -* c.neuronlist can now join lists with attached data.frames with different - columns (missing values are filled with NAs). This also applies when some - neuronlists have no attached data.frame at all. -* read.neurons can read neuronlist files from disk -* cmtk.statistics now has a Verbose argument -* warn if resmapling a neuron with multiple subtrees that only the main subtree - will be kept. - -nat 1.5.11 -========== -* add cmtk.statistics function -* fix infinite recursion in cmtk.targetvolume - -nat 1.5.10 -========== -* fix: write.neurons subdir argument can accept a column of the attached - data.frame (unquoted) -* fix: write.neuron(s) can add an extension to an output filename that does not - have one -* write.neurons now has an explicit files argument -* cmtk.targetvolume (and therefore cmtk.reformatx) can accept e.g. - templatebrains (as contained in nat.flybrains package) to specify target - image for registration. - -nat 1.5.9 -========= -* fix transformation of points using compound CMTK registrations - (this was broken for CMTK<3.2.2, so a workaround is required). -* Add cmtk.version function. -* xyzmatrix can cope with lower case x,y,z for column names -* doc: fixes in xform - -* dev: fix test for winbuilder - -nat 1.5.8 -========= -* Add boundingbox.list method to find boundingbox for neurons, surfaces etc -* nmapply and nlapply get OmitFailures arguments -* nlapply also gets a subset argument -* both arguments are also added to xform/mirror.neuronlist -* dotprops.neuronlist also gets the OmitFailures argument. -* fix subset.neuronlist handling of numeric indices -* minor bug/doc fixes - -nat 1.5.7 -========= -* teach plot3d.neuronlist and friends to plot soma locations. -* add npop3d function to remove last plotted neurons - (identical to flycircuit::pop3dfc, except that it works with any neurons - plotted by plot3d.neuronlist, rather than only those plotted by plot3dfc) - -nat 1.5.6 -========= -* give mirror/xform.neuronlist subset arguments -* add plot3d.boundingbox -* give plot(3d).neuronlist a SUBSTITUTE argument that can be used to control - non-stadard evaluation. This is useful for people who wish to incoroporate - these funcitons inside other user-defined functions. See ?subset.neuronlist - for details. -* fix: write.neurons into subdirs when df=NULL - -nat 1.5.5 -========== -* fix bug in reading swc files with many decimal places specific to R 3.1.0 -* fix bug in header when writing swc files [ajdm] -* read.im3d now adds file as an attribute to output -* read.im3d can now add amiramesh files without the standard file extension -* doc: minor improvements to read.im3d docs and examples - -nat 1.5.4 -========== -* remove internal is.gzip function and depend on nat.utils >=0.4.2 - -nat 1.5.3 -========== -* new function pointsinside to determine if points (e.g. neuron) are inside a - closedd surface -* resample.neuron implemented (no support for interpolating widths or multiple - subtrees) -* dotprops.neuron can resample to a consistent segment length -* consistent return values for as.seglist and seglengths when all subtrees are - returned -* seglengths can return lengths for each edge as well as the sum for each - neurite segment (the default) -* suppress remote tests if flybrain unreachable -* zenodo DOI for package - -nat 1.5.2 -========== -* add seglengths function for neurons -* add segmentgraph function to produced a simplified graph representation of - neurons with one edge per segment -* add potential_synapses.dotprops method -* add as.seglist.neuron method -* teach plot3d.hxsurf and subset.hxsurf to accept regexes -* always drop unused vertices in as.mesh3d.hxsurf -* fix bug in write.neurons when subdir not specified -* fix colouring of vectors by plot3d.dotprops -* dev: switch to roxygygen2 v4 - -nat 1.5.1 -========== -* add potential_synapses (from nat.as) -* surfaces: add subset.hxsurf and as.mesh3d -* Teach read.im3d to read Vaa3d raw format -* add plot.neuronlist (for 2d plotting) -* add c.neuronlist function to combine neuronlists -* add db argument to plot3d.character -* make WithNodes=FALSE the default for plot3d.neuronlist -* make asp=1 the default for image.im3d -* write.cmtkreg warns if versions specified by cmtkreg attribute and argument - differ (to avoid writing old registrations as if they were new or vice versa) -* fix: prune.neuronlist method signature (and therefore dispatch) - -nat 1.4.10 -========== -* add function to prune objects by removing points close to or far from another - object -* add nmapply function for neuronlists -* add xyzmatrix method for neuronlists -* add materials function with methods for im3d and hxsurf objects -* enh: read.im3d can read materials from amiramesh files -* enh: download neurnonlistfh objects to session temp directory if no localdir - is specified -* fix: find CMTK in its new default location on macosx -* fix: plot3d should skip redrawing if par3d() skipRedraw is set -* fix: failure to export ngraph constructor function -* fix: set NeuronName when no InputFile argument is passed to neuron - constructor -* fix: im3d axis labels -* doc: numerous small documentation improvements - -nat 1.4.9 -========= -* add spine() function to find longest path (aka backbone) of a neuron -* give ngraph (and therefore as.ngraph methods) a weights argument so that - resultant ngraph objects have edge weights defined by segment lengths. -* add as.im3d generic and as.im3d.im3d method -* fix bug in setting graph attributes in ngraph - -nat 1.4.8 -========= -* bugfix: ensure ind2coords.im3d is exported - -nat 1.4.7 -========= -* add ability to make a dotprops object directly from an image file on disk or - an im3d object in memory. -* port ind2coord, coord2ind and sub2ind functions from AnalysisSuite -* fix clampmax function so that it removes Infinite values -* fix reading of gzip encoded amiramesh files -* fix mirror so that dotprops are recalculated for a simple flip -* make plot(3d).neuron colour settings more consistent -* simplify axis handling in plot.neuron -* dev: build nat.flybrains (as well as nat) after flycircuit build - -nat 1.4.6 -========= -* fix bug in handling vertexData argument in as.neuron.ngraph -* fix test error on Solaris (thanks to Brian Ripley) -* dev: fix remaining warnings in tests - -nat 1.4.5 -========= -* add plot.neuron for 2d plots (ajdm, from code in AnalysisSuite) -* add nopen3d() which opens an rgl viewer that allows panning. See ?nopen3d for - details of how to use this. -* teach read.neurons to report files that have problems as they are read -* fix temp file left behind by xform.cmtkreg -* fix dangerous looking warning when amira binary files have empty sections -* fix ability of read.neurons to set InputFileName and therefore retain - status information for the file along with its MD5 hash -* fix bug exporting xform.default (so that xform(matrix()) works) -* docs: improve coverage of BoundingBox vs bounds -* tests: simple tests for plot(3d).neuron -* tests: clear up temp files and suppress most warnings -* dev: restart travis build of flycircuit package when nat is pushed to github - -nat 1.4.4 -========= -* fix handling of logical expressions including NAs by subset.neuronlist -* add soma argument to plot3d.neuron -* fix: boundingbox.im3d() returns NULL when bounding box is not defined -* give remotesync.neuronlistfh an indices argument to allow download/update - from the web of a selected population of neurons -* add ndigest.neuron method -* fix: export ndigest.dotprops method -* give image.im3d a useRaster option, which defaults to TRUE when possible. - -nat 1.4.3 -========= -* new ndigest (normalised digest) function to compute hash values. Methods for - neuronlistfh and dotprops objects. Can be used e.g. to compute a hash value - for a standard dps object to determine if a data. -* new threshold function with a method for im3d objects. Can be used to make - masks. -* more flexible im3d constructor can use an existing im3d object to supply - spatial attributes. - -nat 1.4.2 -========= -* fix bug in read.neuronlistfh resulting in error if a remote file was - downloaded and then read back in (using cached copy) before any neurons were - downloaded. - -nat 1.4.1 -========= -* fix bug in write.nrrd - was failing to write essential space dimensions field. -* make gzip the default encoding for nrrd images - this is pretty much always - what one wants. - -nat 1.4.0 -========= -* add cmtk.reformatx command for reformatting images using CMTK registrations -* new function remotesync to synchronise a neuronlistfh object with its remote - source. -* add write.neuronlistfh and improve consistency/docs of path handling in - read.neuronlistfh -* option to write missing (or no) neurons when using as.neuronlistfh.neuronlist - this makes it _much_ faster to re-export these objects or prepare neuronlistfh - for subsets of an existing group of neurons -* fix hashmap functionality of neuronlistfh (speeds up access to single neurons) - -nat 1.3.2 -========= -* fix bug in find.neuron for neuronlistfh objects -* fix bug in neuronlistfh constructor (wasn't adding hashmap) and - [[.neuronlistfh (was not searching properly for objects when using hashmap). - -nat 1.3.1 -========= -* add find.neuron for interactive selection of neurons in 3d. - -nat 1.3 -======= -* implementation of new im3d image manipulations functions including image.im3d, - projection, unmask, imslice, imscalebar, imexpand.grid, flip, origin, - boundingbox<-, xyzpos, ijkpos -* see ?im3d, ?boundingbox, ?image3d.im3d, ?imscalebar and ?flip for details -* fix reading of gzipped nrrds on windows -* dev: fix nocran tests - -nat 1.2 -======= -* Basic implementation of reading/writing NRRD format image data. - See read.nrrd and write.nrrd for details. -* Basic implementation of reading/writing Amira format image data. - See read.amiramesh and write.amiramesh for details. -* Basic implementation of a class for 3d images, im3d -* see read.im3d and write.im3d for I/O -* and voxdims and boundingbox methods for physical dimensions -* switch to more flexible neuronlistfh structure in which objects on disk are - named by the md5 hash of their contents. -* workaround for connection leak in filehashRDS objects that stopped downloads - of more than 124 new objects by a neuronlistfh (ajdm). - (see https://github.com/rdpeng/filehash/pull/3 for details) -* dev: approach allowing some tests (e.g. those using the web) to be ignored on - CRAN (ajdm) -* dev: travis continuous integration support (ajdm) - -nat 1.1 -======= -* Implemented reading and writing of groups of neurons from/to neuronlists. - See read.neurons and write.neurons. -* Implemented writing of single neurons in swc format, Amira's HxLineSet and - SkeletonGraph formats, and R's rds format. -* Can now read Amira HxLineSet format neurons (see read.neuron) -* Give read.neuronlistfh an update argument (default:FALSE) so that it does not - re-download remote data. -* dev: speed and flexibility improvements in fileformats ioregistry. - see ?fileformats for details of new functions. - -nat 1.0.1 -========= -* fix bug in cmtk.bindir() on Solaris (thanks to Brian Ripley) - -nat 1.0 -======= -* implement reading of amiramesh data -* including amira SkeletonGraph format tracings -* switch to filehashRDS format for repositories of remote neurons -* retire stashR backend for neuronlistfh remote repositories (too slow) - -nat 0.9 -======= -* support for automatic download of neurons from stashR remote repositories on - the web. ?neuronlistfh for details and an example. -* Relies on stashR package -* dev: small doc fixes to make package CRAN compatible. - -nat 0.8 -======= -* important new feature: neuronlistfh objects backed by an on disk filehash - allow single neurons to be loaded from disk on demand -* this allows 1) fast startup suitable for knitr documents and 2) working with - more neurons than fit in main memory -* of course this is slower than working with an in-memory list but for plotting - etc this should not be problem -* furthermore neuronlistfh objects can be subsetted/converted to give in memory - neuronlist objects. - -nat 0.7 -======= -* implement read.neuron and read.neurons -* so far only works for rda, rds and swc files -* reading of additional file types will be implemented by registering functions = - to test, read and write for the format using a package regsistry controlled by - nat::neuronformats. -* developer: seglists in neurons now have class 'seglist' - -nat 0.6 -======= -* major new functionality - bidirectional interconversion of graph and regular - neuron representation -* see as.neuron.* methods and as.ngraph.* methods -* plan is to use graph representation as the common intermediate with reading - different neuron file formats -* depends on igraph package - -nat 0.5.2 -========= -* add subset.neuronlist -* add methods for working with dataframe attached to neuronlist - (see e.g. ?with.neuronlist) -* TODO harmonise plot3d.neuronlist subset expressions with subset.neuronlist - -nat 0.5.1 -========= -* Switch license to GPL-3 -* xform (transformation) of hxsurf objects -* fix xform of neuronlist objects -* switch from CMTK gregxform to streamxform (gregxform is deprecated; streamxform can concatenate registrations) -* teach mirror function to accept numeric axis specification -* Fix bug in checking extra directories in cmtk.bindir -* Add dotprops.neuronlist and include all dotprops methods in documentation -* Fix longstanding bug in parsing cmtk warping registrations (only relevant for - reading these into R lists - no effect on transformations). -* fix bug in class of cmtkreg objects -* Remove call to .Internal(La_rs) by calling eigen directly -* doc: some notes on CMTK installation - -nat 0.5 -======= -* fix broken handling of cmtk affine transformations -* implement mirroring of neurons and other objects -* teach xformpoints (and therefore xform) to handle "~/" in paths -* bugfix in visibility of S3method xformpoints.character -* (developer) Switch to roxygen2 v3.0 for documentation - -nat 0.4 -======= -* read.hxsurf and plot3d.hxsurf for reading/plotting Amira surfaces -* better handling of location of cmtk command line tools see ?cmtk for details -* add neuronlist and associated methods (including plot) -* plot3d for neurons and dotprops - -nat 0.3 -======= -* basic and self-contained implementation of neuron class -* basic and self-contained implementation of dotprops -* new xform generic + methods for clean transformation of objects including - neurons and dotprops objects -* this includes improved interaction between dotprops and xform so that xform - can use the previously value of k when recalculating a dotprops object post - transformation -* sample data (40 PNs from Jefferis, Potter et al. '07 and 20 KCs from Chiang - et al. 2011) -* 1 use of .Internal and missing nlapply remain to be fixed. - -nat 0.2.1 -========= -* fix install error due to missing neuron(*).R files that contain docs only so far - -nat 0.2 -======= -* Fairly complete implementation of CMTK registration I/O and geometry -* All functionality is self-contained (i.e. independent of nat.as/AnalysisSuite) -* passes check() -* can be augmented by nat.as (0.6) diff --git a/R/alphashape3d.R b/R/alphashape3d.R index ad5519a7..b7f95ff8 100644 --- a/R/alphashape3d.R +++ b/R/alphashape3d.R @@ -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 diff --git a/R/amiralandmarks-io.R b/R/amiralandmarks-io.R index 201b4a87..110b040c 100644 --- a/R/amiralandmarks-io.R +++ b/R/amiralandmarks-io.R @@ -62,7 +62,7 @@ write.landmarks.amira<-function(x, file){ #' #' \item CMTK #' -#' \item Fiji (see \url{http://fiji.sc/Name_Landmarks_and_Register}) } +#' \item Fiji (see \url{https://imagej.net/plugins/name-landmarks-and-register}) } #' #' See examples section for how to produce a listing of all currently #' available formats with \code{fileformats}. diff --git a/R/amiramesh-io.R b/R/amiramesh-io.R index 92e0a0ce..6bf4acf0 100644 --- a/R/amiramesh-io.R +++ b/R/amiramesh-io.R @@ -626,7 +626,7 @@ write.amiramesh<-function(x, file, enc=c("binary","raw","text","hxzip"), close(fc) # Write a Nrrd header to accompany the amira file if desired - # see http://teem.sourceforge.net/nrrd/ + # see https://teem.sourceforge.net/nrrd/ if(WriteNrrdHeader) { if(enc=="hxzip") stop("Nrrd cannot handle Amira's HxZip encoding (which is subtly different from gzip)") nrrdfile=paste(file,sep=".","nhdr") diff --git a/R/cmtk-reformat.R b/R/cmtk-reformat.R index cbab65a2..b20ab83d 100644 --- a/R/cmtk-reformat.R +++ b/R/cmtk-reformat.R @@ -34,6 +34,7 @@ cmtk.targetvolume.list<-function(target, ...) { cmtk.targetvolume(as.im3d(target)) } +#' @export cmtk.targetvolume.character <- function(target, ...) { if (isTRUE(substr(target,1,2) == "--")) { # we've already processed this, no action required @@ -85,47 +86,48 @@ 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 unintened consequences. Presently we have -#' no way of knowing whether an image should be treated as a mask, so the +#' +#' @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 +#' have no way of knowing whether an image should be treated as a mask, so the #' \code{interpolation} must be handled manually. #' @param floating The floating image to be reformatted #' @param registrations One or more CMTK format registrations on disk #' @param output The path to the output image (defaults to #' \code{"_.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 ouput 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, @@ -325,4 +327,4 @@ cmtk.statistics<-function(f, mask, imagetype=c("greyscale","label"), read.table(text=rval,header=TRUE,skip=1,comment.char="") } } - \ No newline at end of file + diff --git a/R/cmtk.R b/R/cmtk.R index 5a9f2129..d75e876f 100644 --- a/R/cmtk.R +++ b/R/cmtk.R @@ -76,45 +76,46 @@ cmtk.mat2dof<-function(m, f=NULL, centre=NULL, Transpose=TRUE, version=FALSE){ } #' Return path to directory containing CMTK binaries -#' -#' @description The \href{www.nitrc.org/projects/cmtk}{Computational Morphometry -#' Toolkit} (CMTK) is the default image registration toolkit supported by nat. -#' An external CMTK installation is required in order to apply CMTK -#' registrations. This function attempts to locate the full path to the CMTK -#' executable files and can query and set an option. -#' @details Queries options('nat.cmtk.bindir') if \code{firstdir} is not -#' specified. If that does not contain the appropriate binaries, it will look -#' in the system PATH for the \code{cmtk} wrapper script installed by most +#' +#' @description The \href{https://www.nitrc.org/projects/cmtk}{Computational +#' Morphometry Toolkit} (CMTK) is the default image registration toolkit +#' supported by nat. An external CMTK installation is required in order to +#' apply CMTK registrations. This function attempts to locate the full path to +#' the CMTK executable files and can query and set an option. +#' @details Queries options('nat.cmtk.bindir') if \code{firstdir} is not +#' specified. If that does not contain the appropriate binaries, it will look +#' in the system PATH for the \code{cmtk} wrapper script installed by most #' recent cmtk installations. -#' -#' Failing that, it will look for the cmtk tool specified by \code{cmtktool}, -#' first in the path and then a succession of plausible places until it finds -#' something. Setting \code{options(nat.cmtk.bindir=NA)} or passing -#' \code{firstdir=NA} will stop the function from trying to locate CMTK, +#' +#' Failing that, it will look for the cmtk tool specified by \code{cmtktool}, +#' first in the path and then a succession of plausible places until it finds +#' something. Setting \code{options(nat.cmtk.bindir=NA)} or passing +#' \code{firstdir=NA} will stop the function from trying to locate CMTK, #' always returning NULL unless \code{check=TRUE}, in which case it will error #' out. -#' @param firstdir Character vector specifying path containing CMTK binaries or +#' @param firstdir Character vector specifying path containing CMTK binaries or #' NA (see details). This defaults to options('nat.cmtk.bindir'). #' @param extradirs Where to look if CMTK is not in \code{firstdir} or the PATH -#' @param set Whether to set options('nat.cmtk.bindir') with the found -#' directory. Also check/sets cygwin path on Windows (see Installation +#' @param set Whether to set options('nat.cmtk.bindir') with the found +#' directory. Also check/sets cygwin path on Windows (see Installation #' section). #' @param check Whether to (re)check that a path that has been set appropriately -#' in options(nat.cmtk.bindir='/some/path') or now found in the PATH or +#' in options(nat.cmtk.bindir='/some/path') or now found in the PATH or #' alternative directories. Will throw an error on failure. -#' @param cmtktool Name of a specific cmtk tool which will be used to identify +#' @param cmtktool Name of a specific cmtk tool which will be used to identify #' the location of all cmtk binaries. -#' @return Character vector giving path to CMTK binary directory or NULL when +#' @return Character vector giving path to CMTK binary directory or NULL when #' this cannot be found. #' @export #' @aliases cmtk -#' @section Installation: It is recommended to install released CMTK versions -#' available from the \href{www.nitrc.org/projects/cmtk/}{NITRC website}. A -#' bug in composition of affine transformations from CMTK parameters in the -#' CMTK versions <2.4 series means that CMTK>=3.0 is strongly recommended. -#' CMTK v3 registrations are not backwards compatible with CMTK v2, but CMTKv3 -#' can correctly interpret and convert registrations from earlier versions. -#' +#' @section Installation: It is recommended to install released CMTK versions +#' available from the \href{https://www.nitrc.org/projects/cmtk/}{NITRC +#' website}. A bug in composition of affine transformations from CMTK +#' parameters in the CMTK versions <2.4 series means that CMTK>=3.0 is +#' strongly recommended. CMTK v3 registrations are not backwards compatible +#' with CMTK v2, but CMTKv3 can correctly interpret and convert registrations +#' from earlier versions. +#' #' On Windows, when \code{set=TRUE}, cmtk.bindir will also check that the #' cygwin bin directory is in the PATH. If it is not, then it is added for the #' current R session. This should solve issues with missing cygwin dlls. @@ -168,7 +169,7 @@ cmtk.bindir<-function(firstdir=getOption('nat.cmtk.bindir'), } if(check && is.null(bindir)) stop("Cannot find CMTK. Please install from ", - "http://www.nitrc.org/projects/cmtk and make sure that it is your path!") + "https://www.nitrc.org//projects/cmtk and make sure that it is your path!") if(set) { options(nat.cmtk.bindir=bindir) @@ -224,7 +225,7 @@ cmtk.version<-function(minimum=NULL){ #' #' @details \code{cmtk.call} processes arguments in ... as follows: #' -#' \itemize{ +#' \describe{ #' #' \item{argument names}{ will be converted from \code{arg.name} to #' \code{--arg-name}} diff --git a/R/cmtk_io.R b/R/cmtk_io.R index 36c2d576..62f2508a 100644 --- a/R/cmtk_io.R +++ b/R/cmtk_io.R @@ -153,9 +153,9 @@ read.cmtk<-function(con, CheckLabel=TRUE){ } #' Write out CMTK registration list to folder -#' +#' #' @details Note that transformation in the forward direction (i.e. sample->ref) -#' e.g. as calculated from a set of landmarks where set 1 is the sample is +#' e.g. as calculated from a set of landmarks where set 1 is the sample is #' considered an inverse transformation by the IGS software. So in order to #' use such a transformation as an initial affine with the registration #' command the switch --initial-inverse must be used specifying the folder @@ -167,11 +167,16 @@ read.cmtk<-function(con, CheckLabel=TRUE){ #' by default. #' @param reglist List specifying CMTK registration parameters #' @param foldername Path to registration folder (usually ending in .list) -#' @param version CMTK version for registration (default 2.4) +#' @param version CMTK version for registration (default 2.4). Will be converted +#' to character vector if not already. #' @export #' @family cmtk-io -write.cmtkreg<-function(reglist, foldername, version="2.4"){ - if(!is.null(attr(reglist, 'version')) && (attr(reglist, 'version') != version)) warning("Specified version (", version, ") is not the same as the version stored in the reglist object (", attr(reglist, 'version'), ").") +write.cmtkreg<-function(reglist, foldername, version="2.4") { + if(!is.character(version)) + version=as.character(version) + if(!is.null(attr(reglist, 'version')) && (attr(reglist, 'version') != version)) + warning("Specified version (", version, ") is not the same as the version stored in the reglist object (", attr(reglist, 'version'), ").") + dir.create(foldername, showWarnings=FALSE, recursive=TRUE) if(!is.list(reglist)) reglist=cmtkreglist(reglist) write.cmtk(reglist,file.path(foldername, "registration"), diff --git a/R/cmtkreg.R b/R/cmtkreg.R index 14749381..02c79e1f 100644 --- a/R/cmtkreg.R +++ b/R/cmtkreg.R @@ -1,7 +1,7 @@ #' Create and test cmtkreg objects that specify path to a CMTK registration #' #' @description \code{cmtkreg} creates an object of class \code{cmtkreg} that -#' describes one (or more) \href{www.nitrc.org/projects/cmtk/}{CMTK} +#' describes one (or more) \href{https://www.nitrc.org/projects/cmtk/}{CMTK} #' registrations. This is simply a character vector that also has class #' cmtkreg. #' @param x Path to a cmtk registration (either plain character vector or diff --git a/R/dotprops.R b/R/dotprops.R index ef0fd0bf..14300654 100644 --- a/R/dotprops.R +++ b/R/dotprops.R @@ -140,21 +140,21 @@ dotprops.neuron<-function(x, Labels=NULL, resample=NA, ...) { #' @method dotprops default #' @export #' @rdname dotprops -#' @param k Number of nearest neighbours to use for tangent vector calculation +#' @param k Number of nearest neighbours to use for tangent vector calculation #' (set to k=20 when passed NULL) -#' @param Labels Vector of labels for each point e.g. identifying axon vs +#' @param Labels Vector of labels for each point e.g. identifying axon vs #' dendrite. The default value \code{NULL} will produce class-specific default -#' behaviour for different classes of input object, \code{TRUE} always uses +#' 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) #' @importFrom nabor knn -#' @references The dotprops format is essentially identical to that developed +#' @references The dotprops format is essentially identical to that developed #' in: -#' -#' Masse N.Y., Cachero S., Ostrovsky A., and Jefferis G.S.X.E. (2012). A +#' +#' Masse N.Y., Cachero S., Ostrovsky A., and Jefferis G.S.X.E. (2012). A #' mutual information approach to automate identification of neuronal clusters #' in \emph{Drosophila} brain images. Frontiers in Neuroinformatics 6 (00021). -#' \href{http://dx.doi.org/10.3389/fninf.2012.00021}{doi: 10.3389/fninf.2012.00021} +#' \doi{10.3389/fninf.2012.00021} dotprops.default<-function(x, k=NULL, Labels=NULL, na.rm=FALSE, ...){ # store labels from SWC format data if this is a neuron x=xyzmatrix(x) diff --git a/R/graph-nodes.R b/R/graph-nodes.R index 6a5d8774..c1a70a8e 100644 --- a/R/graph-nodes.R +++ b/R/graph-nodes.R @@ -1,17 +1,23 @@ #' Return root, end, or branchpoints of an igraph object -#' -#' @details Note that the graph must be directed in order to return a root point -#' @param x An igraph object +#' +#' @details This function underlies \code{\link{rootpoints.igraph}} methods and +#' 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]{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]{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. #' @param exclude.isolated Do not count isolated vertices as root points #' (default) -#' @importFrom igraph V degree get.vertex.attribute +#' @importFrom igraph V degree vertex_attr graph.nodes<-function(x, type=c('root','end','branch'), original.ids='label', exclude.isolated=TRUE){ type=match.arg(type) - if(type=='root' && !is.directed(x)) + if(type=='root' && !is_directed(x)) stop("Cannot establish root points for undirected graph") # root points are those without incoming edges @@ -26,7 +32,7 @@ graph.nodes<-function(x, type=c('root','end','branch'), original.ids='label', } if(is.character(original.ids)) - vertex_names=get.vertex.attribute(x,original.ids,index=vertex_ids) + vertex_names=vertex_attr(x,original.ids,index=vertex_ids) if(!is.character(original.ids) || is.null(vertex_names)) as.integer(vertex_ids) else diff --git a/R/hxsurf.R b/R/hxsurf.R index 0ce5c9a3..8268f17f 100644 --- a/R/hxsurf.R +++ b/R/hxsurf.R @@ -25,7 +25,7 @@ #' details. #' @param FallbackRegionCol Colour to set regions when no colour is defined #' @param Verbose Print status messages during parsing when \code{TRUE} -#' @return A list with S3 class hxsurf with elements \itemize{ +#' @return A list with S3 class hxsurf with elements \describe{ #' #' \item{Vertices}{ A data.frame with columns \code{X, Y, Z, PointNo}} #' @@ -440,6 +440,7 @@ NULL #' @param ... additional arguments for methods, eventually passed to as.mesh3d. #' @export #' @examples +#' \donttest{ #' # check if the vertices in these neurons are inside the mushroom body calyx #' # surface object #' inout=pointsinside(kcs20, surf=subset(MBL.surf, "MB_CA_L")) @@ -449,7 +450,7 @@ NULL #' MBCAL=subset(MBL.surf, "MB_CA_L") #' inout5=pointsinside(kcs20, surf=MBCAL, rval='distance') > -5 #' table(inout5) -#' \donttest{ +#' #' # show which points are in or out #' # Hmm seems like there are a few red points in the vertical lobe #' # that are well outside the calyx diff --git a/R/im3d.R b/R/im3d.R index 66f7fa58..fde7ac1b 100644 --- a/R/im3d.R +++ b/R/im3d.R @@ -1,24 +1,26 @@ #' Construct an im3d object representing 3D image data, densities etc -#' -#' \code{im3d} objects consist of a data array with attributes defining the -#' spatial positions at which the voxels are located. There should always be a -#' \code{BoundingBox} attribute which defines the physical extent of the volume -#' in the same manner as the Amira 3D visualisation and analysis software. This -#' corresponds to the \strong{node} centers option in the -#' \href{http://teem.sourceforge.net/nrrd/format.html}{NRRD format}. +#' +#' \code{im3d} objects consist of a data array with attributes defining the +#' spatial positions at which the voxels are located. There should always be a +#' \code{BoundingBox} attribute which defines the physical extent of the volume +#' in the same manner as the Amira 3D visualisation and analysis software. This +#' corresponds to the \strong{node} centers option in the +#' \href{https://teem.sourceforge.net/nrrd/format.html}{NRRD format}. #' @param x The object to turn into an im3d -#' @param dims The dimensions of the image array either as an integer vector -#' \emph{or} as an im3d object, whose attributes will provide defaults for -#' \code{dims, origin, BoundingBox, bounds} arguments. The default -#' (\code{dims=NULL}) will result in \code{dims} being set to \code{x} if +#' @param dims The dimensions of the image array either as an integer vector +#' \emph{or} as an im3d object, whose attributes will provide defaults for +#' \code{dims, origin, BoundingBox, bounds} arguments. The default +#' (\code{dims=NULL}) will result in \code{dims} being set to \code{x} if #' \code{x} is an \code{im3d} object or \code{dim(x)} otherwise. #' @param voxdims The voxel dimensions #' @param origin the location (or centre) of the first voxel -#' @param BoundingBox,bounds Physical extent of image. See the details section -#' of \code{\link{boundingbox}}'s help for the distinction. +#' @param bounds Physical extent of image +#' @param BoundingBox Physical extent of the image. See the details section of +#' \code{\link{boundingbox}}'s help for the distinction between +#' \code{BoundingBox} and \code{bounds}. #' @param ... Additional attributes such as units or materials #' @return An array with additional class \code{im3d} -#' @details We follow Amira's convention of setting the bounding box equal to +#' @details We follow Amira's convention of setting the bounding box equal to #' voxel dimension (rather than 0) for any dimension with only 1 voxel. #' @export #' @family im3d @@ -110,8 +112,8 @@ as.im3d.im3d <- function(x, ...) x #' ignored. This can be useful for producing a new im3d to match a target #' image on disk or a \code{nat.templatebrains::templatebrain} object. See #' examples. -#' @inheritParams im3d #' @rdname as.im3d +#' @inheritParams im3d #' @seealso \code{\link{im3d}}, \code{\link{as.im3d}} #' @examples #' ## convert a list of neurons into an image volume @@ -339,7 +341,7 @@ voxdims.default<-function(x, dims, ...){ #' #' Note that there are two competing definitions for the physical extent of an #' image that are discussed e.g. -#' \url{http://teem.sourceforge.net/nrrd/format.html}. The definition that +#' \url{https://teem.sourceforge.net/nrrd/format.html}. The definition that #' makes most sense depends largely on whether you think of a pixel as a #' little square with some defined area (and therefore a voxel as a cube with #' some defined volume) \emph{or} you take the view that you can only define @@ -431,7 +433,7 @@ boundingbox.neuron<-boundingbox.list #' @description \code{boundingbox.shape3d} is designed to be used on objects #' that contain 3D point information and inherit from \code{rgl}'s #' \code{shape3d} class and for which \code{xyzmatrix} is defined. Presently -#' this applies to \code{\link{mesh3d}} objects. +#' this applies to \code{\link[rgl]{mesh3d}} objects. #' #' @rdname boundingbox boundingbox.shape3d<-boundingbox.list @@ -529,7 +531,7 @@ dim.im3d<-function(x){ #' function. #' @return A \code{list} with elements: #' -#' \itemize{ +#' \describe{ #' #' \item{zlim}{ The z (intensity limits)} #' @@ -1005,14 +1007,14 @@ threshold.im3d<-function(x, threshold=0, } #' Return function that finds maximum of its inputs within a clamping range -#' -#' @details Note that by default infinite values in the input vector are +#' +#' @details Note that by default infinite values in the input vector are #' converted to \code{NA}s before the being compared with the clampmax range. -#' @param xmin,xmax clamping range. If xmax is missing xmin should be a vector +#' @param xmin,xmax clamping range. If xmax is missing xmin should be a vector #' of length 2. -#' @param replace.infinite The value with which to replace non-finite values -#' \emph{in the input vector}. When code{replace.infinite=FALSE} no action is -#' taken. The default value of \code{NA} will result in e.g. \code{Inf} being +#' @param replace.infinite The value with which to replace non-finite values +#' \emph{in the input vector}. When \code{replace.infinite=FALSE} no action is +#' taken. The default value of \code{NA} will result in e.g. \code{Inf} being #' mapped to \code{NA}. #' @return A function with signature \code{f(x, ..., na.rm)} #' @export @@ -1238,10 +1240,12 @@ materials.hxsurf<-function(x, ...) { `materials<-`<-function(x, value) UseMethod("materials<-") +#' @export `materials<-.hxsurf`<-function(x, value) { stop("materials<-.hxsurf is not implemented") } +#' @export `materials<-.default`<-function(x, value) { if(!is.data.frame(value)) stop("materials<- expects a data.frame") diff --git a/R/nat-data.R b/R/nat-data.R index 1e5a8f7c..bf6d2888 100644 --- a/R/nat-data.R +++ b/R/nat-data.R @@ -1,7 +1,7 @@ #' Cell07PNs: 40 Sample Projection Neurons from Jefferis, Potter et al 2007 -#' -#' These R lists (which have additional class neuronlist) contain 40 traced -#' olfactory projection neurons from Jefferis, Potter et al 2007 that have been +#' +#' These R lists (which have additional class neuronlist) contain 40 traced +#' olfactory projection neurons from Jefferis, Potter et al 2007 that have been #' transformed onto the IS2 template brain (Cachero, Ostrovsky et al 2010). #' @name Cell07PNs #' @family nat-data @@ -10,37 +10,38 @@ #' head(Cell07PNs) #' table(with(Cell07PNs,Glomerulus)) #' @docType data -#' @references Jefferis G.S.X.E., Potter C.J., Chan A.M., Marin E.C., Rohlfing -#' T., Maurer C.R.J., and Luo L. (2007). Comprehensive maps of Drosophila higher -#' olfactory centers: spatially segregated fruit and pheromone representation. -#' Cell 128 (6), 1187--1203. -#' \href{http://dx.doi.org/10.1016/j.cell.2007.01.040}{doi:10.1016/j.cell.2007.01.040} -#' -#' Cachero S., Ostrovsky A.D., Yu J.Y., Dickson B.J., and Jefferis G.S.X.E. -#' (2010). Sexual dimorphism in the fly brain. Curr Biol 20 (18), 1589--601. -#' \href{http://dx.doi.org/10.1016/j.cub.2010.07.045}{doi:10.1016/j.cub.2010.07.045} +#' @references Jefferis G.S.X.E., Potter C.J., Chan A.M., Marin E.C., Rohlfing +#' T., Maurer C.R.J., and Luo L. (2007). Comprehensive maps of Drosophila +#' higher olfactory centers: spatially segregated fruit and pheromone +#' representation. Cell 128 (6), 1187--1203. \doi{10.1016/j.cell.2007.01.040} +#' +#' Cachero S., Ostrovsky A.D., Yu J.Y., Dickson B.J., and Jefferis G.S.X.E. +#' (2010). Sexual dimorphism in the fly brain. Curr Biol 20 (18), 1589--601. +#' \doi{10.1016/j.cub.2010.07.045} +#' NULL #' List of 20 Kenyon Cells from Chiang et al 2011 converted to dotprops objects -#' -#' This R list (which has additional class \code{neuronlist}) contains 20 -#' skeletonized \emph{Drosophila} Kenyon cells as \code{dotprops} objects. -#' Original data is due to Chiang et al. 2011, who have generously shared their -#' raw data at \url{http://flycircuit.tw}. Image registration and further -#' processing was carried out by Greg Jefferis. +#' +#' This R list (which has additional class \code{neuronlist}) contains 20 +#' skeletonized \emph{Drosophila} Kenyon cells as \code{dotprops} objects. +#' Original data is due to Chiang et al. 2011, who have generously shared their +#' raw data \doi{10.1016/j.cub.2010.11.056}. Image registration and further +#' processing was carried out by Greg Jefferis (see +#' \doi{10.1016/j.neuron.2016.06.012}). #' @name kcs20 #' @family nat-data -#' @seealso \code{\link{head.neuronlist}}, \code{\link{with.neuronlist}}, +#' @seealso \code{\link{head.neuronlist}}, \code{\link{with.neuronlist}}, #' \code{\link{plot3d.neuronlist}}, \code{\link{plot3d.dotprops}}, #' \code{\link{dotprops}} #' @docType data -#' @references [1] Chiang A.S., Lin C.Y., Chuang C.C., Chang H.M., Hsieh C.H., -#' Yeh C.W., Shih C.T., Wu J.J., Wang G.T., Chen Y.C., Wu C.C., Chen G.Y., -#' Ching Y.T., Lee P.C., Lin C.Y., Lin H.H., Wu C.C., Hsu H.W., Huang Y.A., -#' Chen J.Y., et al. (2011). Three-dimensional reconstruction of brain-wide -#' wiring networks in Drosophila at single-cell resolution. Curr Biol 21 (1), +#' @references [1] Chiang A.S., Lin C.Y., Chuang C.C., Chang H.M., Hsieh C.H., +#' Yeh C.W., Shih C.T., Wu J.J., Wang G.T., Chen Y.C., Wu C.C., Chen G.Y., +#' Ching Y.T., Lee P.C., Lin C.Y., Lin H.H., Wu C.C., Hsu H.W., Huang Y.A., +#' Chen J.Y., et al. (2011). Three-dimensional reconstruction of brain-wide +#' wiring networks in Drosophila at single-cell resolution. Curr Biol 21 (1), #' 1--11. -#' @examples +#' @examples #' head(kcs20) #' table(with(kcs20, type)) #' nopen3d() diff --git a/R/nat-package.R b/R/nat-package.R index 81abcf7b..9c1c9a5c 100644 --- a/R/nat-package.R +++ b/R/nat-package.R @@ -1,159 +1,159 @@ #' Analyse 3D biological image data especially neurons -#' -#' \bold{nat} provides tools to read, analyse, plot, transform and convert +#' +#' \bold{nat} provides tools to read, analyse, plot, transform and convert #' neuroanatomical data, especially representations of neurons. -#' @section Neuron Objects: At present there are 2 main representations of +#' @section Neuron Objects: At present there are 2 main representations of #' neuronal data: -#' -#' \itemize{ -#' -#' \item{\code{\link{neuron}}}{ objects contain one or more connected trees +#' +#' \describe{ +#' +#' \item{\code{\link{neuron}}}{ objects contain one or more connected trees #' that make up a neuron} -#' -#' \item{\code{\link{dotprops}}}{ objects can contain one (or more) neurons -#' represented as points and tangent vectors in which the connectivity +#' +#' \item{\code{\link{dotprops}}}{ objects can contain one (or more) neurons +#' represented as points and tangent vectors in which the connectivity #' information has been discarded} -#' +#' #' } -#' -#' The \code{subset} function has both \code{\link{subset.neuron}} and -#' \code{\link{subset.dotprops}} methods, which can be used to keep (or -#' reject) specified vertices within a neuron e.g. by spatial constraints. -#' \code{\link{subset.neuron}} will look after the tree structure of neurons +#' +#' The \code{subset} function has both \code{\link{subset.neuron}} and +#' \code{\link{subset.dotprops}} methods, which can be used to keep (or +#' reject) specified vertices within a neuron e.g. by spatial constraints. +#' \code{\link{subset.neuron}} will look after the tree structure of neurons #' in these circumstances. -#' -#' \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 -#' 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}} -#' function can convert \code{ngraph} objects back to \code{neuron}s or -#' selected vertex indices can be used to subset a neuron with +#' +#' \code{neuron} objects containing connected trees can be converted to +#' \code{\link{ngraph}} objects, a lightweight wrapper around the +#' \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}} +#' function can convert \code{ngraph} objects back to \code{neuron}s or +#' selected vertex indices can be used to subset a neuron with #' \code{\link{subset.neuron}}. -#' -#' @section Collections of Neurons: Neurons can be collected as -#' \code{\link{neuronlist}} objects, which contain multiple -#' \code{\link{neuron}} or \code{dotprops} objects along with an attached -#' dataframe of metadata. The metadata can be accessed and manipulated using -#' the \code{myneuronlist[i,j]} notation (see +#' +#' @section Collections of Neurons: Neurons can be collected as +#' \code{\link{neuronlist}} objects, which contain multiple +#' \code{\link{neuron}} or \code{dotprops} objects along with an attached +#' dataframe of metadata. The metadata can be accessed and manipulated using +#' the \code{myneuronlist[i,j]} notation (see #' \code{\link{neuronlist-dataframe-methods}}). -#' -#' Neurons can be read in to a neuronlist using \code{\link{read.neurons}} or -#' written out using \code{\link{write.neurons}} with support for many of the +#' +#' Neurons can be read in to a neuronlist using \code{\link{read.neurons}} or +#' written out using \code{\link{write.neurons}} with support for many of the #' most common formats including swc. -#' -#' Metadata can be used to colour or subset the neurons during plotting (see -#' \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 rgl's \code{\link{select3d}} -#' function. -#' -#' \code{neuronlist} objects also provide additional functionality to -#' streamline arithmetic (e.g. scaling all the points in all neurons see +#' +#' Metadata can be used to colour or subset the neurons during plotting (see +#' \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[rgl]{select3d}} function. +#' +#' \code{neuronlist} objects also provide additional functionality to +#' streamline arithmetic (e.g. scaling all the points in all neurons see #' \code{\link{*.neuronlist}}) and transformations (see \bold{Transformations} -#' section below and \code{\link{xform}}). Arbitrary functions can be applied -#' to each individual neuron can be applied using the \code{\link{nlapply}} -#' function, which also provides options for progress bars and simple +#' section below and \code{\link{xform}}). Arbitrary functions can be applied +#' to each individual neuron can be applied using the \code{\link{nlapply}} +#' function, which also provides options for progress bars and simple #' parallelisation. -#' -#' @section Transformations: \code{\link{neuron}} or \code{\link{dotprops}} -#' objects can be transformed from e.g. sample to template brain space using -#' affine or non-rigid registrations, typically calculated with the open -#' source CMTK package available at \url{www.nitrc.org/projects/cmtk/}, see -#' ?\link{cmtk} for installation details. The function \code{\link{xform}} has -#' methods to deal with a variety of types of interest. -#' -#' @section 3D Image Data: In addition to data types defined by unstructured -#' collections of 3D vertices such as \code{\link{neuron}}, -#' \code{\link{dotprops}} and \code{\link{hxsurf}} objects nat provides the -#' \code{\link{im3d}} class to handle image/density data on a regular grid. -#' I/O is handled by \code{\link{read.im3d}} and \code{\link{write.im3d}}, -#' which are currently implemented for the amiramesh and nrrd file formats; -#' there is also read only access to the \href{www.vaa3d.org/}{vaa3d} raw -#' format. -#' -#' Spatial information can be queried with \code{\link{voxdims}}, +#' +#' @section Transformations: \code{\link{neuron}} or \code{\link{dotprops}} +#' objects can be transformed from e.g. sample to template brain space using +#' affine or non-rigid registrations, typically calculated with the open +#' source CMTK package available at +#' \url{https://www.nitrc.org/projects/cmtk/}, see ?\link{cmtk} for +#' installation details. The function \code{\link{xform}} has methods to deal +#' with a variety of types of interest. +#' +#' @section 3D Image Data: In addition to data types defined by unstructured +#' collections of 3D vertices such as \code{\link{neuron}}, +#' \code{\link{dotprops}} and \code{\link{hxsurf}} objects nat provides the +#' \code{\link{im3d}} class to handle image/density data on a regular grid. +#' I/O is handled by \code{\link{read.im3d}} and \code{\link{write.im3d}}, +#' which are currently implemented for the amiramesh and nrrd file formats; +#' there is also read only access to the \href{http://www.vaa3d.org/}{vaa3d} +#' raw format. +#' +#' Spatial information can be queried with \code{\link{voxdims}}, #' \code{\link{boundingbox}} and \code{\link{ijkpos}}, \code{\link{xyzpos}} -#' methods. You can convert between voxel data and coordinate (vertex) -based +#' methods. You can convert between voxel data and coordinate (vertex) -based #' representations using the following functions: -#' +#' #' \itemize{ -#' -#' \item \code{\link{as.im3d}} The \code{as.im3d.matrix} method converts XYZ +#' +#' \item \code{\link{as.im3d}} The \code{as.im3d.matrix} method converts XYZ #' coordinates to an \code{im3d} image volume -#' -#' \item \code{\link{ind2coord}} Find XYZ coordinates of specified voxels of +#' +#' \item \code{\link{ind2coord}} Find XYZ coordinates of specified voxels of #' an \code{im3d} image volume -#' -#' \item \code{\link{dotprops}} The \code{dotprops.im3d} method converts an -#' \code{im3d} object to a \code{dotprops} format neuron, i.e. a cloud of +#' +#' \item \code{\link{dotprops}} The \code{dotprops.im3d} method converts an +#' \code{im3d} object to a \code{dotprops} format neuron, i.e. a cloud of #' unconnected segments. -#' +#' #' } -#' -#' @section Surface Data: \bold{nat} can read, write, transform and subset -#' surface (mesh) objects defined by Amira's HxSurface class. See +#' +#' @section Surface Data: \bold{nat} can read, write, transform and subset +#' surface (mesh) objects defined by Amira's HxSurface class. See #' \code{\link{read.hxsurf}} and links therein. In addition hxsurf objects can #' be converted to the \code{\link[rgl]{mesh3d}} format, which provides a link -#' to the \code{\link[rgl]{rgl}} package and also to packages for -#' morphometrics and sophisticated mesh manipulation such as -#' \href{https://cran.r-project.org/package=Morpho}{Morpho} and +#' to the \code{\link[rgl]{rgl}} package and also to packages for +#' morphometrics and sophisticated mesh manipulation such as +#' \href{https://cran.r-project.org/package=Morpho}{Morpho} and #' \href{https://cran.r-project.org/package=Rvcg}{Rvcg}. -#' -#' @section rgl Package: \bold{nat} uses the \bold{\code{\link[rgl]{rgl}}} +#' +#' @section rgl Package: \bold{nat} uses the \bold{\code{\link[rgl]{rgl}}} #' package extensively for 3D visualisation. rgl's core function is to provide -#' interactive visualisation (usually in an X11 window depending on OpenGL - -#' and therefore on a graphics card or OpenGL software emulator) but recently -#' significant functionality for static snapshots and embedding results in +#' interactive visualisation (usually in an X11 window depending on OpenGL - +#' and therefore on a graphics card or OpenGL software emulator) but recently +#' significant functionality for static snapshots and embedding results in #' reports such as web pages has been added. With this in mind, Duncan Murdoch -#' has added the \code{\link[rgl]{rgl.useNULL}} option. As of nat 1.8.0, -#' \code{options(rgl.useNULL=TRUE)} will be set before nat is loaded in -#' non-interactive R sessions. If you want to use nat in interactive -#' environments where X11 is not available, you may want to set +#' has added the \code{\link[rgl]{rgl.useNULL}} option. As of nat 1.8.0, +#' \code{options(rgl.useNULL=TRUE)} will be set before nat is loaded in +#' non-interactive R sessions. If you want to use nat in interactive +#' environments where X11 is not available, you may want to set #' \code{options(rgl.useNULL=TRUE)} manually before loading nat. -#' -#' -#' @section File Formats: \bold{nat} supports multiple input and output data -#' formats for the object classes. There is a registry-based mechanism which -#' allows support for reading or writing specific file formats (see +#' +#' +#' @section File Formats: \bold{nat} supports multiple input and output data +#' formats for the object classes. There is a registry-based mechanism which +#' allows support for reading or writing specific file formats (see #' \code{\link{fileformats}}) to be plugged in to reasonably generic functions -#' such as \code{\link{read.neurons}}. It is perfectly possible for other R -#' packages or end users to extend the supported list of file types by +#' such as \code{\link{read.neurons}}. It is perfectly possible for other R +#' packages or end users to extend the supported list of file types by #' registering new read/write or identification functions. -#' +#' #' @section Package Options: The following options can be set to specify default #' behaviour. -#' -#' \itemize{ -#' -#' \item{\code{nat.cmtk.bindir}}{ Location of CMTK binaries. See +#' +#' \describe{ +#' +#' \item{\code{nat.cmtk.bindir}}{ Location of CMTK binaries. See #' \code{\link{cmtk.bindir}}} -#' +#' #' \item{\code{nat.default.neuronlist}}{ A character string naming a #' neuronlist to use with the \code{\link{plot3d.character}} method} -#' -#' \item{\code{nat.progress}}{ The default progress reporter to use with -#' \code{\link{nlapply}}. See \code{\link[plyr]{create_progress_bar}} for -#' possible values. When unset is equivalent to special value \code{'auto'}. +#' +#' \item{\code{nat.progress}}{ The default progress reporter to use with +#' \code{\link{nlapply}}. See \code{\link[plyr]{create_progress_bar}} for +#' possible values. When unset is equivalent to special value \code{'auto'}. #' To suppress altogether, use \code{nat.progress="none"}.} -#' +#' #' } -#' +#' #' In addition there is one read-only option: \itemize{ -#' -#' \item \code{nat.cmtk.version} which is used to store the current cmtk +#' +#' \item \code{nat.cmtk.version} which is used to store the current cmtk #' version when there are repeated calls to \code{\link{cmtk.version}}. -#' +#' #' } #' @name nat-package #' @aliases nat -#' @seealso \code{\link{neuron}}, \code{\link{dotprops}}, +#' @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}}. -#' @docType package #' @keywords package #' @import rgl graphics grDevices utils -NULL +"_PACKAGE" diff --git a/R/ndigest.R b/R/ndigest.R index c1b407f8..ae48cecd 100644 --- a/R/ndigest.R +++ b/R/ndigest.R @@ -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 diff --git a/R/neuron-io-amira.R b/R/neuron-io-amira.R index ba0d71d0..27195786 100644 --- a/R/neuron-io-amira.R +++ b/R/neuron-io-amira.R @@ -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") @@ -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 diff --git a/R/neuron-io-fiji.R b/R/neuron-io-fiji.R index d18bce19..2e531a21 100644 --- a/R/neuron-io-fiji.R +++ b/R/neuron-io-fiji.R @@ -39,8 +39,8 @@ read.fijixml<-function(f, ..., Verbose=FALSE){ #' @param Verbose Whether to print status messages during parsing. #' @details This is an XML based format so parsing it depends on installation of #' the suggested XML package. -#' @references \url{http://fiji.sc/Simple_Neurite_Tracer} -#' \url{http://fiji.sc/Simple_Neurite_Tracer:_.traces_File_Format} +#' @references \url{https://imagej.net/plugins/snt/} +#' \url{https://imagej.net/plugins/snt/extending} #' @export read.neuron.fiji<-function(f, ..., simplify=TRUE, Verbose=FALSE){ l=read.fijixml(f, ..., Verbose=Verbose) diff --git a/R/neuron-io-neuroml.R b/R/neuron-io-neuroml.R index c237786b..165e15a9 100644 --- a/R/neuron-io-neuroml.R +++ b/R/neuron-io-neuroml.R @@ -28,7 +28,7 @@ #' \code{XMLDocument} when \code{ReturnXML=TRUE}. #' @export #' @seealso \code{link[XML]{xmlParse}}, \code{\link{read.neuron.neuroml}} -#' @references \url{http://www.neuroml.org/specifications} +#' @references \url{https://neuroml.org/} read.morphml<-function(f, ..., ReturnXML=FALSE){ # basic parsing of xml doc (using libxml) doc=try(XML::xmlParse(f, ...)) @@ -208,8 +208,10 @@ as.data.frame.morphml_cell<-function(x, ...){ structure(r[in_names], .Names=out_names) } +#' @export as.neuron.morphml_cell<-function(x, ...) as.neuron(as.data.frame(x, ...)) +#' @export as.ngraph.morphml_cell<-function(x, ...) { as.ngraph(as.data.frame(x), ...) } @@ -223,7 +225,7 @@ as.ngraph.morphml_cell<-function(x, ...) { #' @return When the XML file contains only 1 cell \emph{and} #' \code{AlwaysReturnNeuronList=FALSE}, a \code{\link{neuron}} object, #' otherwise a \code{\link{neuronlist}} containing one or more neurons. -#' @references \url{http://www.neuroml.org/specifications} +#' @references \url{https://neuroml.org/} #' @export #' @seealso \code{\link{read.morphml}} read.neuron.neuroml<-function(f, ..., AlwaysReturnNeuronList=FALSE) { diff --git a/R/neuron-io.R b/R/neuron-io.R index 58449052..d7b8a89d 100644 --- a/R/neuron-io.R +++ b/R/neuron-io.R @@ -1,49 +1,48 @@ #' Read a single neuron from a file -#' -#' @details This function will handle \code{neuron} and \code{dotprops} objects -#' saved in R .rds or .rda format by default. Additional file formats can be +#' +#' @details This function will handle \code{neuron} and \code{dotprops} objects +#' saved in R .rds or .rda format by default. Additional file formats can be #' registered using \code{fileformats}. -#' -#' At the moment the following formats are supported using file readers +#' +#' At the moment the following formats are supported using file readers #' already included with the nat package: \itemize{ -#' -#' \item \bold{swc} See \code{\link{read.neuron.swc}}. SWC files can also -#' return an \code{\link{ngraph}} object containing the neuron structure in a -#' (permissive) general graph format that also contains the 3D positions for +#' +#' \item \bold{swc} See \code{\link{read.neuron.swc}}. SWC files can also +#' return an \code{\link{ngraph}} object containing the neuron structure in a +#' (permissive) general graph format that also contains the 3D positions for #' each vertex. -#' +#' #' \item \bold{neuroml} See \code{\link{read.neuron.neuroml}} -#' +#' #' \item \bold{fijitraces} See \code{\link{read.neuron.fiji}}. The file format -#' used by the \href{http://fiji.sc/Simple_Neurite_Tracer}{Simple Neurite -#' Tracer} plugin of Fiji/ImageJ. -#' -#' \item \bold{hxlineset,hxskel} Two distinct fileformats used by Amira. -#' \code{hxlineset} is the generic one, \code{hxskel} is used by the +#' used by the \href{https://imagej.net/plugins/snt/}{SNT} plugin of +#' Fiji/ImageJ. +#' +#' \item \bold{hxlineset,hxskel} Two distinct fileformats used by Amira. +#' \code{hxlineset} is the generic one, \code{hxskel} is used by the #' hxskeletonize extension of Schmitt and Evers (see refs). -#' -#' \item \bold{rda,rds} Native R cross-platform binary formats (see -#' \code{\link{load}, \link{readRDS}}). Note that RDS only contains a single +#' +#' \item \bold{rda,rds} Native R cross-platform binary formats (see +#' \code{\link{load}, \link{readRDS}}). Note that RDS only contains a single #' unnamed neuron, whereas rda contains one or more named neurons. -#' +#' #' } #' @export -#' @param f Path to file. This can be a URL, in which case the file is +#' @param f Path to file. This can be a URL, in which case the file is #' downloaded to a temporary location before reading. -#' @param format The file format of the neuron. When \code{format=NULL}, the -#' default, \code{read.neuron} will infer the file format from the extension +#' @param format The file format of the neuron. When \code{format=NULL}, the +#' default, \code{read.neuron} will infer the file format from the extension #' or file header (aka magic) using the \code{fileformats} registry. -#' @param class The class of the returned object - presently either +#' @param class The class of the returned object - presently either #' \code{"neuron"} or \code{"ngraph"} #' @param ... additional arguments passed to format-specific readers #' @seealso \code{\link{write.neuron}}, \code{\link{read.neurons}}, #' \code{\link{fileformats}} -#' @references Schmitt, S. and Evers, J. F. and Duch, C. and Scholz, M. and -#' Obermayer, K. (2004). New methods for the computer-assisted 3-D -#' reconstruction of neurons from confocal image stacks. Neuroimage 4, -#' 1283--98. -#' \href{http://dx.doi.org/10.1016/j.neuroimage.2004.06.047}{doi:10.1016/j.neuroimage.2004.06.047} -#' +#' @references Schmitt, S. and Evers, J. F. and Duch, C. and Scholz, M. and +#' Obermayer, K. (2004). New methods for the computer-assisted 3-D +#' reconstruction of neurons from confocal image stacks. Neuroimage 4, +#' 1283--98. \doi{10.1016/j.neuroimage.2004.06.047} +#' #' @examples #' \dontrun{ #' # note that we override the default NeuronName field @@ -277,9 +276,8 @@ read.neurons<-function(paths, pattern=NULL, neuronnames=basename, format=NULL, #' list or a table of information about the formats that match the given #' filter conditions. #' @details if a \code{format} argument is passed to \code{fileformats} it will -#' be matched wigth partial string matching and iif a unique match exists that +#' be matched with partial string matching and if a unique match exists that #' will be returned. -#' @inheritParams registerformat #' @param rval Character vector choosing what kind of return value #' \code{fileformats} will give. #' @return \itemize{ @@ -288,7 +286,7 @@ read.neurons<-function(paths, pattern=NULL, neuronnames=basename, format=NULL, #' according to the value of rval. #' #' \item \code{getformatreader} returns a list. The reader can be accessed -#' with \code{$read} and the format can be acessed by \code{$format}. +#' with \code{$read} and the format can be accessed by \code{$format}. #' #' \item \code{getformatwriter} returns a list. The writer can be accessed #' with \code{$write}.} @@ -490,7 +488,7 @@ getformatwriter<-function(format=NULL, file=NULL, ext=NULL, class=NULL){ #' These functions would normally be called from \code{read.neuron(s)} rather #' than used directly. #' @section SWC Format: According to -#' \url{http://research.mssm.edu/cnic/swc.html} SWC file format has a +#' \url{http://www.neuronland.org/NLMorphologyConverter/MorphologyFormats/SWC/Spec.html} SWC file format has a #' radius not a diameter specification #' @param f path to file #' @param ... Additional arguments. \code{read.neuron.swc} passes theseto diff --git a/R/neuron-plot.R b/R/neuron-plot.R index 24ff29cb..928cbab0 100644 --- a/R/neuron-plot.R +++ b/R/neuron-plot.R @@ -42,7 +42,7 @@ #' # include cell bodies #' plot3d(Cell07PNs[3:4], col='red', soma=TRUE) #' plot3d(Cell07PNs[5], col='red', soma=3) -#' rgl.close() +#' close3d() #' } plot3d.neuron<-function(x, WithLine=TRUE, NeuronNames=FALSE, WithNodes=TRUE, WithAllPoints=FALSE, WithText=FALSE, PlotSubTrees=TRUE, @@ -153,7 +153,7 @@ NULL #' @param ... additional options passed to open3d #' @return current rgl device #' @export -#' @seealso \code{\link{open3d},\link{pan3d}} +#' @seealso \code{\link[rgl]{open3d},\link{pan3d}} nopen3d<- function(bgcol='white', FOV=0, ...){ res=open3d(mouseMode=c("trackball","user","zoom"), FOV=FOV, ...) bg3d(col=bgcol) @@ -169,7 +169,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 @@ -213,10 +213,10 @@ nview3d <- function(viewpoint=c("frontal", "anterior", "dorsal", "ventral", #' 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 +#' 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 #' @examples #' \dontrun{ diff --git a/R/neuron.R b/R/neuron.R index 3353d3e3..636be151 100644 --- a/R/neuron.R +++ b/R/neuron.R @@ -63,13 +63,14 @@ #' #' # converting back and forth between neurons and graphs #' g=as.ngraph(Cell07PNs[[1]]) -#' gstem=igraph::induced.subgraph(g, 1:10) +#' gstem=igraph::induced_subgraph(g, 1:10) #' # this is fine #' plot(gstem) #' 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) #' @@ -77,6 +78,7 @@ #' 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 @@ -143,11 +145,11 @@ as.neuron.data.frame<-function(x, ...) { #' @param x A data.frame containing neuron morphology data #' @param requiredColumns Character vector naming columns we should have #' @param ifMissing What to do if \code{x} is missing a required column -#' @param includeExtraCols Whether to include any extra columns include in -#' code{x} -#' @param defaultValue A list containing default values to use for any missing +#' @param includeExtraCols Whether to include any extra columns included in +#' \code{x} +#' @param defaultValue A list containing default values to use for any missing #' columns -#' @return A data.frame containing the normalised block of SWC data with +#' @return A data.frame containing the normalised block of SWC data with #' standard columns in standard order. #' @seealso \code{\link{as.neuron.data.frame}}, \code{\link{seglist2swc}} #' @details Note that row.names of the resultant data.frame will be set to NULL @@ -203,9 +205,9 @@ normalise_swc<-function(x, requiredColumns=c('PointNo','Label','X','Y','Z','W',' #' [SubTrees]) NB SubTrees will only be present when nTrees>1. #' @export #' @method as.neuron ngraph -#' @importFrom igraph V V<- vcount decompose.graph +#' @importFrom igraph V V<- vcount decompose #' @rdname neuron -#' @seealso \code{\link{graph.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)){ @@ -218,11 +220,11 @@ as.neuron.ngraph<-function(x, vertexData=NULL, origin=NULL, Verbose=FALSE, ...){ # save original vertex ids igraph::V(x)$vid=seq.int(igraph::vcount(x)) # check if we have multiple subgraphs - if(igraph::no.clusters(x)>1){ + if(igraph::count_components(x)>1){ if(!length(origin)){ # no origin specified, will pick the biggest subtree # decompose into list of subgraphs - gg=igraph::decompose.graph(x) + gg=igraph::decompose(x) # reorder by descending number of vertices gg=gg[order(sapply(gg,igraph::vcount), decreasing=TRUE)] subtrees=lapply(gg, as.seglist, Verbose=Verbose) @@ -230,15 +232,15 @@ as.neuron.ngraph<-function(x, vertexData=NULL, origin=NULL, Verbose=FALSE, ...){ masterg=gg[[1]] } else { # origin specified, subtree containing origin will be the master - cg=igraph::clusters(x) + cg=igraph::components(x) master_tree_num=cg$membership[origin] # make a master graph with the vertices from subgraph including origin - masterg=igraph::induced.subgraph(x, which(cg$membership==master_tree_num)) + masterg=igraph::induced_subgraph(x, which(cg$membership==master_tree_num)) # ... and then corresponding seglist sl=as.seglist(masterg, origin=origin) # now deal with remaining vertices - remainderg=igraph::induced.subgraph(x, which(cg$membership!=master_tree_num)) - gg=igraph::decompose.graph(remainderg) + remainderg=igraph::induced_subgraph(x, which(cg$membership!=master_tree_num)) + gg=igraph::decompose(remainderg) # reorder by descending number of vertices gg=gg[order(sapply(gg,igraph::vcount), decreasing=TRUE)] subtrees=c(list(sl),lapply(gg, as.seglist, Verbose=Verbose)) @@ -259,7 +261,7 @@ as.neuron.ngraph<-function(x, vertexData=NULL, origin=NULL, Verbose=FALSE, ...){ # sort out the vertex information # TODO refactor this into a separate function e.g. normalise.swc since # we need to do something similar in as.neuron.dataframe and seglist2swc etc - d=data.frame(PointNo=get.vertex.attribute(x,'label')) + d=data.frame(PointNo=vertex_attr(x,'label')) if(is.null(vertexData)){ # get vertex information from graph object xyz=xyzmatrix(x) @@ -287,7 +289,7 @@ as.neuron.ngraph<-function(x, vertexData=NULL, origin=NULL, Verbose=FALSE, ...){ d=seglist2swc(x=subtrees,d=d) d=normalise_swc(d) - n=list(d=d,NumPoints=igraph::vcount(masterg), + n=list(d=d,NumPoints=nvertices(masterg), StartPoint=StartPoint, BranchPoints=branchpoints(masterg, original.ids='vid'), EndPoints=endpoints(masterg, original.ids='vid'), @@ -469,7 +471,7 @@ all.equal.neuron<-function(target,current,tolerance=1e-6,check.attributes=FALSE, #' @param flatten Whether to flatten the lists of lists into a single list when #' \code{all=TRUE} #' @param sumsegment Whether to return the length of each segment (when -#' {sumsegment=TRUE}, the default) or a list of vectors of lengths of each +#' \code{sumsegment=TRUE}, the default) or a list of vectors of lengths of each #' individual edge in the segment. #' @details A segment is an ubranched portion of neurite consisting of at least #' one vertex joined by edges.Only segments in x$SegList will be calculated @@ -754,9 +756,9 @@ smooth_segment_spline <- function(xyz, ...) { #' #' # now find the points downstream (distal) of that with respect to the root #' ng=as.ngraph(n) -#' # use a depth first search -#' distal_points=igraph::graph.dfs(ng, root=n$AxonLHEP, unreachable=FALSE, -#' neimode='out')$order +#' # use a depth first search +#' distal_points=igraph::dfs(ng, root=n$AxonLHEP, unreachable=FALSE, +#' mode='out')$order #' distal_tree=subset(n, distal_points) #' plot(distal_tree, add=TRUE, col='red', lwd=2) #' diff --git a/R/neuronlist.R b/R/neuronlist.R index 6051e88c..cf88c0ae 100644 --- a/R/neuronlist.R +++ b/R/neuronlist.R @@ -386,8 +386,8 @@ as.data.frame.neuronlist<-function(x, row.names = names(x), optional = FALSE, .. #' open3d() #' plot3d(kcs.reduced,col='red', lwd=2) #' plot3d(kcs20,col='grey') -#' rgl.close() -#' +#' close3d() +#' #' \dontrun{ #' # example of using plyr's .inform argument for debugging error conditions #' xx=nlapply(Cell07PNs, prune_strahler) @@ -417,7 +417,7 @@ as.data.frame.neuronlist<-function(x, row.names = names(x), optional = FALSE, .. #' open3d() #' plot3d(kcs20[1:3]) #' plot3d(xyzflip) -#' rgl.close() +#' close3d() #' } #' #' \dontrun{ diff --git a/R/neuronlist_interactive_3d.R b/R/neuronlist_interactive_3d.R index 53f3d4d8..a566eccc 100644 --- a/R/neuronlist_interactive_3d.R +++ b/R/neuronlist_interactive_3d.R @@ -1,21 +1,22 @@ #' Find neurons within a 3D selection box (usually drawn in rgl window) -#' -#' @details Uses \code{\link{subset.neuronlist}}, so can work on dotprops or +#' +#' @details Uses \code{\link{subset.neuronlist}}, so can work on dotprops or #' neuron lists. -#' @param sel3dfun A \code{\link{select3d}} style function to indicate if points -#' are within region +#' @param sel3dfun A \code{\link[rgl]{select3d}} style function to indicate if +#' points are within region #' @param indices Names of neurons to search (defaults to all neurons in list) -#' @param db \code{neuronlist} to search. Can also be a character vector naming +#' @param db \code{neuronlist} to search. Can also be a character vector naming #' the neuronlist. Defaults to \code{options('nat.default.neuronlist')}. #' @param threshold More than this many points must be present in region -#' @param invert Whether to return neurons outside the selection box (default +#' @param invert Whether to return neurons outside the selection box (default #' \code{FALSE}) #' @param rval What to return (character vector, default='names') -#' -#' @return Character vector of names of selected neurons, neuronlist, or +#' +#' @return Character vector of names of selected neurons, neuronlist, or #' data.frame of attached metadata according to the value of \code{rval}. #' @export -#' @seealso \code{\link{select3d}, \link{find.soma}, \link{subset.neuronlist}} +#' @seealso \code{\link[rgl]{select3d}, \link{find.soma}, +#' \link{subset.neuronlist}} #' @examples #' \dontrun{ #' plot3d(kcs20) @@ -25,7 +26,7 @@ #' # make a standalone selection function #' vertical_lobe=select3d() #' find.neuron(vertical_lobe, db=kcs20) -#' # use base::Negate function to invert the selection function +#' # use base::Negate function to invert the selection function #' # i.e. choose neurons that do not overlap the selection region #' find.neuron(Negate(vertical_lobe), db=kcs20) #' } @@ -49,14 +50,15 @@ find.neuron<-function(sel3dfun=select3d(), indices=names(db), } #' Find neurons with soma inside 3D selection box (usually drawn in rgl window) -#' -#' @details Can work on \code{neuronlist}s containing \code{neuron} objects -#' \emph{or} \code{neuronlist}s whose attached data.frame contains soma +#' +#' @details Can work on \code{neuronlist}s containing \code{neuron} objects +#' \emph{or} \code{neuronlist}s whose attached data.frame contains soma #' positions specified in columns called X,Y,Z . #' @inheritParams find.neuron #' @return Character vector of names of selected neurons #' @export -#' @seealso \code{\link{select3d}, \link{subset.neuronlist}, \link{find.neuron}} +#' @seealso \code{\link[rgl]{select3d}, \link{subset.neuronlist}, +#' \link{find.neuron}} find.soma <- function (sel3dfun = select3d(), indices = names(db), db = getOption("nat.default.neuronlist"), invert=FALSE, @@ -189,8 +191,8 @@ nlscan <- function(neurons, db=NULL, col='red', Verbose=T, Wait=T, sleep=0.1, if(Wait){ chc <- readline("Return to continue, b to go back, s to select, d [save to disk], t to stop, c to cancel (without returning a selection): ") if(chc=="c" || chc=='t'){ - sapply(pl, rgl.pop, type='shape') - sapply(more_rgl_ids, rgl.pop, type='shape') + sapply(pl, pop3d, type='shape') + sapply(more_rgl_ids, pop3d, type='shape') break } if(chc=="s") { @@ -206,8 +208,8 @@ nlscan <- function(neurons, db=NULL, col='red', Verbose=T, Wait=T, sleep=0.1, Sys.sleep(sleep) i <- i+1 } - sapply(pl, rgl.pop, type='shape') - sapply(more_rgl_ids, rgl.pop, type='shape') + sapply(pl, pop3d, type='shape') + sapply(more_rgl_ids, pop3d, type='shape') } if(is.null(chc) || chc=='c') return(NULL) if(!is.null(selected_file)) savetodisk(selected, selected_file) diff --git a/R/neuronlistfh.R b/R/neuronlistfh.R index f5a315d8..999b13b9 100644 --- a/R/neuronlistfh.R +++ b/R/neuronlistfh.R @@ -29,7 +29,7 @@ #' neurons e.g. for dynamic report generation using knitr or for users with #' <8Gb RAM or running 32 bit R. #' -#' neuronlistfh objects include: \itemize{ +#' neuronlistfh objects include: \describe{ #' #' \item{attr("keyfilemap")}{ A named character vector that determines the #' ordering of objects in the neuronlist and translates keys in R to filenames @@ -196,9 +196,9 @@ as.neuronlistfh.neuronlist<-function(x, df=attr(x,'df'), dbdir=NULL, names(x)=seq(x) } WriteObjects=match.arg(WriteObjects) + dbClass=match.arg(dbClass) if(WriteObjects!='yes' && dbClass!='RDS') stop("Must always write objects when dbClass!='RDS'") - dbClass=match.arg(dbClass) if(dbClass!='RDS' && !is.null(remote)) stop("remote download only implemented for RDS class at the moment") # md5 by default. Should we use something else? @@ -249,16 +249,9 @@ as.neuronlist.neuronlistfh<-function(l, ...){ return(attr(x,'db')[[i,...]]) } - # The tryCatch block below will leak a connection, so make a note of how many - # we start with so we can remove the extra one once the block has finished - connBefore <- rownames(showConnections(all=T)) - - # we have a remote. let's try and use it to fetch these keys tryCatch({ - # DEBUG: The leak happens here - attr(x,'db')[[i,...]] + attr(x, 'db')[[i, ...]] }, error = function(e) { - # DEBUG: We'll have an extra connection now fillMissing(i, x) tryCatch({ attr(x, 'db')[[i, ...]] @@ -266,12 +259,6 @@ as.neuronlist.neuronlistfh<-function(l, ...){ "Unable to download file." stop(e) }) - }, finally = { - # Deal with connection leak - connAfter <- rownames(showConnections(all=T)) - connNew <- setdiff(connAfter,connBefore) - if(length(connNew) > 0) - close(getConnection(as.integer(connNew))) }) } diff --git a/R/ngraph.R b/R/ngraph.R index c5d98242..3945b2db 100644 --- a/R/ngraph.R +++ b/R/ngraph.R @@ -1,3 +1,19 @@ +# local functions to handle deprecated functions in igraph >= 2.1.0 +make_graph_nat <- function(...) { + pvi <- packageVersion('igraph') + if(pvi>='2.1.0') igraph::make_graph(...) else igraph::graph(...) +} + +as_directed_nat <- function(...) { + pvi <- packageVersion('igraph') + if(pvi>='2.1.0') igraph::as_directed(...) else igraph::as.directed(...) +} + +as_undirected_nat <- function(...) { + pvi <- packageVersion('igraph') + if(pvi>='2.1.0') igraph::as_undirected(...) else igraph::as.undirected(...) +} + #' ngraph: a graph to encode a neuron's connectivity #' #' @description the \code{ngraph} class contains a (completely general) graph @@ -41,15 +57,15 @@ #' 3D distance between points should be added to graph (default \code{FALSE}) #' \emph{or} a numeric vector of weights. #' @param directed Whether the resultant graph should be directed (default TRUE) -#' @param vertex.attributes,graph.attributes List of named attributes to be -#' added to the graph. The elements of \code{vertex.attributes} must be -#' vectors whose length is compatible with the number of elements in the -#' graph. See \code{\link[igraph]{set.vertex.attribute}} for details. +#' @param vertex.attributes,graph.attributes List of named attributes to be +#' added to the graph. The elements of \code{vertex.attributes} must be +#' vectors whose length is compatible with the number of elements in the +#' graph. See \code{\link[igraph]{set_vertex_attr}} for details. #' @return an \code{igraph} object with additional class \code{ngraph}, having a #' vertex for each entry in vertexlabels, each vertex having a \code{label} #' attribute. All vertices are included whether connected or not. #' @family neuron -#' @seealso \code{\link{igraph}}, \code{\link[igraph]{set.vertex.attribute}}, +#' @seealso \code{\link[igraph]{igraph}}, \code{\link[igraph]{set_vertex_attr}}, #' \code{\link{subset.neuron}} for example of graph-based manipulation of a #' neuron. #' @export @@ -73,7 +89,7 @@ ngraph<-function(el, vertexlabels, xyz=NULL, diam=NULL, directed=TRUE, vecs=xyz[stops, , drop=FALSE] - xyz[starts, , drop=FALSE] weights=sqrt(rowSums(vecs*vecs)) } - g=igraph::graph(rawel, n=length(vertexlabels), directed=directed) + g=make_graph_nat(rawel, n=length(vertexlabels), directed=directed) igraph::V(g)$label=vertexlabels if(is.numeric(weights)) igraph::E(g)$weight=weights @@ -86,10 +102,10 @@ ngraph<-function(el, vertexlabels, xyz=NULL, diam=NULL, directed=TRUE, } if(!is.null(diam)) igraph::V(g)$diam=diam for(n in names(vertex.attributes)){ - g=igraph::set.vertex.attribute(g,name=n,value=vertex.attributes[[n]]) + g=igraph:: set_vertex_attr(g,name=n,value=vertex.attributes[[n]]) } for(n in names(graph.attributes)){ - g=igraph::set.graph.attribute(g,name=n,value=graph.attributes[[n]]) + g=igraph::set_graph_attr(g, name=n,value=graph.attributes[[n]]) } class(g)=c("ngraph",class(g)) g @@ -133,14 +149,13 @@ as.ngraph.neuron<-function(x, directed=TRUE, method=c('swc','seglist'), ...){ } } -#' @importFrom igraph as.undirected as.directed #' @export as.ngraph.igraph<-function(x, directed=TRUE, root, mode=c('out','in'), ...){ if(inherits(x,'ngraph')) - if(igraph::is.directed(x)==directed) return(x) + if(igraph::is_directed(x)==directed) return(x) - if(igraph::is.directed(x) && !directed) x=as.undirected(x, ...) - else if(!igraph::is.directed(x) && directed) x=as.directed.usingroot(x, root, mode=mode, ...) + if(igraph::is_directed(x) && !directed) x=as_undirected_nat(x, ...) + else if(!igraph::is_directed(x) && directed) x=as.directed.usingroot(x, root, mode=mode, ...) if(!inherits(x,'ngraph')){ class(x)=c("ngraph",class(x)) @@ -151,11 +166,11 @@ as.ngraph.igraph<-function(x, directed=TRUE, root, mode=c('out','in'), ...){ as.directed.usingroot<-function(g, root, mode=c('out','in')){ mode=match.arg(mode) # make a directed graph _keeping any attributes_ - if(!igraph::is.directed(g)) - dg=igraph::as.directed(g, mode='arbitrary') + if(!igraph::is_directed(g)) + dg=as_directed_nat(g, mode='arbitrary') else dg=g - dfs=igraph::graph.dfs(dg, root, unreachable=FALSE, dist=TRUE, neimode='all') - el=igraph::get.edgelist(dg) + dfs=igraph::dfs(dg, root, unreachable=FALSE, dist=TRUE, mode='all') + el=igraph::as_edgelist(dg) connected_vertices=which(is.finite(dfs$order)) edges_to_check=which(el[,1]%in%connected_vertices) @@ -171,8 +186,8 @@ as.directed.usingroot<-function(g, root, mode=c('out','in')){ if(any(same_dist)) warning(sum(same_dist)," edges connect vertices that are the same distance from the root => cycles.") edges_to_flip <- edges_to_check[if(mode=='out') parent_further else parent_closer] - dg=igraph::delete.edges(dg,edges_to_flip) - dg=igraph::add.edges(dg,t(el[edges_to_flip,2:1])) + dg=igraph::delete_edges(dg,edges_to_flip) + dg=igraph::add_edges(dg,t(el[edges_to_flip,2:1])) dg } @@ -198,9 +213,9 @@ as.directed.usingroot<-function(g, root, mode=c('out','in')){ #' \item an integer vector of raw point indices (when \code{rval="ids"}). #' #' } -#' @seealso \code{\link[igraph]{diameter}}, -#' \code{\link[igraph]{shortest.paths}}, \code{\link{prune_strahler}} for -#' removing lower order branches from a neuron, \code{\link{prune}} for +#' @seealso \code{\link[igraph]{diameter}}, +#' \code{\link[igraph]{distances}}, \code{\link{prune_strahler}} for +#' removing lower order branches from a neuron, \code{\link{prune}} for #' removing parts of a neuron by spatial criteria. #' @export #' @examples @@ -220,9 +235,9 @@ as.directed.usingroot<-function(g, root, mode=c('out','in')){ #' plot3d(Cell07PNs[[1]]) #' plot3d(antispine, lwd=4, col='red') #' } -#' -#' @importFrom igraph shortest.paths get.shortest.paths diameter get.diameter -#' delete.vertices +#' +#' @importFrom igraph distances shortest_paths diameter get_diameter +#' delete_vertices #' @family neuron spine <- function(n, UseStartPoint=FALSE, SpatialWeights=TRUE, invert=FALSE, rval=c("neuron", "length", "ids")) { @@ -232,16 +247,16 @@ spine <- function(n, UseStartPoint=FALSE, SpatialWeights=TRUE, invert=FALSE, stop("invert=TRUE is not implemented for rval='length'") if(UseStartPoint) { # Find longest shortest path from given start point to all end points - lps=shortest.paths(graph = ng, n$StartPoint, to = n$EndPoints, + lps= distances(graph = ng, n$StartPoint, to = n$EndPoints, mode = 'all') if(rval=='length') return(max(lps)) to=n$EndPoints[which.max(lps)] - longestpath=get.shortest.paths(ng, from = n$StartPoint, to = to, mode = 'all')$vpath[[1]] + longestpath=shortest_paths(ng, from = n$StartPoint, to = to, mode = 'all')$vpath[[1]] } else { if(rval=='length') { return(diameter(ng, directed=FALSE)) } else { - longestpath=get.diameter(ng, directed=FALSE) + longestpath=get_diameter(ng, directed=FALSE) } } if(rval=='ids') { @@ -277,7 +292,7 @@ spine <- function(n, UseStartPoint=FALSE, SpatialWeights=TRUE, invert=FALSE, #' @return \code{igraph} object containing only nodes of neuron keeping original #' labels (\code{x$d$PointNo} => \code{V(g)$label}) and vertex indices #' (\code{1:nrow(x$d)} => \code{V(g)$vid)}. -#' @importFrom igraph graph.empty add.edges E +#' @importFrom igraph make_empty_graph add_edges E #' @export #' @examples #' sg=segmentgraph(Cell07PNs[[1]]) @@ -286,7 +301,7 @@ spine <- function(n, UseStartPoint=FALSE, SpatialWeights=TRUE, invert=FALSE, #' plot(sg, edge.arrow.size=.4, vertex.size=10) segmentgraph<-function(x, weights=TRUE, segids=FALSE, exclude.isolated=FALSE, include.xyz=FALSE, reverse.edges=FALSE){ - g=graph.empty() + g=make_empty_graph() pointnos=x$d$PointNo sts=as.seglist(x, all=TRUE, flatten = TRUE) topntail<-function(x) if(length(x)==1) x else x[c(1,length(x))] @@ -294,7 +309,7 @@ segmentgraph<-function(x, weights=TRUE, segids=FALSE, exclude.isolated=FALSE, simple_sts=lapply(sts,topntail) all_nodes=sort(unique(unlist(simple_sts))) # make empty graph with approriate nodes - g=graph.empty(n=length(all_nodes)) + g=make_empty_graph(n=length(all_nodes)) # store external pointnos igraph::V(g)$label=pointnos[all_nodes] # store original vertex ids @@ -314,9 +329,9 @@ segmentgraph<-function(x, weights=TRUE, segids=FALSE, exclude.isolated=FALSE, } if(weights){ weights=seglengths(x, all=TRUE) - g=add.edges(g, elred, weight=weights, segid=segids) + g=add_edges(g, elred, weight=weights, segid=segids) } else { - g=add.edges(g, elred, segid=segids) + g=add_edges(g, elred, segid=segids) } if(include.xyz){ @@ -327,7 +342,7 @@ segmentgraph<-function(x, weights=TRUE, segids=FALSE, exclude.isolated=FALSE, if(exclude.isolated){ # remove any points with no neighbours isolated_vertices=igraph::V(g)[igraph::degree(g)==0] - g=igraph::delete.vertices(graph=g,isolated_vertices) + g=igraph::delete_vertices(graph=g,isolated_vertices) } g } @@ -351,7 +366,7 @@ segmentgraph<-function(x, weights=TRUE, segids=FALSE, exclude.isolated=FALSE, #' @seealso \code{\link{prune_strahler}}, a \code{\link{segmentgraph}} (a form #' of \code{\link{ngraph}}) representation is used to calculate the Strahler #' order. -#' @importFrom igraph graph.bfs neighborhood V +#' @importFrom igraph bfs neighborhood V #' @return A list containing \itemize{ #' #' \item points Vector of integer Strahler orders for each point in the neuron @@ -365,7 +380,7 @@ strahler_order<-function(x){ if(length(roots)>1) stop("strahler_order not yet defined for multiple subtrees") - b=graph.bfs(s, root=roots, neimode = 'out', unreachable=F, father=T) + b=bfs(s, root=roots, mode = 'out', unreachable=F, father=T) # find neighbours for each node n=neighborhood(s, 1, mode='out') @@ -498,15 +513,17 @@ prune_strahler<-function(x, orderstoprune=1:2, ...) { prune_vertices<-function(x, verticestoprune, invert=FALSE, ...) { g=as.ngraph(x) - # because igraph.vs sequences are atttached to a specific graph + # because igraph.vs sequences are attached to a specific graph if(inherits(verticestoprune, "igraph.vs")) verticestoprune=as.integer(verticestoprune) if(invert) { - nvertices=nrow(xyzmatrix(x)) + nvertices=igraph::vcount(g) verticestoprune=setdiff(seq_len(nvertices), verticestoprune) + } else { + verticestoprune=setdiff(verticestoprune, 0) } - dg=igraph::delete.vertices(g, verticestoprune) - # delete.vertices will return an igraph + dg=igraph::delete_vertices(g, verticestoprune) + # delete_vertices will return an igraph as.neuron(as.ngraph(dg), ...) } @@ -543,10 +560,10 @@ prune_edges<-function(x, edges, invert=FALSE, ...) { if(invert) edges=setdiff(igraph::E(g), edges) - dg=igraph::delete.edges(g, edges = edges) + dg=igraph::delete_edges(g, edges = edges) # remove unreferenced vertices - dg=igraph::delete.vertices(dg, which(igraph::degree(dg, mode='all')==0)) + dg=igraph::delete_vertices(dg, which(igraph::degree(dg, mode='all')==0)) as.neuron(as.ngraph(dg), ...) } diff --git a/R/nrrd-io.R b/R/nrrd-io.R index dbd470e4..5df51ec3 100644 --- a/R/nrrd-io.R +++ b/R/nrrd-io.R @@ -148,7 +148,7 @@ read.nrrd.header<-function(file, Verbose=FALSE){ close(tc) } else if(fieldname=="datafile"){ # TODO fix handling of complex datafile specifications - # See http://teem.sourceforge.net/nrrd/format.html#detached + # See https://teem.sourceforge.net/nrrd/format.html#detached if(substring(fieldval,1,4)=="LIST"){ # we need to keep reading in lines until we hit EOF fieldval=c(fieldval,readLines(con)) @@ -297,7 +297,7 @@ nrrd.voxdims<-function(file, ReturnAbsoluteDims=TRUE){ #' calibration fields are added to the header. #' #' @section Detached NRRDs: NRRD files can be written in \emph{detached} format -#' (see \url{http://teem.sourceforge.net/nrrd/format.html#detached}) in which +#' (see \url{https://teem.sourceforge.net/nrrd/format.html#detached}) in which #' a text \bold{nhdr} file is used to described the contents of a separate #' (usually binary) data file. This means that the nhdr file can be inspected #' and edited with a text editor, while the datablock can be in a completely @@ -346,7 +346,7 @@ nrrd.voxdims<-function(file, ReturnAbsoluteDims=TRUE){ #' and \code{endian} along with the dimensions of the input (\code{x}) will #' override the corresponding NRRD header fields from any supplied #' \code{header} argument. See -#' \url{http://teem.sourceforge.net/nrrd/format.html} for details of the NRRD +#' \url{https://teem.sourceforge.net/nrrd/format.html} for details of the NRRD #' fields. #' #' @param x Data to write as an \code{array}, \code{vector} or diff --git a/R/potential_synapses.R b/R/potential_synapses.R index 61d09748..af1fc355 100644 --- a/R/potential_synapses.R +++ b/R/potential_synapses.R @@ -1,31 +1,31 @@ #' Calculate number of potential synapses between two neurons -#' +#' #' This implements the method of Stepanyants and Chklovskii -#' +#' #' @param a,b neurons or neuronlists #' @param s the approach distance to consider a potential synapse #' @param sigma the smoothing parameter in the approximate method (see details) #' @param method Whether to use the direct or approximate method (see details) #' @param bounds Optional bounding box to restrict comparison #' @param ... Additional arguments passed to methods (see details ) -#' @details Note that \code{potential_synapses.neuronlist} uses -#' \code{\link{nlapply}} to process its first argument (\code{a}). This -#' enables progress bars, robustness to errors and simple parallel execution. -#' See the \code{\link{nlapply}} examples for further details of these +#' @details Note that \code{potential_synapses.neuronlist} uses +#' \code{\link{nlapply}} to process its first argument (\code{a}). This +#' enables progress bars, robustness to errors and simple parallel execution. +#' See the \code{\link{nlapply}} examples for further details of these #' arguments in action. -#' -#' For this reason if you have two neuronlists of unequal sizes, it is +#' +#' For this reason if you have two neuronlists of unequal sizes, it is #' recommended to put the larger one in argument \code{a}. #' @export #' @references Neurogeometry and potential synaptic connectivity. Stepanyants A, -#' Chklovskii DB. Trends Neurosci. 2005 Jul;28(7):387-94. -#' \url{http://dx.doi.org/10.1016/j.tins.2005.05.006} +#' Chklovskii DB. Trends Neurosci. 2005 Jul;28(7):387-94. +#' \doi{10.1016/j.tins.2005.05.006} #' @examples #' potential_synapses(Cell07PNs[1], Cell07PNs[1:3], s=2) #' \dontrun{ -#' # if you have many neurons to calculate you should get a progress bar +#' # if you have many neurons to calculate you should get a progress bar #' potential_synapses(Cell07PNs[1:10], Cell07PNs[11:20], s=2) -#' +#' #' # you can also use parallel execution, here over 7 cores #' # doMC::registerDoMC(7) #' potential_synapses(Cell07PNs[1:10], Cell07PNs[11:20], s=2, .parallel=TRUE) @@ -98,7 +98,7 @@ potential_synapses.dotprops<-function(a, b, s, sigma=s, seglength=1, bounds=NULL PotentialSynapses <- function(a, b, s, sigma, ...) UseMethod("PotentialSynapses") #' @method PotentialSynapses default -PotentialSynapses.default <- function(a, b, s=2, sigma=2) { +PotentialSynapses.default <- function(a, b, s=2, sigma=2, ...) { #Compare for matrices of input data rather than neurons # short circuit if there are no points to check in one list or other! @@ -148,8 +148,8 @@ PotentialSynapses.default <- function(a, b, s=2, sigma=2) { return(rval) } -#' @method PotentialSynapses dotprops -PotentialSynapses.dotprops <- function(a, b, s, sigma, seglength) { +#' @export +PotentialSynapses.dotprops <- function(a, b, s, sigma, seglength, ...) { # short circuit if there are no points to check in one list or other! if(nrow(a$points) * nrow(b$points) == 0) return(0) diff --git a/R/seglist.R b/R/seglist.R index e4b78819..ba70c7e5 100644 --- a/R/seglist.R +++ b/R/seglist.R @@ -70,19 +70,19 @@ as.seglist.default<-function(x, ...) stop("Not yet implemented!") #' @param origin The origin of the tree (see details) #' @param Verbose Whether to print progress updates to console (default FALSE) #' @return a \code{list} with one entry for each unbranched segment. -#' @seealso \code{\link{ngraph},\link{igraph}} +#' @seealso \code{\link{ngraph},\link[igraph]{igraph}} #' @export #' @method as.seglist igraph -#' @importFrom igraph is.directed is.connected graph.dfs degree +#' @importFrom igraph is_directed is_connected dfs degree #' @rdname seglist as.seglist.igraph<-function(x, origin=NULL, Verbose=FALSE, ...){ # Handle degenerate cases - if(!is.connected(x)) stop("Graph is not fully connected!") if(vcount(x)==0) { if(Verbose) warning("Empty graph! Seglist not defined") return(NULL) } - if(is.directed(x) && !igraph::is.dag(x)){ + if(!is_connected(x)) stop("Graph is not fully connected!") + if(is_directed(x) && !igraph::is_dag(x)){ stop("Graph has cycles!") } @@ -104,7 +104,7 @@ as.seglist.igraph<-function(x, origin=NULL, Verbose=FALSE, ...){ # Handle Origin if(is.null(origin)){ # no explicit origin specified, use raw vertex id of graph root - if(is.directed(x)) + if(is_directed(x)) origin=rootpoints(x, original.ids=FALSE) } else { # we've been given an origin but it may not be a raw vertex id for this @@ -121,7 +121,7 @@ as.seglist.igraph<-function(x, origin=NULL, Verbose=FALSE, ...){ } # Now do a depth first search to ensure that ordering is correct - dfs=graph.dfs(x, root=origin, father=TRUE, neimode='all') + dfs=dfs(x, root=origin, father=TRUE, mode='all') # cache orders for speed: dfs$order[i] is slooooow in igraph>=1.0 orders=as.integer(dfs$order) ncount=degree(x) diff --git a/R/summary.R b/R/summary.R index 6b38da90..446a777b 100644 --- a/R/summary.R +++ b/R/summary.R @@ -27,17 +27,17 @@ summary.neuronlist<-function(object, ..., include.attached.dataframe=FALSE) { #' @return A \code{data.frame} summarising the tree properties of the neuron #' with columns \itemize{ #' -#' \item{root} +#' \item root #' -#' \item{nodes} +#' \item nodes #' -#' \item{segments} +#' \item segments #' -#' \item{branchpoints} +#' \item branchpoints #' -#' \item{endpoints} +#' \item endpoints #' -#' \item{cable.length} +#' \item cable.length #' #' } #' @export diff --git a/R/vaa3draw-io.R b/R/vaa3draw-io.R index ca417dd2..c9160826 100644 --- a/R/vaa3draw-io.R +++ b/R/vaa3draw-io.R @@ -3,7 +3,7 @@ #' Check if a file is in the raw image format used by Hanchuan Peng's Vaa3D #' #' @description See http://www.vaa3d.org/ -#' https://svn.janelia.org/penglab/projects/vaa3d/trunk/imagej_io/v3draw_io_imagej/raw_reader.java +#' https://github.com/Vaa3D/v3d_external/blob/master/imagej_io/v3draw_io_imagej/raw_reader.java #' #' @details Note that multiple files can be checked when a character vector of #' length > 1 is provided, but only one file can be checked when a raw byte diff --git a/R/xform.R b/R/xform.R index 7446195d..8cad78dc 100644 --- a/R/xform.R +++ b/R/xform.R @@ -297,7 +297,7 @@ xyzmatrix.hxsurf<-function(x, ...) { #' @rdname xyzmatrix #' @export xyzmatrix.igraph<-function(x, ...){ - xyz=sapply(c("X","Y","Z"), function(c) igraph::get.vertex.attribute(x, c)) + xyz=sapply(c("X","Y","Z"), function(c) igraph::vertex_attr(x, c)) if(is.list(xyz) && all(sapply(xyz, is.null))) xyz = NULL xyz @@ -364,7 +364,7 @@ xyzmatrix.mesh3d<-function(x, ...){ `xyzmatrix<-.igraph`<-function(x, value){ colnames(value)=c("X","Y","Z") for(col in colnames(value)){ - x=igraph::set.vertex.attribute(x, col, value=value[,col]) + x=igraph::set_vertex_attr(x, col, value=value[,col]) } x } @@ -423,6 +423,13 @@ nvertices.neuronlist <- function(x, ...) { sapply(x, nvertices) } +#' @rdname nvertices +#' @export +nvertices.igraph <- function(x, ...) { + # as of igraph 2.0 this is numeric + as.integer(igraph::vcount(x)) +} + #' Mirror 3D object about a given axis, optionally using a warping registration #' #' @description mirroring with a warping registration can be used to account diff --git a/README.md b/README.md index eefb9bed..95e02c5a 100644 --- a/README.md +++ b/README.md @@ -1,21 +1,26 @@ -# nat: NeuroAnatomy Toolbox +# nat: NeuroAnatomy Toolbox + +[![natverse](https://img.shields.io/badge/natverse-Part%20of%20the%20natverse-a241b6)](https://natverse.org/) [![DOI](https://img.shields.io/badge/doi-10.5281%2Fzenodo.10171-blue.svg)](http://dx.doi.org/10.5281/zenodo.10171) -[![Release Version](https://img.shields.io/github/release/jefferis/nat.svg)](https://github.com/jefferis/nat/releases/latest) +[![Release Version](https://img.shields.io/github/release/natverse/nat.svg)](https://github.com/natverse/nat/releases/latest) [![CRAN_Status_Badge](http://www.r-pkg.org/badges/version/nat)](https://cran.r-project.org/package=nat) -[![Build Status](https://img.shields.io/travis/jefferis/nat.svg)](https://travis-ci.org/jefferis/nat) -[![Coverage Status](https://coveralls.io/repos/jefferis/nat/badge.svg?branch=master)](https://coveralls.io/r/jefferis/nat?branch=master) -[![Docs](https://img.shields.io/badge/docs-100%25-brightgreen.svg)](http://jefferis.github.io/nat/reference/) - +[![Build status](https://github.com/natverse/nat/workflows/R-CMD-check/badge.svg)](https://github.com/natverse/nat/actions) +[![Coverage Status](https://codecov.io/gh/natverse/nat/branch/master/graph/badge.svg)](https://app.codecov.io/gh/natverse/nat) +[![Docs](https://img.shields.io/badge/docs-100%25-brightgreen.svg)](https://natverse.org//nat/reference/) +[![Downloads](http://cranlogs.r-pkg.org/badges/nat?color=brightgreen)](https://www.r-pkg.org:443/pkg/nat) + An R package for the (3D) visualisation and analysis of biological image data, especially tracings of -single neurons. See [nat.examples](https://github.com/jefferis/nat.examples) and [frulhns](https://github.com/jefferis/frulhns) for sample code. - -**nat** is a cleaned up version of [code](https://github.com/jefferis/AnalysisSuite) that has been used in a number of papers from our group including: +single neurons. **nat** is the core package of a wider suite of neuroanatomy +tools introduced at http://natverse.github.io. **nat** (and its [ancestors](https://github.com/jefferis/AnalysisSuite)) +have been used in a number of papers from our group including: [![Cell 2007 Cover](http://www.cell.com/cms/attachment/602399/4753939/cov200h.gif "Olfactory Projection Neuron Mapping")](http://dx.doi.org/10.1016/j.cell.2007.01.040) [![CB 2010 Cover](http://www.cell.com/cms/attachment/612001/4900537/cov200h.gif "fruitless Circuit Mapping")](http://dx.doi.org/10.1016/j.cub.2010.07.045) -[![Nature 2011](http://www.nature.com/nature/journal/v478/n7368/carousel/nature10428-f4.2.jpg "Food and Pheromone Integration")](http://dx.doi.org/10.1038/nature10428) -[Cell 2013 Abstract](http://dx.doi.org/10.1016/j.cell.2013.11.025) +[Food and Pheromone Integration](http://dx.doi.org/10.1038/nature10428) +[Cell 2013 Abstract](http://dx.doi.org/10.1016/j.cell.2013.11.025) +[![Neuron 2016](http://www2.mrc-lmb.cam.ac.uk/wordpress/wp-content/uploads/P1Clustering_200_sq_crop-215x215.jpg "NBLAST")](http://dx.doi.org/10.1016/j.neuron.2016.06.012) + ## Quick Start @@ -44,7 +49,8 @@ A confirmed stable version of **nat** can be installed from CRAN. install.packages("nat") ```` -However, **nat** remains under quite active development, so we generally +However, **nat** remains under quite active development, so if you will be +using **nat** extensively, we generally recommend installing the latest development version directly from github using the [devtools](https://cran.r-project.org/package=devtools) package. @@ -52,27 +58,43 @@ the [devtools](https://cran.r-project.org/package=devtools) package. # install devtools if required if (!requireNamespace("devtools")) install.packages("devtools") # then install nat -devtools::install_github("jefferis/nat") +devtools::install_github("natverse/nat") + ``` +## Learn + +To get an idea of what **nat** can do: + +* Skim through the Articles listed at https://natverse.org//nat/ +* Take a look at the [R Markdown](https://rmarkdown.rstudio.com/) reports used + to generate the [figures for our NBLAST paper](https://doi.org/10.1016/j.neuron.2016.06.012). + +When you're ready to learn more: + +* Read the [overview package documentation](https://natverse.org//nat/reference/nat-package.html) + (`?nat` in R) +* Read the [Introduction to neurons](https://natverse.org//nat/articles/neurons-intro.html) article +* Check out the thematically organised [function reference documentation](https://natverse.org//nat/reference/). + * Most help pages include examples. +* Try out sample code: + - [nat.examples](https://github.com/natverse/nat.examples) has detailed + examples for data sets from a range of model organisms and techniques + - [frulhns](https://github.com/jefferis/frulhns) analysis of sexually dimorphic circuits + - [NBLAST figures](https://github.com/jefferislab/NBLAST_figures/) ## Help -If you want some help using **nat**, then please use the following resources +If you want some help using **nat**: -* For installation issues, see the [Installation vignette](http://jefferis.github.io/nat/articles/Installation.html) -* Start with the [overview package documentation](http://jefferis.github.io/nat/reference/nat-package.html) (`?nat` in R) -* Thematically organised [function reference documentation](http://jefferis.github.io/nat/reference/) -* [nat.examples](https://github.com/jefferis/nat.examples) sample code -* [nat-user](https://groups.google.com/forum/#!forum/nat-user) Google group - +* For installation issues, see the [Installation vignette](https://natverse.org//nat/articles/Installation.html) +* Contact [nat-user](https://groups.google.com/forum/#!forum/nat-user) Google group - we normally respond promptly and you will also be helping future users. -## Problems -If you think that you have found a bug +If you think that you have found a bug: -* Install the development version of nat using devtools (see above) -* Check the [github issues](https://github.com/jefferis/nat/issues?q=is%3Aissue) and - * [file a bug report](https://github.com/jefferis/nat/issues/new) if this seems to be a new problem - * comment on an existing bug report -* Write to the [nat-user](https://groups.google.com/forum/#!forum/nat-user) list - for help. +* Install the development version of nat using devtools (see above) and see if + that helps. +* Check the [github issues](https://github.com/natverse/nat/issues?q=is%3Aissue) and + - [file a bug report](https://github.com/natverse/nat/issues/new) if this seems to be a new problem + - comment on an existing bug report -Thanks for your interest in *nat*! +Thanks for your interest in **nat**! diff --git a/cran-comments.md b/cran-comments.md index ff019c07..dcee242f 100644 --- a/cran-comments.md +++ b/cran-comments.md @@ -1,26 +1,19 @@ -# nat 1.8.11 +# nat 1.8.25 -* minor updates and fixes -* includes fix for upcoming testthat v2 at request of Hadley Wickham -* fixes error on Solaris test suite due to network connectivity issue - https://www.r-project.org/nosvn/R.check/r-patched-solaris-x86/nat-00check.html +This submission fixes Rd link targets missing package anchors as requested by +Kurt Hornik on behalf of CRAN on 2025-07-23. -## Test environments -* local OS X install, R 3.4.2 -* ubuntu 12.04 (on travis-ci), R 3.4.2 -* win-builder (devel) +With many thanks, -## R CMD check results +Greg Jefferis. -0 errors | 0 warnings | 0 notes +## Test environments -https://win-builder.r-project.org/2x7Txk57YxtD/00check.log +* local OS X install, R 4.5.1. +* win-builder (r-devel) -Please note that previous versions of R reported possible spelling errors in -the DESCRIPTION file, but these were all false positives. +## R CMD check results -## Tests -Note that some tests have been marked as donttest to reduce the standard test -time including on CRAN. I have succesfully run all tests using +0 errors | 0 warnings | 0 notes - R CMD CHECK --run-donttest --as-cran +https://win-builder.r-project.org/T27GG01jiPjz diff --git a/data/Cell07PNs.rda b/data/Cell07PNs.rda index 00d117df..55999d67 100644 Binary files a/data/Cell07PNs.rda and b/data/Cell07PNs.rda differ diff --git a/docs/404.html b/docs/404.html new file mode 100644 index 00000000..2d24a338 --- /dev/null +++ b/docs/404.html @@ -0,0 +1,160 @@ + + + + + + + + +Page not found (404) • nat + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + + +
+ +
+
+ + +Content not found. Please use links in the navbar. + +
+ + + +
+ + + +
+ + +
+

Site built with pkgdown 1.6.1.

+
+ +
+
+ + + + + + + + diff --git a/docs/articles/Installation.html b/docs/articles/Installation.html index 4fd4b022..50771fd6 100644 --- a/docs/articles/Installation.html +++ b/docs/articles/Installation.html @@ -1,36 +1,45 @@ - + Installation Details • nat - - - - + + + + + + + - -
+ +
-
+ +
+
+

2021-09-05

+ + Source: vignettes/Installation.Rmd + + +
-

Preface

This document provides additional details about installation that may help you solve certain difficulties, especially on Windows or Mac platforms.

-

The source code for this vignette is available at https://github.com/jefferis/nat/blob/master/vignettes/Installation.Rmd. If you find something unclear or notice a typo, I would be very happy if you would click on the Pencil Icon on that page or follow this link to edit and suggest an alternative wording. Don’t be shy about doing this; I have to review any change and even if your suggestion is not perfect it will still be a prompt for me to improve this document. Thank you!

+

The source code for this vignette is available at https://github.com/natverse/nat/blob/master/vignettes/Installation.Rmd. If you find something unclear or notice a typo, I would be very happy if you would click on the Pencil Icon on that page or follow this link to edit and suggest an alternative wording. Don’t be shy about doing this; I have to review any change and even if your suggestion is not perfect it will still be a prompt for me to improve this document. Thank you!

@@ -94,40 +107,44 @@

-

3D visualisation is provided by the rgl package based on OpenGL. On Mac OS X if you use RStudio or R from the terminal, you must have a copy of XQuartz, the X11 window manager, installed. This is no longer a default install since Mac OS X 10.8. You need to install XQuartz, before installing the nat package. Logout and login for the installation to take effect. You can get it from https://xquartz.macosforge.org/landing/. This page is also linked from the Download R for (Mac) OS X page.

+

3D visualisation is provided by the rgl package based on OpenGL. On Mac OS X if you use RStudio or R from the terminal, you must have a copy of XQuartz, the X11 window manager, installed. This is no longer a default install since Mac OS X 10.8. You need to install XQuartz, before installing the nat package. Logout and login for the installation to take effect. You can get it from https://www.xquartz.org/. This page is also linked from the Download R for (Mac) OS X page.

If you want to apply non-rigid registrations calculated by the Computational Morphometry Toolkit (CMTK) you will need to install that separately – see section External Dependencies below.

Basic Installation

As of v1.0 there is a released version on CRAN. This is normally updated only every few months.

-
install.packages("nat")
+

If you wish to run the package tests, it is necessary to install with all dependencies:

-
install.packages("nat", dependencies=TRUE)
+
+install.packages("nat", dependencies=TRUE)

Development version

nat remains under quite active development, so we generally suggest using the development version directly from github. The recommended way to do this is to install Hadley Wickham’s invaluable devtools package (if you have not already done so) and then use that to install nat.

-
# install devtools if required
-if (!require("devtools")) install.packages("devtools")
+
+# install devtools if required
+if (!require("devtools")) install.packages("devtools")
 # then install nat
-devtools::install_github("jefferis/nat")
-

The nat package includes extensive unit tests which are run along with R’s (extremely fastidious) package check routines by the Travis continuous integration server. The master branch is therefore considered very stable and may well contain fixes or enhancements over released versions. However, you can install any release version including the latest release as follows:

-
devtools::install_github("jefferis/nat@v1.8.6")
-

The same syntax can be used to install any arbitrary version that you want from github. See ?install_github for details.

+devtools::install_github("natverse/nat")
+

The nat package includes extensive unit tests which are run along with R’s (extremely fastidious) package check routines by the Travis continuous integration server. The master branch is therefore considered very stable and may well contain fixes or enhancements over released versions. However, you can install any release version including the latest release as follows:

+
+devtools::install_github("natverse/nat@v1.8.6")
+

The same syntax can be used to install any arbitrary version that you want from github. See ?install_github for details.

Note: Windows users need Rtools to install in this way, but devtools should offer to install this for you if you do not already have it.

External Dependencies

-

nat is self sufficient for core functionality, but the transformation of 3D data using Computational Morphometry Toolkit (CMTK) registrations depends on an external installation of that toolkit. CMTK binaries can be downloaded for Windows, Linux and Mac at http://www.nitrc.org/projects/cmtk/. Source code is available from the same site or an unofficial mirror repository at https://github.com/jefferis/cmtk. We have extensive experience of using CMTK under Linux (where we compile from source) and Mac (where we compile or use the MacOSX-10.6-x86_64.dmg binary installers). We have also used neurodebian to install as part of the Travis continuous integration setup (see the project’s .travis.yml file).

+

nat is self sufficient for core functionality, but the transformation of 3D data using Computational Morphometry Toolkit (CMTK) registrations depends on an external installation of that toolkit. CMTK binaries can be downloaded for Windows, Linux and Mac at https://www.nitrc.org/projects/cmtk/. Source code is available from the same site or an unofficial mirror repository at https://github.com/jefferis/cmtk. We have extensive experience of using CMTK under Linux (where we compile from source) and Mac (where we compile or use the MacOSX-10.6-x86_64.dmg binary installers). We have also used neurodebian to install as part of our (now retired) Travis continuous integration setup (see the project’s .travis.yml file).

CMTK+nat on Windows

We have much less experience using CMTK on Windows than on Mac/Linux platforms. Experiments in May 2016 suggest that the best option is to use the cygwin CMTK distribution (cygwin provides a linux like environment). Here are the steps we took:

    -
  • You must ensure that you have at least version nat v1.8.5. It is recommended that follow the steps for installing the development version of nat straight from github as described in section Development version +
  • You must ensure that you have at least version nat v1.8.5. It is recommended that follow the steps for installing the development version of nat straight from github as described in section Development version
  • Install Cygwin accepting the default path C:\cygwin64
  • @@ -135,44 +152,35 @@

  • Download CMTK-3.3.1-CYGWIN-x86_64.tar.gz to the cygwin folder (C:\cygwin64)
  • Start a Cygwin terminal and issue the following command tar -xvf CMTK-3.3.1-CYGWIN-x86_64.tar.gz to extract CMTK to the cygwin folder.
  • Optionally add C:\cygwin64\bin to your windows path (since v1.8.10 nat should look after this - see ?cmtk.bindir).
  • -
  • The nat function cmtk.bindir() should now correctly identify the CMTK binary directory. You can test that the executables are working by trying the following in R library(nat);cmtk.dof2mat(version = TRUE) which should then respond with “3.3.1” if you have installed the CMTK version we have just mentioned.
  • +
  • The nat function cmtk.bindir() should now correctly identify the CMTK binary directory. You can test that the executables are working by trying the following in R library(nat);cmtk.dof2mat(version = TRUE) which should then respond with “3.3.1” if you have installed the CMTK version we have just mentioned.
-
- +
-

Site built with pkgdown.

+

Site built with pkgdown 1.6.1.

+ + + diff --git a/docs/articles/Installation_files/header-attrs-2.10/header-attrs.js b/docs/articles/Installation_files/header-attrs-2.10/header-attrs.js new file mode 100644 index 00000000..dd57d92e --- /dev/null +++ b/docs/articles/Installation_files/header-attrs-2.10/header-attrs.js @@ -0,0 +1,12 @@ +// Pandoc 2.9 adds attributes on both header and div. We remove the former (to +// be compatible with the behavior of Pandoc < 2.8). +document.addEventListener('DOMContentLoaded', function(e) { + var hs = document.querySelectorAll("div.section[class*='level'] > :first-child"); + var i, h, a; + for (i = 0; i < hs.length; i++) { + h = hs[i]; + if (!/^h[1-6]$/i.test(h.tagName)) continue; // it should be a header h1-h6 + a = h.attributes; + while (a.length > 0) h.removeAttribute(a[0].name); + } +}); diff --git a/docs/articles/fig/neuronlist-subsets.pdf b/docs/articles/fig/neuronlist-subsets.pdf deleted file mode 100644 index 9b918eb7..00000000 Binary files a/docs/articles/fig/neuronlist-subsets.pdf and /dev/null differ diff --git a/docs/articles/fig/neuronlist.pdf b/docs/articles/fig/neuronlist.pdf deleted file mode 100644 index cd0dc290..00000000 Binary files a/docs/articles/fig/neuronlist.pdf and /dev/null differ diff --git a/docs/articles/index.html b/docs/articles/index.html index c00451da..10392c9d 100644 --- a/docs/articles/index.html +++ b/docs/articles/index.html @@ -1,6 +1,6 @@ - + @@ -8,25 +8,45 @@ Articles • nat + - + - - + + + + + + + - + + + + + + + + - - - + + + + + + + + + - + + + - -
+ +
-
- +
- +
-

Site built with pkgdown.

+

Site built with pkgdown 1.6.1.

+ + + + + diff --git a/docs/articles/neurons-intro.html b/docs/articles/neurons-intro.html index bac8437f..d86d440d 100644 --- a/docs/articles/neurons-intro.html +++ b/docs/articles/neurons-intro.html @@ -1,36 +1,45 @@ - + Introduction to neurons and neuronlists • nat - - - - + + + + + + + - -
+ +
-
+ + +
+
+

2021-09-05

+ + Source: vignettes/neurons-intro.Rmd + + +
-

Preface

This vignette is designed to give you a good introduction to some of the key features of nat by teaching you about how it handles individual neurons and collections of neurons.

-

The source code for this vignette is available at https://github.com/jefferis/nat/blob/master/vignettes/neurons-intro.Rmd. If you find something unclear or notice a typo, I would be very happy if you would click on the Pencil Icon on that page or follow this link to edit and suggest an alternative wording. Don’t be shy about doing this; I have to review any change and even if your suggestion is not perfect it will still be a prompt for me to improve this document. Thank you!

+

The source code for this vignette is available at https://github.com/natverse/nat/blob/master/vignettes/neurons-intro.Rmd. If you find something unclear or notice a typo, I would be very happy if you would click on the Pencil Icon on that page or follow this link to edit and suggest an alternative wording. Don’t be shy about doing this; I have to review any change and even if your suggestion is not perfect it will still be a prompt for me to improve this document. Thank you!

Startup

Install the package if required

-
install.packages('nat', dependencies = TRUE)
+
+install.packages('nat', dependencies = TRUE)

Load the package

-
library(nat)
+

@@ -108,16 +124,20 @@

Sample Data

As an example we’re going to look at a data set of olfactory projection neurons originally published as Supplemental Information to accompany Jefferis, Potter et al, Cell (2007). A subset of the original data are distributed as a sample data object with the nat package, which we can load like so.

-
data("Cell07PNs")
-

For more information about these data see Cell07PNs.

+
+data("Cell07PNs")
+

For more information about these data see Cell07PNs.

This Cell07PNs object has two classes neuronlist and the base class list

-
class(Cell07PNs)
+
+class(Cell07PNs)
## [1] "neuronlist" "list"

Many R objects inherit from the base class list (objects can have multiple classes in the same way that a mitral cell is also neuron) because this is a convenient container class into which you can put a variety of different kinds of data. In this case the Cell07PNs neuronlist contains 40 objects:

-
length(Cell07PNs)
+
+length(Cell07PNs)
## [1] 40
-
# access the first neuron in the neuronlist
-class(Cell07PNs[[1]])
+
+# access the first neuron in the neuronlist
+class(Cell07PNs[[1]])
## [1] "neuron" "list"

each representing a traced neuron. We will now look in detail at these two classes.

@@ -126,26 +146,28 @@

Neurons

We start by extracting the first neuron in Cell07PNs, and assigning it to a variable. We can then plot the neuron so that we have an image of what we are talking about.

-
n1=Cell07PNs[[1]]
-plot(n1)
+
+n1=Cell07PNs[[1]]
+plot(n1)

Neuron internal structure

The str function (short for structure) allows us to take a look at the internal structure of this neuron object.

-
# Use =1 so that we don't show complete structure
+
+# Use =1 so that we don't show complete structure
 # for objects inside n1
-str(n1, max.level=1)
+str(n1, max.level=1)
## List of 24
 ##  $ CellType     : chr "DA1"
 ##  $ NeuronName   : chr "EBH11R"
-##  $ InputFileName:Class 'AsIs'  chr "/GD/projects/PN2/TransformedTraces/DA1/EBH11R.tasc"
+##  $ InputFileName: 'AsIs' chr "/GD/projects/PN2/TransformedTraces/DA1/EBH11R.tasc"
 ##  $ CreatedAt    : POSIXt[1:1], format: "2006-01-17 15:21:14"
 ##  $ NodeName     : Named chr "jefferis.joh.cam.ac.uk"
 ##   ..- attr(*, "names")= chr "nodename"
 ##  $ InputFileStat:'data.frame':   1 obs. of  10 variables:
 ##  $ InputFileMD5 : Named chr "fcacee3f874cbe2c6ad96214e6fee337"
-##   ..- attr(*, "names")=Class 'AsIs'  chr "/GD/projects/PN2/TransformedTraces/DA1/EBH11R.tasc"
+##   ..- attr(*, "names")= 'AsIs' chr "/GD/projects/PN2/TransformedTraces/DA1/EBH11R.tasc"
 ##  $ NumPoints    : int 180
 ##  $ StartPoint   : num 1
 ##  $ BranchPoints : num [1:16] 34 48 51 75 78 95 98 99 108 109 ...
@@ -164,15 +186,19 @@ 

## $ NumMBBranches: num 2 ## $ AxonLHEP : num 72 ## - attr(*, "class")= chr [1:2] "neuron" "list"

-

From this you can see that there are a large number of fields inside the neuron. Each field can be accessed using the $ or [[ operators

-
n1$NumPoints
+

From this you can see that there are a large number of fields inside the neuron. Each field can be accessed using the $ or [[ operators

+
+n1$NumPoints
## [1] 180
-
n1[["NumPoints"]]
+
+n1[["NumPoints"]]
## [1] 180

There are a set of core fields (described in ?neuron documentation); the key ones will be described shortly. However there are also quite a few user fields in this neuron and you can safely add any field you like so long as its name does not clash with an existing field. For example:

-
n1$Comment='The sex of this specimen is uncertain'
+
+n1$Comment='The sex of this specimen is uncertain'

The single most important field in a neuron is the $d data.frame. This contains a block of data closely reminiscent of the SWC data format for traced neurons:

-
str(n1$d)
+
+str(n1$d)
## 'data.frame':    180 obs. of  7 variables:
 ##  $ PointNo: int  1 2 3 4 5 6 7 8 9 10 ...
 ##  $ Label  : num  2 2 2 2 2 2 2 2 2 2 ...
@@ -189,46 +215,51 @@ 

R’s simple S3 object oriented system allows specialised functions for particular classes to be defined. These functions tailored to a particular class are called methods. Methods can be provided for pre-existing functions supplied with base R as well as new user-written functions. The system is quite simple. If a function foo is defined as a generic function then you can define new functions called foo.bar that will be called when you write foo(x) and x has class `bar.

We already used one such method without comment, plot.neuron. There is a base R function called plot. nat defines a new function called plot.neuron, which R interprets as a plot method specialised for neuron objects. When the base R plot function is called, it looks at the class of its first object to see whether a specialised method exists. If there is none, it will use a fallback method called plot.default.

The plot.neuron method interprets the branching structure of a neuron and draws line segments joining up the connected nodes at the appropriate 2D positions. You can compare it with what you would get if you just plotted the XY position of all nodes joined together by a single line:

-
plot(n1$d$X, n1$d$Y, type = 'l')
+
+plot(n1$d$X, n1$d$Y, type = 'l')

You can find out what methods are available for a particular class like so:

-
methods(class = 'neuron')
-
##  [1] -                  *                  /                 
-##  [4] +                  all.equal          as.neuron         
-##  [7] as.ngraph          as.seglist         boundingbox       
-## [10] branchpoints       dotprops           endpoints         
-## [13] ndigest            nvertices          plot              
-## [16] plot3d             potential_synapses prune             
-## [19] resample           rootpoints         scale             
-## [22] subset             summary            write.vtk         
-## [25] xform              xyzmatrix          xyzmatrix<-       
+
+methods(class = 'neuron')
+
##  [1] all.equal          as.neuron          as.ngraph          as.seglist        
+##  [5] branchpoints       dotprops           endpoints          intersect_plane   
+##  [9] ndigest            nvertices          Ops                plot              
+## [13] plot3d             potential_synapses print              prune_in_volume   
+## [17] prune_online       prune_twigs        prune              reroot            
+## [21] resample           rootpoints         scale              sholl_analysis    
+## [25] subset             summary            write.vtk          xform             
+## [29] xyzmatrix          xyzmatrix<-       
 ## see '?methods' for accessing help and source code
-

You can then find the help page for any method in the console with ?plot.neuron. Note that if you write ?plot you will get the documentation for the basic plot function supplied with R.

-

It is also good idea to look at nat’s function reference page which groups available functions into categories that often reflect the class of object they can work on.

-

In R, operators such as * or + are actually special functions with two arguments, so one can add methods for these in the same way. In the following example we use this arithmetic to shift a neuron by a small amount:

-
plot(n1, col = 'black', WithNodes = F, main="Shifting neurons")
+

You can then find the help page for any method in the console with ?plot.neuron. Note that if you write ?plot you will get the documentation for the basic plot function supplied with R.

+

It is also good idea to look at nat’s function reference page which groups available functions into categories that often reflect the class of object they can work on.

+

In R, operators such as * or + are actually special functions with two arguments, so one can add methods for these in the same way. In the following example we use this arithmetic to shift a neuron by a small amount:

+
+plot(n1, col = 'black', WithNodes = F, main="Shifting neurons")
 # shift by 3 microns in x,y,z
-plot(n1+3, col = 'red', add = TRUE, WithNodes = F)
+plot(n1+3, col = 'red', add = TRUE, WithNodes = F)
 # shift by -5 microns in y
-plot(n1+c(0,-5,0), col = 'blue', add = TRUE, WithNodes = F)
+plot(n1+c(0,-5,0), col = 'blue', add = TRUE, WithNodes = F)

Another specialised method is subset.neuron which we can use to extract part of a neuron into a new object. For example, a simple spatial criterion, X location must be >240, is used to extract the axon terminal arborisation field in this example

-
plot(n1, col = 'black', WithAllPoints = T, main="Subsetting a neuron")
+
+plot(n1, col = 'black', WithAllPoints = T, main="Subsetting a neuron")
 # keep only nodes with X position >20
-n1.lh=subset(n1, X>240)
+n1.lh=subset(n1, X>240)
 # plot the selected part of the neuron in blue
-plot(n1.lh, col='blue', lwd=3, add=TRUE)
+plot(n1.lh, col='blue', lwd=3, add=TRUE)
 # add a line illustrating the cut point
-abline(v=240, lty=2)
+abline(v=240, lty=2)

We can also summarise the morphological properties of a neuron using the summary.neuron method, which allows us to compare measurements for the original neuron and the axon arbour that we just cut out above.

- -
##   root nodes segments branchpoints endpoints cable.length
-## 1    1   180       33           16        18     297.1763
-
summary(n1.lh)
-
##   root nodes segments branchpoints endpoints cable.length
-## 1    1   111       27           13        15     156.7654
-

See nat’s function reference page for additional functions for working with neurons.

+
+summary(n1)
+
##   root nodes segments branchpoints endpoints cable.length nTrees
+## 1    1   180       33           16        18     297.1763      1
+
+summary(n1.lh)
+
##   root nodes segments branchpoints endpoints cable.length nTrees
+## 1    1   111       27           13        15     156.7654      1
+

See nat’s function reference page for additional functions for working with neurons.

@@ -236,46 +267,49 @@

Neuronlists

The data statement above loaded a neuronlist object called Cell07PNs containing 40 neuron objects. neuronlist objects are key data structures in nat for convenient handling of collections of neurons.

-Structure of neuronlist objects

Structure of neuronlist objects

+

Structure of neuronlist objects

The diagram above presents the structure of a neuronlist, x, which contains 5 neurons. The main structure is an R list object, which in this case contains 5 slots. Each slot contains a neuron with a unique name. In addition to this list of neurons there is an optional attached data.frame (another standard R class). When present, each neuron in the main list must have a matching row in this data.frame.

Neuronlists can be manipulated use the square bracket subscript operator to extract or replace a subset of their elements. Crucially when this happens the corresponding rows of the attached metadata are also selected as diagrammed for the result of x[1:3] (right hand side of figure above).

When subscripting any list in R, it is very important to understand the difference between using the single and double bracket operator. We can illustrate this difference as follows:

-The difference between single and double bracket subscript operators

The difference between single and double bracket subscript operators

+

The difference between single and double bracket subscript operators

The single bracket operator makes a new list containing a specified subset of elements in the original list, while the double bracket operator extracts the object at the given position. So in the figure x[1] is a neuronlist object of length 1, whereas x[[1]] is the neuron object at the first position in the list.

Worked Examples

Let us start by extracting the first five neurons from our sample data.

-
# we can select neurons by indexing 
-first5=Cell07PNs[1:5]
-summary(first5)
-
##        root nodes segments branchpoints endpoints cable.length
-## EBH11R    1   180       33           16        18     297.1763
-## EBH20L    1   200       26           12        15     327.0929
-## EBH20R    1   199       25           12        14     347.6153
-## EBI12L    1   169       23           11        13     294.4680
-## EBI22R    1   160       27           13        15     303.0150
+
+# we can select neurons by indexing 
+first5=Cell07PNs[1:5]
+summary(first5)
+
##        root nodes segments branchpoints endpoints cable.length nTrees
+## EBH11R    1   180       33           16        18     297.1763      1
+## EBH20L    1   200       26           12        15     327.0929      1
+## EBH20R    1   199       25           12        14     347.6153      1
+## EBI12L    1   169       23           11        13     294.4680      1
+## EBI22R    1   160       27           13        15     303.0150      1

Each neuron in the neuronlist has an associated name which can be used to select it. We can get the names of all neurons using the names function.

-
names(Cell07PNs)
-
##  [1] "EBH11R" "EBH20L" "EBH20R" "EBI12L" "EBI22R" "EBJ23L" "EBJ3R" 
-##  [8] "EBN19L" "EBO15L" "EBO53L" "ECA34L" "ECB3L"  "LI23L"  "LIC2R" 
-## [15] "LJ5L"   "MC3B"   "MH16L"  "MM14L"  "NA7L"   "NH15L"  "NH29B" 
-## [22] "NI16L"  "NIA8L"  "NIA8R"  "NNA9L"  "NNC4R"  "NNE1L"  "OFD2L" 
-## [29] "OKC9R"  "SDD8L"  "SH21L"  "SL20L"  "TKC8R"  "TL4R"   "TS7L"  
-## [36] "TT27R"  "VA15R"  "VA20R"  "VB37L"  "VB58L"
-
nl3=Cell07PNs[c("EBH11R", "EBH20L", "EBH20R")]
-all.equal(nl3, Cell07PNs[1:3])
+
+names(Cell07PNs)
+
##  [1] "EBH11R" "EBH20L" "EBH20R" "EBI12L" "EBI22R" "EBJ23L" "EBJ3R"  "EBN19L"
+##  [9] "EBO15L" "EBO53L" "ECA34L" "ECB3L"  "LI23L"  "LIC2R"  "LJ5L"   "MC3B"  
+## [17] "MH16L"  "MM14L"  "NA7L"   "NH15L"  "NH29B"  "NI16L"  "NIA8L"  "NIA8R" 
+## [25] "NNA9L"  "NNC4R"  "NNE1L"  "OFD2L"  "OKC9R"  "SDD8L"  "SH21L"  "SL20L" 
+## [33] "TKC8R"  "TL4R"   "TS7L"   "TT27R"  "VA15R"  "VA20R"  "VB37L"  "VB58L"
+
+nl3=Cell07PNs[c("EBH11R", "EBH20L", "EBH20R")]
+all.equal(nl3, Cell07PNs[1:3])
## [1] TRUE
-

You can also use the $ operator to access a single neuron e.g. Cell07PNs$EBH11R. This can be quite useful when working interactively in the console because RStudio will offer to autocomplete the neuron name when you start typing past the $ symbol, but is not recommended for scripts.

+

You can also use the $ operator to access a single neuron e.g. Cell07PNs$EBH11R. This can be quite useful when working interactively in the console because RStudio will offer to autocomplete the neuron name when you start typing past the $ symbol, but is not recommended for scripts.

Metadata

The names of neurons are also used to index a data.frame object attached to the neuronlist with one row for each neuron. You can use the head function to give a summary of the attached metadata in this neuronlist. Using the as.data.frame method on a neuronlist allows you to extract this attached metadata to a separate object.

-
head(Cell07PNs)
+
+head(Cell07PNs)
##         Brain RegistrationScore Notes Glomerulus Batch Directory Traced
 ## EBH11R EBH11R                 4              DA1   PN2    unsure    yes
 ## EBH20L EBH20L                 4              DL3   PN2   unsure2    yes
@@ -318,11 +352,13 @@ 

## EBI12L /GD/projects/PN2/allreg/warp/unsure3/average-goodbrains_EBI12L101_warp_m0g40c4e1e-1x16r3.list ## EBI22R /GD/projects/PN2/allreg/warp/unsure3/average-goodbrains_EBI22R101_warp_m0g40c4e1e-1x16r3.list ## EBJ23L /GD/projects/PN2/allreg/warp/unsure4/average-goodbrains_EBJ23L101_warp_m0g40c4e1e-1x16r3.list

-
df=as.data.frame(Cell07PNs)
-nrow(df)
+
+df=as.data.frame(Cell07PNs)
+nrow(df)
## [1] 40
-
# rownames of data.frame are the same as names of Cell07PNs list.
-all.equal(rownames(df), names(Cell07PNs))
+
+# rownames of data.frame are the same as names of Cell07PNs list.
+all.equal(rownames(df), names(Cell07PNs))
## [1] TRUE

You can use columns in the attached metadata in expressions that select or operate on the neurons in the list. In the next two examples we

    @@ -330,57 +366,65 @@

    subset the neurons in a neuronlist based on a metadata column
  • use the with function to carry out a calculation using column(s) of metadata.
-
# subset.neuronlist method (which you call using the subset function)
-da1n=subset(Cell07PNs, Glomerulus=="DA1")
+
+# subset.neuronlist method (which you call using the subset function)
+da1n=subset(Cell07PNs, Glomerulus=="DA1")
 
 # with.neuronlist method
-with(Cell07PNs, table(Glomerulus))
+with(Cell07PNs, table(Glomerulus))
## Glomerulus
 ##  DA1  DL3 DP1m VA1d 
 ##   11   10    8   11

There is a second approach to accessing this attached metadata data.frame, using the square bracket operator with two arguments as used for subscripting (2D) matrices or data.frames. For example we can access the Glomerulus column like so:

-
Cell07PNs[, 'Glomerulus']
-
##  [1] DA1  DL3  DA1  DA1  DL3  DL3  VA1d VA1d VA1d VA1d DP1m DP1m DA1  DL3 
-## [15] VA1d VA1d DL3  DA1  DA1  VA1d VA1d VA1d DL3  VA1d DP1m DP1m DP1m DP1m
-## [29] DP1m DP1m DA1  DL3  DL3  DL3  VA1d DA1  DA1  DA1  DL3  DA1 
+
+Cell07PNs[, 'Glomerulus']
+
##  [1] DA1  DL3  DA1  DA1  DL3  DL3  VA1d VA1d VA1d VA1d DP1m DP1m DA1  DL3  VA1d
+## [16] VA1d DL3  DA1  DA1  VA1d VA1d VA1d DL3  VA1d DP1m DP1m DP1m DP1m DP1m DP1m
+## [31] DA1  DL3  DL3  DL3  VA1d DA1  DA1  DA1  DL3  DA1 
 ## Levels: DA1 DL3 DP1m VA1d

This approach has some features that make for additional flexibility. For example you can acess the whole data.frame like so:

-
summary(Cell07PNs[,])
+
+summary(Cell07PNs[,])

The form [,] which includes a comma implies two (missing) arguments. nat therefore interprets this as request for the 2D data.frame attached to Cell07PNs rather than the neuronlist itself. You can also use this notation to add new columns or modify existing columns in place.

-
Cell07PNs[, 'NewColumn'] = somevariable
-Cell07PNs[, "Sex"] = sub("F", "female", Cell07PNs[, "Sex"])
-Cell07PNs[, "Sex"] = sub("M", "male", Cell07PNs[, "Sex"])
+
+Cell07PNs[, 'NewColumn'] = somevariable
+Cell07PNs[, "Sex"] = sub("F", "female", Cell07PNs[, "Sex"])
+Cell07PNs[, "Sex"] = sub("M", "male", Cell07PNs[, "Sex"])

You can also access selected rows of the data.frame in the normal way:

-
Cell07PNs[1:5, "Glomerulus"]
-Cell07PNs[Cell07PNs[, "Sex"]=="F", "Glomerulus"]
+
+Cell07PNs[1:5, "Glomerulus"]
+Cell07PNs[Cell07PNs[, "Sex"]=="F", "Glomerulus"]

Working on all the neurons in a neuronlist

There are quite a few methods defined for the neuronlist class:

-
methods(class = "neuronlist")
-
##  [1] -                  [                  [<-               
-##  [4] *                  /                  +                 
-##  [7] as.data.frame      as.neuronlistfh    c                 
-## [10] data.frame<-       dimnames           dotprops          
-## [13] droplevels         head               intersect         
-## [16] mirror             nvertices          plot              
-## [19] plot3d             potential_synapses prune             
-## [22] setdiff            subset             summary           
-## [25] tail               union              with              
-## [28] xform              xyzmatrix          xyzmatrix<-       
+
+methods(class = "neuronlist")
+
##  [1] -                  [                  [<-                *                 
+##  [5] /                  +                  as.data.frame      as.neuronlistfh   
+##  [9] c                  data.frame<-       dimnames           dotprops          
+## [13] droplevels         head               intersect          mirror            
+## [17] nvertices          plot               plot3d             potential_synapses
+## [21] print              prune_in_volume    prune_online       prune_twigs       
+## [25] prune              reroot             resample           setdiff           
+## [29] sholl_analysis     subset             summary            tail              
+## [33] union              with               xform              xyzmatrix         
+## [37] xyzmatrix<-       
 ## see '?methods' for accessing help and source code
-

For example we can scale the position (and diameter) of all of the neurons in a neuronlist using the * operator:

-
# convert from microns to nm
-Cell07PNs.nm = Cell07PNs*1e3
-plot(Cell07PNs.nm)
+

For example we can scale the position (and diameter) of all of the neurons in a neuronlist using the * operator:

+
+# convert from microns to nm
+Cell07PNs.nm = Cell07PNs*1e3
+plot(Cell07PNs.nm)

There is also a more powerful xform function that allows arbitrary transformations to be applied. For example here we apply a 3D rotation expressed as a homogeneous affine matrix:

-
# define a 180 degree rotation around the x axis
-rotm=cmtkparams2affmat(rx=180)
+
+# define a 180 degree rotation around the x axis
+rotm=cmtkparams2affmat(rx=180)
 # remove tiny values due to rounding errors
-rotm=zapsmall(rotm)
-plot(xform(Cell07PNs, rotm))
+rotm=zapsmall(rotm) +plot(xform(Cell07PNs, rotm))

More generally any function that works on a neuron can be applied to a neuronlist by using the function nlapply. This is an analogue to base R’s lapply function. This will take care of returning a new neuronlist with the attached metadata and includes additional features such as error tolerance, progress bars and parallelisation for multi-core machines. It is worth reviewing the help and examples for this function carefully if you start to work regularly with neuronlists.

@@ -389,3225 +433,44 @@

Plots

We have already seen that we can plot a single neuron (the first) like so:

-
plot(Cell07PNs[[1]])
+
+plot(Cell07PNs[[1]])

The purple node higlights the root or soma of the neuron, red nodes are branch points, green nodes are end points. We can also label each node with its PointNo index.

-
plot(Cell07PNs[[1]], col='red', WithText=T)
+
+plot(Cell07PNs[[1]], col='red', WithText=T)

Multiple neurons can be plotted by passing a whole neuronlist or indexing it

-
plot(Cell07PNs[1:3])
+
+plot(Cell07PNs[1:3])

More complex subsets are possible by using plot.neuronlist subset argument (which works in the same way as the subset.neuronlist function). For example here we select neurons by which olfactory glomeruli their dendrites occupy:

-
plot(Cell07PNs, subset=Glomerulus!="DA1", col='grey', WithNodes=F, main="DA1 neurons")
-plot(Cell07PNs, subset=Glomerulus=="DA1", add=TRUE)
+
+plot(Cell07PNs, subset=Glomerulus!="DA1", col='grey', WithNodes=F, main="DA1 neurons")
+plot(Cell07PNs, subset=Glomerulus=="DA1", add=TRUE)

3D plots

-

So far we have only used 2D plots in this document, but especially for interactive analysis and exploration, it is much more helpful to have 3D plots that can be rotated, zoomed etc. nat provides numerous functions for 3D plots based on the rgl package. It is actually possible to embed fully interactive 3d figures in rmarkdown reports like this one by setting the webgl chunk option.

-
clear3d()
-plot3d(Cell07PNs[[1]], col='red')
+

So far we have only used 2D plots in this document, but especially for interactive analysis and exploration, it is much more helpful to have 3D plots that can be rotated, zoomed etc. nat provides numerous functions for 3D plots based on the rgl package. It is actually possible to embed fully interactive 3d figures in rmarkdown reports like this one by setting the webgl chunk option.

+
+clear3d()
+plot3d(Cell07PNs[[1]], col='red')
 # set a grey background so it's easier to see extent of the webgl canvas
-bg3d(col='lightgrey')
-
- -
-

-You must enable Javascript to view this page properly. -

-

You should be able to rotate (click and drag) and zoom (mouse wheel) this figure.

+bg3d(col='lightgrey')
+
+

You should be able to rotate (click and drag) and zoom (mouse wheel) this figure.

Since this results in quite large html files when used with many neurons, we will not use it further here. For now let’s show a plot in which we both select a subset of neurons and colour them according to their glomerulus of origin.

-
# 3d plot of neurons from olfactory glomeruli beginning with a D
+
+# 3d plot of neurons from olfactory glomeruli beginning with a D
 # coloured by glomerulus
-rval=plot3d(Cell07PNs, subset=grepl("^D", Glomerulus), col=Glomerulus,
-  lwd=2, WithNodes=FALSE)
+rval=plot3d(Cell07PNs, subset=grepl("^D", Glomerulus), col=Glomerulus, + lwd=2, WithNodes=FALSE)

-
# make a legend so that you know which colours match which glomerulus
-plot.new()
-with(attr(rval,'df'), legend('center', legend = unique(Glomerulus), fill=unique(col)))
+
+# make a legend so that you know which colours match which glomerulus
+plot.new()
+with(attr(rval,'df'), legend('center', legend = unique(Glomerulus), fill=unique(col)))

@@ -3616,33 +479,38 @@

Putting it all together

To close this tutorial, let’s do some morphological analysis of the neurons in this dataset. There are second order olfactory projection neurons originating from 4 different glomeruli in the Cell07PNs sample dataset, each coming from a different animal. We can ask whether their axon terminal arborisations in a brain area called the lateral horn show any features that are distinctive for different classes. This would be consistent with the hypothesis that information from different glomeruli (i.e. olfactory channels) is handled in a stereotyped way in this brain area.

Let’s start by cutting out the arbour within the lateral horn from all of the neurons. We’ll use a very simple approach of cutting at X=250, although nat has more sophisticated ways to do this e.g. by using 3D spaces defined by a surface mesh.

-
# note that we had to use OmitFailures=T due to a problem with the graph
+
+# note that we had to use OmitFailures=T due to a problem with the graph
 # structure of one neuron
-lha=nlapply(Cell07PNs, subset, X>250, OmitFailures = T)
+lha=nlapply(Cell07PNs, subset, X>250, OmitFailures = T)
 # Let's plot what we have colouring by glomerulus
-plot(lha, col=Glomerulus, WithNodes=F)
+plot(lha, col=Glomerulus, WithNodes=F)

Now we can get a basic statistical summary by axon arbour.

-
lhstats=summary(lha, include.attached.dataframe = TRUE)
-boxplot(lhstats$cable.length~lhstats$Glomerulus, log='y')
+
+lhstats=summary(lha, include.attached.dataframe = TRUE)
+boxplot(lhstats$cable.length~lhstats$Glomerulus, log='y')

-
boxplot(lhstats$branchpoints~lhstats$Glomerulus)
+
+boxplot(lhstats$branchpoints~lhstats$Glomerulus)

We can also calculate the median position of the arbour for each neuron and add that to the lhstats database

-
# quick function to calculate centroid
-arbour_centroid <- function(n) {
+
+# quick function to calculate centroid
+arbour_centroid <- function(n) {
   # extract location of all points in neuron object
-  xyzs=xyzmatrix(n)
+  xyzs=xyzmatrix(n)
   # median in all 3 axes (=>2 columns)
-  apply(xyzs, 2, median)
-}
+  apply(xyzs, 2, median)
+}
 # note that we have to transpose because sapply results in x,y,z rows
-centroids=t(sapply(lha, arbour_centroid))
-lhstats=cbind(lhstats, centroids)
+centroids=t(sapply(lha, arbour_centroid)) +lhstats=cbind(lhstats, centroids)

Finally we can take these data and see how well we can predict the identity of the neuron (i.e. its glomerulus) based on the statistics of the axon arbour in the lateral horn. We use the linear discriminant analysis (provided by the function lda in recommended package MASS). This also runs a leave one out cross-validation to get a more robust initial estimate of prediction error.

-
library(MASS)
-lda.fit = lda(Glomerulus ~ cable.length+X+Y+Z+branchpoints, lhstats, CV = T)
-table(lda.fit$class, lhstats$Glomerulus)
+
+library(MASS)
+lda.fit = lda(Glomerulus ~ cable.length+X+Y+Z+branchpoints, lhstats, CV = T)
+table(lda.fit$class, lhstats$Glomerulus)
##       
 ##        DA1 DL3 DP1m VA1d
 ##   DA1   10   2    0    1
@@ -3654,41 +522,33 @@ 

Learning More

-

We hope this tutorial will provide you with a good foundation for further use of the nat and related packages. Please visit the main nat README for suggestions of resources to learn more and solve problems. You may also find that some time spent reading Hadley Wickham’s Advanced R is a worthwhile investment. I recommend the first 7 chapters (Introduction to OO field guide) as material that will be helpful for anyone who intends to carry out a significant project using R.

-
+

We hope this tutorial will provide you with a good foundation for further use of the nat and related packages. Please visit the main nat README for suggestions of resources to learn more and solve problems. You may also find that some time spent reading Hadley Wickham’s Advanced R is a worthwhile investment. I recommend the first 7 chapters (Introduction to OO field guide) as material that will be helpful for anyone who intends to carry out a significant project using R.

- +
-

Site built with pkgdown.

+

Site built with pkgdown 1.6.1.

+ + + diff --git a/docs/articles/neurons-intro_files/CanvasMatrix4-0.107.10/CanvasMatrix.min.js b/docs/articles/neurons-intro_files/CanvasMatrix4-0.107.10/CanvasMatrix.min.js new file mode 100644 index 00000000..fd3708f1 --- /dev/null +++ b/docs/articles/neurons-intro_files/CanvasMatrix4-0.107.10/CanvasMatrix.min.js @@ -0,0 +1 @@ +CanvasMatrix4=function(m){if("object"==typeof m){if("length"in m&&m.length>=16)return void this.load(m[0],m[1],m[2],m[3],m[4],m[5],m[6],m[7],m[8],m[9],m[10],m[11],m[12],m[13],m[14],m[15]);if(m instanceof CanvasMatrix4)return void this.load(m)}this.makeIdentity()},CanvasMatrix4.prototype.load=function(){if(1==arguments.length&&"object"==typeof arguments[0]){var matrix=arguments[0];if("length"in matrix&&16==matrix.length)return this.m11=matrix[0],this.m12=matrix[1],this.m13=matrix[2],this.m14=matrix[3],this.m21=matrix[4],this.m22=matrix[5],this.m23=matrix[6],this.m24=matrix[7],this.m31=matrix[8],this.m32=matrix[9],this.m33=matrix[10],this.m34=matrix[11],this.m41=matrix[12],this.m42=matrix[13],this.m43=matrix[14],void(this.m44=matrix[15]);if(arguments[0]instanceof CanvasMatrix4)return this.m11=matrix.m11,this.m12=matrix.m12,this.m13=matrix.m13,this.m14=matrix.m14,this.m21=matrix.m21,this.m22=matrix.m22,this.m23=matrix.m23,this.m24=matrix.m24,this.m31=matrix.m31,this.m32=matrix.m32,this.m33=matrix.m33,this.m34=matrix.m34,this.m41=matrix.m41,this.m42=matrix.m42,this.m43=matrix.m43,void(this.m44=matrix.m44)}this.makeIdentity()},CanvasMatrix4.prototype.getAsArray=function(){return[this.m11,this.m12,this.m13,this.m14,this.m21,this.m22,this.m23,this.m24,this.m31,this.m32,this.m33,this.m34,this.m41,this.m42,this.m43,this.m44]},CanvasMatrix4.prototype.getAsWebGLFloatArray=function(){return new WebGLFloatArray(this.getAsArray())},CanvasMatrix4.prototype.makeIdentity=function(){this.m11=1,this.m12=0,this.m13=0,this.m14=0,this.m21=0,this.m22=1,this.m23=0,this.m24=0,this.m31=0,this.m32=0,this.m33=1,this.m34=0,this.m41=0,this.m42=0,this.m43=0,this.m44=1},CanvasMatrix4.prototype.transpose=function(){var tmp=this.m12;this.m12=this.m21,this.m21=tmp,tmp=this.m13,this.m13=this.m31,this.m31=tmp,tmp=this.m14,this.m14=this.m41,this.m41=tmp,tmp=this.m23,this.m23=this.m32,this.m32=tmp,tmp=this.m24,this.m24=this.m42,this.m42=tmp,tmp=this.m34,this.m34=this.m43,this.m43=tmp},CanvasMatrix4.prototype.invert=function(){var det=this._determinant4x4();return Math.abs(det)<1e-8?null:(this._makeAdjoint(),this.m11/=det,this.m12/=det,this.m13/=det,this.m14/=det,this.m21/=det,this.m22/=det,this.m23/=det,this.m24/=det,this.m31/=det,this.m32/=det,this.m33/=det,this.m34/=det,this.m41/=det,this.m42/=det,this.m43/=det,void(this.m44/=det))},CanvasMatrix4.prototype.translate=function(x,y,z){void 0===x&&(x=0),void 0===y&&(y=0),void 0===z&&(z=0);var matrix=new CanvasMatrix4;matrix.m41=x,matrix.m42=y,matrix.m43=z,this.multRight(matrix)},CanvasMatrix4.prototype.scale=function(x,y,z){void 0===x&&(x=1),void 0===z?void 0===y?(y=x,z=x):z=1:void 0===y&&(y=x);var matrix=new CanvasMatrix4;matrix.m11=x,matrix.m22=y,matrix.m33=z,this.multRight(matrix)},CanvasMatrix4.prototype.rotate=function(angle,x,y,z){angle=angle/180*Math.PI,angle/=2;var sinA=Math.sin(angle),cosA=Math.cos(angle),sinA2=sinA*sinA,length=Math.sqrt(x*x+y*y+z*z);0===length?(x=0,y=0,z=1):1!=length&&(x/=length,y/=length,z/=length);var mat=new CanvasMatrix4;if(1==x&&0===y&&0===z)mat.m11=1,mat.m12=0,mat.m13=0,mat.m21=0,mat.m22=1-2*sinA2,mat.m23=2*sinA*cosA,mat.m31=0,mat.m32=-2*sinA*cosA,mat.m33=1-2*sinA2,mat.m14=mat.m24=mat.m34=0,mat.m41=mat.m42=mat.m43=0,mat.m44=1;else if(0===x&&1==y&&0===z)mat.m11=1-2*sinA2,mat.m12=0,mat.m13=-2*sinA*cosA,mat.m21=0,mat.m22=1,mat.m23=0,mat.m31=2*sinA*cosA,mat.m32=0,mat.m33=1-2*sinA2,mat.m14=mat.m24=mat.m34=0,mat.m41=mat.m42=mat.m43=0,mat.m44=1;else if(0===x&&0===y&&1==z)mat.m11=1-2*sinA2,mat.m12=2*sinA*cosA,mat.m13=0,mat.m21=-2*sinA*cosA,mat.m22=1-2*sinA2,mat.m23=0,mat.m31=0,mat.m32=0,mat.m33=1,mat.m14=mat.m24=mat.m34=0,mat.m41=mat.m42=mat.m43=0,mat.m44=1;else{var x2=x*x,y2=y*y,z2=z*z;mat.m11=1-2*(y2+z2)*sinA2,mat.m12=2*(x*y*sinA2+z*sinA*cosA),mat.m13=2*(x*z*sinA2-y*sinA*cosA),mat.m21=2*(y*x*sinA2-z*sinA*cosA),mat.m22=1-2*(z2+x2)*sinA2,mat.m23=2*(y*z*sinA2+x*sinA*cosA),mat.m31=2*(z*x*sinA2+y*sinA*cosA),mat.m32=2*(z*y*sinA2-x*sinA*cosA),mat.m33=1-2*(x2+y2)*sinA2,mat.m14=mat.m24=mat.m34=0,mat.m41=mat.m42=mat.m43=0,mat.m44=1}this.multRight(mat)},CanvasMatrix4.prototype.multRight=function(mat){var m11=this.m11*mat.m11+this.m12*mat.m21+this.m13*mat.m31+this.m14*mat.m41,m12=this.m11*mat.m12+this.m12*mat.m22+this.m13*mat.m32+this.m14*mat.m42,m13=this.m11*mat.m13+this.m12*mat.m23+this.m13*mat.m33+this.m14*mat.m43,m14=this.m11*mat.m14+this.m12*mat.m24+this.m13*mat.m34+this.m14*mat.m44,m21=this.m21*mat.m11+this.m22*mat.m21+this.m23*mat.m31+this.m24*mat.m41,m22=this.m21*mat.m12+this.m22*mat.m22+this.m23*mat.m32+this.m24*mat.m42,m23=this.m21*mat.m13+this.m22*mat.m23+this.m23*mat.m33+this.m24*mat.m43,m24=this.m21*mat.m14+this.m22*mat.m24+this.m23*mat.m34+this.m24*mat.m44,m31=this.m31*mat.m11+this.m32*mat.m21+this.m33*mat.m31+this.m34*mat.m41,m32=this.m31*mat.m12+this.m32*mat.m22+this.m33*mat.m32+this.m34*mat.m42,m33=this.m31*mat.m13+this.m32*mat.m23+this.m33*mat.m33+this.m34*mat.m43,m34=this.m31*mat.m14+this.m32*mat.m24+this.m33*mat.m34+this.m34*mat.m44,m41=this.m41*mat.m11+this.m42*mat.m21+this.m43*mat.m31+this.m44*mat.m41,m42=this.m41*mat.m12+this.m42*mat.m22+this.m43*mat.m32+this.m44*mat.m42,m43=this.m41*mat.m13+this.m42*mat.m23+this.m43*mat.m33+this.m44*mat.m43,m44=this.m41*mat.m14+this.m42*mat.m24+this.m43*mat.m34+this.m44*mat.m44;this.m11=m11,this.m12=m12,this.m13=m13,this.m14=m14,this.m21=m21,this.m22=m22,this.m23=m23,this.m24=m24,this.m31=m31,this.m32=m32,this.m33=m33,this.m34=m34,this.m41=m41,this.m42=m42,this.m43=m43,this.m44=m44},CanvasMatrix4.prototype.multLeft=function(mat){var m11=mat.m11*this.m11+mat.m12*this.m21+mat.m13*this.m31+mat.m14*this.m41,m12=mat.m11*this.m12+mat.m12*this.m22+mat.m13*this.m32+mat.m14*this.m42,m13=mat.m11*this.m13+mat.m12*this.m23+mat.m13*this.m33+mat.m14*this.m43,m14=mat.m11*this.m14+mat.m12*this.m24+mat.m13*this.m34+mat.m14*this.m44,m21=mat.m21*this.m11+mat.m22*this.m21+mat.m23*this.m31+mat.m24*this.m41,m22=mat.m21*this.m12+mat.m22*this.m22+mat.m23*this.m32+mat.m24*this.m42,m23=mat.m21*this.m13+mat.m22*this.m23+mat.m23*this.m33+mat.m24*this.m43,m24=mat.m21*this.m14+mat.m22*this.m24+mat.m23*this.m34+mat.m24*this.m44,m31=mat.m31*this.m11+mat.m32*this.m21+mat.m33*this.m31+mat.m34*this.m41,m32=mat.m31*this.m12+mat.m32*this.m22+mat.m33*this.m32+mat.m34*this.m42,m33=mat.m31*this.m13+mat.m32*this.m23+mat.m33*this.m33+mat.m34*this.m43,m34=mat.m31*this.m14+mat.m32*this.m24+mat.m33*this.m34+mat.m34*this.m44,m41=mat.m41*this.m11+mat.m42*this.m21+mat.m43*this.m31+mat.m44*this.m41,m42=mat.m41*this.m12+mat.m42*this.m22+mat.m43*this.m32+mat.m44*this.m42,m43=mat.m41*this.m13+mat.m42*this.m23+mat.m43*this.m33+mat.m44*this.m43,m44=mat.m41*this.m14+mat.m42*this.m24+mat.m43*this.m34+mat.m44*this.m44;this.m11=m11,this.m12=m12,this.m13=m13,this.m14=m14,this.m21=m21,this.m22=m22,this.m23=m23,this.m24=m24,this.m31=m31,this.m32=m32,this.m33=m33,this.m34=m34,this.m41=m41,this.m42=m42,this.m43=m43,this.m44=m44},CanvasMatrix4.prototype.ortho=function(left,right,bottom,top,near,far){var tx=(left+right)/(left-right),ty=(top+bottom)/(bottom-top),tz=(far+near)/(near-far),matrix=new CanvasMatrix4;matrix.m11=2/(right-left),matrix.m12=0,matrix.m13=0,matrix.m14=0,matrix.m21=0,matrix.m22=2/(top-bottom),matrix.m23=0,matrix.m24=0,matrix.m31=0,matrix.m32=0,matrix.m33=-2/(far-near),matrix.m34=0,matrix.m41=tx,matrix.m42=ty,matrix.m43=tz,matrix.m44=1,this.multRight(matrix)},CanvasMatrix4.prototype.frustum=function(left,right,bottom,top,near,far){var matrix=new CanvasMatrix4,A=(right+left)/(right-left),B=(top+bottom)/(top-bottom),C=-(far+near)/(far-near),D=-(2*far*near)/(far-near);matrix.m11=2*near/(right-left),matrix.m12=0,matrix.m13=0,matrix.m14=0,matrix.m21=0,matrix.m22=2*near/(top-bottom),matrix.m23=0,matrix.m24=0,matrix.m31=A,matrix.m32=B,matrix.m33=C,matrix.m34=-1,matrix.m41=0,matrix.m42=0,matrix.m43=D,matrix.m44=0,this.multRight(matrix)},CanvasMatrix4.prototype.perspective=function(fovy,aspect,zNear,zFar){var top=Math.tan(fovy*Math.PI/360)*zNear,bottom=-top,left=aspect*bottom,right=aspect*top;this.frustum(left,right,bottom,top,zNear,zFar)},CanvasMatrix4.prototype.lookat=function(eyex,eyey,eyez,centerx,centery,centerz,upx,upy,upz){var xx,xy,xz,matrix=new CanvasMatrix4,zx=eyex-centerx,zy=eyey-centery,zz=eyez-centerz,mag=Math.sqrt(zx*zx+zy*zy+zz*zz);mag&&(zx/=mag,zy/=mag,zz/=mag);var yx=upx,yy=upy,yz=upz;xx=yy*zz-yz*zy,xy=-yx*zz+yz*zx,xz=yx*zy-yy*zx,yx=zy*xz-zz*xy,yy=-zx*xz+zz*xx,yx=zx*xy-zy*xx,mag=Math.sqrt(xx*xx+xy*xy+xz*xz),mag&&(xx/=mag,xy/=mag,xz/=mag),mag=Math.sqrt(yx*yx+yy*yy+yz*yz),mag&&(yx/=mag,yy/=mag,yz/=mag),matrix.m11=xx,matrix.m12=xy,matrix.m13=xz,matrix.m14=0,matrix.m21=yx,matrix.m22=yy,matrix.m23=yz,matrix.m24=0,matrix.m31=zx,matrix.m32=zy,matrix.m33=zz,matrix.m34=0,matrix.m41=0,matrix.m42=0,matrix.m43=0,matrix.m44=1,matrix.translate(-eyex,-eyey,-eyez),this.multRight(matrix)},CanvasMatrix4.prototype._determinant2x2=function(a,b,c,d){return a*d-b*c},CanvasMatrix4.prototype._determinant3x3=function(a1,a2,a3,b1,b2,b3,c1,c2,c3){return a1*this._determinant2x2(b2,b3,c2,c3)-b1*this._determinant2x2(a2,a3,c2,c3)+c1*this._determinant2x2(a2,a3,b2,b3)},CanvasMatrix4.prototype._determinant4x4=function(){var a1=this.m11,b1=this.m12,c1=this.m13,d1=this.m14,a2=this.m21,b2=this.m22,c2=this.m23,d2=this.m24,a3=this.m31,b3=this.m32,c3=this.m33,d3=this.m34,a4=this.m41,b4=this.m42,c4=this.m43,d4=this.m44;return a1*this._determinant3x3(b2,b3,b4,c2,c3,c4,d2,d3,d4)-b1*this._determinant3x3(a2,a3,a4,c2,c3,c4,d2,d3,d4)+c1*this._determinant3x3(a2,a3,a4,b2,b3,b4,d2,d3,d4)-d1*this._determinant3x3(a2,a3,a4,b2,b3,b4,c2,c3,c4)},CanvasMatrix4.prototype._makeAdjoint=function(){var a1=this.m11,b1=this.m12,c1=this.m13,d1=this.m14,a2=this.m21,b2=this.m22,c2=this.m23,d2=this.m24,a3=this.m31,b3=this.m32,c3=this.m33,d3=this.m34,a4=this.m41,b4=this.m42,c4=this.m43,d4=this.m44;this.m11=this._determinant3x3(b2,b3,b4,c2,c3,c4,d2,d3,d4),this.m21=-this._determinant3x3(a2,a3,a4,c2,c3,c4,d2,d3,d4),this.m31=this._determinant3x3(a2,a3,a4,b2,b3,b4,d2,d3,d4),this.m41=-this._determinant3x3(a2,a3,a4,b2,b3,b4,c2,c3,c4),this.m12=-this._determinant3x3(b1,b3,b4,c1,c3,c4,d1,d3,d4),this.m22=this._determinant3x3(a1,a3,a4,c1,c3,c4,d1,d3,d4),this.m32=-this._determinant3x3(a1,a3,a4,b1,b3,b4,d1,d3,d4),this.m42=this._determinant3x3(a1,a3,a4,b1,b3,b4,c1,c3,c4),this.m13=this._determinant3x3(b1,b2,b4,c1,c2,c4,d1,d2,d4),this.m23=-this._determinant3x3(a1,a2,a4,c1,c2,c4,d1,d2,d4),this.m33=this._determinant3x3(a1,a2,a4,b1,b2,b4,d1,d2,d4),this.m43=-this._determinant3x3(a1,a2,a4,b1,b2,b4,c1,c2,c4),this.m14=-this._determinant3x3(b1,b2,b3,c1,c2,c3,d1,d2,d3),this.m24=this._determinant3x3(a1,a2,a3,c1,c2,c3,d1,d2,d3),this.m34=-this._determinant3x3(a1,a2,a3,b1,b2,b3,d1,d2,d3),this.m44=this._determinant3x3(a1,a2,a3,b1,b2,b3,c1,c2,c3)}; diff --git a/docs/articles/neurons-intro_files/figure-html/plot3d-legend-1.png b/docs/articles/neurons-intro_files/figure-html/plot3d-legend-1.png index 76c8d16c..03ae23a6 100644 Binary files a/docs/articles/neurons-intro_files/figure-html/plot3d-legend-1.png and b/docs/articles/neurons-intro_files/figure-html/plot3d-legend-1.png differ diff --git a/docs/articles/neurons-intro_files/figure-html/unnamed-chunk-11-1.png b/docs/articles/neurons-intro_files/figure-html/unnamed-chunk-11-1.png index 823dd6e9..2420c45e 100644 Binary files a/docs/articles/neurons-intro_files/figure-html/unnamed-chunk-11-1.png and b/docs/articles/neurons-intro_files/figure-html/unnamed-chunk-11-1.png differ diff --git a/docs/articles/neurons-intro_files/figure-html/unnamed-chunk-13-1.png b/docs/articles/neurons-intro_files/figure-html/unnamed-chunk-13-1.png index d19dec38..84c634d2 100644 Binary files a/docs/articles/neurons-intro_files/figure-html/unnamed-chunk-13-1.png and b/docs/articles/neurons-intro_files/figure-html/unnamed-chunk-13-1.png differ diff --git a/docs/articles/neurons-intro_files/figure-html/unnamed-chunk-14-1.png b/docs/articles/neurons-intro_files/figure-html/unnamed-chunk-14-1.png index bce627a9..ee468340 100644 Binary files a/docs/articles/neurons-intro_files/figure-html/unnamed-chunk-14-1.png and b/docs/articles/neurons-intro_files/figure-html/unnamed-chunk-14-1.png differ diff --git a/docs/articles/neurons-intro_files/figure-html/unnamed-chunk-25-1.png b/docs/articles/neurons-intro_files/figure-html/unnamed-chunk-25-1.png index af5979f4..a573dc32 100644 Binary files a/docs/articles/neurons-intro_files/figure-html/unnamed-chunk-25-1.png and b/docs/articles/neurons-intro_files/figure-html/unnamed-chunk-25-1.png differ diff --git a/docs/articles/neurons-intro_files/figure-html/unnamed-chunk-26-1.png b/docs/articles/neurons-intro_files/figure-html/unnamed-chunk-26-1.png index c1937dc6..a6503234 100644 Binary files a/docs/articles/neurons-intro_files/figure-html/unnamed-chunk-26-1.png and b/docs/articles/neurons-intro_files/figure-html/unnamed-chunk-26-1.png differ diff --git a/docs/articles/neurons-intro_files/figure-html/unnamed-chunk-27-1.png b/docs/articles/neurons-intro_files/figure-html/unnamed-chunk-27-1.png index 9a864034..3756757e 100644 Binary files a/docs/articles/neurons-intro_files/figure-html/unnamed-chunk-27-1.png and b/docs/articles/neurons-intro_files/figure-html/unnamed-chunk-27-1.png differ diff --git a/docs/articles/neurons-intro_files/figure-html/unnamed-chunk-28-1.png b/docs/articles/neurons-intro_files/figure-html/unnamed-chunk-28-1.png index 55bd9bd7..c48d45e5 100644 Binary files a/docs/articles/neurons-intro_files/figure-html/unnamed-chunk-28-1.png and b/docs/articles/neurons-intro_files/figure-html/unnamed-chunk-28-1.png differ diff --git a/docs/articles/neurons-intro_files/figure-html/unnamed-chunk-29-1.png b/docs/articles/neurons-intro_files/figure-html/unnamed-chunk-29-1.png index 7be7fcb2..2e10cb5c 100644 Binary files a/docs/articles/neurons-intro_files/figure-html/unnamed-chunk-29-1.png and b/docs/articles/neurons-intro_files/figure-html/unnamed-chunk-29-1.png differ diff --git a/docs/articles/neurons-intro_files/figure-html/unnamed-chunk-30-1.png b/docs/articles/neurons-intro_files/figure-html/unnamed-chunk-30-1.png index eecf8e73..d67624db 100644 Binary files a/docs/articles/neurons-intro_files/figure-html/unnamed-chunk-30-1.png and b/docs/articles/neurons-intro_files/figure-html/unnamed-chunk-30-1.png differ diff --git a/docs/articles/neurons-intro_files/figure-html/unnamed-chunk-32-1.png b/docs/articles/neurons-intro_files/figure-html/unnamed-chunk-32-1.png index 415f247d..463ef947 100644 Binary files a/docs/articles/neurons-intro_files/figure-html/unnamed-chunk-32-1.png and b/docs/articles/neurons-intro_files/figure-html/unnamed-chunk-32-1.png differ diff --git a/docs/articles/neurons-intro_files/figure-html/unnamed-chunk-33-1.png b/docs/articles/neurons-intro_files/figure-html/unnamed-chunk-33-1.png index 711de81f..74ccdfda 100644 Binary files a/docs/articles/neurons-intro_files/figure-html/unnamed-chunk-33-1.png and b/docs/articles/neurons-intro_files/figure-html/unnamed-chunk-33-1.png differ diff --git a/docs/articles/neurons-intro_files/figure-html/unnamed-chunk-34-1.png b/docs/articles/neurons-intro_files/figure-html/unnamed-chunk-34-1.png index 85787f33..62058436 100644 Binary files a/docs/articles/neurons-intro_files/figure-html/unnamed-chunk-34-1.png and b/docs/articles/neurons-intro_files/figure-html/unnamed-chunk-34-1.png differ diff --git a/docs/articles/neurons-intro_files/figure-html/unnamed-chunk-34-2.png b/docs/articles/neurons-intro_files/figure-html/unnamed-chunk-34-2.png index e0bea426..96e42363 100644 Binary files a/docs/articles/neurons-intro_files/figure-html/unnamed-chunk-34-2.png and b/docs/articles/neurons-intro_files/figure-html/unnamed-chunk-34-2.png differ diff --git a/docs/articles/neurons-intro_files/figure-html/unnamed-chunk-6-1.png b/docs/articles/neurons-intro_files/figure-html/unnamed-chunk-6-1.png index 8d7362cb..fb179e66 100644 Binary files a/docs/articles/neurons-intro_files/figure-html/unnamed-chunk-6-1.png and b/docs/articles/neurons-intro_files/figure-html/unnamed-chunk-6-1.png differ diff --git a/docs/articles/neurons-intro_files/header-attrs-2.10/header-attrs.js b/docs/articles/neurons-intro_files/header-attrs-2.10/header-attrs.js new file mode 100644 index 00000000..dd57d92e --- /dev/null +++ b/docs/articles/neurons-intro_files/header-attrs-2.10/header-attrs.js @@ -0,0 +1,12 @@ +// Pandoc 2.9 adds attributes on both header and div. We remove the former (to +// be compatible with the behavior of Pandoc < 2.8). +document.addEventListener('DOMContentLoaded', function(e) { + var hs = document.querySelectorAll("div.section[class*='level'] > :first-child"); + var i, h, a; + for (i = 0; i < hs.length; i++) { + h = hs[i]; + if (!/^h[1-6]$/i.test(h.tagName)) continue; // it should be a header h1-h6 + a = h.attributes; + while (a.length > 0) h.removeAttribute(a[0].name); + } +}); diff --git a/docs/articles/neurons-intro_files/htmlwidgets-1.5.3/htmlwidgets.js b/docs/articles/neurons-intro_files/htmlwidgets-1.5.3/htmlwidgets.js new file mode 100644 index 00000000..3d227624 --- /dev/null +++ b/docs/articles/neurons-intro_files/htmlwidgets-1.5.3/htmlwidgets.js @@ -0,0 +1,903 @@ +(function() { + // If window.HTMLWidgets is already defined, then use it; otherwise create a + // new object. This allows preceding code to set options that affect the + // initialization process (though none currently exist). + window.HTMLWidgets = window.HTMLWidgets || {}; + + // See if we're running in a viewer pane. If not, we're in a web browser. + var viewerMode = window.HTMLWidgets.viewerMode = + /\bviewer_pane=1\b/.test(window.location); + + // See if we're running in Shiny mode. If not, it's a static document. + // Note that static widgets can appear in both Shiny and static modes, but + // obviously, Shiny widgets can only appear in Shiny apps/documents. + var shinyMode = window.HTMLWidgets.shinyMode = + typeof(window.Shiny) !== "undefined" && !!window.Shiny.outputBindings; + + // We can't count on jQuery being available, so we implement our own + // version if necessary. + function querySelectorAll(scope, selector) { + if (typeof(jQuery) !== "undefined" && scope instanceof jQuery) { + return scope.find(selector); + } + if (scope.querySelectorAll) { + return scope.querySelectorAll(selector); + } + } + + function asArray(value) { + if (value === null) + return []; + if ($.isArray(value)) + return value; + return [value]; + } + + // Implement jQuery's extend + function extend(target /*, ... */) { + if (arguments.length == 1) { + return target; + } + for (var i = 1; i < arguments.length; i++) { + var source = arguments[i]; + for (var prop in source) { + if (source.hasOwnProperty(prop)) { + target[prop] = source[prop]; + } + } + } + return target; + } + + // IE8 doesn't support Array.forEach. + function forEach(values, callback, thisArg) { + if (values.forEach) { + values.forEach(callback, thisArg); + } else { + for (var i = 0; i < values.length; i++) { + callback.call(thisArg, values[i], i, values); + } + } + } + + // Replaces the specified method with the return value of funcSource. + // + // Note that funcSource should not BE the new method, it should be a function + // that RETURNS the new method. funcSource receives a single argument that is + // the overridden method, it can be called from the new method. The overridden + // method can be called like a regular function, it has the target permanently + // bound to it so "this" will work correctly. + function overrideMethod(target, methodName, funcSource) { + var superFunc = target[methodName] || function() {}; + var superFuncBound = function() { + return superFunc.apply(target, arguments); + }; + target[methodName] = funcSource(superFuncBound); + } + + // Add a method to delegator that, when invoked, calls + // delegatee.methodName. If there is no such method on + // the delegatee, but there was one on delegator before + // delegateMethod was called, then the original version + // is invoked instead. + // For example: + // + // var a = { + // method1: function() { console.log('a1'); } + // method2: function() { console.log('a2'); } + // }; + // var b = { + // method1: function() { console.log('b1'); } + // }; + // delegateMethod(a, b, "method1"); + // delegateMethod(a, b, "method2"); + // a.method1(); + // a.method2(); + // + // The output would be "b1", "a2". + function delegateMethod(delegator, delegatee, methodName) { + var inherited = delegator[methodName]; + delegator[methodName] = function() { + var target = delegatee; + var method = delegatee[methodName]; + + // The method doesn't exist on the delegatee. Instead, + // call the method on the delegator, if it exists. + if (!method) { + target = delegator; + method = inherited; + } + + if (method) { + return method.apply(target, arguments); + } + }; + } + + // Implement a vague facsimilie of jQuery's data method + function elementData(el, name, value) { + if (arguments.length == 2) { + return el["htmlwidget_data_" + name]; + } else if (arguments.length == 3) { + el["htmlwidget_data_" + name] = value; + return el; + } else { + throw new Error("Wrong number of arguments for elementData: " + + arguments.length); + } + } + + // http://stackoverflow.com/questions/3446170/escape-string-for-use-in-javascript-regex + function escapeRegExp(str) { + return str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&"); + } + + function hasClass(el, className) { + var re = new RegExp("\\b" + escapeRegExp(className) + "\\b"); + return re.test(el.className); + } + + // elements - array (or array-like object) of HTML elements + // className - class name to test for + // include - if true, only return elements with given className; + // if false, only return elements *without* given className + function filterByClass(elements, className, include) { + var results = []; + for (var i = 0; i < elements.length; i++) { + if (hasClass(elements[i], className) == include) + results.push(elements[i]); + } + return results; + } + + function on(obj, eventName, func) { + if (obj.addEventListener) { + obj.addEventListener(eventName, func, false); + } else if (obj.attachEvent) { + obj.attachEvent(eventName, func); + } + } + + function off(obj, eventName, func) { + if (obj.removeEventListener) + obj.removeEventListener(eventName, func, false); + else if (obj.detachEvent) { + obj.detachEvent(eventName, func); + } + } + + // Translate array of values to top/right/bottom/left, as usual with + // the "padding" CSS property + // https://developer.mozilla.org/en-US/docs/Web/CSS/padding + function unpackPadding(value) { + if (typeof(value) === "number") + value = [value]; + if (value.length === 1) { + return {top: value[0], right: value[0], bottom: value[0], left: value[0]}; + } + if (value.length === 2) { + return {top: value[0], right: value[1], bottom: value[0], left: value[1]}; + } + if (value.length === 3) { + return {top: value[0], right: value[1], bottom: value[2], left: value[1]}; + } + if (value.length === 4) { + return {top: value[0], right: value[1], bottom: value[2], left: value[3]}; + } + } + + // Convert an unpacked padding object to a CSS value + function paddingToCss(paddingObj) { + return paddingObj.top + "px " + paddingObj.right + "px " + paddingObj.bottom + "px " + paddingObj.left + "px"; + } + + // Makes a number suitable for CSS + function px(x) { + if (typeof(x) === "number") + return x + "px"; + else + return x; + } + + // Retrieves runtime widget sizing information for an element. + // The return value is either null, or an object with fill, padding, + // defaultWidth, defaultHeight fields. + function sizingPolicy(el) { + var sizingEl = document.querySelector("script[data-for='" + el.id + "'][type='application/htmlwidget-sizing']"); + if (!sizingEl) + return null; + var sp = JSON.parse(sizingEl.textContent || sizingEl.text || "{}"); + if (viewerMode) { + return sp.viewer; + } else { + return sp.browser; + } + } + + // @param tasks Array of strings (or falsy value, in which case no-op). + // Each element must be a valid JavaScript expression that yields a + // function. Or, can be an array of objects with "code" and "data" + // properties; in this case, the "code" property should be a string + // of JS that's an expr that yields a function, and "data" should be + // an object that will be added as an additional argument when that + // function is called. + // @param target The object that will be "this" for each function + // execution. + // @param args Array of arguments to be passed to the functions. (The + // same arguments will be passed to all functions.) + function evalAndRun(tasks, target, args) { + if (tasks) { + forEach(tasks, function(task) { + var theseArgs = args; + if (typeof(task) === "object") { + theseArgs = theseArgs.concat([task.data]); + task = task.code; + } + var taskFunc = tryEval(task); + if (typeof(taskFunc) !== "function") { + throw new Error("Task must be a function! Source:\n" + task); + } + taskFunc.apply(target, theseArgs); + }); + } + } + + // Attempt eval() both with and without enclosing in parentheses. + // Note that enclosing coerces a function declaration into + // an expression that eval() can parse + // (otherwise, a SyntaxError is thrown) + function tryEval(code) { + var result = null; + try { + result = eval("(" + code + ")"); + } catch(error) { + if (!error instanceof SyntaxError) { + throw error; + } + try { + result = eval(code); + } catch(e) { + if (e instanceof SyntaxError) { + throw error; + } else { + throw e; + } + } + } + return result; + } + + function initSizing(el) { + var sizing = sizingPolicy(el); + if (!sizing) + return; + + var cel = document.getElementById("htmlwidget_container"); + if (!cel) + return; + + if (typeof(sizing.padding) !== "undefined") { + document.body.style.margin = "0"; + document.body.style.padding = paddingToCss(unpackPadding(sizing.padding)); + } + + if (sizing.fill) { + document.body.style.overflow = "hidden"; + document.body.style.width = "100%"; + document.body.style.height = "100%"; + document.documentElement.style.width = "100%"; + document.documentElement.style.height = "100%"; + if (cel) { + cel.style.position = "absolute"; + var pad = unpackPadding(sizing.padding); + cel.style.top = pad.top + "px"; + cel.style.right = pad.right + "px"; + cel.style.bottom = pad.bottom + "px"; + cel.style.left = pad.left + "px"; + el.style.width = "100%"; + el.style.height = "100%"; + } + + return { + getWidth: function() { return cel.offsetWidth; }, + getHeight: function() { return cel.offsetHeight; } + }; + + } else { + el.style.width = px(sizing.width); + el.style.height = px(sizing.height); + + return { + getWidth: function() { return el.offsetWidth; }, + getHeight: function() { return el.offsetHeight; } + }; + } + } + + // Default implementations for methods + var defaults = { + find: function(scope) { + return querySelectorAll(scope, "." + this.name); + }, + renderError: function(el, err) { + var $el = $(el); + + this.clearError(el); + + // Add all these error classes, as Shiny does + var errClass = "shiny-output-error"; + if (err.type !== null) { + // use the classes of the error condition as CSS class names + errClass = errClass + " " + $.map(asArray(err.type), function(type) { + return errClass + "-" + type; + }).join(" "); + } + errClass = errClass + " htmlwidgets-error"; + + // Is el inline or block? If inline or inline-block, just display:none it + // and add an inline error. + var display = $el.css("display"); + $el.data("restore-display-mode", display); + + if (display === "inline" || display === "inline-block") { + $el.hide(); + if (err.message !== "") { + var errorSpan = $("").addClass(errClass); + errorSpan.text(err.message); + $el.after(errorSpan); + } + } else if (display === "block") { + // If block, add an error just after the el, set visibility:none on the + // el, and position the error to be on top of the el. + // Mark it with a unique ID and CSS class so we can remove it later. + $el.css("visibility", "hidden"); + if (err.message !== "") { + var errorDiv = $("
").addClass(errClass).css("position", "absolute") + .css("top", el.offsetTop) + .css("left", el.offsetLeft) + // setting width can push out the page size, forcing otherwise + // unnecessary scrollbars to appear and making it impossible for + // the element to shrink; so use max-width instead + .css("maxWidth", el.offsetWidth) + .css("height", el.offsetHeight); + errorDiv.text(err.message); + $el.after(errorDiv); + + // Really dumb way to keep the size/position of the error in sync with + // the parent element as the window is resized or whatever. + var intId = setInterval(function() { + if (!errorDiv[0].parentElement) { + clearInterval(intId); + return; + } + errorDiv + .css("top", el.offsetTop) + .css("left", el.offsetLeft) + .css("maxWidth", el.offsetWidth) + .css("height", el.offsetHeight); + }, 500); + } + } + }, + clearError: function(el) { + var $el = $(el); + var display = $el.data("restore-display-mode"); + $el.data("restore-display-mode", null); + + if (display === "inline" || display === "inline-block") { + if (display) + $el.css("display", display); + $(el.nextSibling).filter(".htmlwidgets-error").remove(); + } else if (display === "block"){ + $el.css("visibility", "inherit"); + $(el.nextSibling).filter(".htmlwidgets-error").remove(); + } + }, + sizing: {} + }; + + // Called by widget bindings to register a new type of widget. The definition + // object can contain the following properties: + // - name (required) - A string indicating the binding name, which will be + // used by default as the CSS classname to look for. + // - initialize (optional) - A function(el) that will be called once per + // widget element; if a value is returned, it will be passed as the third + // value to renderValue. + // - renderValue (required) - A function(el, data, initValue) that will be + // called with data. Static contexts will cause this to be called once per + // element; Shiny apps will cause this to be called multiple times per + // element, as the data changes. + window.HTMLWidgets.widget = function(definition) { + if (!definition.name) { + throw new Error("Widget must have a name"); + } + if (!definition.type) { + throw new Error("Widget must have a type"); + } + // Currently we only support output widgets + if (definition.type !== "output") { + throw new Error("Unrecognized widget type '" + definition.type + "'"); + } + // TODO: Verify that .name is a valid CSS classname + + // Support new-style instance-bound definitions. Old-style class-bound + // definitions have one widget "object" per widget per type/class of + // widget; the renderValue and resize methods on such widget objects + // take el and instance arguments, because the widget object can't + // store them. New-style instance-bound definitions have one widget + // object per widget instance; the definition that's passed in doesn't + // provide renderValue or resize methods at all, just the single method + // factory(el, width, height) + // which returns an object that has renderValue(x) and resize(w, h). + // This enables a far more natural programming style for the widget + // author, who can store per-instance state using either OO-style + // instance fields or functional-style closure variables (I guess this + // is in contrast to what can only be called C-style pseudo-OO which is + // what we required before). + if (definition.factory) { + definition = createLegacyDefinitionAdapter(definition); + } + + if (!definition.renderValue) { + throw new Error("Widget must have a renderValue function"); + } + + // For static rendering (non-Shiny), use a simple widget registration + // scheme. We also use this scheme for Shiny apps/documents that also + // contain static widgets. + window.HTMLWidgets.widgets = window.HTMLWidgets.widgets || []; + // Merge defaults into the definition; don't mutate the original definition. + var staticBinding = extend({}, defaults, definition); + overrideMethod(staticBinding, "find", function(superfunc) { + return function(scope) { + var results = superfunc(scope); + // Filter out Shiny outputs, we only want the static kind + return filterByClass(results, "html-widget-output", false); + }; + }); + window.HTMLWidgets.widgets.push(staticBinding); + + if (shinyMode) { + // Shiny is running. Register the definition with an output binding. + // The definition itself will not be the output binding, instead + // we will make an output binding object that delegates to the + // definition. This is because we foolishly used the same method + // name (renderValue) for htmlwidgets definition and Shiny bindings + // but they actually have quite different semantics (the Shiny + // bindings receive data that includes lots of metadata that it + // strips off before calling htmlwidgets renderValue). We can't + // just ignore the difference because in some widgets it's helpful + // to call this.renderValue() from inside of resize(), and if + // we're not delegating, then that call will go to the Shiny + // version instead of the htmlwidgets version. + + // Merge defaults with definition, without mutating either. + var bindingDef = extend({}, defaults, definition); + + // This object will be our actual Shiny binding. + var shinyBinding = new Shiny.OutputBinding(); + + // With a few exceptions, we'll want to simply use the bindingDef's + // version of methods if they are available, otherwise fall back to + // Shiny's defaults. NOTE: If Shiny's output bindings gain additional + // methods in the future, and we want them to be overrideable by + // HTMLWidget binding definitions, then we'll need to add them to this + // list. + delegateMethod(shinyBinding, bindingDef, "getId"); + delegateMethod(shinyBinding, bindingDef, "onValueChange"); + delegateMethod(shinyBinding, bindingDef, "onValueError"); + delegateMethod(shinyBinding, bindingDef, "renderError"); + delegateMethod(shinyBinding, bindingDef, "clearError"); + delegateMethod(shinyBinding, bindingDef, "showProgress"); + + // The find, renderValue, and resize are handled differently, because we + // want to actually decorate the behavior of the bindingDef methods. + + shinyBinding.find = function(scope) { + var results = bindingDef.find(scope); + + // Only return elements that are Shiny outputs, not static ones + var dynamicResults = results.filter(".html-widget-output"); + + // It's possible that whatever caused Shiny to think there might be + // new dynamic outputs, also caused there to be new static outputs. + // Since there might be lots of different htmlwidgets bindings, we + // schedule execution for later--no need to staticRender multiple + // times. + if (results.length !== dynamicResults.length) + scheduleStaticRender(); + + return dynamicResults; + }; + + // Wrap renderValue to handle initialization, which unfortunately isn't + // supported natively by Shiny at the time of this writing. + + shinyBinding.renderValue = function(el, data) { + Shiny.renderDependencies(data.deps); + // Resolve strings marked as javascript literals to objects + if (!(data.evals instanceof Array)) data.evals = [data.evals]; + for (var i = 0; data.evals && i < data.evals.length; i++) { + window.HTMLWidgets.evaluateStringMember(data.x, data.evals[i]); + } + if (!bindingDef.renderOnNullValue) { + if (data.x === null) { + el.style.visibility = "hidden"; + return; + } else { + el.style.visibility = "inherit"; + } + } + if (!elementData(el, "initialized")) { + initSizing(el); + + elementData(el, "initialized", true); + if (bindingDef.initialize) { + var result = bindingDef.initialize(el, el.offsetWidth, + el.offsetHeight); + elementData(el, "init_result", result); + } + } + bindingDef.renderValue(el, data.x, elementData(el, "init_result")); + evalAndRun(data.jsHooks.render, elementData(el, "init_result"), [el, data.x]); + }; + + // Only override resize if bindingDef implements it + if (bindingDef.resize) { + shinyBinding.resize = function(el, width, height) { + // Shiny can call resize before initialize/renderValue have been + // called, which doesn't make sense for widgets. + if (elementData(el, "initialized")) { + bindingDef.resize(el, width, height, elementData(el, "init_result")); + } + }; + } + + Shiny.outputBindings.register(shinyBinding, bindingDef.name); + } + }; + + var scheduleStaticRenderTimerId = null; + function scheduleStaticRender() { + if (!scheduleStaticRenderTimerId) { + scheduleStaticRenderTimerId = setTimeout(function() { + scheduleStaticRenderTimerId = null; + window.HTMLWidgets.staticRender(); + }, 1); + } + } + + // Render static widgets after the document finishes loading + // Statically render all elements that are of this widget's class + window.HTMLWidgets.staticRender = function() { + var bindings = window.HTMLWidgets.widgets || []; + forEach(bindings, function(binding) { + var matches = binding.find(document.documentElement); + forEach(matches, function(el) { + var sizeObj = initSizing(el, binding); + + if (hasClass(el, "html-widget-static-bound")) + return; + el.className = el.className + " html-widget-static-bound"; + + var initResult; + if (binding.initialize) { + initResult = binding.initialize(el, + sizeObj ? sizeObj.getWidth() : el.offsetWidth, + sizeObj ? sizeObj.getHeight() : el.offsetHeight + ); + elementData(el, "init_result", initResult); + } + + if (binding.resize) { + var lastSize = { + w: sizeObj ? sizeObj.getWidth() : el.offsetWidth, + h: sizeObj ? sizeObj.getHeight() : el.offsetHeight + }; + var resizeHandler = function(e) { + var size = { + w: sizeObj ? sizeObj.getWidth() : el.offsetWidth, + h: sizeObj ? sizeObj.getHeight() : el.offsetHeight + }; + if (size.w === 0 && size.h === 0) + return; + if (size.w === lastSize.w && size.h === lastSize.h) + return; + lastSize = size; + binding.resize(el, size.w, size.h, initResult); + }; + + on(window, "resize", resizeHandler); + + // This is needed for cases where we're running in a Shiny + // app, but the widget itself is not a Shiny output, but + // rather a simple static widget. One example of this is + // an rmarkdown document that has runtime:shiny and widget + // that isn't in a render function. Shiny only knows to + // call resize handlers for Shiny outputs, not for static + // widgets, so we do it ourselves. + if (window.jQuery) { + window.jQuery(document).on( + "shown.htmlwidgets shown.bs.tab.htmlwidgets shown.bs.collapse.htmlwidgets", + resizeHandler + ); + window.jQuery(document).on( + "hidden.htmlwidgets hidden.bs.tab.htmlwidgets hidden.bs.collapse.htmlwidgets", + resizeHandler + ); + } + + // This is needed for the specific case of ioslides, which + // flips slides between display:none and display:block. + // Ideally we would not have to have ioslide-specific code + // here, but rather have ioslides raise a generic event, + // but the rmarkdown package just went to CRAN so the + // window to getting that fixed may be long. + if (window.addEventListener) { + // It's OK to limit this to window.addEventListener + // browsers because ioslides itself only supports + // such browsers. + on(document, "slideenter", resizeHandler); + on(document, "slideleave", resizeHandler); + } + } + + var scriptData = document.querySelector("script[data-for='" + el.id + "'][type='application/json']"); + if (scriptData) { + var data = JSON.parse(scriptData.textContent || scriptData.text); + // Resolve strings marked as javascript literals to objects + if (!(data.evals instanceof Array)) data.evals = [data.evals]; + for (var k = 0; data.evals && k < data.evals.length; k++) { + window.HTMLWidgets.evaluateStringMember(data.x, data.evals[k]); + } + binding.renderValue(el, data.x, initResult); + evalAndRun(data.jsHooks.render, initResult, [el, data.x]); + } + }); + }); + + invokePostRenderHandlers(); + } + + + function has_jQuery3() { + if (!window.jQuery) { + return false; + } + var $version = window.jQuery.fn.jquery; + var $major_version = parseInt($version.split(".")[0]); + return $major_version >= 3; + } + + /* + / Shiny 1.4 bumped jQuery from 1.x to 3.x which means jQuery's + / on-ready handler (i.e., $(fn)) is now asyncronous (i.e., it now + / really means $(setTimeout(fn)). + / https://jquery.com/upgrade-guide/3.0/#breaking-change-document-ready-handlers-are-now-asynchronous + / + / Since Shiny uses $() to schedule initShiny, shiny>=1.4 calls initShiny + / one tick later than it did before, which means staticRender() is + / called renderValue() earlier than (advanced) widget authors might be expecting. + / https://github.com/rstudio/shiny/issues/2630 + / + / For a concrete example, leaflet has some methods (e.g., updateBounds) + / which reference Shiny methods registered in initShiny (e.g., setInputValue). + / Since leaflet is privy to this life-cycle, it knows to use setTimeout() to + / delay execution of those methods (until Shiny methods are ready) + / https://github.com/rstudio/leaflet/blob/18ec981/javascript/src/index.js#L266-L268 + / + / Ideally widget authors wouldn't need to use this setTimeout() hack that + / leaflet uses to call Shiny methods on a staticRender(). In the long run, + / the logic initShiny should be broken up so that method registration happens + / right away, but binding happens later. + */ + function maybeStaticRenderLater() { + if (shinyMode && has_jQuery3()) { + window.jQuery(window.HTMLWidgets.staticRender); + } else { + window.HTMLWidgets.staticRender(); + } + } + + if (document.addEventListener) { + document.addEventListener("DOMContentLoaded", function() { + document.removeEventListener("DOMContentLoaded", arguments.callee, false); + maybeStaticRenderLater(); + }, false); + } else if (document.attachEvent) { + document.attachEvent("onreadystatechange", function() { + if (document.readyState === "complete") { + document.detachEvent("onreadystatechange", arguments.callee); + maybeStaticRenderLater(); + } + }); + } + + + window.HTMLWidgets.getAttachmentUrl = function(depname, key) { + // If no key, default to the first item + if (typeof(key) === "undefined") + key = 1; + + var link = document.getElementById(depname + "-" + key + "-attachment"); + if (!link) { + throw new Error("Attachment " + depname + "/" + key + " not found in document"); + } + return link.getAttribute("href"); + }; + + window.HTMLWidgets.dataframeToD3 = function(df) { + var names = []; + var length; + for (var name in df) { + if (df.hasOwnProperty(name)) + names.push(name); + if (typeof(df[name]) !== "object" || typeof(df[name].length) === "undefined") { + throw new Error("All fields must be arrays"); + } else if (typeof(length) !== "undefined" && length !== df[name].length) { + throw new Error("All fields must be arrays of the same length"); + } + length = df[name].length; + } + var results = []; + var item; + for (var row = 0; row < length; row++) { + item = {}; + for (var col = 0; col < names.length; col++) { + item[names[col]] = df[names[col]][row]; + } + results.push(item); + } + return results; + }; + + window.HTMLWidgets.transposeArray2D = function(array) { + if (array.length === 0) return array; + var newArray = array[0].map(function(col, i) { + return array.map(function(row) { + return row[i] + }) + }); + return newArray; + }; + // Split value at splitChar, but allow splitChar to be escaped + // using escapeChar. Any other characters escaped by escapeChar + // will be included as usual (including escapeChar itself). + function splitWithEscape(value, splitChar, escapeChar) { + var results = []; + var escapeMode = false; + var currentResult = ""; + for (var pos = 0; pos < value.length; pos++) { + if (!escapeMode) { + if (value[pos] === splitChar) { + results.push(currentResult); + currentResult = ""; + } else if (value[pos] === escapeChar) { + escapeMode = true; + } else { + currentResult += value[pos]; + } + } else { + currentResult += value[pos]; + escapeMode = false; + } + } + if (currentResult !== "") { + results.push(currentResult); + } + return results; + } + // Function authored by Yihui/JJ Allaire + window.HTMLWidgets.evaluateStringMember = function(o, member) { + var parts = splitWithEscape(member, '.', '\\'); + for (var i = 0, l = parts.length; i < l; i++) { + var part = parts[i]; + // part may be a character or 'numeric' member name + if (o !== null && typeof o === "object" && part in o) { + if (i == (l - 1)) { // if we are at the end of the line then evalulate + if (typeof o[part] === "string") + o[part] = tryEval(o[part]); + } else { // otherwise continue to next embedded object + o = o[part]; + } + } + } + }; + + // Retrieve the HTMLWidget instance (i.e. the return value of an + // HTMLWidget binding's initialize() or factory() function) + // associated with an element, or null if none. + window.HTMLWidgets.getInstance = function(el) { + return elementData(el, "init_result"); + }; + + // Finds the first element in the scope that matches the selector, + // and returns the HTMLWidget instance (i.e. the return value of + // an HTMLWidget binding's initialize() or factory() function) + // associated with that element, if any. If no element matches the + // selector, or the first matching element has no HTMLWidget + // instance associated with it, then null is returned. + // + // The scope argument is optional, and defaults to window.document. + window.HTMLWidgets.find = function(scope, selector) { + if (arguments.length == 1) { + selector = scope; + scope = document; + } + + var el = scope.querySelector(selector); + if (el === null) { + return null; + } else { + return window.HTMLWidgets.getInstance(el); + } + }; + + // Finds all elements in the scope that match the selector, and + // returns the HTMLWidget instances (i.e. the return values of + // an HTMLWidget binding's initialize() or factory() function) + // associated with the elements, in an array. If elements that + // match the selector don't have an associated HTMLWidget + // instance, the returned array will contain nulls. + // + // The scope argument is optional, and defaults to window.document. + window.HTMLWidgets.findAll = function(scope, selector) { + if (arguments.length == 1) { + selector = scope; + scope = document; + } + + var nodes = scope.querySelectorAll(selector); + var results = []; + for (var i = 0; i < nodes.length; i++) { + results.push(window.HTMLWidgets.getInstance(nodes[i])); + } + return results; + }; + + var postRenderHandlers = []; + function invokePostRenderHandlers() { + while (postRenderHandlers.length) { + var handler = postRenderHandlers.shift(); + if (handler) { + handler(); + } + } + } + + // Register the given callback function to be invoked after the + // next time static widgets are rendered. + window.HTMLWidgets.addPostRenderHandler = function(callback) { + postRenderHandlers.push(callback); + }; + + // Takes a new-style instance-bound definition, and returns an + // old-style class-bound definition. This saves us from having + // to rewrite all the logic in this file to accomodate both + // types of definitions. + function createLegacyDefinitionAdapter(defn) { + var result = { + name: defn.name, + type: defn.type, + initialize: function(el, width, height) { + return defn.factory(el, width, height); + }, + renderValue: function(el, x, instance) { + return instance.renderValue(x); + }, + resize: function(el, width, height, instance) { + return instance.resize(width, height); + } + }; + + if (defn.find) + result.find = defn.find; + if (defn.renderError) + result.renderError = defn.renderError; + if (defn.clearError) + result.clearError = defn.clearError; + + return result; + } +})(); + diff --git a/docs/articles/neurons-intro_files/rglWebGL-binding-0.107.10/rglWebGL.js b/docs/articles/neurons-intro_files/rglWebGL-binding-0.107.10/rglWebGL.js new file mode 100644 index 00000000..52c8fe64 --- /dev/null +++ b/docs/articles/neurons-intro_files/rglWebGL-binding-0.107.10/rglWebGL.js @@ -0,0 +1,79 @@ +/* el is the div, holding the rgl object as el.rglinstance, + which holds x as el.rglinstance.scene + x is the JSON encoded rglwidget. +*/ + + +HTMLWidgets.widget({ + + name: 'rglWebGL', + + type: 'output', + + factory: function(el, width, height) { + el.width = width; + el.height = height; + var rgl = new rglwidgetClass(), + onchangeselection = function(e) { + for (var i = 0; i < rgl.scene.crosstalk.sel_handle.length; i++) + rgl.clearBrush(except = e.rglSubsceneId); + rgl.selection(e, false); + }, + onchangefilter = function(e) { + rgl.selection(e, true); + }; + + return { + renderValue: function(x) { + var i, pel, player, groups, + inShiny = (typeof Shiny !== "undefined"); + + x.crosstalk.group = groups = [].concat(x.crosstalk.group); + x.crosstalk.id = [].concat(x.crosstalk.id); + x.crosstalk.key = [].concat(x.crosstalk.key); + x.crosstalk.sel_handle = new Array(groups.length); + x.crosstalk.fil_handle = new Array(groups.length); + x.crosstalk.selection = []; + for (i = 0; i < groups.length; i++) { + x.crosstalk.sel_handle[i] = new crosstalk.SelectionHandle(groups[i], {sharedId: x.crosstalk.id[i]}); + x.crosstalk.sel_handle[i].on("change", onchangeselection); + x.crosstalk.fil_handle[i] = new crosstalk.FilterHandle(groups[i], {sharedId: x.crosstalk.id[i]}); + x.crosstalk.fil_handle[i].on("change", onchangefilter); + } + if (inShiny) { + // Shiny calls this multiple times, so we need extra cleanup + // between + rgl.sphere = undefined; + } + rgl.initialize(el, x); + rgl.initGL(); + + /* We might have been called after (some of) the players were rendered. + We need to make sure we respond to their initial values. */ + + if (typeof x.players !== "undefined") { + var players = [].concat(x.players); + for (i = 0; i < players.length; i++) { + pel = document.getElementById(players[i]); + if (pel) { + player = pel.rglPlayer; + if (player && (!player.initialized || inShiny)) { + rgl.Player(pel, player); + player.initialized = true; + } + } + } + } + rgl.drag = 0; + rgl.drawScene(); + }, + + resize: function(width, height) { + el.width = width; + el.height = height; + el.rglinstance.resize(el); + el.rglinstance.drawScene(); + } + }; + } +}); diff --git a/docs/articles/neurons-intro_files/rglwidgetClass-0.107.10/rgl.css b/docs/articles/neurons-intro_files/rglwidgetClass-0.107.10/rgl.css new file mode 100644 index 00000000..b22aaf65 --- /dev/null +++ b/docs/articles/neurons-intro_files/rglwidgetClass-0.107.10/rgl.css @@ -0,0 +1,21 @@ +.rglPlayer { + width: auto; + height: auto; +} + +.rglPlayer .rgl-button { + width: auto; + display: inline-block; + font-size: 75%; +} + +.rglPlayer .rgl-slider { + display: inline-block; + width: 30%; +} + +.rglPlayer .rgl-label { + display: inline; + padding-left: 6px; + padding-right: 6px; +} diff --git a/docs/articles/neurons-intro_files/rglwidgetClass-0.107.10/rglClass.min.js b/docs/articles/neurons-intro_files/rglwidgetClass-0.107.10/rglClass.min.js new file mode 100644 index 00000000..e5736e7d --- /dev/null +++ b/docs/articles/neurons-intro_files/rglwidgetClass-0.107.10/rglClass.min.js @@ -0,0 +1,4 @@ +rglwidgetClass=function(){this.canvas=null,this.userMatrix=new CanvasMatrix4,this.types=[],this.prMatrix=new CanvasMatrix4,this.mvMatrix=new CanvasMatrix4,this.vp=null,this.prmvMatrix=null,this.origs=null,this.gl=null,this.scene=null,this.select={state:"inactive",subscene:null,region:{p1:{x:0,y:0},p2:{x:0,y:0}}},this.drawing=!1},rglwidgetClass.prototype.f_is_lit=1,rglwidgetClass.prototype.f_is_smooth=2,rglwidgetClass.prototype.f_has_texture=4,rglwidgetClass.prototype.f_depth_sort=8,rglwidgetClass.prototype.f_fixed_quads=16,rglwidgetClass.prototype.f_is_transparent=32,rglwidgetClass.prototype.f_is_lines=64,rglwidgetClass.prototype.f_sprites_3d=128,rglwidgetClass.prototype.f_is_subscene=256,rglwidgetClass.prototype.f_is_clipplanes=512,rglwidgetClass.prototype.f_fixed_size=1024,rglwidgetClass.prototype.f_is_points=2048,rglwidgetClass.prototype.f_is_twosided=4096,rglwidgetClass.prototype.f_fat_lines=8192,rglwidgetClass.prototype.f_is_brush=16384,rglwidgetClass.prototype.f_has_fog=32768,rglwidgetClass.prototype.fogNone=0,rglwidgetClass.prototype.fogLinear=1,rglwidgetClass.prototype.fogExp=2,rglwidgetClass.prototype.fogExp2=3,rglwidgetClass.prototype.start=function(){"undefined"!=typeof this.prefix&&(this.debugelement=document.getElementById(this.prefix+"debug"),this.debug("")),this.drag=0,this.drawScene()},rglwidgetClass.prototype.multMV=function(M,v){return[M.m11*v[0]+M.m12*v[1]+M.m13*v[2]+M.m14*v[3],M.m21*v[0]+M.m22*v[1]+M.m23*v[2]+M.m24*v[3],M.m31*v[0]+M.m32*v[1]+M.m33*v[2]+M.m34*v[3],M.m41*v[0]+M.m42*v[1]+M.m43*v[2]+M.m44*v[3]]},rglwidgetClass.prototype.multVM=function(v,M){return[M.m11*v[0]+M.m21*v[1]+M.m31*v[2]+M.m41*v[3],M.m12*v[0]+M.m22*v[1]+M.m32*v[2]+M.m42*v[3],M.m13*v[0]+M.m23*v[1]+M.m33*v[2]+M.m43*v[3],M.m14*v[0]+M.m24*v[1]+M.m34*v[2]+M.m44*v[3]]},rglwidgetClass.prototype.vlen=function(v){return Math.sqrt(this.dotprod(v,v))},rglwidgetClass.prototype.dotprod=function(a,b){return a[0]*b[0]+a[1]*b[1]+a[2]*b[2]},rglwidgetClass.prototype.xprod=function(a,b){return[a[1]*b[2]-a[2]*b[1],a[2]*b[0]-a[0]*b[2],a[0]*b[1]-a[1]*b[0]]},rglwidgetClass.prototype.cbind=function(a,b){return b.lengthi;i++)value=arr[i],Array.isArray(value)?this.flatten(value,result):result.push(value);return result},rglwidgetClass.prototype.setElement=function(a,i,value){if(Array.isArray(a[0])){var dim=a.length,col=Math.floor(i/dim),row=i%dim;a[row][col]=value}else a[i]=value},rglwidgetClass.prototype.transpose=function(a){var i,newArray=[],n=a.length,m=a[0].length;for(i=0;m>i;i++)newArray.push([]);for(i=0;n>i;i++)for(var j=0;m>j;j++)newArray[j].push(a[i][j]);return newArray},rglwidgetClass.prototype.sumsq=function(x){var i,result=0;for(i=0;i>16&255)/255,(bigint>>8&255)/255,(255&bigint)/255]},rglwidgetClass.prototype.whichList=function(id){var obj=this.getObj(id),flags=obj.flags;return"light"===obj.type?"lights":this.isSet(flags,this.f_is_subscene)?"subscenes":this.isSet(flags,this.f_is_clipplanes)?"clipplanes":this.isSet(flags,this.f_is_transparent)?"transparent":"opaque"},rglwidgetClass.prototype.componentProduct=function(x,y){"undefined"==typeof y&&this.alertOnce("Bad arg to componentProduct");var i,result=new Float32Array(3);for(i=0;3>i;i++)result[i]=x[i]*y[i];return result},rglwidgetClass.prototype.getPowerOfTwo=function(value){for(var pow=1;value>pow;)pow*=2;return pow},rglwidgetClass.prototype.unique=function(arr){return arr=[].concat(arr),arr.filter(function(value,index,self){return self.indexOf(value)===index})},rglwidgetClass.prototype.equalArrays=function(a,b){return a===b||a&&b&&a.length===b.length&&a.every(function(v,i){return v===b[i]})},rglwidgetClass.prototype.repeatToLen=function(arr,len){if(arr=[].concat(arr),!arr.length)throw new RangeError("array is length 0");for(;arr.length=-windHeight&&rect.left>=-windWidth&&rect.bottom<=2*windHeight&&rect.right<=2*windWidth},rglwidgetClass.prototype.keydiff=function(obj1,obj2){var i,keys=Object.keys(obj1),result=[];for(i=0;i=2&&cross(lower[lower.length-2],lower[lower.length-1],points[i])<=0;)lower.pop();lower.push(points[i])}for(i=points.length-1;i>=0;i--){for(;upper.length>=2&&cross(upper[upper.length-2],upper[upper.length-1],points[i])<=0;)upper.pop();upper.push(points[i])}return upper.pop(),lower.pop(),lower.concat(upper)},rglwidgetClass.prototype.signif=function(x,digits){return parseFloat(x.toPrecision(digits))},rglwidgetClass.prototype.missing=function(x){return"-Inf"!==x&&"Inf"!==x&&(isNaN(x)||null===x||"undefined"==typeof x)},rglwidgetClass.prototype.inSubscene=function(id,subscene){return this.getObj(subscene).objects.indexOf(id)>-1},rglwidgetClass.prototype.translateCoords=function(subsceneid,coords){var viewport=this.getObj(subsceneid).par3d.viewport;return{x:coords.x-viewport.x*this.canvas.width,y:coords.y-viewport.y*this.canvas.height}},rglwidgetClass.prototype.inViewport=function(coords,subsceneid){var viewport=this.getObj(subsceneid).par3d.viewport,x0=coords.x-viewport.x*this.canvas.width,y0=coords.y-viewport.y*this.canvas.height;return x0>=0&&x0<=viewport.width*this.canvas.width&&y0>=0&&y0<=viewport.height*this.canvas.height},rglwidgetClass.prototype.whichSubscene=function(coords){var self=this,recurse=function(subsceneid){var i,id,subscenes=self.getChildSubscenes(subsceneid);for(i=0;i-1&&(thesub.objects.splice(i,1),thelist=this.whichList(id),i=thesub[thelist].indexOf(id),thesub[thelist].splice(i,1))},rglwidgetClass.prototype.setSubsceneEntries=function(ids,subsceneid){var sub=this.getObj(subsceneid);sub.objects=ids,this.initSubscene(subsceneid)},rglwidgetClass.prototype.getSubsceneEntries=function(subscene){return this.getObj(subscene).objects},rglwidgetClass.prototype.getChildSubscenes=function(subscene){return this.getObj(subscene).subscenes},rglwidgetClass.prototype.useid=function(subsceneid,type){var sub=this.getObj(subsceneid);return"inherit"===sub.embeddings[type]?this.useid(sub.parent,type):subsceneid},rglwidgetClass.prototype.getBBoxDeco=function(sub){var i,obj,objects=sub.objects;for(i=0;ii;i++)result=result+" uniform vec4 vClipplane"+i+";\n";if(is_lit&&(nlights=this.countLights(),nlights?result+=" uniform mat4 mvMatrix;\n":is_lit=!1),is_lit)for(result+=" uniform vec3 emission;\n uniform float shininess;\n",i=0;nlights>i;i++)result=result+" uniform vec3 ambient"+i+";\n uniform vec3 specular"+i+"; // light*material\n uniform vec3 diffuse"+i+";\n uniform vec3 lightDir"+i+";\n uniform bool viewpoint"+i+";\n uniform bool finite"+i+";\n";if(is_twosided&&(result+=" uniform bool front;\n varying float normz;\n"),fat_lines&&(result+=" varying vec2 vPoint;\n varying float vLength;\n"),result+=" void main(void) {\n vec4 fragColor;\n",fat_lines&&(result+=" vec2 point = vPoint;\n bool neg = point.y < 0.0;\n point.y = neg ? (point.y + vLength)/(1.0 - vLength) :\n -(point.y - vLength)/(1.0 - vLength);\n",is_transparent&&"linestrip"===type&&(result+=" if (neg && length(point) <= 1.0) discard;\n"),result+=" point.y = min(point.y, 0.0);\n if (length(point) > 1.0) discard;\n"),is_points){var round=this.getMaterial(obj,"point_antialias");round&&(result+=" vec2 coord = gl_PointCoord - vec2(0.5);\n if (length(coord) > 0.5) discard;\n")}for(i=0;nclipplanes>i;i++)result=result+" if (dot(vPosition, vClipplane"+i+") < 0.0) discard;\n";if(fixed_quads?result+=" vec3 n = vec3(0., 0., 1.);\n":is_lit&&(result+=" vec3 n = normalize(vNormal);\n"),is_twosided&&(result+=" if ((normz <= 0.) != front) discard;\n"),is_lit)for(result+=" vec3 eye = normalize(-vPosition.xyz);\n vec3 lightdir;\n vec4 colDiff;\n vec3 halfVec;\n vec4 lighteffect = vec4(emission, 0.);\n vec3 col;\n float nDotL;\n",fixed_quads||(result+=" n = -faceforward(n, n, eye);\n"),i=0;nlights>i;i++)result=result+" colDiff = vec4(vCol.rgb * diffuse"+i+", vCol.a);\n lightdir = lightDir"+i+";\n if (!viewpoint"+i+")\n lightdir = (mvMatrix * vec4(lightdir, 1.)).xyz;\n if (!finite"+i+") {\n halfVec = normalize(lightdir + eye);\n } else {\n lightdir = normalize(lightdir - vPosition.xyz);\n halfVec = normalize(lightdir + eye);\n }\n col = ambient"+i+";\n nDotL = dot(n, lightdir);\n col = col + max(nDotL, 0.) * colDiff.rgb;\n col = col + pow(max(dot(halfVec, n), 0.), shininess) * specular"+i+";\n lighteffect = lighteffect + vec4(col, colDiff.a);\n";else result+=" vec4 colDiff = vCol;\n vec4 lighteffect = colDiff;\n";return"text"===type&&(result+=" vec4 textureColor = lighteffect*texture2D(uSampler, vTexcoord);\n"),has_texture?result=result+{rgb:" vec4 textureColor = lighteffect*vec4(texture2D(uSampler, vTexcoord).rgb, 1.);\n",rgba:" vec4 textureColor = lighteffect*texture2D(uSampler, vTexcoord);\n",alpha:" vec4 textureColor = texture2D(uSampler, vTexcoord);\n float luminance = dot(vec3(1.,1.,1.), textureColor.rgb)/3.;\n textureColor = vec4(lighteffect.rgb, lighteffect.a*luminance);\n",luminance:" vec4 textureColor = vec4(lighteffect.rgb*dot(texture2D(uSampler, vTexcoord).rgb, vec3(1.,1.,1.))/3., lighteffect.a);\n","luminance.alpha":" vec4 textureColor = texture2D(uSampler, vTexcoord);\n float luminance = dot(vec3(1.,1.,1.),textureColor.rgb)/3.;\n textureColor = vec4(lighteffect.rgb*luminance, lighteffect.a*textureColor.a);\n"}[texture_format]+" fragColor = textureColor;\n":result+="text"===type?" if (textureColor.a < 0.1)\n discard;\n else\n fragColor = textureColor;\n":" fragColor = lighteffect;\n",result+=has_fog?" float fogF;\n if (uFogMode > 0) {\n fogF = (uFogParms.y - vPosition.z/vPosition.w)/(uFogParms.y - uFogParms.x);\n if (uFogMode > 1)\n fogF = mix(uFogParms.w, 1.0, fogF);\n fogF = fogF*uFogParms.z;\n if (uFogMode == 2)\n fogF = 1.0 - exp(-fogF);\n else if (uFogMode == 3)\n fogF = 1.0 - exp(-fogF*fogF);\n fogF = clamp(fogF, 0.0, 1.0);\n gl_FragColor = vec4(mix(fragColor.rgb, uFogColor, fogF), fragColor.a);\n } else gl_FragColor = fragColor;\n":" gl_FragColor = fragColor;\n",result+=" }\n"}},rglwidgetClass.prototype.getShader=function(shaderType,code){var shader,gl=this.gl;return shader=gl.createShader(shaderType),gl.shaderSource(shader,code),gl.compileShader(shader),gl.getShaderParameter(shader,gl.COMPILE_STATUS)||gl.isContextLost()||alert(gl.getShaderInfoLog(shader)),shader},rglwidgetClass.prototype.handleLoadedTexture=function(texture,textureCanvas){var gl=this.gl||this.initGL();gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL,!0),gl.bindTexture(gl.TEXTURE_2D,texture),gl.texImage2D(gl.TEXTURE_2D,0,gl.RGBA,gl.RGBA,gl.UNSIGNED_BYTE,textureCanvas),gl.texParameteri(gl.TEXTURE_2D,gl.TEXTURE_MAG_FILTER,gl.LINEAR),gl.texParameteri(gl.TEXTURE_2D,gl.TEXTURE_MIN_FILTER,gl.LINEAR_MIPMAP_NEAREST),gl.generateMipmap(gl.TEXTURE_2D),gl.bindTexture(gl.TEXTURE_2D,null)},rglwidgetClass.prototype.getMaxTexSize=function(){var gl=this.gl||this.initGL();return Math.min(4096,gl.getParameter(gl.MAX_TEXTURE_SIZE))},rglwidgetClass.prototype.loadImageToTexture=function(uri,texture){var canvas=this.textureCanvas,ctx=canvas.getContext("2d"),image=new Image,self=this;image.onload=function(){for(var w=image.width,h=image.height,canvasX=self.getPowerOfTwo(w),canvasY=self.getPowerOfTwo(h),maxTexSize=self.getMaxTexSize();canvasX>1&&canvasY>1&&(canvasX>maxTexSize||canvasY>maxTexSize);)canvasX/=2,canvasY/=2;canvas.width=canvasX,canvas.height=canvasY,ctx.imageSmoothingEnabled=!0,ctx.drawImage(image,0,0,canvasX,canvasY),self.handleLoadedTexture(texture,canvas),self.drawScene()},image.src=uri},rglwidgetClass.prototype.drawTextToCanvas=function(text,cex,family,font){var canvasX,canvasY,i,width,offsetx,line,scaling=20,textColour="white",backgroundColour="rgba(0,0,0,0)",canvas=this.textureCanvas,ctx=canvas.getContext("2d"),textHeight=0,textHeights=[],widths=[],offsety=0,lines=[],offsetsx=[],offsetsy=[],lineoffsetsy=[],fontStrings=[],maxTexSize=this.getMaxTexSize(),getFontString=function(i){textHeights[i]=scaling*cex[i];var fontString=textHeights[i]+"px",family0=family[i],font0=font[i];return"sans"===family0?family0="sans-serif":"mono"===family0&&(family0="monospace"),fontString=fontString+" "+family0,(2===font0||4===font0)&&(fontString="bold "+fontString),(3===font0||4===font0)&&(fontString="italic "+fontString),fontString};for(cex=this.repeatToLen(cex,text.length),family=this.repeatToLen(family,text.length),font=this.repeatToLen(font,text.length),canvasX=1,line=-1,offsetx=maxTexSize,i=0;imaxTexSize&&(offsety+=2*textHeight,line>=0&&(lineoffsetsy[line]=offsety),line+=1,offsety>maxTexSize&&console.error("Too many strings for texture."),textHeight=0,offsetx=0),textHeight=Math.max(textHeight,textHeights[i]),offsetsx[i]=offsetx,offsetx+=width,canvasX=Math.max(canvasX,offsetx),lines[i]=line;for(offsety=lineoffsetsy[line]=offsety+2*textHeight,i=0;i=radius&&(radius=1);var hlen,observer=subscene.par3d.observer,distance=observer[2],FOV=subscene.par3d.FOV,ortho=0===FOV,t=ortho?1:Math.tan(FOV*Math.PI/360),near=distance-radius,far=distance+radius,aspect=this.vp.width/this.vp.height,z=subscene.par3d.zoom,userProjection=subscene.par3d.userProjection;0>far&&(far=1),far/100>near&&(near=far/100),this.frustum={near:near,far:far},hlen=t*near,ortho?aspect>1?this.prMatrix.ortho(-hlen*aspect*z,hlen*aspect*z,-hlen*z,hlen*z,near,far):this.prMatrix.ortho(-hlen*z,hlen*z,-hlen*z/aspect,hlen*z/aspect,near,far):aspect>1?this.prMatrix.frustum(-hlen*aspect*z,hlen*aspect*z,-hlen*z,hlen*z,near,far):this.prMatrix.frustum(-hlen*z,hlen*z,-hlen*z/aspect,hlen*z/aspect,near,far),this.prMatrix.multRight(userProjection)}},rglwidgetClass.prototype.setmvMatrix=function(id){var observer=this.getObj(id).par3d.observer;this.mvMatrix.makeIdentity(),this.setmodelMatrix(id),this.mvMatrix.translate(-observer[0],-observer[1],-observer[2])},rglwidgetClass.prototype.setmodelMatrix=function(id){var subscene=this.getObj(id),embedding=subscene.embeddings.model;if("inherit"!==embedding){var scale=subscene.par3d.scale,bbox=subscene.par3d.bbox,center=[(bbox[0]+bbox[1])/2,(bbox[2]+bbox[3])/2,(bbox[4]+bbox[5])/2];this.mvMatrix.translate(-center[0],-center[1],-center[2]),this.mvMatrix.scale(scale[0],scale[1],scale[2]),this.mvMatrix.multRight(subscene.par3d.userMatrix)}"replace"!==embedding&&this.setmodelMatrix(subscene.parent)},rglwidgetClass.prototype.setnormMatrix=function(subsceneid){var self=this,recurse=function(id){var sub=self.getObj(id),embedding=sub.embeddings.model;if("inherit"!==embedding){var scale=sub.par3d.scale;self.normMatrix.scale(1/scale[0],1/scale[1],1/scale[2]),self.normMatrix.multRight(sub.par3d.userMatrix)}"replace"!==embedding&&recurse(sub.parent)};self.normMatrix.makeIdentity(),recurse(subsceneid)},rglwidgetClass.prototype.setprmvMatrix=function(){this.prmvMatrix=new CanvasMatrix4(this.mvMatrix),this.prmvMatrix.multRight(this.prMatrix)},rglwidgetClass.prototype.getCursor=function(mode){switch(mode){case"none":return"none";case"trackball":case"xAxis":case"yAxis":case"zAxis":case"polar":return"grab";case"selecting":return"crosshair";case"fov":case"zoom":return"zoom-in";case"user":return"default"}return"dragging"},rglwidgetClass.prototype.setMouseMode=function(mode,button,subscene,stayActive){var sub=this.getObj(subscene),which=["none","left","right","middle","wheel"][button];stayActive||"selecting"!==sub.par3d.mouseMode[which]||this.clearBrush(null),sub.par3d.mouseMode[which]=mode,(1===button||0===button&&"none"!==mode)&&(this.canvas.style.cursor=this.getCursor(mode)),0===button&&"none"!==mode&&(sub.needsBegin=mode)},rglwidgetClass.prototype.relMouseCoords=function(event){var rect=this.canvas.getBoundingClientRect();return{x:event.clientX-rect.left,y:event.clientY-rect.top}},rglwidgetClass.prototype.recordSelection=function(subid){var result={};"undefined"!=typeof this.select&&"undefined"!=typeof this.select.state&&"inactive"!==this.select.state?(result={subscene:subid,state:this.select.state,region:this.select.region},this.setmvMatrix(subid),result.model=this.mvMatrix,this.setprMatrix(subid),result.proj=this.prMatrix,this.getViewport(subid),result.view=this.vp):result.state="inactive",Shiny.setInputValue(this.scene.selectionInput+":shinyMouse3d",result)},rglwidgetClass.prototype.setMouseHandlers=function(){var activeSubscene,handler,self=this,handlers={},drag=0;handlers.rotBase=0,self.screenToVector=function(x,y){var viewport=self.getObj(activeSubscene).par3d.viewport,width=viewport.width*self.canvas.width,height=viewport.height*self.canvas.height,radius=Math.max(width,height)/2,cx=width/2,cy=height/2,px=(x-cx)/radius,py=(y-cy)/radius,plen=Math.sqrt(px*px+py*py);plen>1e-6&&(px/=plen,py/=plen);var angle=(Math.SQRT2-plen)/Math.SQRT2*Math.PI/2,z=Math.sin(angle),zlen=Math.sqrt(1-z*z);return px*=zlen,py*=zlen,[px,py,z]},handlers.trackballdown=function(x,y){var i,activeSub=self.getObj(activeSubscene),activeModel=self.getObj(self.useid(activeSub.id,"model")),l=activeModel.par3d.listeners;for(handlers.rotBase=self.screenToVector(x,y),self.saveMat=[],i=0;ij;j++)changepos[j]=-(dragCurrent[j]-handlers.dragBase[j]);activeSub.par3d.userMatrix.makeIdentity(),activeSub.par3d.userMatrix.rotate(180*changepos[0]/Math.PI,0,-1,0),activeSub.par3d.userMatrix.multRight(objects[l[i]].saveMat),activeSub.par3d.userMatrix.rotate(180*changepos[1]/Math.PI,-1,0,0)}self.drawScene()},handlers.polarend=0,handlers.axisdown=function(x){handlers.rotBase=self.screenToVector(x,self.canvas.height/2);var i,activeSub=self.getObj(activeSubscene),activeModel=self.getObj(self.useid(activeSub.id,"model")),l=activeModel.par3d.listeners;for(i=0;i1){var coords=self.relMouseCoords(touch),new_dist=handlers.get_finger_dist(ev);coords.y=self.canvas.height*Math.log(handlers.finger_dist0/new_dist)+handlers.y0zoom,handlers.zoommove(coords.x,coords.y)}else mouseEvent=new MouseEvent("mousemove",{clientX:touch.clientX,clientY:touch.clientY}),self.dispatchEvent(mouseEvent)},self.canvas.addEventListener("DOMMouseScroll",handlers.wheelHandler,!1),self.canvas.addEventListener("mousewheel",handlers.wheelHandler,!1),self.canvas.addEventListener("touchstart",handlers.touchstart,{passive:!1}),self.canvas.addEventListener("touchend",handlers.touchend,{passive:!1}),self.canvas.addEventListener("touchmove",handlers.touchmove,{passive:!1})},rglwidgetClass.prototype.initGL0=function(){return window.WebGLRenderingContext?void 0:void this.alertOnce("Your browser does not support WebGL. See http://get.webgl.org")},rglwidgetClass.prototype.initGL=function(){var self=this,success=!1;if(this.gl){if(this.drawing||!this.gl.isContextLost())return this.gl;this.restartCanvas()}this.canvas.addEventListener("webglcontextrestored",this.onContextRestored,!1),this.canvas.addEventListener("webglcontextlost",this.onContextLost,!1),this.gl=this.canvas.getContext("webgl",this.webGLoptions)||this.canvas.getContext("experimental-webgl",this.webGLoptions),success=!!(this.gl&&this.gl instanceof WebGLRenderingContext),success||this.alertOnce("Your browser does not support WebGL. See http://get.webgl.org"),this.index_uint=this.gl.getExtension("OES_element_index_uint");var save=this.startDrawing();return Object.keys(this.scene.objects).forEach(function(key){self.initObjId(parseInt(key,10))}),this.stopDrawing(save),this.gl},rglwidgetClass.prototype.resize=function(el){this.canvas.width=el.width,this.canvas.height=el.height},rglwidgetClass.prototype.initSphere=function(sections,segments){var i,j,k,ind,mod1,pole,v=[],phi=[],theta=[],it=[],centers=[],result={};for(i=0;sections-1>i;i++)phi.push((i+1)/sections-.5);for(j=0;segments>j;j++)for(theta.push(2*j/segments),i=0;sections-1>i;i++)v.push([Math.sin(Math.PI*theta[j])*Math.cos(Math.PI*phi[i]),Math.sin(Math.PI*phi[i]),Math.cos(Math.PI*theta[j])*Math.cos(Math.PI*phi[i]),theta[j]/2,phi[i]+.5]);for(pole=v.length,v.push([0,-1,0,0,0]),v.push([0,1,0,0,1]),result.values=new Float32Array(this.flatten(v)),result.vertexCount=v.length,mod1=segments*(sections-1),j=0;segments>j;j++){for(i=0;sections-2>i;i++)ind=i+(sections-1)*j,it.push([ind%mod1,(ind+sections-1)%mod1,(ind+sections)%mod1]),it.push([ind%mod1,(ind+sections)%mod1,(ind+1)%mod1]);it.push([pole,(j+1)*(sections-1)%mod1,((j+1)*(sections-1)-sections+1)%mod1]),it.push([pole+1,((j+1)*(sections-1)-1)%mod1,((j+1)*(sections-1)+sections-2)%mod1])}for(result.it=new Uint16Array(this.flatten(it)),i=0;ij;j++)for(k=0;3>k;k++)centers[i][j]+=v[it[i][k]][j]/3;result.centers=centers,result.vOffsets={vofs:0,cofs:-1,nofs:0,radofs:-1,oofs:-1,tofs:3,nextofs:-1,pointofs:-1,stride:5},result.f=[],result.indices={},result.colorCount=1,result.type="sphere",this.sphere=result,this.initShapeGL(this.sphere)},rglwidgetClass.prototype.initCube=function(){var i,j,k,v=[[0,0,0],[1,0,0],[0,1,0],[1,1,0],[0,0,1],[1,0,1],[0,1,1],[1,1,1]],ib=[[0,2,3,1],[2,6,7,3],[1,3,7,5],[0,4,6,2],[0,1,5,4],[4,5,7,6]],centers=[],result={};for(result.values=new Float32Array(this.flatten(v)),result.vertexCount=v.length,result.ib=new Uint16Array(this.flatten(ib)),i=0;ij;j++)for(k=0;4>k;k++)centers[i][j]+=v[ib[i][k]][j]/4;result.centers=centers,result.vOffsets={vofs:0,cofs:-1,nofs:0,radofs:-1,oofs:-1,tofs:-1,nextofs:-1,pointofs:-1,stride:3},result.f=[],result.indices={},result.colorCount=1,result.type="cube",result.vertices=v,this.cube=result,this.initShapeGL(this.cube)},rglwidgetClass.prototype.initShapeGL=function(shape){var gl=this.gl||this.initGL();gl.isContextLost()||(shape.buf=gl.createBuffer(),gl.bindBuffer(gl.ARRAY_BUFFER,shape.buf),gl.bufferData(gl.ARRAY_BUFFER,shape.values,gl.STATIC_DRAW),shape.ibuf=[gl.createBuffer(),gl.createBuffer()])},rglwidgetClass.prototype.initShapeFromObj=function(shape,obj){var i,pass,f,mode;if(shape.ofsLoc=obj.ofsLoc,shape.texLoc=obj.texLoc,shape.sampler=obj.sampler,shape.uFogMode=obj.uFogMode,shape.uFogColor=obj.uFogColor,shape.uFogParms=obj.uFogParms,shape.userAttribLocations=obj.userAttribLocations,shape.userUniformLocations=obj.userUniformLocations,shape.normLoc=obj.normLoc,shape.clipLoc=obj.clipLoc,shape.nextLoc=obj.nextLoc,shape.pointLoc=obj.pointLoc,shape.aspectLoc=obj.aspectLoc,shape.lwdLoc=obj.lwdLoc,shape.prog=obj.prog,shape.material=obj.material,shape.flags=obj.flags,shape.someHidden=obj.someHidden,shape.fastTransparency=obj.fastTransparency,shape.nlights=obj.nlights,shape.emission=obj.emission,shape.emissionLoc=obj.emissionLoc,shape.shininess=obj.shininess,shape.shininessLoc=obj.shininessLoc,shape.ambient=obj.ambient,shape.ambientLoc=obj.ambientLoc,shape.specular=obj.specular,shape.specularLoc=obj.specularLoc,shape.diffuse=obj.diffuse,shape.diffuseLoc=obj.diffuseLoc,shape.lightDir=obj.lightDir,shape.lightDirLoc=obj.lightDirLoc,shape.viewpoint=obj.viewpoint,shape.viewpointLoc=obj.viewpointLoc,shape.finite=obj.finite,shape.finiteLoc=obj.finiteLoc,shape.prMatLoc=obj.prMatLoc,shape.mvMatLoc=obj.mvMatLoc,shape.normMatLoc=obj.normMatLoc,shape.frontLoc=obj.frontLoc,shape.index_uint=!1,shape.is_transparent=obj.is_transparent,shape.ignoreExtent=obj.ignoreExtent,shape.passes!==obj.passes||JSON.stringify(shape.pmode)!==JSON.stringify(obj.pmode))for(shape.passes=obj.passes,shape.pmode=obj.pmode,pass=0;pass1?obj.colors[1]:[obj.colors[0]],axes:obj.axes,initialized:!1},obj.labels={id:obj.id+.3,type:"text",flags:this.f_has_fog+this.f_fixed_size+this.f_fixed_quads,material:{lit:!1},colors:obj.colors.length>1?obj.colors[1]:[obj.colors[0]],cex:[[1]],family:[["sans"]],font:[[1]],adj:[[.5,.5]],ignoreExtent:!0,initialized:!1},obj.initialized=!0},rglwidgetClass.prototype.initObjId=function(id){return"number"!=typeof id&&this.alertOnce("initObj id is "+typeof id),this.initObj(this.getObj(id))},rglwidgetClass.prototype.initObj=function(obj){var polygon_offset,texinfo,drawtype,nclipplanes,f,nrows,oldrows,i,j,v,v1,v2,mat,uri,matobj,pass,pmode,dim,nx,nz,nrow,flags=obj.flags,type=obj.type,is_lit=this.isSet(flags,this.f_is_lit),fat_lines=this.isSet(flags,this.f_fat_lines),has_texture=this.isSet(flags,this.f_has_texture),fixed_quads=this.isSet(flags,this.f_fixed_quads),is_transparent=this.isSet(flags,this.f_is_transparent),depth_sort=this.isSet(flags,this.f_depth_sort),sprites_3d=this.isSet(flags,this.f_sprites_3d),fixed_size=this.isSet(flags,this.f_fixed_size),is_twosided=this.isSet(flags,this.f_is_twosided),is_brush=this.isSet(flags,this.f_is_brush),has_fog=this.isSet(flags,this.f_has_fog),has_normals="undefined"!=typeof obj.normals,gl=this.gl||this.initGL();if(obj.initialized=!0,obj.someHidden=!1,obj.is_transparent=is_transparent,"subscene"!==type){if("bboxdeco"===type)return this.initBBox(obj);if("spheres"===type&&"undefined"==typeof this.sphere&&this.initSphere(16,16),"light"===type)return obj.ambient=new Float32Array(obj.colors[0].slice(0,3)),obj.diffuse=new Float32Array(obj.colors[1].slice(0,3)),obj.specular=new Float32Array(obj.colors[2].slice(0,3)),void(obj.lightDir=new Float32Array(obj.vertices[0]));if("clipplanes"===type)return void(obj.vClipplane=this.flatten(this.cbind(obj.normals,obj.offsets)));if("background"===type&&"undefined"!=typeof obj.ids)return void(obj.quad=this.flatten([].concat(obj.ids)));if(polygon_offset=this.getMaterial(obj,"polygon_offset"),(0!==polygon_offset[0]||0!==polygon_offset[1])&&(obj.polygon_offset=polygon_offset),is_transparent&&(depth_sort=["triangles","quads","surface","spheres","sprites","text"].indexOf(type)>=0),is_brush&&this.initSelection(obj.id),"undefined"==typeof obj.vertices&&(obj.vertices=[]),v=obj.vertices,obj.vertexCount=v.length,obj.vertexCount){if(is_twosided&&!has_normals){if("undefined"==typeof obj.userAttributes&&(obj.userAttributes={}),v1=Array(v.length),v2=Array(v.length),"triangles"===obj.type||"quads"===obj.type)for(nrow="triangles"===obj.type?3:4,i=0;ij;j++)v1[nrow*i+j]=v[nrow*i+(j+1)%nrow],v2[nrow*i+j]=v[nrow*i+(j+2)%nrow];else if("surface"===obj.type)for(dim=obj.dim[0],nx=dim[0],nz=dim[1],j=0;nx>j;j++)for(i=0;nz>i;i++)nz>i+1&&nx>j+1?(v2[j+nx*i]=v[j+nx*(i+1)],v1[j+nx*i]=v[j+1+nx*(i+1)]):nz>i+1?(v2[j+nx*i]=v[j-1+nx*i],v1[j+nx*i]=v[j+nx*(i+1)]):(v2[j+nx*i]=v[j+nx*(i-1)],v1[j+nx*i]=v[j-1+nx*(i-1)]);obj.userAttributes.aPos1=v1,obj.userAttributes.aPos2=v2}if(!sprites_3d){if(gl.isContextLost())return;"undefined"!=typeof obj.prog&&(gl.deleteProgram(obj.prog),obj.prog=void 0),obj.prog=gl.createProgram(),gl.attachShader(obj.prog,this.getShader(gl.VERTEX_SHADER,this.getVertexShader(obj))),gl.attachShader(obj.prog,this.getShader(gl.FRAGMENT_SHADER,this.getFragmentShader(obj))),gl.bindAttribLocation(obj.prog,0,"aPos"),gl.bindAttribLocation(obj.prog,1,"aCol"),gl.linkProgram(obj.prog);var linked=gl.getProgramParameter(obj.prog,gl.LINK_STATUS);if(!linked){var lastError=gl.getProgramInfoLog(obj.prog);return console.warn("Error in program linking:"+lastError),void gl.deleteProgram(obj.prog)}}"text"===type&&(texinfo=this.drawTextToCanvas(obj.texts,this.flatten(obj.cex),this.flatten(obj.family),this.flatten(obj.family))),fixed_quads&&!sprites_3d&&(obj.ofsLoc=gl.getAttribLocation(obj.prog,"aOfs")),(has_texture||"text"===type)&&(obj.texture||(obj.texture=gl.createTexture()),obj.texLoc=gl.getAttribLocation(obj.prog,"aTexcoord"),obj.sampler=gl.getUniformLocation(obj.prog,"uSampler")),has_fog&&!sprites_3d&&(obj.uFogMode=gl.getUniformLocation(obj.prog,"uFogMode"),obj.uFogColor=gl.getUniformLocation(obj.prog,"uFogColor"),obj.uFogParms=gl.getUniformLocation(obj.prog,"uFogParms")),has_texture&&(mat=obj.material,"undefined"!=typeof mat.uri?uri=mat.uri:"undefined"==typeof mat.uriElementId?(matobj=this.getObj(mat.uriId),uri="undefined"!=typeof matobj?matobj.material.uri:""):uri=document.getElementById(mat.uriElementId).rglinstance.getObj(mat.uriId).material.uri,this.loadImageToTexture(uri,obj.texture)),"text"===type&&this.handleLoadedTexture(obj.texture,this.textureCanvas);var nc,cofs,nofs,radofs,oofs,tofs,vnew,fnew,alias,colors,key,selection,filter,adj,pos,offset,attr,last,options,stride=3,nextofs=-1,pointofs=-1;if(obj.alias=void 0,colors=obj.colors,j=this.scene.crosstalk.id.indexOf(obj.id),j>=0){for(key=this.scene.crosstalk.key[j],options=this.scene.crosstalk.options[j],colors=colors.slice(0),i=0;i1?(cofs=stride,stride+=4,v=this.cbind(v,colors)):(cofs=-1,obj.onecolor=this.flatten(colors)),has_normals?(nofs=stride,stride+=3,v=this.cbind(v,"undefined"!=typeof obj.pnormals?obj.pnormals:obj.normals)):nofs=-1,"undefined"!=typeof obj.radii?(radofs=stride,stride+=1,obj.radii.length===v.length?v=this.cbind(v,obj.radii):1===obj.radii.length&&(v=v.map(function(row){return row.concat(obj.radii[0])}))):radofs=-1,f=Array(v.length),i=0;ij;j++)v1=vnew[fnew[4*i+j]],v1[tofs+2]=2*(v1[tofs]-v1[tofs+2])*texinfo.widths[i],v1[tofs+3]=2*(v1[tofs+1]-v1[tofs+3])*texinfo.textHeights[i],v1[tofs]=(texinfo.offsetsx[i]+v1[tofs]*texinfo.widths[i])/texinfo.canvasX,v1[tofs+1]=1-(texinfo.offsetsy[i]-v1[tofs+1]*texinfo.textHeights[i])/texinfo.canvasY,vnew[fnew[4*i+j]]=v1;v=vnew,obj.vertexCount=v.length,obj.f=[fnew,fnew]}else"undefined"!=typeof obj.texcoords?(tofs=stride,stride+=2,oofs=-1,v=this.cbind(v,obj.texcoords)):(tofs=-1,oofs=-1);else{tofs=stride,stride+=2,oofs=stride,stride+=2,vnew=new Array(4*v.length),fnew=new Array(4*v.length),alias=new Array(v.length);var rescale=fixed_size?72:1,size=obj.radii,s=rescale*size[0]/2;for(last=v.length,f=obj.f[0],i=0;i1&&(s=rescale*size[i]/2),vnew[i]=v[i].concat([0,0,-s,-s]),fnew[4*i]=f[i],vnew[last]=v[i].concat([1,0,s,-s]),fnew[4*i+1]=last++,vnew[last]=v[i].concat([1,1,s,s]),fnew[4*i+2]=last++,vnew[last]=v[i].concat([0,1,-s,s]),fnew[4*i+3]=last++,alias[i]=[last-3,last-2,last-1];v=vnew,obj.vertexCount=v.length,obj.f=[fnew,fnew]}if(obj.alias=alias,"undefined"!=typeof obj.userAttributes){obj.userAttribOffsets={},obj.userAttribLocations={},obj.userAttribSizes={};for(attr in obj.userAttributes)obj.userAttribLocations[attr]=gl.getAttribLocation(obj.prog,attr),obj.userAttribLocations[attr]>=0&&(obj.userAttribOffsets[attr]=stride,v=this.cbind(v,obj.userAttributes[attr]),stride=v[0].length,obj.userAttribSizes[attr]=stride-obj.userAttribOffsets[attr])}if("undefined"!=typeof obj.userUniforms){obj.userUniformLocations={};for(attr in obj.userUniforms)obj.userUniformLocations[attr]=gl.getUniformLocation(obj.prog,attr)}if(sprites_3d)for(obj.userMatrix=new CanvasMatrix4(obj.usermatrix),obj.objects=this.flatten([].concat(obj.ids)),is_lit=!1,i=0;ii;i++)obj.clipLoc[i]=gl.getUniformLocation(obj.prog,"vClipplane"+i);if(is_lit)for(obj.emissionLoc=gl.getUniformLocation(obj.prog,"emission"),obj.emission=new Float32Array(this.stringToRgb(this.getMaterial(obj,"emission"))),obj.shininessLoc=gl.getUniformLocation(obj.prog,"shininess"),obj.shininess=this.getMaterial(obj,"shininess"),obj.nlights=this.countLights(),obj.ambientLoc=[],obj.ambient=new Float32Array(this.stringToRgb(this.getMaterial(obj,"ambient"))),obj.specularLoc=[],obj.specular=new Float32Array(this.stringToRgb(this.getMaterial(obj,"specular"))),obj.diffuseLoc=[],obj.lightDirLoc=[],obj.viewpointLoc=[],obj.finiteLoc=[],i=0;ii;i++)fnew[6*i]=f[3*i],fnew[6*i+1]=f[3*i+1],fnew[6*i+2]=f[3*i+1],fnew[6*i+3]=f[3*i+2],fnew[6*i+4]=f[3*i+2],fnew[6*i+5]=f[3*i]}else if("spheres"===type);else if("surface"===type)if(dim=obj.dim[0],nx=dim[0],nz=dim[1],"filled"===pmode)for(fnew=[],j=0;nx-1>j;j++)for(i=0;nz-1>i;i++)fnew.push(f[j+nx*i],f[j+nx*(i+1)],f[j+1+nx*(i+1)],f[j+nx*i],f[j+1+nx*(i+1)],f[j+1+nx*i]);else if("lines"===pmode)for(fnew=[],j=0;nx>j;j++)for(i=0;nz>i;i++)nz>i+1&&fnew.push(f[j+nx*i],f[j+nx*(i+1)]),nx>j+1&&fnew.push(f[j+nx*i],f[j+1+nx*i])}else if(nrows=Math.floor(obj.vertexCount/4),"filled"===pmode)for(fnew=Array(6*nrows),i=0;nrows>i;i++)fnew[6*i]=f[4*i],fnew[6*i+1]=f[4*i+1],fnew[6*i+2]=f[4*i+2],fnew[6*i+3]=f[4*i],fnew[6*i+4]=f[4*i+2],fnew[6*i+5]=f[4*i+3];else for(fnew=Array(8*nrows),i=0;nrows>i;i++)fnew[8*i]=f[4*i],fnew[8*i+1]=f[4*i+1],fnew[8*i+2]=f[4*i+1],fnew[8*i+3]=f[4*i+2],fnew[8*i+4]=f[4*i+2],fnew[8*i+5]=f[4*i+3],fnew[8*i+6]=f[4*i+3],fnew[8*i+7]=f[4*i];obj.f[pass]=fnew,drawtype=depth_sort?"DYNAMIC_DRAW":"STATIC_DRAW"}if(fat_lines){for(alias=void 0,obj.nextLoc=gl.getAttribLocation(obj.prog,"aNext"),obj.pointLoc=gl.getAttribLocation(obj.prog,"aPoint"),obj.aspectLoc=gl.getUniformLocation(obj.prog,"uAspect"),obj.lwdLoc=gl.getUniformLocation(obj.prog,"uLwd"),pass=0;passj;j++)vnew[k][nextofs+j]=vnew[f[i+1]][j];for(vnew[k][pointofs]=-1,vnew[k][pointofs+1]=-1,fnew[ind]=k,last++,vnew[last]=vnew[k].slice(),vnew[last][pointofs]=1,fnew[ind+1]=last,alias[f[i]].push(last-1,last),last++,k=last,vnew[k]=vnew[f[i+1]].slice(),j=0;3>j;j++)vnew[k][nextofs+j]=vnew[f[i]][j];vnew[k][pointofs]=-1,vnew[k][pointofs+1]=1,fnew[ind+2]=k,fnew[ind+3]=fnew[ind+1],last++,vnew[last]=vnew[k].slice(),vnew[last][pointofs]=1,fnew[ind+4]=last,fnew[ind+5]=fnew[ind+2],ind+=6,alias[f[i+1]].push(last-1,last)}if(vnew.length=last+1,v=vnew,obj.vertexCount=v.length,"undefined"!=typeof alias&&"undefined"!=typeof obj.alias){var oldalias=obj.alias,newalias=Array(obj.alias.length);for(i=0;i65535?this.index_uint?(obj.f[pass]=new Uint32Array(obj.f[pass]),obj.index_uint=!0):this.alertOnce("Object has "+obj.vertexCount+" vertices, not supported in this browser."):(obj.f[pass]=new Uint16Array(obj.f[pass]),obj.index_uint=!1);stride!==v[0].length&&this.alertOnce("problem in stride calculation"),obj.vOffsets={vofs:0,cofs:cofs,nofs:nofs,radofs:radofs,oofs:oofs,tofs:tofs,nextofs:nextofs,pointofs:pointofs,stride:stride},obj.values=new Float32Array(this.flatten(v)),"spheres"===type||sprites_3d||(obj.buf=gl.createBuffer(),gl.bindBuffer(gl.ARRAY_BUFFER,obj.buf),gl.bufferData(gl.ARRAY_BUFFER,obj.values,gl.STATIC_DRAW),obj.ibuf=Array(obj.passes),obj.ibuf[0]=gl.createBuffer(),gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER,obj.ibuf[0]),gl.bufferData(gl.ELEMENT_ARRAY_BUFFER,obj.f[0],gl[drawtype]),is_twosided&&(obj.ibuf[1]=gl.createBuffer(),gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER,obj.ibuf[1]),gl.bufferData(gl.ELEMENT_ARRAY_BUFFER,obj.f[1],gl[drawtype]))),sprites_3d||(obj.mvMatLoc=gl.getUniformLocation(obj.prog,"mvMatrix"),obj.prMatLoc=gl.getUniformLocation(obj.prog,"prMatrix")),fixed_size&&(obj.textScaleLoc=gl.getUniformLocation(obj.prog,"textScale")),is_lit&&!sprites_3d&&(obj.normMatLoc=gl.getUniformLocation(obj.prog,"normMatrix")),is_twosided&&(obj.frontLoc=gl.getUniformLocation(obj.prog,"front"))}}},rglwidgetClass.prototype.initialize=function(el,x){if(this.textureCanvas=document.createElement("canvas"),this.textureCanvas.style.display="block",this.scene=x,this.normMatrix=new CanvasMatrix4,this.saveMat={},this.distance=null,this.posLoc=0,this.colLoc=1,el&&(el.rglinstance=this,this.el=el,this.webGLoptions=el.rglinstance.scene.webGLoptions,this.initCanvas()),"undefined"!=typeof Shiny){var self=this;Shiny.addCustomMessageHandler("shinyGetPar3d",function(message){var i,param,subscene=self.getObj(message.subscene),parameters=[].concat(message.parameters),result={tag:message.tag,subscene:message.subscene};if("undefined"!=typeof subscene)for(i=0;ii;i++)z=this.prmvMatrix.m13*obj.centers[i][0]+this.prmvMatrix.m23*obj.centers[i][1]+this.prmvMatrix.m33*obj.centers[i][2]+this.prmvMatrix.m43,w=this.prmvMatrix.m14*obj.centers[i][0]+this.prmvMatrix.m24*obj.centers[i][1]+this.prmvMatrix.m34*obj.centers[i][2]+this.prmvMatrix.m44,depth=z/w,result[i]={context:context,objid:objid,subid:subid,index:i,depth:depth};return result},rglwidgetClass.prototype.getSpherePieces=function(context,subid,obj){return obj.fastTransparency?0===subid?this.getPieces(context,obj.id,-1,obj):[]:this.getPieces(context,obj.id,subid,this.sphere)},rglwidgetClass.prototype.getCubePieces=function(context,obj){return this.getPieces(context,obj.id,0,this.cube)},rglwidgetClass.prototype.mergePieces=function(pieces){var result=[];if(pieces.length>0){var i,thiscontext=pieces[0].context,thisobjid=pieces[0].objid,thissubid=pieces[0].subid,indices=[];for(i=0;i0;)diff=c1.pop()-c2.pop();0===diff&&(diff=j.objid-i.objid),0===diff&&(diff=j.subid-i.subid)}return diff},result=[];return pieces.length&&(result=pieces.sort(compare)),result},rglwidgetClass.prototype.startDrawing=function(){var value=this.drawing;return this.drawing=!0,value},rglwidgetClass.prototype.stopDrawing=function(saved){this.drawing=saved,!saved&&this.gl&&this.gl.isContextLost()&&this.restartCanvas()},rglwidgetClass.prototype.planeUpdateTriangles=function(obj,bbox){var x,xrow,elem,A,d,nhits,i,j,k,u,v,w,intersect,which,v0,v2,vx,reverse,perms=[[0,0,1],[1,2,2],[2,1,0]],face1=[],face2=[],normals=[],nPlanes=obj.normals.length;for(obj.bbox=bbox,obj.vertices=[],obj.initialized=!1,elem=0;nPlanes>elem;elem++){for(x=[],A=obj.normals[elem],d=obj.offsets[elem][0],nhits=0,i=0;3>i;i++)for(j=0;2>j;j++)for(k=0;2>k;k++)u=perms[0][i],v=perms[1][i],w=perms[2][i],0!==A[w]&&(intersect=-(d+A[u]*bbox[j+2*u]+A[v]*bbox[k+2*v])/A[w],bbox[2*w]3)for(i=0;nhits-2>i;i++){for(which=0,j=i+1;nhits>j;j++)if(face1[i]===face1[j]||face1[i]===face2[j]||face2[i]===face1[j]||face2[i]===face2[j]){which=j;break}which>i+1&&(this.swap(x,i+1,which),this.swap(face1,i+1,which),this.swap(face2,i+1,which))}if(nhits>=3)for(v0=[x[0][0]-x[1][0],x[0][1]-x[1][1],x[0][2]-x[1][2]],v2=[x[2][0]-x[1][0],x[2][1]-x[1][1],x[2][2]-x[1][2]],vx=this.xprod(v0,v2),reverse=this.dotprod(vx,A)>0,i=0;nhits-2>i;i++)for(obj.vertices.push(x[0]),normals.push(A),j=1;3>j;j++)obj.vertices.push(x[i+(reverse?3-j:j)]),normals.push(A)}obj.pnormals=normals},rglwidgetClass.prototype.mode4type={points:"POINTS",linestrip:"LINE_STRIP",abclines:"LINES",lines:"LINES",sprites:"TRIANGLES",planes:"TRIANGLES",text:"TRIANGLES",quads:"TRIANGLES",surface:"TRIANGLES",triangles:"TRIANGLES",sphere:"TRIANGLES"},rglwidgetClass.prototype.disableArrays=function(obj,enabled){var i,attr,gl=this.gl||this.initGL(),objLocs=["normLoc","texLoc","ofsLoc","pointLoc","nextLoc"],thisLocs=["posLoc","colLoc"];for(i=0;i=0?(gl.enableVertexAttribArray(obj.normLoc),gl.vertexAttribPointer(obj.normLoc,3,gl.FLOAT,!1,4*obj.vOffsets.stride,4*obj.vOffsets.nofs),!0):!1},rglwidgetClass.prototype.doTexture=function(obj){var gl=this.gl,is_spheres="spheres"===obj.type;return gl.enableVertexAttribArray(obj.texLoc),is_spheres?gl.vertexAttribPointer(obj.texLoc,2,gl.FLOAT,!1,4*this.sphere.vOffsets.stride,4*this.sphere.vOffsets.tofs):gl.vertexAttribPointer(obj.texLoc,2,gl.FLOAT,!1,4*obj.vOffsets.stride,4*obj.vOffsets.tofs),gl.activeTexture(gl.TEXTURE0),gl.bindTexture(gl.TEXTURE_2D,obj.texture),gl.uniform1i(obj.sampler,0),!0},rglwidgetClass.prototype.doUserAttributes=function(obj){if("undefined"!=typeof obj.userAttributes){var gl=this.gl;for(var attr in obj.userAttribSizes)gl.enableVertexAttribArray(obj.userAttribLocations[attr]),gl.vertexAttribPointer(obj.userAttribLocations[attr],obj.userAttribSizes[attr],gl.FLOAT,!1,4*obj.vOffsets.stride,4*obj.userAttribOffsets[attr])}},rglwidgetClass.prototype.doUserUniforms=function(obj){if("undefined"!=typeof obj.userUniforms){var gl=this.gl;for(var attr in obj.userUniformLocations){var loc=obj.userUniformLocations[attr];if(null!==loc){var uniform=obj.userUniforms[attr];if("undefined"==typeof uniform.length)gl.uniform1f(loc,uniform);else if("undefined"==typeof uniform[0].length)switch(uniform=new Float32Array(uniform),uniform.length){case 2:gl.uniform2fv(loc,uniform);break;case 3:gl.uniform3fv(loc,uniform);break;case 4:gl.uniform4fv(loc,uniform);break;default:console.warn("bad uniform length")}else 4===uniform.length&&4===uniform[0].length?gl.uniformMatrix4fv(loc,!1,new Float32Array(uniform.getAsArray())):console.warn("unsupported uniform matrix")}}}},rglwidgetClass.prototype.doLoadIndices=function(obj,pass,indices){var fnew,step,gl=this.gl,f=obj.f[pass],type=obj.type,fat_lines=this.isSet(obj.flags,this.f_fat_lines);switch(type){case"points":step=1;break;case"abclines":case"lines":step=fat_lines?6:2;break;case"linestrip":step=fat_lines?6:1;break;case"sphere":case"planes":case"triangles":step=3;break;case"text":case"sprites":case"quads":case"surface":step=6;break;default:return console.error("loadIndices for "+type),0}fnew=obj.index_uint?new Uint32Array(step*indices.length):new Uint16Array(step*indices.length);for(var i=0;ij;j++)fnew[step*i+j]=f[step*indices[i]+j];return gl.bufferData(gl.ELEMENT_ARRAY_BUFFER,fnew,gl.DYNAMIC_DRAW),fnew.length},rglwidgetClass.prototype.doMasking=function(mask){var gl=this.gl;gl.depthMask(mask)},rglwidgetClass.prototype.doBlending=function(blend){var gl=this.gl;blend?(gl.blendFuncSeparate(gl.SRC_ALPHA,gl.ONE_MINUS_SRC_ALPHA,gl.ONE,gl.ONE),gl.enable(gl.BLEND)):gl.disable(gl.BLEND)},rglwidgetClass.prototype.doFog=function(obj,subscene){var fogmode,color,gl=this.gl,observer=subscene.par3d.observer[2],sintheta=Math.sin(subscene.par3d.FOV*Math.PI/180/2),parms=[this.frustum.near-2*observer,this.frustum.far-2*observer,this.fogScale,(1-sintheta)/(1+sintheta)];switch("undefined"==typeof this.fogType&&(this.fogType="none"),"undefined"==typeof this.fogScale&&(parms[2]=1),0===sintheta&&(parms[3]=1/3),this.fogType){case"none":fogmode=0;break;case"linear":fogmode=1;break;case"exp":fogmode=2;break;case"exp2":fogmode=3;break;default:console.error("Unknown fogtype "+this.fogType)}gl.uniform1i(obj.uFogMode,fogmode),color=this.fogColor,gl.uniform3f(obj.uFogColor,color[0],color[1],color[2]),gl.uniform4f(obj.uFogParms,parms[0],parms[1],parms[2],parms[3])},rglwidgetClass.prototype.drawSimple=function(obj,subscene,context){var count,pass,mode,pmode,flags=obj.flags,type=obj.type,is_lit=this.isSet(flags,this.f_is_lit),has_texture=this.isSet(flags,this.f_has_texture),is_transparent=this.isSet(flags,this.f_is_transparent),fixed_size=this.isSet(flags,this.f_fixed_size),fixed_quads=this.isSet(flags,this.f_fixed_quads),is_lines=this.isSet(flags,this.f_is_lines),fat_lines=this.isSet(flags,this.f_fat_lines),is_twosided=this.isSet(flags,this.f_is_twosided),has_fog=this.isSet(flags,this.f_has_fog),gl=this.gl||this.initGL(),enabled={};if(obj.initialized||this.initObj(obj),count=obj.vertexCount,!count)return[];if(is_transparent=is_transparent||obj.someHidden,is_transparent&&this.opaquePass)return this.getPieces(context,obj.id,0,obj);for(this.doDepthTest(obj),this.doMasking(this.getMaterial(obj,"depth_mask")),gl.useProgram(obj.prog),this.doPolygonOffset(obj),gl.bindBuffer(gl.ARRAY_BUFFER,obj.buf),gl.uniformMatrix4fv(obj.prMatLoc,!1,new Float32Array(this.prMatrix.getAsArray())),gl.uniformMatrix4fv(obj.mvMatLoc,!1,new Float32Array(this.mvMatrix.getAsArray())),this.doClipping(obj,subscene),is_lit&&this.doLighting(obj,subscene),has_fog&&this.doFog(obj,subscene),this.doUserAttributes(obj),this.doUserUniforms(obj),gl.enableVertexAttribArray(this.posLoc),enabled.posLoc=!0,(has_texture||"text"===obj.type)&&(enabled.texLoc=this.doTexture(obj)),enabled.colLoc=this.doColors(obj),is_lit&&(enabled.normLoc=this.doNormals(obj)),fixed_size&&gl.uniform2f(obj.textScaleLoc,.75/this.vp.width,.75/this.vp.height),fixed_quads&&(gl.enableVertexAttribArray(obj.ofsLoc),enabled.ofsLoc=!0,gl.vertexAttribPointer(obj.ofsLoc,2,gl.FLOAT,!1,4*obj.vOffsets.stride,4*obj.vOffsets.oofs)),pass=0;passi;i++)sphereMV=new CanvasMatrix4,idx=this.opaquePass?i:obj.fastTransparency?indices[i]:context.subid,"undefined"==typeof idx&&console.error("idx is undefined"),baseofs=idx*obj.vOffsets.stride,ofs=baseofs+obj.vOffsets.radofs,sscale=obj.values[ofs],sphereMV.scale(sscale/scale[0],sscale/scale[1],sscale/scale[2]),sphereMV.translate(obj.values[baseofs],obj.values[baseofs+1],obj.values[baseofs+2]),sphereMV.multRight(saveMV),this.mvMatrix=sphereMV,this.setprmvMatrix(),drawing?(nc>1&&(this.sphere.onecolor=obj.values.slice(baseofs+obj.vOffsets.cofs,baseofs+obj.vOffsets.cofs+4)),this.drawSimple(this.sphere,subscene,context)):result=result.concat(this.getSpherePieces(context,i,obj));return drawing&&this.disableArrays(obj,enabled),this.normMatrix=saveNorm,this.mvMatrix=saveMV,this.prmvMatrix=savePRMV,result},rglwidgetClass.prototype.drawClipplanes=function(obj){for(var count=obj.offsets.length,IMVClip=[],i=0;count>i;i++)IMVClip[i]=this.multMV(this.invMatrix,obj.vClipplane.slice(4*i,4*(i+1)));return obj.IMVClip=IMVClip,[]},rglwidgetClass.prototype.drawLinestrip=function(obj,subscene,context){var origIndices,i,j,margin=obj.material.margin;if("undefined"!=typeof margin&&!this.marginVecToDataVec(obj,subscene))return[];if(this.opaquePass)return this.drawSimple(obj,subscene,context);for(origIndices=context.indices.slice(),i=0;iiOrig;iOrig++)for(j=this.opaquePass?iOrig:context.subid,pos=this.multVM([].concat(obj.vertices[j]).concat(1),origMV),radius=obj.radii.length>1?obj.radii[j][0]:obj.radii[0][0],this.mvMatrix=new CanvasMatrix4(userMatrix),this.mvMatrix.scale(radius),this.mvMatrix.translate(pos[0]/pos[3],pos[1]/pos[3],pos[2]/pos[3]),this.setprmvMatrix(),i=0;i0)for(this.invMatrix=new CanvasMatrix4(this.mvMatrix),this.invMatrix.invert(),i=0;i0;)switch(objid=context.pop(),obj=this.getObj(objid),type=obj.type){case"subscene":this.drawSubscene(objid,!1);break;case"sprites":result=result.concat(context.pop());break;case"spheres":break;default:console.error("bad type '",type,"' in setContext")}return result},rglwidgetClass.prototype.drawPieces=function(pieces){var i,context,prevcontext=[];for(this.doBlending(!0),i=0;i=i;i++)adds=adds.concat(control.subsets[i]);else adds=adds.concat(control.subsets[value]);for(deletes=fullset.filter(function(x){return adds.indexOf(x)<0}),i=0;ivalue-svals[j-1]&&(j-=1);break}if(obj=this.getObj(control.objid),"undefined"!=typeof obj.vOffsets){for(varies=!0,k=0;ncol>k;k++)if(attrib=attributes[k],"undefined"!=typeof attrib&&(ofs=obj.vOffsets[ofss[attrib]],0>ofs)){switch(attrib){case"alpha":case"red":case"green":case"blue":obj.colors=[obj.colors[0],obj.colors[0]]}varies=!1}varies||this.initObjId(control.objid)}for(propvals=obj.values,aliases=obj.alias,"undefined"==typeof aliases&&(aliases=[]),k=0;ncol>k;k++)if(newval=direct?value:interp?p*values[j-1][k]+(1-p)*values[j][k]:values[j][k],attrib=attributes[k],vertex=vertices[k],alias=aliases[vertex],("planes"===obj.type||"clipplanes"===obj.type)&&(ofs=["nx","ny","nz","offset"].indexOf(attrib),ofs>=0))3>ofs?obj.normals[vertex][ofs]!==newval&&(obj.normals[vertex][ofs]=newval,obj.initialized=!1):obj.offsets[vertex][0]!==newval&&(obj.offsets[vertex][0]=newval,obj.initialized=!1);else if(ofs=obj.vOffsets[ofss[attrib]],0>ofs)this.alertOnce("Attribute '"+attrib+"' not found in object "+control.objid);else if(stride=obj.vOffsets.stride,ofs+=pos[attrib],entry=vertex*stride+ofs,propvals[entry]=newval,"undefined"!=typeof alias)for(a=0;ai;i++)if(null!==births[i]){for(age=time-births[i],j0=1;age>ages[j0];j0++);p[i]=1/0===ages[j0]?1:ages[j0]>ages[j0-1]?(ages[j0]-age)/(ages[j0]-ages[j0-1]):0,j[i]=j0}for(l=0;nobjs>l;l++)if(objid=objids[l],obj=this.getObj(objid),varies=!0,"undefined"!=typeof obj.vOffsets){for(k=0;kofs)){switch(attribs[k]){case"colors":case"alpha":case"red":case"green":case"blue":obj.colors=[obj.colors[0],obj.colors[0]]}varies=!1}varies||this.initObjId(objid)}for(l=0;nobjs>l;l++)if(objid=objids[l],obj=this.getObj(objid),"undefined"!=typeof obj.vOffsets){for(aliases=obj.alias,"undefined"==typeof aliases&&(aliases=[]),propvals=obj.values,stride=obj.vOffsets.stride,k=0;k=0){for(dim=dims[k],ofs+=pos[k],i=0;steps>i;i++)if(alias=aliases[i],null!==births[i])for(d=0;dim>d;d++)if(propvals[i*stride+ofs+d]=p[i]*attrib[dim*(j[i]-1)+d]+(1-p[i])*attrib[dim*j[i]+d],"undefined"!=typeof alias)for(a=0;a=0){for(keys=this.scene.crosstalk.key[j],obj=this.getObj(id),someHidden=!1,k=0;k=xmin&&xmax>=x&&y>=ymin&&ymax>=y&&z>=-1&&1>=z?selection.push(keys[k]):someHidden=!0);obj.someHidden=someHidden&&(filter||selection.length),obj.initialized=!1,this.equalArrays(selection,this.scene.crosstalk.selection)||(handle=this.scene.crosstalk.sel_handle[j],handle.set(selection,{rglSubsceneId:this.select.subscene}))}},rglwidgetClass.prototype.selection=function(event,filter){var i,j,ids,obj,keys,selection,someHidden,crosstalk=this.scene.crosstalk;for(crosstalk=this.scene.crosstalk,filter?(filter=crosstalk.filter=event.value,selection=crosstalk.selection):(selection=crosstalk.selection=event.value,filter=crosstalk.filter),ids=crosstalk.id,i=0;ithis.stopTime+this.stepSize/2||this.value=1.5*h+.5)?1/(1+h):1.5/(1+h5),i_small=dx10&&(cell=9+cell/10),cell*=shrink_sml,min_n>1&&(cell/=min_n)):(cell=dx,ndiv>1&&(cell/=ndiv)),20*DBL_MIN>cell?cell=20*DBL_MIN:10*cell>DBL_MAX&&(cell=.1*DBL_MAX),base=Math.pow(10,Math.floor(Math.log10(cell))),unit=base,(U=2*base)-cell1||!i_small)&&(0!==lo?lo*=1-DBL_EPSILON:lo=-DBL_MIN,0!==up?up*=1+DBL_EPSILON:up=+DBL_MIN);ns*unit>lo+rounding_eps*unit;)ns--;for(;up-rounding_eps*unit>nu*unit;)nu++;return k=Math.floor(.5+nu-ns),min_n>k?(k=min_n-k,ns>=0?(nu+=k/2,ns-=k/2+k%2):(ns-=k/2,nu+=k/2+k%2),ndiv=min_n):ndiv=k,return_bounds?(lo>ns*unit&&(lo=ns*unit),nu*unit>up&&(up=nu*unit)):(lo=ns,up=nu),{lo:lo,up:up,ndiv:ndiv,unit:unit}},rglwidgetClass.prototype.getTickEdges=function(prmv){var dim,i,j,k,edges,hull,step,vertices=[[0,0,0,1],[0,0,1,1],[0,1,0,1],[0,1,1,1],[1,0,0,1],[1,0,1,1],[1,1,0,1],[1,1,1,1]],result=[],proj=[];for(i=0;idim;dim++){for(edges=[],step=Math.pow(2,2-dim),i=0;4>i;i++)for(j=0===dim?i:1===dim?i+2*(i>1):2*i,k=0;knewval&&(best=j,best2=edges[i][1],val=newval);result[dim]=vertices[best].slice(0,3),result[dim][dim]=void 0}}return result},rglwidgetClass.prototype.getTickLocations=function(obj){var dim,i,limits,value,len,delta,range,locations=[],result=[[],[],[]],bbox=obj.bbox;for(obj.needsAxisCallback=!1,dim=0;3>dim;dim++)switch(limits=bbox.slice(2*dim,2*dim+2),range=limits[1]-limits[0],obj.axes.mode[dim]){case"custom":for(i=0;ii;i++)result[dim].push(i*delta);break;case"fixednum":for(len=obj.axes.nticks[dim],delta=len>1?range/(len-1):0,i=0;len>i;i++)result[dim].push(i*delta/range);break;case"pretty":for(locations=this.R_pretty(limits[0],limits[1],5,2,.75,[1.5,2.75],0,0),i=locations.lo;i<=locations.up;i++)value=(i*locations.unit-limits[0])/range,value>0&&1>value&&result[dim].push(value);break;case"user":obj.needsAxisCallback=!0}return result},rglwidgetClass.prototype.getTickVertices=function(ticks){var dim,i,j,locations,edge,vertices=[],edges=ticks.edges;for(dim=0;3>dim;dim++)if(locations=ticks.locations[dim],locations.length)for(i=0;ij;j++)(2>dim&&j===1-dim||2===dim&&0===j)&&(edge[j]+=2*(edge[j]-.5)/ticks.axes.marklen[dim]);vertices.push(edge)}ticks.vertices=vertices,ticks.vertexCount=vertices.length,ticks.values=new Float32Array(this.flatten(vertices)),ticks.initialized=!1},rglwidgetClass.prototype.placeTickLabels=function(obj){var i,j,k,vertex,locations,dim,ticks=obj.ticks,labels=obj.labels,vertices=[],tickvertices=ticks.vertices,edges=obj.ticks.edges;for(j=0,dim=0;3>dim;dim++)if("undefined"!=typeof edges[dim]&&(locations=ticks.locations[dim],locations.length))for(i=0;i=tickvertices.length)break;for(vertex=tickvertices[j].slice(),k=0;3>k;k++)vertex[k]+=2*(tickvertices[j+1][k]-vertex[k]);vertices.push(vertex),j+=2}labels.vertices=vertices,labels.centers=labels.vertices,labels.initialized=!1},rglwidgetClass.prototype.setTickLabels=function(obj){var mode,locations,nticks,dim,i,limits,range,values,max,ticks=obj.ticks,labels=[],start=0,edges=obj.ticks.edges;for(dim=0;3>dim;dim++)if("undefined"!=typeof edges[dim]){if(mode=obj.axes.mode[dim],nticks=obj.axes.nticks[dim],"custom"===mode)labels=labels.concat(obj.texts.slice(start,start+nticks));else{for(limits=obj.bbox.slice(2*dim,2*(dim+1)),range=limits[1]-limits[0],locations=ticks.locations[dim],max=-1/0,values=[],i=0;ii;i++)expand=obj.axes.expand[i],center[i]=(bbox[2*i]+bbox[2*i+1])/2,bbox[2*i]=center[i]-expand*(bbox[2*i+1]-center[i]),bbox[2*i+1]=center[i]+expand*(bbox[2*i+1]-center[i]);obj.bbox=bbox,obj.center=center},rglwidgetClass.prototype.setBBoxMatrices=function(obj){var bboxNorm,bboxMV,scale,saved={normMatrix:new CanvasMatrix4(this.normMatrix),mvMatrix:new CanvasMatrix4(this.mvMatrix)},bbox=obj.bbox;return bboxNorm=new CanvasMatrix4,scale=[bbox[1]-bbox[0],bbox[3]-bbox[2],bbox[5]-bbox[4]],bboxNorm.scale(1/scale[0],1/scale[1],1/scale[2]),bboxNorm.multRight(saved.normMatrix),this.normMatrix=bboxNorm,bboxMV=new CanvasMatrix4,bboxMV.scale(scale[0],scale[1],scale[2]),bboxMV.translate(bbox[0],bbox[2],bbox[4]),bboxMV.multRight(saved.mvMatrix),this.mvMatrix=bboxMV,saved.prmvMatrix=null===this.prmvMatrix?null:new CanvasMatrix4(this.prmvMatrix),this.setprmvMatrix(),saved},rglwidgetClass.prototype.restoreBBoxMatrices=function(saved){this.normMatrix=saved.normMatrix,this.mvMatrix=saved.mvMatrix,this.prmvMatrix=saved.prmvMatrix},rglwidgetClass.prototype.getMarginParameters=function(bboxdeco,material){var saved,edges,i,line,level,trans,scale,bbox=bboxdeco.bbox,edge=[].concat(material.edge),at=material.margin;if(material.floating){if(saved=this.setBBoxMatrices(bboxdeco),edges=this.getTickEdges(this.prmvMatrix)[at],this.restoreBBoxMatrices(saved),"undefined"==typeof edges)return void 0;for(i=0;3>i;i++)edges[i]<1&&(edges[i]=-1),edge[i]=edge[i]*edges[i]}switch(at){case 0:line=1,level=2;break;case 1:line=0,level=2;break;case 2:line=0,level=1}return scale=[edge[0]*(bbox[1]-bbox[0])/bboxdeco.axes.marklen[0],edge[1]*(bbox[3]-bbox[2])/bboxdeco.axes.marklen[1],edge[2]*(bbox[5]-bbox[4])/bboxdeco.axes.marklen[2]],trans=[1===edge[0]?bbox[1]:bbox[0],1===edge[1]?bbox[3]:bbox[2],1===edge[2]?bbox[5]:bbox[4]],{at:at,line:line,level:level,trans:trans,scale:scale}},rglwidgetClass.prototype.fixVertex=function(orig,parms,center,bbox){var vertex=[0,0,0];return vertex[parms.at]=this.missing(orig[0])?center[parms.at]:"-Inf"===orig[0]?bbox[2*parms.at]:"Inf"===orig[0]?bbox[2*parms.at+1]:orig[0],vertex[parms.line]=parms.scale[parms.line]*orig[1]+parms.trans[parms.line],vertex[parms.level]=parms.scale[parms.level]*orig[2]+parms.trans[parms.level],vertex},rglwidgetClass.prototype.fixNormal=function(orig,parms){var vertex=[0,0,0];return vertex[parms.at]=orig[0],vertex[parms.line]=orig[1]/parms.scale[parms.line],vertex[parms.level]=orig[2]/parms.scale[parms.level],vertex},rglwidgetClass.prototype.marginVecToDataVec=function(obj,subscene){var center,bbox,parms,parmsjson,i,vertex,bboxdeco=this.getBBoxDeco(subscene),orig=obj.orig,vertices=[],normals=[],centers=[];if("undefined"==typeof orig&&(orig={vert:obj.vertices,norm:obj.normals,cent:obj.centers,doNormals:"undefined"!=typeof obj.normals,doCenters:"undefined"!=typeof obj.centers,parms:""},obj.orig=orig),"undefined"!=typeof bboxdeco){if(this.setBbox(bboxdeco,subscene),center=bboxdeco.center,bbox=bboxdeco.bbox,parms=this.getMarginParameters(bboxdeco,obj.material),"undefined"==typeof parms)return!1;if(parmsjson=JSON.stringify(parms),parmsjson===orig.parms)return!0;for(orig.parms=parmsjson,i=0;ii;i++)if("user"===obj.axes.mode[i]&&(axis=["x","y","z"][i],"undefined"!=typeof obj.callbacks&&"undefined"!=typeof(code=obj.callbacks[axis]))){if("undefined"!=typeof edges[i])for(j=0;3>j;j++)"undefined"!=typeof edges[i][j]&&(axis+=edges[i][j]>0?"+":"-");fn=Function('"use strict";return ('+code+")")(),fn.call(this,axis)}}; diff --git a/docs/authors.html b/docs/authors.html index ce956b0d..f1de0ebb 100644 --- a/docs/authors.html +++ b/docs/authors.html @@ -1,6 +1,6 @@ - + @@ -8,25 +8,45 @@ Citation and Authors • nat + - + - - + + + + + + + - + + + + + + + + - - - + + + + + + + + + - + + + - +
+
-
+
- -

Jefferis, Gregory S X E and Manton, James D (2014). -“NeuroAnatomy Toolbox v1.5.2.” -ZENODO. -doi: 10.5281/zenodo.10171. -

+

Gregory S X E Jefferis and James D Manton (2014). NeuroAnatomy Toolbox v1.5.2. ZENODO. 10.5281/zenodo.10171

@Article{,
   title = {{NeuroAnatomy Toolbox v1.5.2}},
   author = {{Jefferis, Gregory S X E} and {Manton, James D}},
@@ -112,17 +135,18 @@ 

Citation

month = {May}, year = {2014}, }
+
  • -

    Gregory Jefferis. Author, maintainer. +

    Gregory Jefferis. Author, maintainer.

  • -

    James Manton. Author. +

    James Manton. Author.

@@ -132,17 +156,23 @@

Authors

+
-

Site built with pkgdown.

+

Site built with pkgdown 1.6.1.

+ + + + + diff --git a/docs/bootstrap-toc.css b/docs/bootstrap-toc.css new file mode 100644 index 00000000..5a859415 --- /dev/null +++ b/docs/bootstrap-toc.css @@ -0,0 +1,60 @@ +/*! + * Bootstrap Table of Contents v0.4.1 (http://afeld.github.io/bootstrap-toc/) + * Copyright 2015 Aidan Feldman + * Licensed under MIT (https://github.com/afeld/bootstrap-toc/blob/gh-pages/LICENSE.md) */ + +/* modified from https://github.com/twbs/bootstrap/blob/94b4076dd2efba9af71f0b18d4ee4b163aa9e0dd/docs/assets/css/src/docs.css#L548-L601 */ + +/* All levels of nav */ +nav[data-toggle='toc'] .nav > li > a { + display: block; + padding: 4px 20px; + font-size: 13px; + font-weight: 500; + color: #767676; +} +nav[data-toggle='toc'] .nav > li > a:hover, +nav[data-toggle='toc'] .nav > li > a:focus { + padding-left: 19px; + color: #563d7c; + text-decoration: none; + background-color: transparent; + border-left: 1px solid #563d7c; +} +nav[data-toggle='toc'] .nav > .active > a, +nav[data-toggle='toc'] .nav > .active:hover > a, +nav[data-toggle='toc'] .nav > .active:focus > a { + padding-left: 18px; + font-weight: bold; + color: #563d7c; + background-color: transparent; + border-left: 2px solid #563d7c; +} + +/* Nav: second level (shown on .active) */ +nav[data-toggle='toc'] .nav .nav { + display: none; /* Hide by default, but at >768px, show it */ + padding-bottom: 10px; +} +nav[data-toggle='toc'] .nav .nav > li > a { + padding-top: 1px; + padding-bottom: 1px; + padding-left: 30px; + font-size: 12px; + font-weight: normal; +} +nav[data-toggle='toc'] .nav .nav > li > a:hover, +nav[data-toggle='toc'] .nav .nav > li > a:focus { + padding-left: 29px; +} +nav[data-toggle='toc'] .nav .nav > .active > a, +nav[data-toggle='toc'] .nav .nav > .active:hover > a, +nav[data-toggle='toc'] .nav .nav > .active:focus > a { + padding-left: 28px; + font-weight: 500; +} + +/* from https://github.com/twbs/bootstrap/blob/e38f066d8c203c3e032da0ff23cd2d6098ee2dd6/docs/assets/css/src/docs.css#L631-L634 */ +nav[data-toggle='toc'] .nav > .active > ul { + display: block; +} diff --git a/docs/bootstrap-toc.js b/docs/bootstrap-toc.js new file mode 100644 index 00000000..1cdd573b --- /dev/null +++ b/docs/bootstrap-toc.js @@ -0,0 +1,159 @@ +/*! + * Bootstrap Table of Contents v0.4.1 (http://afeld.github.io/bootstrap-toc/) + * Copyright 2015 Aidan Feldman + * Licensed under MIT (https://github.com/afeld/bootstrap-toc/blob/gh-pages/LICENSE.md) */ +(function() { + 'use strict'; + + window.Toc = { + helpers: { + // return all matching elements in the set, or their descendants + findOrFilter: function($el, selector) { + // http://danielnouri.org/notes/2011/03/14/a-jquery-find-that-also-finds-the-root-element/ + // http://stackoverflow.com/a/12731439/358804 + var $descendants = $el.find(selector); + return $el.filter(selector).add($descendants).filter(':not([data-toc-skip])'); + }, + + generateUniqueIdBase: function(el) { + var text = $(el).text(); + var anchor = text.trim().toLowerCase().replace(/[^A-Za-z0-9]+/g, '-'); + return anchor || el.tagName.toLowerCase(); + }, + + generateUniqueId: function(el) { + var anchorBase = this.generateUniqueIdBase(el); + for (var i = 0; ; i++) { + var anchor = anchorBase; + if (i > 0) { + // add suffix + anchor += '-' + i; + } + // check if ID already exists + if (!document.getElementById(anchor)) { + return anchor; + } + } + }, + + generateAnchor: function(el) { + if (el.id) { + return el.id; + } else { + var anchor = this.generateUniqueId(el); + el.id = anchor; + return anchor; + } + }, + + createNavList: function() { + return $(''); + }, + + createChildNavList: function($parent) { + var $childList = this.createNavList(); + $parent.append($childList); + return $childList; + }, + + generateNavEl: function(anchor, text) { + var $a = $(''); + $a.attr('href', '#' + anchor); + $a.text(text); + var $li = $('
  • '); + $li.append($a); + return $li; + }, + + generateNavItem: function(headingEl) { + var anchor = this.generateAnchor(headingEl); + var $heading = $(headingEl); + var text = $heading.data('toc-text') || $heading.text(); + return this.generateNavEl(anchor, text); + }, + + // Find the first heading level (`

    `, then `

    `, etc.) that has more than one element. Defaults to 1 (for `

    `). + getTopLevel: function($scope) { + for (var i = 1; i <= 6; i++) { + var $headings = this.findOrFilter($scope, 'h' + i); + if ($headings.length > 1) { + return i; + } + } + + return 1; + }, + + // returns the elements for the top level, and the next below it + getHeadings: function($scope, topLevel) { + var topSelector = 'h' + topLevel; + + var secondaryLevel = topLevel + 1; + var secondarySelector = 'h' + secondaryLevel; + + return this.findOrFilter($scope, topSelector + ',' + secondarySelector); + }, + + getNavLevel: function(el) { + return parseInt(el.tagName.charAt(1), 10); + }, + + populateNav: function($topContext, topLevel, $headings) { + var $context = $topContext; + var $prevNav; + + var helpers = this; + $headings.each(function(i, el) { + var $newNav = helpers.generateNavItem(el); + var navLevel = helpers.getNavLevel(el); + + // determine the proper $context + if (navLevel === topLevel) { + // use top level + $context = $topContext; + } else if ($prevNav && $context === $topContext) { + // create a new level of the tree and switch to it + $context = helpers.createChildNavList($prevNav); + } // else use the current $context + + $context.append($newNav); + + $prevNav = $newNav; + }); + }, + + parseOps: function(arg) { + var opts; + if (arg.jquery) { + opts = { + $nav: arg + }; + } else { + opts = arg; + } + opts.$scope = opts.$scope || $(document.body); + return opts; + } + }, + + // accepts a jQuery object, or an options object + init: function(opts) { + opts = this.helpers.parseOps(opts); + + // ensure that the data attribute is in place for styling + opts.$nav.attr('data-toggle', 'toc'); + + var $topContext = this.helpers.createChildNavList(opts.$nav); + var topLevel = this.helpers.getTopLevel(opts.$scope); + var $headings = this.helpers.getHeadings(opts.$scope, topLevel); + this.helpers.populateNav($topContext, topLevel, $headings); + } + }; + + $(function() { + $('nav[data-toggle="toc"]').each(function(i, el) { + var $nav = $(el); + Toc.init($nav); + }); + }); +})(); diff --git a/docs/docsearch.css b/docs/docsearch.css new file mode 100644 index 00000000..e5f1fe1d --- /dev/null +++ b/docs/docsearch.css @@ -0,0 +1,148 @@ +/* Docsearch -------------------------------------------------------------- */ +/* + Source: https://github.com/algolia/docsearch/ + License: MIT +*/ + +.algolia-autocomplete { + display: block; + -webkit-box-flex: 1; + -ms-flex: 1; + flex: 1 +} + +.algolia-autocomplete .ds-dropdown-menu { + width: 100%; + min-width: none; + max-width: none; + padding: .75rem 0; + background-color: #fff; + background-clip: padding-box; + border: 1px solid rgba(0, 0, 0, .1); + box-shadow: 0 .5rem 1rem rgba(0, 0, 0, .175); +} + +@media (min-width:768px) { + .algolia-autocomplete .ds-dropdown-menu { + width: 175% + } +} + +.algolia-autocomplete .ds-dropdown-menu::before { + display: none +} + +.algolia-autocomplete .ds-dropdown-menu [class^=ds-dataset-] { + padding: 0; + background-color: rgb(255,255,255); + border: 0; + max-height: 80vh; +} + +.algolia-autocomplete .ds-dropdown-menu .ds-suggestions { + margin-top: 0 +} + +.algolia-autocomplete .algolia-docsearch-suggestion { + padding: 0; + overflow: visible +} + +.algolia-autocomplete .algolia-docsearch-suggestion--category-header { + padding: .125rem 1rem; + margin-top: 0; + font-size: 1.3em; + font-weight: 500; + color: #00008B; + border-bottom: 0 +} + +.algolia-autocomplete .algolia-docsearch-suggestion--wrapper { + float: none; + padding-top: 0 +} + +.algolia-autocomplete .algolia-docsearch-suggestion--subcategory-column { + float: none; + width: auto; + padding: 0; + text-align: left +} + +.algolia-autocomplete .algolia-docsearch-suggestion--content { + float: none; + width: auto; + padding: 0 +} + +.algolia-autocomplete .algolia-docsearch-suggestion--content::before { + display: none +} + +.algolia-autocomplete .ds-suggestion:not(:first-child) .algolia-docsearch-suggestion--category-header { + padding-top: .75rem; + margin-top: .75rem; + border-top: 1px solid rgba(0, 0, 0, .1) +} + +.algolia-autocomplete .ds-suggestion .algolia-docsearch-suggestion--subcategory-column { + display: block; + padding: .1rem 1rem; + margin-bottom: 0.1; + font-size: 1.0em; + font-weight: 400 + /* display: none */ +} + +.algolia-autocomplete .algolia-docsearch-suggestion--title { + display: block; + padding: .25rem 1rem; + margin-bottom: 0; + font-size: 0.9em; + font-weight: 400 +} + +.algolia-autocomplete .algolia-docsearch-suggestion--text { + padding: 0 1rem .5rem; + margin-top: -.25rem; + font-size: 0.8em; + font-weight: 400; + line-height: 1.25 +} + +.algolia-autocomplete .algolia-docsearch-footer { + width: 110px; + height: 20px; + z-index: 3; + margin-top: 10.66667px; + float: right; + font-size: 0; + line-height: 0; +} + +.algolia-autocomplete .algolia-docsearch-footer--logo { + background-image: url("data:image/svg+xml;utf8,"); + background-repeat: no-repeat; + background-position: 50%; + background-size: 100%; + overflow: hidden; + text-indent: -9000px; + width: 100%; + height: 100%; + display: block; + transform: translate(-8px); +} + +.algolia-autocomplete .algolia-docsearch-suggestion--highlight { + color: #FF8C00; + background: rgba(232, 189, 54, 0.1) +} + + +.algolia-autocomplete .algolia-docsearch-suggestion--text .algolia-docsearch-suggestion--highlight { + box-shadow: inset 0 -2px 0 0 rgba(105, 105, 105, .5) +} + +.algolia-autocomplete .ds-suggestion.ds-cursor .algolia-docsearch-suggestion--content { + background-color: rgba(192, 192, 192, .15) +} diff --git a/docs/docsearch.js b/docs/docsearch.js new file mode 100644 index 00000000..b35504cd --- /dev/null +++ b/docs/docsearch.js @@ -0,0 +1,85 @@ +$(function() { + + // register a handler to move the focus to the search bar + // upon pressing shift + "/" (i.e. "?") + $(document).on('keydown', function(e) { + if (e.shiftKey && e.keyCode == 191) { + e.preventDefault(); + $("#search-input").focus(); + } + }); + + $(document).ready(function() { + // do keyword highlighting + /* modified from https://jsfiddle.net/julmot/bL6bb5oo/ */ + var mark = function() { + + var referrer = document.URL ; + var paramKey = "q" ; + + if (referrer.indexOf("?") !== -1) { + var qs = referrer.substr(referrer.indexOf('?') + 1); + var qs_noanchor = qs.split('#')[0]; + var qsa = qs_noanchor.split('&'); + var keyword = ""; + + for (var i = 0; i < qsa.length; i++) { + var currentParam = qsa[i].split('='); + + if (currentParam.length !== 2) { + continue; + } + + if (currentParam[0] == paramKey) { + keyword = decodeURIComponent(currentParam[1].replace(/\+/g, "%20")); + } + } + + if (keyword !== "") { + $(".contents").unmark({ + done: function() { + $(".contents").mark(keyword); + } + }); + } + } + }; + + mark(); + }); +}); + +/* Search term highlighting ------------------------------*/ + +function matchedWords(hit) { + var words = []; + + var hierarchy = hit._highlightResult.hierarchy; + // loop to fetch from lvl0, lvl1, etc. + for (var idx in hierarchy) { + words = words.concat(hierarchy[idx].matchedWords); + } + + var content = hit._highlightResult.content; + if (content) { + words = words.concat(content.matchedWords); + } + + // return unique words + var words_uniq = [...new Set(words)]; + return words_uniq; +} + +function updateHitURL(hit) { + + var words = matchedWords(hit); + var url = ""; + + if (hit.anchor) { + url = hit.url_without_anchor + '?q=' + escape(words.join(" ")) + '#' + hit.anchor; + } else { + url = hit.url + '?q=' + escape(words.join(" ")); + } + + return url; +} diff --git a/docs/index.html b/docs/index.html index 585b1c18..7964cc72 100644 --- a/docs/index.html +++ b/docs/index.html @@ -1,36 +1,55 @@ - + NeuroAnatomy Toolbox for Analysis of 3D Image Data • nat - - - - + + + + + + + - +
    -
    +
    +nat: NeuroAnatomy Toolbox +

    + -

    An R package for the (3D) visualisation and analysis of biological image data, especially tracings of single neurons. See nat.examples and frulhns for sample code.

    -

    nat is a cleaned up version of code that has been used in a number of papers from our group including:

    -

    Cell 2007 Cover CB 2010 Cover Nature 2011 Cell 2013 Abstract

    +

    An R package for the (3D) visualisation and analysis of biological image data, especially tracings of single neurons. nat is the core package of a wider suite of neuroanatomy tools introduced at http://natverse.github.io. nat (and its ancestors) have been used in a number of papers from our group including:

    +

    Cell 2007 Cover CB 2010 Cover Nature 2011 Cell 2013 Abstract Neuron 2016

    Quick Start

    For the impatient …

    -
    # install
    -install.packages("nat")
    +
    +# install
    +install.packages("nat")
     # use
    -library(nat)
    +library(nat)
     
     # plot some test data (?kcs20 for details)
     # Drosophila Kenyon cells processed from raw data at http://flycircuit.tw
    -head(kcs20)
    -open3d()
    -plot3d(kcs20, col=type)
    +head(kcs20)
    +open3d()
    +plot3d(kcs20, col=type)
     # get help
    -?nat
    +?nat

    Installation

    A confirmed stable version of nat can be installed from CRAN.

    -
    install.packages("nat")
    -

    However, nat remains under quite active development, so we generally recommend installing the latest development version directly from github using the devtools package.

    -
    # install devtools if required
    -if (!requireNamespace("devtools")) install.packages("devtools")
    +
    +

    However, nat remains under quite active development, so if you will be using nat extensively, we generally recommend installing the latest development version directly from github using the devtools package.

    +
    +# install devtools if required
    +if (!requireNamespace("devtools")) install.packages("devtools")
     # then install nat
    -devtools::install_github("jefferis/nat")
    +devtools::install_github("natverse/nat")
    -
    +

    -Help

    -

    If you want some help using nat, then please use the following resources

    +Learn +

    To get an idea of what nat can do:

    +

    When you’re ready to learn more:

    +
    -
    +

    -Problems

    -

    If you think that you have found a bug

    +Help +

    If you want some help using nat:

    +
      +
    • For installation issues, see the Installation vignette +
    • +
    • Contact nat-user Google group - we normally respond promptly and you will also be helping future users.
    • +
    +

    If you think that you have found a bug:

    +
      +
    • Install the development version of nat using devtools (see above) and see if that helps.
    • +
    • Check the github issues and
        -
      • Install the development version of nat using devtools (see above)
      • -
      • Check the github issues and
      • -file a bug report if this seems to be a new problem
      • +file a bug report if this seems to be a new problem
      • comment on an existing bug report
      • -
      • Write to the nat-user list for help.
      -

      Thanks for your interest in nat!

      +
    • +
    +

    Thanks for your interest in nat!

    - @@ -178,11 +238,14 @@

    Dev status

    -

    Site built with pkgdown.

    +

    Site built with pkgdown 1.6.1.

    + + + diff --git a/docs/jquery.sticky-kit.min.js b/docs/jquery.sticky-kit.min.js deleted file mode 100644 index e2a3c6de..00000000 --- a/docs/jquery.sticky-kit.min.js +++ /dev/null @@ -1,9 +0,0 @@ -/* - Sticky-kit v1.1.2 | WTFPL | Leaf Corcoran 2015 | http://leafo.net -*/ -(function(){var b,f;b=this.jQuery||window.jQuery;f=b(window);b.fn.stick_in_parent=function(d){var A,w,J,n,B,K,p,q,k,E,t;null==d&&(d={});t=d.sticky_class;B=d.inner_scrolling;E=d.recalc_every;k=d.parent;q=d.offset_top;p=d.spacer;w=d.bottoming;null==q&&(q=0);null==k&&(k=void 0);null==B&&(B=!0);null==t&&(t="is_stuck");A=b(document);null==w&&(w=!0);J=function(a,d,n,C,F,u,r,G){var v,H,m,D,I,c,g,x,y,z,h,l;if(!a.data("sticky_kit")){a.data("sticky_kit",!0);I=A.height();g=a.parent();null!=k&&(g=g.closest(k)); -if(!g.length)throw"failed to find stick parent";v=m=!1;(h=null!=p?p&&a.closest(p):b("
    "))&&h.css("position",a.css("position"));x=function(){var c,f,e;if(!G&&(I=A.height(),c=parseInt(g.css("border-top-width"),10),f=parseInt(g.css("padding-top"),10),d=parseInt(g.css("padding-bottom"),10),n=g.offset().top+c+f,C=g.height(),m&&(v=m=!1,null==p&&(a.insertAfter(h),h.detach()),a.css({position:"",top:"",width:"",bottom:""}).removeClass(t),e=!0),F=a.offset().top-(parseInt(a.css("margin-top"),10)||0)-q, -u=a.outerHeight(!0),r=a.css("float"),h&&h.css({width:a.outerWidth(!0),height:u,display:a.css("display"),"vertical-align":a.css("vertical-align"),"float":r}),e))return l()};x();if(u!==C)return D=void 0,c=q,z=E,l=function(){var b,l,e,k;if(!G&&(e=!1,null!=z&&(--z,0>=z&&(z=E,x(),e=!0)),e||A.height()===I||x(),e=f.scrollTop(),null!=D&&(l=e-D),D=e,m?(w&&(k=e+u+c>C+n,v&&!k&&(v=!1,a.css({position:"fixed",bottom:"",top:c}).trigger("sticky_kit:unbottom"))),eb&&!v&&(c-=l,c=Math.max(b-u,c),c=Math.min(q,c),m&&a.css({top:c+"px"})))):e>F&&(m=!0,b={position:"fixed",top:c},b.width="border-box"===a.css("box-sizing")?a.outerWidth()+"px":a.width()+"px",a.css(b).addClass(t),null==p&&(a.after(h),"left"!==r&&"right"!==r||h.append(a)),a.trigger("sticky_kit:stick")),m&&w&&(null==k&&(k=e+u+c>C+n),!v&&k)))return v=!0,"static"===g.css("position")&&g.css({position:"relative"}), -a.css({position:"absolute",bottom:d,top:"auto"}).trigger("sticky_kit:bottom")},y=function(){x();return l()},H=function(){G=!0;f.off("touchmove",l);f.off("scroll",l);f.off("resize",y);b(document.body).off("sticky_kit:recalc",y);a.off("sticky_kit:detach",H);a.removeData("sticky_kit");a.css({position:"",bottom:"",top:"",width:""});g.position("position","");if(m)return null==p&&("left"!==r&&"right"!==r||a.insertAfter(h),h.remove()),a.removeClass(t)},f.on("touchmove",l),f.on("scroll",l),f.on("resize", -y),b(document.body).on("sticky_kit:recalc",y),a.on("sticky_kit:detach",H),setTimeout(l,0)}};n=0;for(K=this.length;n body > .container + * .Site-content -> body > .container .row + * .footer -> footer + * + * Key idea seems to be to ensure that .container and __all its parents__ + * have height set to 100% + * + */ + +html, body { + height: 100%; +} + +body { + position: relative; +} + body > .container { display: flex; - padding-top: 60px; - min-height: calc(100vh); + height: 100%; flex-direction: column; } body > .container .row { - flex: 1; + flex: 1 0 auto; } footer { @@ -16,6 +37,7 @@ footer { border-top: 1px solid #e5e5e5; color: #666; display: flex; + flex-shrink: 0; } footer p { margin-bottom: 0; @@ -38,6 +60,21 @@ img { max-width: 100%; } +/* Fix bug in bootstrap (only seen in firefox) */ +summary { + display: list-item; +} + +/* Typographic tweaking ---------------------------------*/ + +.contents .page-header { + margin-top: calc(-60px + 1em); +} + +dd { + margin-left: 3em; +} + /* Section anchors ---------------------------------*/ a.anchor { @@ -68,52 +105,153 @@ a.anchor { .contents h1, .contents h2, .contents h3, .contents h4 { padding-top: 60px; - margin-top: -60px; + margin-top: -40px; } -/* Static header placement on mobile devices */ -@media (max-width: 767px) { - .navbar-fixed-top { - position: absolute; - } - .navbar { - padding: 0; - } +/* Navbar submenu --------------------------*/ + +.dropdown-submenu { + position: relative; } +.dropdown-submenu>.dropdown-menu { + top: 0; + left: 100%; + margin-top: -6px; + margin-left: -1px; + border-radius: 0 6px 6px 6px; +} + +.dropdown-submenu:hover>.dropdown-menu { + display: block; +} + +.dropdown-submenu>a:after { + display: block; + content: " "; + float: right; + width: 0; + height: 0; + border-color: transparent; + border-style: solid; + border-width: 5px 0 5px 5px; + border-left-color: #cccccc; + margin-top: 5px; + margin-right: -10px; +} + +.dropdown-submenu:hover>a:after { + border-left-color: #ffffff; +} + +.dropdown-submenu.pull-left { + float: none; +} + +.dropdown-submenu.pull-left>.dropdown-menu { + left: -100%; + margin-left: 10px; + border-radius: 6px 0 6px 6px; +} /* Sidebar --------------------------*/ -#sidebar { +#pkgdown-sidebar { margin-top: 30px; + position: -webkit-sticky; + position: sticky; + top: 70px; } -#sidebar h2 { + +#pkgdown-sidebar h2 { font-size: 1.5em; margin-top: 1em; } -#sidebar h2:first-child { +#pkgdown-sidebar h2:first-child { margin-top: 0; } -#sidebar .list-unstyled li { +#pkgdown-sidebar .list-unstyled li { margin-bottom: 0.5em; } +/* bootstrap-toc tweaks ------------------------------------------------------*/ + +/* All levels of nav */ + +nav[data-toggle='toc'] .nav > li > a { + padding: 4px 20px 4px 6px; + font-size: 1.5rem; + font-weight: 400; + color: inherit; +} + +nav[data-toggle='toc'] .nav > li > a:hover, +nav[data-toggle='toc'] .nav > li > a:focus { + padding-left: 5px; + color: inherit; + border-left: 1px solid #878787; +} + +nav[data-toggle='toc'] .nav > .active > a, +nav[data-toggle='toc'] .nav > .active:hover > a, +nav[data-toggle='toc'] .nav > .active:focus > a { + padding-left: 5px; + font-size: 1.5rem; + font-weight: 400; + color: inherit; + border-left: 2px solid #878787; +} + +/* Nav: second level (shown on .active) */ + +nav[data-toggle='toc'] .nav .nav { + display: none; /* Hide by default, but at >768px, show it */ + padding-bottom: 10px; +} + +nav[data-toggle='toc'] .nav .nav > li > a { + padding-left: 16px; + font-size: 1.35rem; +} + +nav[data-toggle='toc'] .nav .nav > li > a:hover, +nav[data-toggle='toc'] .nav .nav > li > a:focus { + padding-left: 15px; +} + +nav[data-toggle='toc'] .nav .nav > .active > a, +nav[data-toggle='toc'] .nav .nav > .active:hover > a, +nav[data-toggle='toc'] .nav .nav > .active:focus > a { + padding-left: 15px; + font-weight: 500; + font-size: 1.35rem; +} + +/* orcid ------------------------------------------------------------------- */ + +.orcid { + font-size: 16px; + color: #A6CE39; + /* margins are required by official ORCID trademark and display guidelines */ + margin-left:4px; + margin-right:4px; + vertical-align: middle; +} + /* Reference index & topics ----------------------------------------------- */ .ref-index th {font-weight: normal;} -.ref-index h2 {font-size: 20px;} - -.ref-index td {vertical-align: top;} -.ref-index .alias {width: 40%;} -.ref-index .title {width: 60%;} +.ref-index td {vertical-align: top; min-width: 100px} +.ref-index .icon {width: 40px;} .ref-index .alias {width: 40%;} +.ref-index-icons .alias {width: calc(40% - 40px);} .ref-index .title {width: 60%;} .ref-arguments th {text-align: right; padding-right: 10px;} -.ref-arguments th, .ref-arguments td {vertical-align: top;} +.ref-arguments th, .ref-arguments td {vertical-align: top; min-width: 100px} .ref-arguments .name {width: 20%;} .ref-arguments .desc {width: 80%;} @@ -137,6 +275,12 @@ pre, code { color: #333; } +pre code { + overflow: auto; + word-wrap: normal; + white-space: pre; +} + pre .img { margin: 5px 0; } @@ -151,6 +295,10 @@ code a, pre a { color: #375f84; } +a.sourceLine:hover { + text-decoration: none; +} + .fl {color: #1514b5;} .fu {color: #000000;} /* function */ .ch,.st {color: #036a07;} /* string */ @@ -161,3 +309,59 @@ code a, pre a { .error { color: orange; font-weight: bolder;} .warning { color: #6A0366; font-weight: bolder;} +/* Clipboard --------------------------*/ + +.hasCopyButton { + position: relative; +} + +.btn-copy-ex { + position: absolute; + right: 0; + top: 0; + visibility: hidden; +} + +.hasCopyButton:hover button.btn-copy-ex { + visibility: visible; +} + +/* headroom.js ------------------------ */ + +.headroom { + will-change: transform; + transition: transform 200ms linear; +} +.headroom--pinned { + transform: translateY(0%); +} +.headroom--unpinned { + transform: translateY(-100%); +} + +/* mark.js ----------------------------*/ + +mark { + background-color: rgba(255, 255, 51, 0.5); + border-bottom: 2px solid rgba(255, 153, 51, 0.3); + padding: 1px; +} + +/* vertical spacing after htmlwidgets */ +.html-widget { + margin-bottom: 10px; +} + +/* fontawesome ------------------------ */ + +.fab { + font-family: "Font Awesome 5 Brands" !important; +} + +/* don't display links in code chunks when printing */ +/* source: https://stackoverflow.com/a/10781533 */ +@media print { + code a:link:after, code a:visited:after { + content: ""; + } +} diff --git a/docs/pkgdown.js b/docs/pkgdown.js index 4b817132..7e7048fa 100644 --- a/docs/pkgdown.js +++ b/docs/pkgdown.js @@ -1,45 +1,108 @@ -$(function() { - $("#sidebar").stick_in_parent({offset_top: 40}); - $('body').scrollspy({ - target: '#sidebar', - offset: 60 - }); +/* http://gregfranko.com/blog/jquery-best-practices/ */ +(function($) { + $(function() { + + $('.navbar-fixed-top').headroom(); + + $('body').css('padding-top', $('.navbar').height() + 10); + $(window).resize(function(){ + $('body').css('padding-top', $('.navbar').height() + 10); + }); + + $('[data-toggle="tooltip"]').tooltip(); + + var cur_path = paths(location.pathname); + var links = $("#navbar ul li a"); + var max_length = -1; + var pos = -1; + for (var i = 0; i < links.length; i++) { + if (links[i].getAttribute("href") === "#") + continue; + // Ignore external links + if (links[i].host !== location.host) + continue; + + var nav_path = paths(links[i].pathname); - var cur_path = paths(location.pathname); - $("#navbar ul li a").each(function(index, value) { - if (value.text == "Home") - return; - if (value.getAttribute("href") === "#") - return; - - var path = paths(value.pathname); - if (is_prefix(cur_path, path)) { - // Add class to parent
  • , and enclosing
  • if in dropdown - var menu_anchor = $(value); + var length = prefix_length(nav_path, cur_path); + if (length > max_length) { + max_length = length; + pos = i; + } + } + + // Add class to parent
  • , and enclosing
  • if in dropdown + if (pos >= 0) { + var menu_anchor = $(links[pos]); menu_anchor.parent().addClass("active"); menu_anchor.closest("li.dropdown").addClass("active"); } }); -}); -function paths(pathname) { - var pieces = pathname.split("/"); - pieces.shift(); // always starts with / + function paths(pathname) { + var pieces = pathname.split("/"); + pieces.shift(); // always starts with / + + var end = pieces[pieces.length - 1]; + if (end === "index.html" || end === "") + pieces.pop(); + return(pieces); + } - var end = pieces[pieces.length - 1]; - if (end === "index.html" || end === "") - pieces.pop(); - return(pieces); -} + // Returns -1 if not found + function prefix_length(needle, haystack) { + if (needle.length > haystack.length) + return(-1); -function is_prefix(needle, haystack) { - if (needle.length > haystack.lengh) - return(false); + // Special case for length-0 haystack, since for loop won't run + if (haystack.length === 0) { + return(needle.length === 0 ? 0 : -1); + } - for (var i = 0; i < haystack.length; i++) { - if (needle[i] != haystack[i]) - return(false); + for (var i = 0; i < haystack.length; i++) { + if (needle[i] != haystack[i]) + return(i); + } + + return(haystack.length); + } + + /* Clipboard --------------------------*/ + + function changeTooltipMessage(element, msg) { + var tooltipOriginalTitle=element.getAttribute('data-original-title'); + element.setAttribute('data-original-title', msg); + $(element).tooltip('show'); + element.setAttribute('data-original-title', tooltipOriginalTitle); } - return(true); -} + if(ClipboardJS.isSupported()) { + $(document).ready(function() { + var copyButton = ""; + + $(".examples, div.sourceCode").addClass("hasCopyButton"); + + // Insert copy buttons: + $(copyButton).prependTo(".hasCopyButton"); + + // Initialize tooltips: + $('.btn-copy-ex').tooltip({container: 'body'}); + + // Initialize clipboard: + var clipboardBtnCopies = new ClipboardJS('[data-clipboard-copy]', { + text: function(trigger) { + return trigger.parentNode.textContent; + } + }); + + clipboardBtnCopies.on('success', function(e) { + changeTooltipMessage(e.trigger, 'Copied!'); + e.clearSelection(); + }); + + clipboardBtnCopies.on('error', function() { + changeTooltipMessage(e.trigger,'Press Ctrl+C or Command+C to copy'); + }); + }); + } +})(window.jQuery || window.$) diff --git a/docs/pkgdown.yml b/docs/pkgdown.yml new file mode 100644 index 00000000..66f0862b --- /dev/null +++ b/docs/pkgdown.yml @@ -0,0 +1,8 @@ +pandoc: 2.11.4 +pkgdown: 1.6.1 +pkgdown_sha: ~ +articles: + Installation: Installation.html + neurons-intro: neurons-intro.html +last_built: 2021-09-05T13:04Z + diff --git a/docs/reference/Cell07PNs.html b/docs/reference/Cell07PNs.html index 57d3ef6d..09f4f9e8 100644 --- a/docs/reference/Cell07PNs.html +++ b/docs/reference/Cell07PNs.html @@ -1,6 +1,6 @@ - + @@ -8,25 +8,48 @@ Cell07PNs: 40 Sample Projection Neurons from Jefferis, Potter et al 2007 — Cell07PNs • nat + - + - - + + + + + + + - + + + + + + + + - - - + + + + + + + + + + - + + + - +
  • - +
    + -
    +
    - -

    These R lists (which have additional class neuronlist) contain 40 traced -olfactory projection neurons from Jefferis, Potter et al 2007 that have been +

    +

    These R lists (which have additional class neuronlist) contain 40 traced +olfactory projection neurons from Jefferis, Potter et al 2007 that have been transformed onto the IS2 template brain (Cachero, Ostrovsky et al 2010).

    - +
    + + -

    References

    -

    Jefferis G.S.X.E., Potter C.J., Chan A.M., Marin E.C., Rohlfing -T., Maurer C.R.J., and Luo L. (2007). Comprehensive maps of Drosophila higher -olfactory centers: spatially segregated fruit and pheromone representation. -Cell 128 (6), 1187--1203. -doi:10.1016/j.cell.2007.01.040

    -

    Cachero S., Ostrovsky A.D., Yu J.Y., Dickson B.J., and Jefferis G.S.X.E. -(2010). Sexual dimorphism in the fly brain. Curr Biol 20 (18), 1589--601. -doi:10.1016/j.cub.2010.07.045

    - +

    Jefferis G.S.X.E., Potter C.J., Chan A.M., Marin E.C., Rohlfing + T., Maurer C.R.J., and Luo L. (2007). Comprehensive maps of Drosophila + higher olfactory centers: spatially segregated fruit and pheromone + representation. Cell 128 (6), 1187--1203. doi: 10.1016/j.cell.2007.01.040

    +

    Cachero S., Ostrovsky A.D., Yu J.Y., Dickson B.J., and Jefferis G.S.X.E. + (2010). Sexual dimorphism in the fly brain. Curr Biol 20 (18), 1589--601. + doi: 10.1016/j.cub.2010.07.045

    See also

    -

    head.neuronlist, with.neuronlist

    -

    Other nat-data: MBL.surf, kcs20

    - +

    Examples

    -
    head(Cell07PNs)
    #> Brain RegistrationScore Notes Glomerulus Batch Directory Traced +
    head(Cell07PNs) +
    #> Brain RegistrationScore Notes Glomerulus Batch Directory Traced #> EBH11R EBH11R 4 DA1 PN2 unsure yes #> EBH20L EBH20L 4 DL3 PN2 unsure2 yes #> EBH20R EBH20R 4 DA1 PN2 unsure2 yes @@ -164,35 +197,35 @@

    Examp #> EBH20R /GD/projects/PN2/allreg/warp/unsure2/average-goodbrains_EBH20R101_warp_m0g40c4e1e-1x16r3.list #> EBI12L /GD/projects/PN2/allreg/warp/unsure3/average-goodbrains_EBI12L101_warp_m0g40c4e1e-1x16r3.list #> EBI22R /GD/projects/PN2/allreg/warp/unsure3/average-goodbrains_EBI22R101_warp_m0g40c4e1e-1x16r3.list -#> EBJ23L /GD/projects/PN2/allreg/warp/unsure4/average-goodbrains_EBJ23L101_warp_m0g40c4e1e-1x16r3.list

    table(with(Cell07PNs,Glomerulus))
    #> +#> EBJ23L /GD/projects/PN2/allreg/warp/unsure4/average-goodbrains_EBJ23L101_warp_m0g40c4e1e-1x16r3.list
    table(with(Cell07PNs,Glomerulus)) +
    #> #> DA1 DL3 DP1m VA1d #> 11 10 8 11
    - +
    -

    Site built with pkgdown.

    +

    Site built with pkgdown 1.6.1.

    + + + + + diff --git a/docs/reference/MBL.surf.html b/docs/reference/MBL.surf.html index 8494aa59..b3cd4123 100644 --- a/docs/reference/MBL.surf.html +++ b/docs/reference/MBL.surf.html @@ -1,6 +1,6 @@ - + @@ -8,25 +8,47 @@ Surface object (hxsurf) for the left mushroom body in FCWB template space — MBL.surf • nat + - + - - + + + + + + + - + + + + + + + + - - - + + + + + + + + + + - + + + - +
    +
    -
    +
    - +

    This surface object is in the same space as the 20 Kenyon cells in kcs20.

    - +
    + + -

    See also

    -

    hxsurf

    -

    Other nat-data: Cell07PNs, - kcs20

    - +

    hxsurf

    +

    Other nat-data: +Cell07PNs, +kcs20

    Examples

    -
    plot3d(kcs20) -plot3d(MBL.surf, alpha=0.3)
    -
    # NOT RUN { +
    # \donttest{ +plot3d(kcs20) +plot3d(MBL.surf, alpha=0.3) +# } + +if (FALSE) { ## originally generated as follows -library(nat.flybrains) -MBL.surf=subset(FCWBNP.surf, "MB.*_L", drop = T) -# }
    +library(nat.flybrains) +MBL.surf=subset(FCWBNP.surf, "MB.*_L", drop = T) +} +
    - +
    -

    Site built with pkgdown.

    +

    Site built with pkgdown 1.6.1.

    + + + + + diff --git a/docs/reference/Rplot001.png b/docs/reference/Rplot001.png new file mode 100644 index 00000000..17a35806 Binary files /dev/null and b/docs/reference/Rplot001.png differ diff --git a/docs/reference/Rplot002.png b/docs/reference/Rplot002.png new file mode 100644 index 00000000..64a4b4b0 Binary files /dev/null and b/docs/reference/Rplot002.png differ diff --git a/docs/reference/Rplot003.png b/docs/reference/Rplot003.png new file mode 100644 index 00000000..c3fffac7 Binary files /dev/null and b/docs/reference/Rplot003.png differ diff --git a/docs/reference/Rplot004.png b/docs/reference/Rplot004.png new file mode 100644 index 00000000..c3947ca0 Binary files /dev/null and b/docs/reference/Rplot004.png differ diff --git a/docs/reference/Rplot005.png b/docs/reference/Rplot005.png new file mode 100644 index 00000000..d4c39747 Binary files /dev/null and b/docs/reference/Rplot005.png differ diff --git a/docs/reference/Rplot006.png b/docs/reference/Rplot006.png new file mode 100644 index 00000000..b8f7acf0 Binary files /dev/null and b/docs/reference/Rplot006.png differ diff --git a/docs/reference/Rplot007.png b/docs/reference/Rplot007.png new file mode 100644 index 00000000..ae65fa56 Binary files /dev/null and b/docs/reference/Rplot007.png differ diff --git a/docs/reference/affmat2cmtkparams.html b/docs/reference/affmat2cmtkparams.html index bb4b6620..37ac55e5 100644 --- a/docs/reference/affmat2cmtkparams.html +++ b/docs/reference/affmat2cmtkparams.html @@ -1,6 +1,6 @@ - + @@ -8,25 +8,46 @@ Decompose homogeneous affine matrix to CMTK registration parameters — affmat2cmtkparams • nat + - + - - + + + + + + + - + + + + + + + + - - - + + + + + + + + + + - + + + - +
    +
    -
    +
    - +

    Decompose homogeneous affine matrix to CMTK registration parameters

    - +
    -
    affmat2cmtkparams(matrix, centre = c(0, 0, 0))
    - -

    Arguments

    +
    affmat2cmtkparams(matrix, centre = c(0, 0, 0))
    + +

    Arguments

    @@ -116,51 +146,47 @@

    Ar

    Rotation centre

    - +

    Value

    5x3 matrix of CMTK registration parameters with a version attribute

    -

    Details

    The version attribute of the resultant matrix marks this as compliant with CMTK>v2.4 (~ Dec 2013) when a bug in affine matrix (de)composition was fixed.

    -

    See also

    -

    Other cmtk-geometry: cmtk.dof2mat, - cmtk.mat2dof, - cmtkparams2affmat

    - +

    Other cmtk-geometry: +cmtk.dof2mat(), +cmtk.mat2dof(), +cmtkparams2affmat()

    - +
    -

    Site built with pkgdown.

    +

    Site built with pkgdown 1.6.1.

    + + + + + diff --git a/docs/reference/all.equal.dotprops.html b/docs/reference/all.equal.dotprops.html index a3b5abb5..70664063 100644 --- a/docs/reference/all.equal.dotprops.html +++ b/docs/reference/all.equal.dotprops.html @@ -1,6 +1,6 @@ - + @@ -8,25 +8,46 @@ all.equal method tailored to dotprops objects — all.equal.dotprops • nat + - + - - + + + + + + + - + + + + + + + + - - - + + + + + + + + + + - + + + - +
    +
    -
    +
    - +

    all.equal method tailored to dotprops objects

    - +
    # S3 method for dotprops
    -all.equal(target, current, check.attributes = FALSE,
    -  absoluteVectors = TRUE, ...)
    - -

    Arguments

    +all.equal( + target, + current, + check.attributes = FALSE, + absoluteVectors = TRUE, + ... +) + +

    Arguments

    @@ -127,50 +162,52 @@

    Ar

    Additional arguments passed to base all.equal.

    - +

    Details

    This method is required because the direction vectors are computed using an eigenvector decomposition where the sign of the eigenvector is essentially random and subject to small numerical instabilities. Therefore it does not usually make sense to check the value of vect exactly.

    -

    Examples

    # equal using default -kc1=kcs20[[1]] -kc1.recalc=dotprops(kc1) +kc1=kcs20[[1]] +kc1.recalc=dotprops(kc1) # not equal due to differences in attributes and vectors -all.equal.default(kc1.recalc, kc1)
    #> [1] "Component “vect”: Mean relative difference: 0.5218482"
    # still not equal because of tangent vector flipping -all.equal.default(kc1.recalc, kc1, check.attributes=FALSE)
    #> [1] "Component “vect”: Mean relative difference: 0.5218482"
    # equal using appropriate method -stopifnot(isTRUE(all.equal(kc1.recalc, kc1))) +all.equal.default(kc1.recalc, kc1) +
    #> [1] "Component “vect”: Mean relative difference: 0.5218482"
    # still not equal because of tangent vector flipping +all.equal.default(kc1.recalc, kc1, check.attributes=FALSE) +
    #> [1] "Component “vect”: Mean relative difference: 0.5218482"
    # equal using appropriate method +stopifnot(isTRUE(all.equal(kc1.recalc, kc1))) # NB identical when recalculated on same setup from same data -stopifnot(isTRUE(all.equal.default(kc1.recalc, dotprops(kc1))))
    +stopifnot(isTRUE(all.equal.default(kc1.recalc, dotprops(kc1)))) +
    - +
    -

    Site built with pkgdown.

    +

    Site built with pkgdown 1.6.1.

    + + + + + diff --git a/docs/reference/all.equal.im3d.html b/docs/reference/all.equal.im3d.html index 31e722fc..19c17bab 100644 --- a/docs/reference/all.equal.im3d.html +++ b/docs/reference/all.equal.im3d.html @@ -1,6 +1,6 @@ - + @@ -8,25 +8,46 @@ Check equality on data and key attributes of im3d objects — all.equal.im3d • nat + - + - - + + + + + + + - + + + + + + + + - - - + + + + + + + + + + - + + + - +
    +
    -
    +
    - +

    Check equality on data and key attributes of im3d objects

    - +
    # S3 method for im3d
    -all.equal(target, current, tolerance = 1e-06,
    -  attrsToCheck = c("BoundingBox"), attrsToCheckIfPresent = c("dim", "names",
    -  "dimnames", "x", "y", "z"), CheckSharedAttrsOnly = FALSE, ...)
    - -

    Arguments

    +all.equal( + target, + current, + tolerance = 1e-06, + attrsToCheck = c("BoundingBox"), + attrsToCheckIfPresent = c("dim", "names", "dimnames", "x", "y", "z"), + CheckSharedAttrsOnly = FALSE, + ... +) + +

    Arguments

    @@ -143,35 +179,36 @@

    Ar

    additional arguments passed to all.equal

    - +

    See also

    -

    all.equal

    - +
    - +
    -

    Site built with pkgdown.

    +

    Site built with pkgdown 1.6.1.

    + + + + + diff --git a/docs/reference/all.equal.neuron.html b/docs/reference/all.equal.neuron.html index 755f1a8f..05a0857c 100644 --- a/docs/reference/all.equal.neuron.html +++ b/docs/reference/all.equal.neuron.html @@ -1,6 +1,6 @@ - + @@ -8,25 +8,46 @@ Check equality on key fields of neuron object — all.equal.neuron • nat + - + - - + + + + + + + - + + + + + + + + - - - + + + + + + + + + + - + + + - +
    +
    -
    +
    - +

    Check equality on key fields of neuron object

    - +
    # S3 method for neuron
    -all.equal(target, current, tolerance = 1e-06,
    -  check.attributes = FALSE, fieldsToCheck = c("NumPoints", "StartPoint",
    -  "BranchPoints", "EndPoints", "NumSegs", "SegList", "d"),
    -  fieldsToCheckIfPresent = c("NeuronName", "nTrees", "SubTrees"),
    -  fieldsToExclude = character(), CheckSharedFieldsOnly = FALSE, ...)
    - -

    Arguments

    +all.equal( + target, + current, + tolerance = 1e-06, + check.attributes = FALSE, + fieldsToCheck = c("NumPoints", "StartPoint", "BranchPoints", "EndPoints", "NumSegs", + "SegList", "d"), + fieldsToCheckIfPresent = c("NeuronName", "nTrees", "SubTrees"), + fieldsToExclude = character(), + CheckSharedFieldsOnly = FALSE, + ... +) + +

    Arguments

    @@ -129,7 +166,7 @@

    Ar

    @@ -157,44 +194,45 @@

    Ar

    check.attributes

    logical indicating if the - attributes of target and current + attributes of target and current (other than the names) should be compared.

    additional arguments passed to all.equal

    - +

    See also

    -

    all.equal

    - +

    Examples

    -
    x=Cell07PNs[[1]] -y=x -y$NeuronName='rhubarb' +
    x=Cell07PNs[[1]] +y=x +y$NeuronName='rhubarb' # NOT TRUE -all.equal(x, y)
    #> [1] "Component “NeuronName”: 1 string mismatch"
    # TRUE -all.equal(x, y, fieldsToExclude='NeuronName')
    #> [1] TRUE
    +all.equal(x, y) +
    #> [1] "Component “NeuronName”: 1 string mismatch"
    # TRUE +all.equal(x, y, fieldsToExclude='NeuronName') +
    #> [1] TRUE
    - +
    -

    Site built with pkgdown.

    +

    Site built with pkgdown 1.6.1.

    + + + + + diff --git a/docs/reference/amiramesh-io.html b/docs/reference/amiramesh-io.html index fbd3212c..567f2934 100644 --- a/docs/reference/amiramesh-io.html +++ b/docs/reference/amiramesh-io.html @@ -1,6 +1,6 @@ - + @@ -8,25 +8,47 @@ Read AmiraMesh data in binary or ascii format — read.amiramesh • nat + - + - - + + + + + + + - + + + + + + + + - - - + + + + + + + + + + - + + + - +
    +
    -
    +
    - +

    Read AmiraMesh data in binary or ascii format

    Read the header of an amiramesh file

    - +
    -
    read.amiramesh(file, sections = NULL, header = FALSE, simplify = TRUE,
    -  endian = NULL, ReadByteAsRaw = FALSE, Verbose = FALSE)
    +    
    read.amiramesh(
    +  file,
    +  sections = NULL,
    +  header = FALSE,
    +  simplify = TRUE,
    +  endian = NULL,
    +  ReadByteAsRaw = FALSE,
    +  Verbose = FALSE
    +)
     
    -read.amiramesh.header(file, Parse = TRUE, Verbose = FALSE)
    - -

    Arguments

    +read.amiramesh.header(file, Parse = TRUE, Verbose = FALSE)
    + +

    Arguments

    @@ -148,53 +186,50 @@

    Ar

    Logical indicating whether to parse header (default: TRUE)

    - +

    Value

    list of named data chunks

    -

    Details

    reading byte data as raw arrays requires 1/4 memory but complicates - arithmetic. - read.amiramesh.header will open a connection if file is a + arithmetic.

    +

    read.amiramesh.header will open a connection if file is a character vector and close it when finished reading.

    -

    See also

    -

    readBin, .Platform

    -

    Other amira: amiratype, - is.amiramesh, read.hxsurf, - write.hxsurf

    - +
    - +
    -

    Site built with pkgdown.

    +

    Site built with pkgdown 1.6.1.

    + + + + + diff --git a/docs/reference/amiratype.html b/docs/reference/amiratype.html index b0a47504..640179f7 100644 --- a/docs/reference/amiratype.html +++ b/docs/reference/amiratype.html @@ -1,6 +1,6 @@ - + @@ -8,25 +8,46 @@ Return the type of an amiramesh file on disk or a parsed header — amiratype • nat + - + - - + + + + + + + - + + + + + + + + - - - + + + + + + + + + + - + + + - +
    +
    -
    +
    - +

    Return the type of an amiramesh file on disk or a parsed header

    - +
    -
    amiratype(x, bytes = NULL)
    - -

    Arguments

    +
    amiratype(x, bytes = NULL)
    + +

    Arguments

    @@ -117,51 +147,48 @@

    Ar file.

    - +

    Value

    character vector (NA_character_ when file invalid)

    -

    Details

    Note that when checking a file we first test if it is an amiramesh file (fast, especially when bytes!=NULL) before reading the header and determining content type (slow).

    -

    See also

    -

    Other amira: is.amiramesh, - read.amiramesh, read.hxsurf, - write.hxsurf

    - +
    - +
    -

    Site built with pkgdown.

    +

    Site built with pkgdown 1.6.1.

    + + + + + diff --git a/docs/reference/as.hxsurf.html b/docs/reference/as.hxsurf.html index b0c2a34e..c620e5f0 100644 --- a/docs/reference/as.hxsurf.html +++ b/docs/reference/as.hxsurf.html @@ -1,6 +1,6 @@ - + @@ -8,25 +8,46 @@ Convert an object to a nat hxsurf object — as.hxsurf • nat + - + - - + + + + + + + - + + + + + + + + - - - + + + + + + + + + + - + + + - +
    +
    -
    +
    - +

    Convert an object to a nat hxsurf object

    - +
    -
    as.hxsurf(x, ...)
    +    
    as.hxsurf(x, ...)
     
     # S3 method for mesh3d
    -as.hxsurf(x, region = "Interior", col = NULL, ...)
    - -

    Arguments

    +as.hxsurf(x, region = "Interior", col = NULL, ...)
    + +

    Arguments

    @@ -129,60 +159,60 @@

    Ar no colour.)

    - +

    Value

    A new surface object of class hxsurf (see read.hxsurf) for details.

    -

    Details

    hxsurf objects are based on the format of Amira's surface objects (see read.hxsurf). They have the ability to include multiple distinct regions. However, at the moment the only method that we provide converts mesh3d objects, which can only include one region.

    -

    See also

    -

    as.mesh3d

    -

    Other hxsurf: as.mesh3d, - materials, plot3d.hxsurf, - read.hxsurf, subset.hxsurf, - write.hxsurf

    - +

    Examples

    -
    tet=tetrahedron3d(col='red') -teth=as.hxsurf(tet)
    plot3d(teth)
    +
    tet=tetrahedron3d(col='red') +teth=as.hxsurf(tet) +# \donttest{ +plot3d(teth) +# } +
    - +
    -

    Site built with pkgdown.

    +

    Site built with pkgdown 1.6.1.

    + + + + + diff --git a/docs/reference/as.im3d.html b/docs/reference/as.im3d.html index d5b630b0..dbbdd69c 100644 --- a/docs/reference/as.im3d.html +++ b/docs/reference/as.im3d.html @@ -1,6 +1,6 @@ - + @@ -8,25 +8,46 @@ Convert a suitable object to an im3d object. — as.im3d • nat + - + - - + + + + + + + - + + + + + + + + - - - + + + + + + + + + + - + + + - +
    +
    -
    +
    - +

    Convert a suitable object to an im3d object.

    - +
    -
    as.im3d(x, ...)
    +    
    as.im3d(x, ...)
     
     # S3 method for im3d
    -as.im3d(x, ...)
    +as.im3d(x, ...)
     
     # S3 method for matrix
    -as.im3d(x, voxdims, origin = NULL, BoundingBox = NULL, ...)
    - -

    Arguments

    +as.im3d(x, voxdims, origin = NULL, BoundingBox = NULL, ...)
    + +

    Arguments

    @@ -136,7 +166,7 @@

    Ar of boundingbox's help for the distinction.

    - +

    Details

    At present the only interesting method in nat is @@ -144,70 +174,75 @@

    Details into a 3D volume representation. ind2coord can be used to do the reverse: convert a set of 3D coords to an im3d volume.

    Other than that, this is a largely a placeholder function with the - expectation that other packages may wish to provide suitable methods. - as.im3d.matrix can accept any object that can be converted to + expectation that other packages may wish to provide suitable methods.

    +

    as.im3d.matrix can accept any object that can be converted to an im3d object in the voxdims argument This will completely specify the dims, voxdims, origin etc. Any value passed to those parameters will be ignored. This can be useful for producing a new im3d to match a target - image on disk or a nat.templatebrains::templatebrain object. See + image on disk or a nat.templatebrains::templatebrain object. See examples.

    -

    See also

    -

    im3d, ind2coord - im3d, as.im3d

    -

    Other im3d: boundingbox, - im3d-coords, im3d-io, - im3d, imexpand.grid, - imslice, is.im3d, - mask, origin, - projection, threshold, - unmask, voxdims

    - +

    im3d, ind2coord

    +

    im3d, as.im3d

    +

    Other im3d: +boundingbox(), +im3d-coords, +im3d-io, +im3d(), +imexpand.grid(), +imslice(), +is.im3d(), +mask(), +origin(), +projection(), +threshold(), +unmask(), +voxdims()

    Examples

    ## convert a list of neurons into an image volume -im=as.im3d(xyzmatrix(kcs20), voxdims=c(1, 1, 1), - BoundingBox=c(250, 410, 0, 130, 0, 120))
    # NOT RUN { -write.im3d(im, 'kc20volume.nrrd') +im=as.im3d(xyzmatrix(kcs20), voxdims=c(1, 1, 1), + BoundingBox=c(250, 410, 0, 130, 0, 120)) +if (FALSE) { +write.im3d(im, 'kc20volume.nrrd') ## use image dimensions of an image on disk # nb note use of ReadData = FALSE so that we just fetch the dimensions of # the target image -diskim=read.im3d("/path/to/my/image.nrrd", ReadData = FALSE) -im=as.im3d(xyzmatrix(kcs20), diskim) +diskim=read.im3d("/path/to/my/image.nrrd", ReadData = FALSE) +im=as.im3d(xyzmatrix(kcs20), diskim) ## use image dimensions of JFRC2 template brain to define the image space -library(nat.flybrains) -im=as.im3d(xyzmatrix(kcs20), JFRC2) -# }
    +library(nat.flybrains) +im=as.im3d(xyzmatrix(kcs20), JFRC2) +} +
    - +
    -

    Site built with pkgdown.

    +

    Site built with pkgdown 1.6.1.

    + + + + + diff --git a/docs/reference/as.mesh3d.html b/docs/reference/as.mesh3d.html index d0294eb7..4c106805 100644 --- a/docs/reference/as.mesh3d.html +++ b/docs/reference/as.mesh3d.html @@ -1,6 +1,6 @@ - + @@ -8,25 +8,49 @@ Convert an object to an rgl mesh3d — as.mesh3d • nat + - + - - + + + + + + + - + + + + + + + + - - - + + + + + + + + + + - + + + - +
    +
    -
    +
    - +

    as.mesh3d.ashape3d converts an - alphashape3d::ashape3d object into a nat/rgl compatible + alphashape3d::ashape3d object into a nat/rgl compatible mesh3d surface

    Note that this provides a link to the Rvcg package

    - +
    # S3 method for ashape3d
    -as.mesh3d(x, tri_to_keep = 2L, ...)
    +as.mesh3d(x, tri_to_keep = 2L, ...)
     
     # S3 method for hxsurf
    -as.mesh3d(x, Regions = NULL, material = NULL,
    -  drop = TRUE, ...)
    - -

    Arguments

    +as.mesh3d(x, Regions = NULL, material = NULL, drop = TRUE, ...) + +

    Arguments

    @@ -123,7 +155,7 @@

    Ar

    +ashape3d docs for details.)

    @@ -143,12 +175,11 @@

    Ar

    tri_to_keep

    Which alphashape triangles to keep (expert use only - see triang entry in Value section of -ashape3d docs for details.)

    ...

    Whether to drop unused vertices (default TRUE)

    - +

    Value

    -

    a mesh3d object which can be plotted and +

    a mesh3d object which can be plotted and manipulated using rgl and nat packages.

    -

    Details

    An alpha shape is @@ -159,63 +190,63 @@

    Details length that defines a spatial domain. When alpha is larger the alpha shape approaches the convex hull; when alpha is smaller the alpha shape has a greater number of faces / vertices i.e. it follows the points more closely.

    -

    See also

    -

    ashape3d, mesh3d - as.mesh3d, tmesh3d, +

    Examples

    -
    library(alphashape3d)
    #> Loading required package: geometry
    #> Loading required package: magic
    #> Loading required package: abind
    kcs20.a=ashape3d(xyzmatrix(kcs20), alpha = 10)
    #> -#> PLEASE NOTE: As of version 0.3-5, no degenerate (zero area) -#> regions are returned with the "Qt" option since the R -#> code removes them from the triangulation. -#> See help("delaunayn"). -#>
    plot(kcs20.a)
    #> Device 1 : alpha = 10
    +
    # \donttest{ +library(alphashape3d) +
    #> Loading required package: geometry
    kcs20.a=ashape3d(xyzmatrix(kcs20), alpha = 10) +plot(kcs20.a) +
    #> Device 1 : alpha = 10
    # convert to mesh3d -kcs20.mesh=as.mesh3d(kcs20.a) +kcs20.mesh=as.mesh3d(kcs20.a) # check that all points are inside mesh -all(pointsinside(kcs20, kcs20.mesh))
    #> [1] TRUE
    # and show that we can also use the alphashape directly -all(pointsinside(kcs20, kcs20.a))
    #> [1] TRUE
    -clear3d() -wire3d(kcs20.mesh) -plot3d(kcs20, col=type, lwd=2)
    +all(pointsinside(kcs20, kcs20.mesh)) +
    #> [1] TRUE
    # and show that we can also use the alphashape directly +all(pointsinside(kcs20, kcs20.a)) +
    #> [1] TRUE
    +clear3d() +wire3d(kcs20.mesh) +plot3d(kcs20, col=type, lwd=2) +# } +
    - +
    -

    Site built with pkgdown.

    +

    Site built with pkgdown 1.6.1.

    + + + + + diff --git a/docs/reference/as.neuronlist.html b/docs/reference/as.neuronlist.html index acdb759c..359e89ad 100644 --- a/docs/reference/as.neuronlist.html +++ b/docs/reference/as.neuronlist.html @@ -1,6 +1,6 @@ - + @@ -8,25 +8,46 @@ Make a list of neurons that can be used for coordinate plotting/analysis — as.neuronlist • nat + - + - - + + + + + + + - + + + + + + + + - - - + + + + + + + + + + - + + + - +
    +
    -
    +
    - +

    Make a list of neurons that can be used for coordinate plotting/analysis

    - +
    -
    as.neuronlist(l, ...)
    +    
    as.neuronlist(l, ...)
     
     # S3 method for default
    -as.neuronlist(l, df = NULL, AddClassToNeurons = TRUE, ...)
    - -

    Arguments

    +as.neuronlist(l, df = NULL, AddClassToNeurons = TRUE, ...)
    + +

    Arguments

    @@ -128,50 +158,45 @@

    Ar (see details).

    - +

    Value

    neuronlist with attr('df')

    -

    Details

    Note that as.neuronlist can cope with both neurons and dotprops objects but AddClassToNeurons will only apply to things that look like neurons but don't have a class of neuron.

    See neuronlist details for more information.

    -

    See also

    -

    is.neuronlist,is.neuron,is.dotprops

    - +
    - +
    -

    Site built with pkgdown.

    +

    Site built with pkgdown 1.6.1.

    + + + + + diff --git a/docs/reference/as.neuronlist.neuronlistfh.html b/docs/reference/as.neuronlist.neuronlistfh.html index 238b1491..10287163 100644 --- a/docs/reference/as.neuronlist.neuronlistfh.html +++ b/docs/reference/as.neuronlist.neuronlistfh.html @@ -1,6 +1,6 @@ - + @@ -8,25 +8,46 @@ convert neuronlistfh to a regular (in memory) neuronlist — as.neuronlist.neuronlistfh • nat + - + - - + + + + + + + - + + + + + + + + - - - + + + + + + + + + + - + + + - +
    +
    -
    +
    - +

    convert neuronlistfh to a regular (in memory) neuronlist

    - +
    # S3 method for neuronlistfh
    -as.neuronlist(l, ...)
    - -

    Arguments

    +as.neuronlist(l, ...) + +

    Arguments

    @@ -117,29 +147,33 @@

    Ar

    Additional arguments passed to methods

    - -
    - +
    +
    -

    Site built with pkgdown.

    +

    Site built with pkgdown 1.6.1.

    + + + + + diff --git a/docs/reference/boundingbox.html b/docs/reference/boundingbox.html index 74d983ae..63c6da4f 100644 --- a/docs/reference/boundingbox.html +++ b/docs/reference/boundingbox.html @@ -1,6 +1,6 @@ - + @@ -8,25 +8,52 @@ Get the bounding box of an im3d volume or other compatible object — boundingbox • nat + - + - - + + + + + + + - + + + + + + + + - - - + + + + + + + + + + - + + + - +
    +
    -
    +
    - -

    Get the bounding box of an im3d volume or other compatible object - - boundingbox.list is designed to be used on objects that - contain 3D point information and for which xyzmatrix is defined. - - boundingbox.shape3d is designed to be used on objects +

    +

    boundingbox.list is designed to be used on objects that + contain 3D point information and for which xyzmatrix is defined.

    +

    boundingbox.shape3d is designed to be used on objects that contain 3D point information and inherit from rgl's shape3d class and for which xyzmatrix is defined. Presently this applies to mesh3d objects.

    Set the bounding box of an im3d object

    - +
    -
    boundingbox(x, ...)
    +    
    boundingbox(x, ...)
     
     # S3 method for im3d
    -boundingbox(x, dims = dim(x), ...)
    +boundingbox(x, dims = dim(x), ...)
     
     # S3 method for character
    -boundingbox(x, ...)
    +boundingbox(x, ...)
     
     # S3 method for list
    -boundingbox(x, na.rm = FALSE, ...)
    +boundingbox(x, na.rm = FALSE, ...)
     
     # S3 method for neuron
    -boundingbox(x, na.rm = FALSE, ...)
    +boundingbox(x, na.rm = FALSE, ...)
     
     # S3 method for shape3d
    -boundingbox(x, na.rm = FALSE, ...)
    +boundingbox(x, na.rm = FALSE, ...)
     
     # S3 method for default
    -boundingbox(x, dims, input = c("boundingbox", "bounds"),
    -  ...)
    +boundingbox(x, dims, input = c("boundingbox", "bounds"), ...)
    +
    +boundingbox(x) <- value
    -boundingbox(x) <- value
    - -

    Arguments

    +

    Arguments

    @@ -169,20 +201,19 @@

    Ar matrix defined according to boundingbox.default.

    - +

    Value

    a matrix with 2 rows and 3 columns with class='boundingbox' or NULL when missing.

    -

    Details

    The bounding box is defined as the position of the voxels at the two opposite corners of the cuboid encompassing an image, when each voxel is assumed to have a single position (sometimes thought of as its centre) and no physical extent. When written as a vector it should look - like: c(x0,x1,y0,y1,z0,z1). When written as a matrix it should look - like: rbind(c(x0,y0,z0),c(x1,y1,z1)) where x0,y0,z0 is the position + like: c(x0,x1,y0,y1,z0,z1). When written as a matrix it should look + like: rbind(c(x0,y0,z0),c(x1,y1,z1)) where x0,y0,z0 is the position of the origin.

    Note that there are two competing definitions for the physical extent of an image that are discussed e.g. @@ -198,59 +229,62 @@

    Details takes this second view and this is the one we favour given our background in microscopy. If you wish to convert a bounds type definition into an im3d BoundingBox, you should pass the argument input='bounds'.

    -

    See also

    -

    plot3d.boundingbox

    -

    Other im3d: as.im3d, - im3d-coords, im3d-io, - im3d, imexpand.grid, - imslice, is.im3d, - mask, origin, - projection, threshold, - unmask, voxdims

    - +

    Examples

    -
    boundingbox(c(x0=0,x1=10,y0=0,y1=20,z0=0,z1=30))
    #> [,1] [,2] [,3] +
    boundingbox(c(x0=0,x1=10,y0=0,y1=20,z0=0,z1=30)) +
    #> [,1] [,2] [,3] #> [1,] 0 0 0 #> [2,] 10 20 30 #> attr(,"class") #> [1] "boundingbox"
    # bounding box for a neuron -boundingbox(Cell07PNs[[1]])
    #> [,1] [,2] [,3] +boundingbox(Cell07PNs[[1]]) +
    #> [,1] [,2] [,3] #> [1,] 186.8660 90.36325 88.20393 #> [2,] 289.5364 132.70932 157.29700 #> attr(,"class") #> [1] "boundingbox"
    - +
    -

    Site built with pkgdown.

    +

    Site built with pkgdown 1.6.1.

    + + + + + diff --git a/docs/reference/c.neuronlist.html b/docs/reference/c.neuronlist.html index 76fb7b9a..fa21abd3 100644 --- a/docs/reference/c.neuronlist.html +++ b/docs/reference/c.neuronlist.html @@ -1,6 +1,6 @@ - + @@ -8,25 +8,46 @@ Combine multiple neuronlists into a single list — c.neuronlist • nat + - + - - + + + + + + + - + + + + + + + + - - - + + + + + + + + + + - + + + - +
    +
    -
    +
    - +

    Combine multiple neuronlists into a single list

    - +
    # S3 method for neuronlist
    -c(..., recursive = FALSE)
    - -

    Arguments

    +c(..., recursive = FALSE) + +

    Arguments

    @@ -117,46 +147,43 @@

    Ar

    Presently ignored

    - +

    Details

    -

    Uses rbind.fill to join any attached dataframes, +

    Uses rbind.fill to join any attached dataframes, so missing values are replaced with NAs.

    -

    See also

    -

    c

    - +

    Examples

    -
    stopifnot(all.equal(kcs20[1:2],c(kcs20[1],kcs20[2])))
    +
    stopifnot(all.equal(kcs20[1:2],c(kcs20[1],kcs20[2]))) +
    - +
    -

    Site built with pkgdown.

    +

    Site built with pkgdown 1.6.1.

    + + + + + diff --git a/docs/reference/clampmax.html b/docs/reference/clampmax.html index 7a65af52..570eda06 100644 --- a/docs/reference/clampmax.html +++ b/docs/reference/clampmax.html @@ -1,6 +1,6 @@ - + @@ -8,25 +8,46 @@ Return function that finds maximum of its inputs within a clamping range — clampmax • nat + - + - - + + + + + + + - + + + + + + + + - - - + + + + + + + + + + - + + + - +
    +
    -
    +
    - +

    Return function that finds maximum of its inputs within a clamping range

    - +
    -
    clampmax(xmin, xmax, replace.infinite = NA_real_)
    - -

    Arguments

    +
    clampmax(xmin, xmax, replace.infinite = NA_real_)
    + +

    Arguments

    @@ -120,53 +150,50 @@

    Ar mapped to NA.

    - +

    Value

    A function with signature f(x, ..., na.rm)

    -

    Details

    Note that by default infinite values in the input vector are converted to NAs before the being compared with the clampmax range.

    -

    Examples

    -
    # NOT RUN {
    -LHMask=read.im3d(system.file('tests/testthat/testdata/nrrd/LHMask.nrrd',package='nat'))
    -d=unmask(rnorm(sum(LHMask),mean=5,sd=5),LHMask)
    -op=par(mfrow=c(1,2))
    -rval=image(projection(d,projfun=max))
    -image(projection(d,projfun=clampmax(0,10)),zlim=rval$zlim)
    -par(op)
    -# }
    +
    if (FALSE) { +LHMask=read.im3d(system.file('tests/testthat/testdata/nrrd/LHMask.nrrd',package='nat')) +d=unmask(rnorm(sum(LHMask),mean=5,sd=5),LHMask) +op=par(mfrow=c(1,2)) +rval=image(projection(d,projfun=max)) +image(projection(d,projfun=clampmax(0,10)),zlim=rval$zlim) +par(op) +} +
    - +
    -

    Site built with pkgdown.

    +

    Site built with pkgdown 1.6.1.

    + + + + + diff --git a/docs/reference/cmtk.bindir.html b/docs/reference/cmtk.bindir.html index f46d9a02..6eaf34bf 100644 --- a/docs/reference/cmtk.bindir.html +++ b/docs/reference/cmtk.bindir.html @@ -1,6 +1,6 @@ - + @@ -8,25 +8,50 @@ Return path to directory containing CMTK binaries — cmtk.bindir • nat + - + - - + + + + + + + - + + + + + + + + - - - + + + + + + + + + + - + + + - +
    +
    -
    +
    - -

    The Computational Morphometry - Toolkit (CMTK) is the default image registration toolkit supported by nat. - An external CMTK installation is required in order to apply CMTK - registrations. This function attempts to locate the full path to the CMTK - executable files and can query and set an option.

    - - -
    cmtk.bindir(firstdir = getOption("nat.cmtk.bindir"), extradirs = c("~/bin",
    -  "/usr/local/lib/cmtk/bin", "/usr/local/bin", "/opt/local/bin",
    -  "/opt/local/lib/cmtk/bin/", "/Applications/IGSRegistrationTools/bin",
    -  "C:\\cygwin64\\usr\\local\\lib\\cmtk\\bin",
    -  "C:\\Program Files\\CMTK-3.3\\CMTK\\lib\\cmtk\\bin"),
    -  set = FALSE, check = FALSE, cmtktool = "gregxform")
    - -

    Arguments

    +
    +

    The Computational + Morphometry Toolkit (CMTK) is the default image registration toolkit + supported by nat. An external CMTK installation is required in order to + apply CMTK registrations. This function attempts to locate the full path to + the CMTK executable files and can query and set an option.

    +
    + +
    cmtk.bindir(
    +  firstdir = getOption("nat.cmtk.bindir"),
    +  extradirs = c("~/bin", "/usr/local/lib/cmtk/bin", "/usr/local/bin", "/opt/local/bin",
    +    "/opt/local/lib/cmtk/bin/", "/Applications/IGSRegistrationTools/bin",
    +    "C:\\cygwin64\\usr\\local\\lib\\cmtk\\bin",
    +    "C:\\Program Files\\CMTK-3.3\\CMTK\\lib\\cmtk\\bin"),
    +  set = FALSE,
    +  check = FALSE,
    +  cmtktool = "gregxform"
    +)
    + +

    Arguments

    - @@ -127,97 +165,89 @@

    Ar

    - -
    firstdir

    Character vector specifying path containing CMTK binaries or +

    Character vector specifying path containing CMTK binaries or NA (see details). This defaults to options('nat.cmtk.bindir').

    set

    Whether to set options('nat.cmtk.bindir') with the found -directory. Also check/sets cygwin path on Windows (see Installation +

    Whether to set options('nat.cmtk.bindir') with the found +directory. Also check/sets cygwin path on Windows (see Installation section).

    check

    Whether to (re)check that a path that has been set appropriately -in options(nat.cmtk.bindir='/some/path') or now found in the PATH or +in options(nat.cmtk.bindir='/some/path') or now found in the PATH or alternative directories. Will throw an error on failure.

    cmtktool

    Name of a specific cmtk tool which will be used to identify +

    Name of a specific cmtk tool which will be used to identify the location of all cmtk binaries.

    - +

    Value

    -

    Character vector giving path to CMTK binary directory or NULL when +

    Character vector giving path to CMTK binary directory or NULL when this cannot be found.

    -

    Details

    -

    Queries options('nat.cmtk.bindir') if firstdir is not - specified. If that does not contain the appropriate binaries, it will look - in the system PATH for the cmtk wrapper script installed by most - recent cmtk installations.

    -

    Failing that, it will look for the cmtk tool specified by cmtktool, - first in the path and then a succession of plausible places until it finds - something. Setting options(nat.cmtk.bindir=NA) or passing - firstdir=NA will stop the function from trying to locate CMTK, +

    Queries options('nat.cmtk.bindir') if firstdir is not + specified. If that does not contain the appropriate binaries, it will look + in the system PATH for the cmtk wrapper script installed by most + recent cmtk installations.

    +

    Failing that, it will look for the cmtk tool specified by cmtktool, + first in the path and then a succession of plausible places until it finds + something. Setting options(nat.cmtk.bindir=NA) or passing + firstdir=NA will stop the function from trying to locate CMTK, always returning NULL unless check=TRUE, in which case it will error out.

    -

    Installation

    -

    It is recommended to install released CMTK versions - available from the NITRC website. A - bug in composition of affine transformations from CMTK parameters in the - CMTK versions <2.4 series means that CMTK>=3.0 is strongly recommended. - CMTK v3 registrations are not backwards compatible with CMTK v2, but CMTKv3 - can correctly interpret and convert registrations from earlier versions.

    +

    It is recommended to install released CMTK versions + available from the NITRC + website. A bug in composition of affine transformations from CMTK + parameters in the CMTK versions <2.4 series means that CMTK>=3.0 is + strongly recommended. CMTK v3 registrations are not backwards compatible + with CMTK v2, but CMTKv3 can correctly interpret and convert registrations + from earlier versions.

    On Windows, when set=TRUE, cmtk.bindir will also check that the cygwin bin directory is in the PATH. If it is not, then it is added for the current R session. This should solve issues with missing cygwin dlls.

    -

    See also

    -

    options

    - +

    Examples

    -
    message(ifelse(is.null(d<-cmtk.bindir()), "CMTK not found!", - paste("CMTK is at:",d)))
    #> CMTK is at: /usr/local/lib/cmtk/bin
    # NOT RUN { +
    message(ifelse(is.null(d<-cmtk.bindir()), "CMTK not found!", + paste("CMTK is at:",d))) +
    #> CMTK is at: /usr/local/lib/cmtk/bin
    if (FALSE) { # set options('nat.cmtk.bindir') according to where cmtk was found -op=options(nat.cmtk.bindir=NULL) -cmtk.bindir(set=TRUE) -options(op) -# }
    +op=options(nat.cmtk.bindir=NULL) +cmtk.bindir(set=TRUE) +options(op)} +
    - +
    -

    Site built with pkgdown.

    +

    Site built with pkgdown 1.6.1.

    + + + + + diff --git a/docs/reference/cmtk.call.html b/docs/reference/cmtk.call.html index 8bb7c7cc..5a60ca10 100644 --- a/docs/reference/cmtk.call.html +++ b/docs/reference/cmtk.call.html @@ -1,6 +1,6 @@ - + @@ -8,25 +8,49 @@ Utility function to create and run calls to CMTK commandline tools — cmtk.call • nat + - + - - + + + + + + + - + + + + + + + + - - - + + + + + + + + + + - + + + - +
    +
    -
    +
    - +

    cmtk.call processes arguments into a form compatible with - CMTK command line tools. - - cmtk.system2 actually calls a cmtk tool using a call list + CMTK command line tools.

    +

    cmtk.system2 actually calls a cmtk tool using a call list produced by cmtk.call

    - +
    + +
    cmtk.call(
    +  tool,
    +  PROCESSED.ARGS = NULL,
    +  ...,
    +  FINAL.ARGS = NULL,
    +  RETURN.TYPE = c("string", "list")
    +)
     
    -    
    cmtk.call(tool, PROCESSED.ARGS = NULL, ..., FINAL.ARGS = NULL,
    -  RETURN.TYPE = c("string", "list"))
    +cmtk.system2(cmtkcall, moreargs = NULL, ...)
    -cmtk.system2(cmtkcall, moreargs = NULL, ...)
    - -

    Arguments

    +

    Arguments

    @@ -137,7 +174,7 @@

    Ar

    +is suitable for use with system2)

    @@ -149,7 +186,7 @@

    Ar

    RETURN.TYPE

    Sets return type to a character string or list (the latter -is suitable for use with system2)

    cmtkcall

    Additional arguments to add to the processed call

    - +

    Value

    Either a string of the form "<tool> <PROCESSED.ARGS> @@ -159,8 +196,7 @@

    Value

  • args A character vector of arguments of length 0 or greater.

  • -

    See the help of system2 for details.

    - +

    See the help of system2 for details.

    Details

    cmtk.call processes arguments in ... as follows:

    @@ -175,53 +211,50 @@

    Details than 1 and then passed on unquoted e.g. target.offset=c(1,2,3) will result in --target-offset 1,2,3

    - +

    See also

    -

    cmtk.bindir

    - +

    Examples

    -
    # NOT RUN {
    -cmtk.call("reformatx",'--outfile=out.nrrd', floating='floating.nrrd',
    -  mask=TRUE, target.offset=c(1,2,3), FINAL.ARGS=c('target.nrrd','reg.list'))
    +    
    if (FALSE) { +cmtk.call("reformatx",'--outfile=out.nrrd', floating='floating.nrrd', + mask=TRUE, target.offset=c(1,2,3), FINAL.ARGS=c('target.nrrd','reg.list')) # get help for a cmtk tool -system(cmtk.call('reformatx', help=TRUE)) -# }# NOT RUN { -cmtk.system2(cmtk.call('mat2dof', help=TRUE, RETURN.TYPE="list")) +system(cmtk.call('reformatx', help=TRUE)) +} +if (FALSE) { +cmtk.system2(cmtk.call('mat2dof', help=TRUE, RETURN.TYPE="list")) # capture response into an R variable -helptext=cmtk.system2(cmtk.call('mat2dof', help=TRUE, RETURN.TYPE="list"), - stdout=TRUE) -# }
    +helptext=cmtk.system2(cmtk.call('mat2dof', help=TRUE, RETURN.TYPE="list"), + stdout=TRUE) +} +
    - +
    -

    Site built with pkgdown.

    +

    Site built with pkgdown 1.6.1.

    + + + + + diff --git a/docs/reference/cmtk.dof2mat.html b/docs/reference/cmtk.dof2mat.html index 1bd2d943..5a88c12a 100644 --- a/docs/reference/cmtk.dof2mat.html +++ b/docs/reference/cmtk.dof2mat.html @@ -1,6 +1,6 @@ - + @@ -8,25 +8,46 @@ Convert CMTK registration to homogeneous affine matrix with dof2mat — cmtk.dof2mat • nat + - + - - + + + + + + + - + + + + + + + + - - - + + + + + + + + + + - + + + - +
    +
    -
    +
    - +

    Convert CMTK registration to homogeneous affine matrix with dof2mat

    - +
    -
    cmtk.dof2mat(reg, Transpose = TRUE, version = FALSE)
    - -

    Arguments

    +
    cmtk.dof2mat(reg, Transpose = TRUE, version = FALSE)
    + +

    Arguments

    @@ -120,52 +150,49 @@

    Ar

    Whether to return CMTK version string

    - +

    Value

    4x4 transformation matrix

    -

    Details

    Transpose is true by default since this results in the orientation of cmtk output files matching the orientation in R. Do not change this unless you're sure you know what you're doing!

    -

    See also

    -

    Other cmtk-commandline: cmtk.mat2dof

    -

    Other cmtk-geometry: affmat2cmtkparams, - cmtk.mat2dof, - cmtkparams2affmat

    - +

    Other cmtk-commandline: +cmtk.mat2dof()

    +

    Other cmtk-geometry: +affmat2cmtkparams(), +cmtk.mat2dof(), +cmtkparams2affmat()

    - +
    -

    Site built with pkgdown.

    +

    Site built with pkgdown 1.6.1.

    + + + + + diff --git a/docs/reference/cmtk.extract_affine.html b/docs/reference/cmtk.extract_affine.html index ba3c6e78..f83632f4 100644 --- a/docs/reference/cmtk.extract_affine.html +++ b/docs/reference/cmtk.extract_affine.html @@ -1,6 +1,6 @@ - + @@ -8,25 +8,46 @@ Extract affine registration from CMTK registration file or in-memory list — cmtk.extract_affine • nat + - + - - + + + + + + + - + + + + + + + + - - - + + + + + + + + + + - + + + - +
    +
    -
    +
    - +

    Extract affine registration from CMTK registration file or in-memory list

    - +
    -
    cmtk.extract_affine(r, outdir)
    - -

    Arguments

    +
    cmtk.extract_affine(r, outdir)
    + +

    Arguments

    @@ -116,45 +146,45 @@

    Ar

    Optional path to output file

    - +

    Value

    When outdir is missing a list containing the registration paramers. Otherwise NULL invisibly.

    -

    See also

    -

    cmtkreglist

    -

    Other cmtk-io: read.cmtkreg, - read.cmtk, write.cmtkreg, - write.cmtk

    - +
    - +
    -

    Site built with pkgdown.

    +

    Site built with pkgdown 1.6.1.

    + + + + + diff --git a/docs/reference/cmtk.mat2dof.html b/docs/reference/cmtk.mat2dof.html index a7196bd4..89e9bcf4 100644 --- a/docs/reference/cmtk.mat2dof.html +++ b/docs/reference/cmtk.mat2dof.html @@ -1,6 +1,6 @@ - + @@ -8,25 +8,46 @@ Use CMTK mat2dof to convert homogeneous affine matrix into CMTK registration — cmtk.mat2dof • nat + - + - - + + + + + + + - + + + + + + + + - - - + + + + + + + + + + - + + + - +
    +
    -
    +
    - +

    Use CMTK mat2dof to convert homogeneous affine matrix into CMTK registration

    - +
    -
    cmtk.mat2dof(m, f = NULL, centre = NULL, Transpose = TRUE,
    -  version = FALSE)
    - -

    Arguments

    +
    cmtk.mat2dof(m, f = NULL, centre = NULL, Transpose = TRUE, version = FALSE)
    + +

    Arguments

    @@ -130,11 +159,10 @@

    Ar tool

    - +

    Value

    5x3 matrix of CMTK registration parameters or logical

    -

    Details

    If no output file is supplied, 5x3 params matrix will be returned @@ -142,42 +170,40 @@

    Details failure at writing to disk.

    Transpose is true by default since this results in an R matrix with the transpose in the fourth column being correctly interpreted by cmtk.

    -

    See also

    -

    Other cmtk-commandline: cmtk.dof2mat

    -

    Other cmtk-geometry: affmat2cmtkparams, - cmtk.dof2mat, - cmtkparams2affmat

    - +

    Other cmtk-commandline: +cmtk.dof2mat()

    +

    Other cmtk-geometry: +affmat2cmtkparams(), +cmtk.dof2mat(), +cmtkparams2affmat()

    - +
    -

    Site built with pkgdown.

    +

    Site built with pkgdown 1.6.1.

    + + + + + diff --git a/docs/reference/cmtk.reformatx.html b/docs/reference/cmtk.reformatx.html index c6f73fdf..3efddadd 100644 --- a/docs/reference/cmtk.reformatx.html +++ b/docs/reference/cmtk.reformatx.html @@ -1,6 +1,6 @@ - + @@ -8,25 +8,46 @@ Reformat an image with a CMTK registration using the reformatx tool — cmtk.reformatx • nat + - + - - + + + + + + + - + + + + + + + + - - - + + + + + + + + + + - + + + - +
    +
    -
    +
    - +

    Reformat an image with a CMTK registration using the reformatx tool

    - - -
    cmtk.reformatx(floating, registrations, output, target, mask = FALSE,
    -  direction = NULL, interpolation = c("linear", "nn", "cubic", "pv",
    -  "sinc-cosine", "sinc-hamming"), dryrun = FALSE, Verbose = TRUE,
    -  MakeLock = TRUE, OverWrite = c("no", "update", "yes"),
    -  filesToIgnoreModTimes = NULL, ...)
    - -

    Arguments

    +
    + +
    cmtk.reformatx(
    +  floating,
    +  registrations,
    +  output,
    +  target,
    +  mask = FALSE,
    +  direction = NULL,
    +  interpolation = c("linear", "nn", "cubic", "pv", "sinc-cosine", "sinc-hamming"),
    +  dryrun = FALSE,
    +  Verbose = TRUE,
    +  MakeLock = TRUE,
    +  OverWrite = c("no", "update", "yes"),
    +  filesToIgnoreModTimes = NULL,
    +  ...
    +)
    + +

    Arguments

    @@ -178,12 +218,11 @@

    Ar processing by cmtk.call.

    - +

    Value

    the path to the ouput image (whether or not it was re-created afresh) or NA_character_ if no output was possible.

    -

    Details

    Note that if you are reformatting a mask then you will need to @@ -191,50 +230,45 @@

    Details levels 72 and 74 with 73 may have unintened consequences. Presently we have no way of knowing whether an image should be treated as a mask, so the interpolation must be handled manually.

    -

    See also

    -

    cmtk.bindir, cmtk.call, makelock, - RunCmdForNewerInput

    - +

    cmtk.bindir, cmtk.call, makelock, + RunCmdForNewerInput

    Examples

    -
    # NOT RUN {
    -cmtk.reformatx('myimage.nrrd', target='template.nrrd',
    -  registrations='template_myimage.list')
    +    
    if (FALSE) { +cmtk.reformatx('myimage.nrrd', target='template.nrrd', + registrations='template_myimage.list') # get full listing of command line options -system(cmtk.call('reformatx', help=TRUE)) -# }
    +system(cmtk.call('reformatx', help=TRUE)) +} +
    - +
    -

    Site built with pkgdown.

    +

    Site built with pkgdown 1.6.1.

    + + + + + diff --git a/docs/reference/cmtk.statistics.html b/docs/reference/cmtk.statistics.html index f17e196d..dfb9b778 100644 --- a/docs/reference/cmtk.statistics.html +++ b/docs/reference/cmtk.statistics.html @@ -1,6 +1,6 @@ - + @@ -8,25 +8,46 @@ Calculate image statistics for a nrrd or other CMTK compatible file — cmtk.statistics • nat + - + - - + + + + + + + - + + + + + + + + - - - + + + + + + + + + + - + + + - +
    +
    -
    +
    - +

    Calculate image statistics for a nrrd or other CMTK compatible file

    - +
    -
    cmtk.statistics(f, mask, imagetype = c("greyscale", "label"),
    -  masktype = c("label", "binary"), ..., Verbose = FALSE)
    - -

    Arguments

    +
    cmtk.statistics(
    +  f,
    +  mask,
    +  imagetype = c("greyscale", "label"),
    +  masktype = c("label", "binary"),
    +  ...,
    +  Verbose = FALSE
    +)
    + +

    Arguments

    @@ -137,7 +173,7 @@

    Ar update checks. Sets command line --verbose option.

    - +

    Value

    data.frame describing results with the following columns when image @@ -166,47 +202,44 @@

    Value

  • X,Y,Z 3D coordinates of the centroid of this region

  • -

    Details

    When given a label mask, returns a dataframe with a row for each level of the label field.

    Note that the Entropy column (sometimes H, sometimes Entropy) will always be named Entropy in the returned dataframe.

    -

    Examples

    -
    # NOT RUN {
    -cmtk.statistics('someneuron.nrrd', mask='neuropilregionmask.nrrd')
    -cmtk.statistics('somelabelfield.nrrd', imagetype='label')
    -# }
    +
    if (FALSE) { +cmtk.statistics('someneuron.nrrd', mask='neuropilregionmask.nrrd') +cmtk.statistics('somelabelfield.nrrd', imagetype='label') +} +
    - +
    -

    Site built with pkgdown.

    +

    Site built with pkgdown 1.6.1.

    + + + + + diff --git a/docs/reference/cmtk.targetvolume.html b/docs/reference/cmtk.targetvolume.html index 948dc14d..aab082cc 100644 --- a/docs/reference/cmtk.targetvolume.html +++ b/docs/reference/cmtk.targetvolume.html @@ -1,6 +1,6 @@ - + @@ -8,25 +8,49 @@ Defines a target volume for a CMTK reformatx operation — cmtk.targetvolume • nat + - + - - + + + + + + + - + + + + + + + + - - - + + + + + + + + + + - + + + - +
    +
    -
    +
    - -

    Defines a target volume for a CMTK reformatx operation - - cmtk.targetvolume.list is designed to cope with any +

    +

    cmtk.targetvolume.list is designed to cope with any user-defined class for which an as.im3d method exists. Presently the only example in the nat.* ecosystem is - nat.templatebrains::as.im3d.templatebrain.

    - + nat.templatebrains::as.im3d.templatebrain.

    +
    -
    cmtk.targetvolume(target, ...)
    +    
    cmtk.targetvolume(target, ...)
     
     # S3 method for im3d
    -cmtk.targetvolume(target, ...)
    +cmtk.targetvolume(target, ...)
     
     # S3 method for list
    -cmtk.targetvolume(target, ...)
    +cmtk.targetvolume(target, ...)
     
     # S3 method for default
    -cmtk.targetvolume(target, ...)
    - -

    Arguments

    +cmtk.targetvolume(target, ...)
    + +

    Arguments

    @@ -132,52 +163,49 @@

    Ar

    additional arguments passed to methods

    - +

    Value

    a character vector specifying the full cmtk reformatx '--target' or '--target-grid' argument

    -

    Details

    if the character vector specifies an amiramesh file, it will be converted to a bare im3d object and then to an appropriate '--target-grid' specification.

    -

    Examples

    -
    # NOT RUN {
    +    
    if (FALSE) { # see https://github.com/jefferislab/nat.flybrains -library(nat.flybrains) -cmtk.targetvolume(FCWB) -# }
    +library(nat.flybrains) +cmtk.targetvolume(FCWB) +} +
    - +
    -

    Site built with pkgdown.

    +

    Site built with pkgdown 1.6.1.

    + + + + + diff --git a/docs/reference/cmtk.version.html b/docs/reference/cmtk.version.html index 9015debf..bda93067 100644 --- a/docs/reference/cmtk.version.html +++ b/docs/reference/cmtk.version.html @@ -1,6 +1,6 @@ - + @@ -8,25 +8,46 @@ Return cmtk version or test for presence of at least a specific version — cmtk.version • nat + - + - - + + + + + + + - + + + + + + + + - - - + + + + + + + + + + - + + + - +
    +
    -
    +
    - +

    Return cmtk version or test for presence of at least a specific version

    - +
    + +
    cmtk.version(minimum = NULL)
    -
    cmtk.version(minimum = NULL)
    - -

    Arguments

    +

    Arguments

    @@ -112,57 +142,51 @@

    Ar

    If specified checks that the cmtk version

    - +

    Value

    returns numeric_version representation of CMTK version or if minimum is not NULL, returns a logical indicating whether the installed version exceeds the current version. If CMTK is not installed returns NA.

    -

    Details

    NB this function has the side effect of setting an option nat.cmtk.version the first time that it is run in the current R session.

    -

    See also

    -

    cmtk.bindir, cmtk.dof2mat

    - +

    Examples

    -
    # NOT RUN {
    -cmtk.version()
    -cmtk.version('3.2.2')
    -# }
    +
    if (FALSE) { +cmtk.version() +cmtk.version('3.2.2') +} +
    - +
    -

    Site built with pkgdown.

    +

    Site built with pkgdown 1.6.1.

    + + + + + diff --git a/docs/reference/cmtkparams2affmat.html b/docs/reference/cmtkparams2affmat.html index 1bf947e0..9012bc0d 100644 --- a/docs/reference/cmtkparams2affmat.html +++ b/docs/reference/cmtkparams2affmat.html @@ -1,6 +1,6 @@ - + @@ -8,25 +8,46 @@ Compose homogeneous affine matrix from CMTK registration parameters — cmtkparams2affmat • nat + - + - - + + + + + + + - + + + + + + + + - - - + + + + + + + + + + - + + + - +
    +
    -
    +
    - +

    Compose homogeneous affine matrix from CMTK registration parameters

    - +
    -
    cmtkparams2affmat(params = NULL, tx = 0, ty = 0, tz = 0, rx = 0,
    -  ry = 0, rz = 0, sx = 1, sy = 1, sz = 1, shx = 0, shy = 0,
    -  shz = 0, cx = 0, cy = 0, cz = 0, legacy = NA)
    - -

    Arguments

    +
    cmtkparams2affmat(
    +  params = NULL,
    +  tx = 0,
    +  ty = 0,
    +  tz = 0,
    +  rx = 0,
    +  ry = 0,
    +  rz = 0,
    +  sx = 1,
    +  sy = 1,
    +  sz = 1,
    +  shx = 0,
    +  shy = 0,
    +  shz = 0,
    +  cx = 0,
    +  cy = 0,
    +  cz = 0,
    +  legacy = NA
    +)
    + +

    Arguments

    @@ -139,11 +185,10 @@

    Ar CMTK <=2.4.0 (default value NA implies FALSE, see details).

    - +

    Value

    4x4 homogeneous affine transformation matrix

    -

    Details

    If the legacy parameter is not set explicitly, then it will @@ -151,40 +196,38 @@

    Details otherwise.

    translation and centre components are assumed to be in physical coordinates.

    -

    See also

    -

    Other cmtk-geometry: affmat2cmtkparams, - cmtk.dof2mat, cmtk.mat2dof

    - +

    Other cmtk-geometry: +affmat2cmtkparams(), +cmtk.dof2mat(), +cmtk.mat2dof()

    - +
    -

    Site built with pkgdown.

    +

    Site built with pkgdown 1.6.1.

    + + + + + diff --git a/docs/reference/cmtkreg.html b/docs/reference/cmtkreg.html index 1e55e505..43e350cc 100644 --- a/docs/reference/cmtkreg.html +++ b/docs/reference/cmtkreg.html @@ -1,6 +1,6 @@ - + @@ -8,25 +8,53 @@ Create and test cmtkreg objects that specify path to a CMTK registration — cmtkreg • nat + - + - - + + + + + + + - + + + + + + + + - - - + + + + + + + + + + - + + + - +
    +
    -
    +
    - +

    cmtkreg creates an object of class cmtkreg that - describes one (or more) CMTK + describes one (or more) CMTK registrations. This is simply a character vector that also has class - cmtkreg. - - as.cmtkreg converts objects to class cmtkreg, - minimally just by adding an approriate class attribute. - - is.cmtkreg checks if an object is a cmtk registration + cmtkreg.

    +

    as.cmtkreg converts objects to class cmtkreg, + minimally just by adding an approriate class attribute.

    +

    is.cmtkreg checks if an object is a cmtk registration either by checking class (default), or inspecting file.

    - +
    -
    cmtkreg(x, returnDir = TRUE)
    +    
    cmtkreg(x, returnDir = TRUE)
     
    -as.cmtkreg(x, ...)
    +as.cmtkreg(x, ...)
     
     # S3 method for matrix
    -as.cmtkreg(x, ...)
    +as.cmtkreg(x, ...)
     
     # S3 method for reglist
    -as.cmtkreg(x, ...)
    +as.cmtkreg(x, ...)
     
     # S3 method for default
    -as.cmtkreg(x, ...)
    +as.cmtkreg(x, ...)
     
    -is.cmtkreg(x, filecheck = c("none", "exists", "magic"))
    - -

    Arguments

    +is.cmtkreg(x, filecheck = c("none", "exists", "magic"))
    + +

    Arguments

    @@ -150,29 +185,33 @@

    Ar value in first line of file.

    - -
    - +
    +
    -

    Site built with pkgdown.

    +

    Site built with pkgdown 1.6.1.

    + + + + + diff --git a/docs/reference/cmtkreglist.html b/docs/reference/cmtkreglist.html index ee504311..6b9f4ff4 100644 --- a/docs/reference/cmtkreglist.html +++ b/docs/reference/cmtkreglist.html @@ -1,6 +1,6 @@ - + @@ -8,25 +8,46 @@ Make in-memory CMTK registration list from affine matrix or CMTK parameters — cmtkreglist • nat + - + - - + + + + + + + - + + + + + + + + - - - + + + + + + + + + + - + + + - +
    +
    -
    +
    - +

    Make in-memory CMTK registration list from affine matrix or CMTK parameters

    - +
    -
    cmtkreglist(x, centre = c(0, 0, 0), reference = "dummy",
    -  floating = "dummy")
    - -

    Arguments

    +
    cmtkreglist(x, centre = c(0, 0, 0), reference = "dummy", floating = "dummy")
    + +

    Arguments

    @@ -123,12 +152,11 @@

    Ar

    Path to refererence and floating images.

    - +

    Value

    list of class cmtkreg containing registration parameters suitable for write.cmtkreg

    -

    Details

    Note that this uses the modern CMTK notation of floating_study @@ -137,39 +165,35 @@

    Details

    Note that the reference and floating fields have no impact on the transformation encoded in the resultant .list folder and can be overridden on the command line of CMTK tools.

    -

    See also

    -

    write.cmtkreg, affmat2cmtkparams, cmtkreg

    - +
    - +
    -

    Site built with pkgdown.

    +

    Site built with pkgdown 1.6.1.

    + + + + + diff --git a/docs/reference/coord2ind.html b/docs/reference/coord2ind.html index bc17160c..d9050f71 100644 --- a/docs/reference/coord2ind.html +++ b/docs/reference/coord2ind.html @@ -1,6 +1,6 @@ - + @@ -8,25 +8,46 @@ Find 1D indices into a 3D image given spatial coordinates — coord2ind • nat + - + - - + + + + + + + - + + + + + + + + - - - + + + + + + + + + + - + + + - +
    +
    -
    +
    - +

    Find 1D indices into a 3D image given spatial coordinates

    - +
    -
    coord2ind(coords, ...)
    +    
    coord2ind(coords, ...)
     
     # S3 method for default
    -coord2ind(coords, imdims, voxdims = NULL, origin = NULL,
    -  aperm, Clamp = FALSE, CheckRanges = !Clamp, ...)
    - -

    Arguments

    +coord2ind( + coords, + imdims, + voxdims = NULL, + origin = NULL, + aperm, + Clamp = FALSE, + CheckRanges = !Clamp, + ... +)
    + +

    Arguments

    @@ -145,56 +183,54 @@

    Ar

    whether to check if coordinates are out of range.

    - +

    Details

    coord2ind is designed to cope with any user-defined class for which an as.im3d method exists. Presently the only example in the nat.* - ecosystem is nat.templatebrains::as.im3d.templatebrain. The + ecosystem is nat.templatebrains::as.im3d.templatebrain. The existence of an as.im3d method implies that voxdims,origin, and dim functions can be called. This is the necessary information required to convert i,j,k logical indices into x,y,z spatial indices.

    -

    See also

    -

    ind2coord, sub2ind, ijkpos

    - +

    Examples

    -
    coord2ind(cbind(1,2,3), imdims = c(1024,512,218), - voxdims = c(0.622088, 0.622088, 0.622088), origin = c(0,0,0))
    #> [1] 2624515
    # NOT RUN { +
    coord2ind(cbind(1,2,3), imdims = c(1024,512,218), + voxdims = c(0.622088, 0.622088, 0.622088), origin = c(0,0,0)) +
    #> [1] 2624515
    if (FALSE) { ## repeat but using a templatebrain object to specify the coordinate system -library(nat.flybrains) -coord2ind(cbind(1,2,3), JFRC2) -# }
    +library(nat.flybrains) +coord2ind(cbind(1,2,3), JFRC2) +} +
    - +
    -

    Site built with pkgdown.

    +

    Site built with pkgdown 1.6.1.

    + + + + + diff --git a/docs/reference/dotprops-arithmetic.html b/docs/reference/dotprops-arithmetic.html index 5445b1c0..6b405df7 100644 --- a/docs/reference/dotprops-arithmetic.html +++ b/docs/reference/dotprops-arithmetic.html @@ -1,6 +1,6 @@ - + @@ -8,25 +8,46 @@ Arithmetic for dotprops objects — *.dotprops • nat + - + - - + + + + + + + - + + + + + + + + - - - + + + + + + + + + + - + + + - +
    +
    -
    +
    - +

    Arithmetic for dotprops objects

    - +
    # S3 method for dotprops
     *(x, y)
    @@ -113,8 +143,8 @@ 

    Arithmetic for dotprops objects

    # S3 method for dotprops /(x, y)
    - -

    Arguments

    + +

    Arguments

    @@ -126,35 +156,36 @@

    Ar

    A scalar or 3-vector that will be applied to the dotprops object

    - +

    Value

    A new dotprops object

    -
    - +
    -

    Site built with pkgdown.

    +

    Site built with pkgdown 1.6.1.

    + + + + + diff --git a/docs/reference/dotprops.html b/docs/reference/dotprops.html index 7d84a34c..5af26794 100644 --- a/docs/reference/dotprops.html +++ b/docs/reference/dotprops.html @@ -1,6 +1,6 @@ - + @@ -8,25 +8,53 @@ dotprops: Neurons as point clouds with tangent vectors (but no connectivity) — dotprops • nat + - + - - + + + + + + + - + + + + + + + + - - - + + + + + + + + + + - + + + - +
    +
    -
    +
    - -

    dotprops: Neurons as point clouds with tangent vectors (but no connectivity) - - dotprops makes dotprops representation from raw 3D points - (extracting vertices from S3 objects that have them) - - dotprops.dotprops will default to the original vale of +

    +

    dotprops makes dotprops representation from raw 3D points + (extracting vertices from S3 objects that have them)

    +

    dotprops.dotprops will default to the original vale of k and copy over all attributes that are not set by - dotprops.default. - - dotprops.neuronlist will run for every object in the + dotprops.default.

    +

    dotprops.neuronlist will run for every object in the neuronlist using nlapply. ... arguments will be passed to nlapply in addition to the named argument OmitFailures.

    - +
    -
    is.dotprops(x)
    +    
    is.dotprops(x)
     
    -as.dotprops(x, ...)
    +as.dotprops(x, ...)
     
    -dotprops(x, ...)
    +dotprops(x, ...)
     
     # S3 method for character
    -dotprops(x, ...)
    +dotprops(x, ...)
     
     # S3 method for dotprops
    -dotprops(x, k = attr(x, "k"), ...)
    +dotprops(x, k = attr(x, "k"), ...)
     
     # S3 method for im3d
    -dotprops(x, ...)
    +dotprops(x, ...)
     
     # S3 method for neuronlist
    -dotprops(x, ..., OmitFailures = NA)
    +dotprops(x, ..., OmitFailures = NA)
     
     # S3 method for neuron
    -dotprops(x, Labels = NULL, resample = NA, ...)
    +dotprops(x, Labels = NULL, resample = NA, ...)
     
     # S3 method for default
    -dotprops(x, k = NULL, Labels = NULL, na.rm = FALSE, ...)
    - -

    Arguments

    +dotprops(x, k = NULL, Labels = NULL, na.rm = FALSE, ...)
    + +

    Arguments

    @@ -150,7 +183,7 @@

    Ar

    - @@ -162,9 +195,9 @@

    Ar

    - @@ -177,54 +210,49 @@

    Ar

    k

    Number of nearest neighbours to use for tangent vector calculation +

    Number of nearest neighbours to use for tangent vector calculation (set to k=20 when passed NULL)

    Labels

    Vector of labels for each point e.g. identifying axon vs +

    Vector of labels for each point e.g. identifying axon vs dendrite. The default value NULL will produce class-specific default -behaviour for different classes of input object, TRUE always uses +behaviour for different classes of input object, TRUE always uses labels when an incoming object has them and FALSE never uses labels.

    Whether to remove NA points (default FALSE)

    - +

    Details

    k will default to 20 nearest neighbours when unset (i.e. when it has default value of NA) unless x is a dotprops object (when the original value of k is reused).

    -

    References

    -

    The dotprops format is essentially identical to that developed - in:

    -

    Masse N.Y., Cachero S., Ostrovsky A., and Jefferis G.S.X.E. (2012). A +

    The dotprops format is essentially identical to that developed + in:

    +

    Masse N.Y., Cachero S., Ostrovsky A., and Jefferis G.S.X.E. (2012). A mutual information approach to automate identification of neuronal clusters in Drosophila brain images. Frontiers in Neuroinformatics 6 (00021). - doi: 10.3389/fninf.2012.00021

    - + doi: 10.3389/fninf.2012.00021

    See also

    -

    nlapply

    - +
    - +
    -

    Site built with pkgdown.

    +

    Site built with pkgdown 1.6.1.

    + + + + + diff --git a/docs/reference/fileformats.html b/docs/reference/fileformats.html index 6285df40..2c5e31af 100644 --- a/docs/reference/fileformats.html +++ b/docs/reference/fileformats.html @@ -1,6 +1,6 @@ - + @@ -8,25 +8,51 @@ Set or return list of registered file formats that we can read — fileformats • nat + - + - - + + + + + + + - + + + + + + + + - - - + + + + + + + + + + - + + + - +
    +
    -
    +
    - +

    fileformats returns format names, a format definition list or a table of information about the formats that match the given - filter conditions. - - registerformat registers a format in the io registry - - getformatreader gets the function to read a file - - getformatwriter gets the function to write a file

    - - -
    fileformats(format = NULL, ext = NULL, read = NULL, write = NULL,
    -  class = NULL, rval = c("names", "info", "all"))
    -
    -registerformat(format = NULL, ext = format, read = NULL, write = NULL,
    -  magic = NULL, magiclen = NA_integer_, class = NULL)
    -
    -getformatreader(file, class = NULL)
    +  filter conditions.

    +

    registerformat registers a format in the io registry

    +

    getformatreader gets the function to read a file

    +

    getformatwriter gets the function to write a file

    +
    -getformatwriter(format = NULL, file = NULL, ext = NULL, class = NULL) - -

    Arguments

    +
    fileformats(
    +  format = NULL,
    +  ext = NULL,
    +  read = NULL,
    +  write = NULL,
    +  class = NULL,
    +  rval = c("names", "info", "all")
    +)
    +
    +registerformat(
    +  format = NULL,
    +  ext = format,
    +  read = NULL,
    +  write = NULL,
    +  magic = NULL,
    +  magiclen = NA_integer_,
    +  class = NULL
    +)
    +
    +getformatreader(file, class = NULL)
    +
    +getformatwriter(format = NULL, file = NULL, ext = NULL, class = NULL)
    + +

    Arguments

    @@ -158,7 +203,7 @@

    Ar

    Path to a file

    - +

    Value

    @@ -166,22 +211,20 @@

    Value

  • fileformats returns a character vector, matrix or list according to the value of rval.

  • getformatreader returns a list. The reader can be accessed - with $read and the format can be acessed by $format.

  • + with $read and the format can be accessed by $format.

  • getformatwriter returns a list. The writer can be accessed with $write.

  • -

    Details

    if a format argument is passed to fileformats it will - be matched wigth partial string matching and iif a unique match exists that - will be returned. - getformatreader starts by reading a set number of bytes from + be matched with partial string matching and if a unique match exists that + will be returned.

    +

    getformatreader starts by reading a set number of bytes from the start off the current file and then checks using file extension and magic functions to see if it can identify the file. Presently formats are in a queue in alphabetical order, dispatching on the first match.

    -

    getformatwriter output file

    If getformatwriter is passed a @@ -202,15 +245,14 @@

    See also

    -

    write.neuron

    - +

    Examples

    # information about the currently registered file formats -fileformats(rval='info')
    #> format class ext read write magic +fileformats(rval='info') +
    #> format class ext read write magic #> 1 amiralandmarks landmarks .landmarkAscii TRUE TRUE TRUE #> 2 amiralandmarks landmarks .landmarkBin TRUE TRUE TRUE #> 3 amiralandmarks landmarks .am TRUE TRUE TRUE @@ -235,44 +277,40 @@

    Examp #> 22 swcng ngraph .swc TRUE FALSE FALSE #> 23 vaa3draw im3d .v3d TRUE FALSE TRUE #> 24 vaa3draw im3d .v3draw TRUE FALSE TRUE -#> 25 vtk neuron .vtk FALSE TRUE FALSE

    # NOT RUN { -registerformat("swc",read=read.swc,write=read.swc,magic=is.swc,magiclen=10, - class='neuron') -# }
    swc=tempfile(fileext = '.swc') -write.neuron(Cell07PNs[[1]], swc) -stopifnot(isTRUE(getformatreader(swc)$format=='swc')) -unlink(swc)
    +#> 25 vtk neuron .vtk FALSE TRUE FALSE
    if (FALSE) { +registerformat("swc",read=read.swc,write=read.swc,magic=is.swc,magiclen=10, + class='neuron') +} +swc=tempfile(fileext = '.swc') +write.neuron(Cell07PNs[[1]], swc) +stopifnot(isTRUE(getformatreader(swc)$format=='swc')) +unlink(swc) +
    - +
    -

    Site built with pkgdown.

    +

    Site built with pkgdown 1.6.1.

    + + + + + diff --git a/docs/reference/find.neuron.html b/docs/reference/find.neuron.html index 74e701b4..bd8d5dd9 100644 --- a/docs/reference/find.neuron.html +++ b/docs/reference/find.neuron.html @@ -1,6 +1,6 @@ - + @@ -8,25 +8,46 @@ Find neurons within a 3D selection box (usually drawn in rgl window) — find.neuron • nat + - + - - + + + + + + + - + + + + + + + + - - - + + + + + + + + + + - + + + - +
    +
    -
    +
    - +

    Find neurons within a 3D selection box (usually drawn in rgl window)

    - +
    + +
    find.neuron(
    +  sel3dfun = select3d(),
    +  indices = names(db),
    +  db = getOption("nat.default.neuronlist"),
    +  threshold = 0,
    +  invert = FALSE,
    +  rval = c("names", "data.frame", "neuronlist")
    +)
    -
    find.neuron(sel3dfun = select3d(), indices = names(db),
    -  db = getOption("nat.default.neuronlist"), threshold = 0, invert = FALSE,
    -  rval = c("names", "data.frame", "neuronlist"))
    - -

    Arguments

    +

    Arguments

    @@ -121,7 +156,7 @@

    Ar

    +the neuronlist. Defaults to options('nat.default.neuronlist').

    @@ -137,64 +172,58 @@

    Ar

    db

    neuronlist to search. Can also be a character vector naming -the neuronlist. Defaults to options('nat.default.neuronlist').

    threshold

    What to return (character vector, default='names')

    - +

    Value

    Character vector of names of selected neurons, neuronlist, or data.frame of attached metadata according to the value of rval.

    -

    Details

    Uses subset.neuronlist, so can work on dotprops or neuron lists.

    -

    See also

    -

    select3d, find.soma, subset.neuronlist

    - +

    Examples

    -
    # NOT RUN {
    -plot3d(kcs20)
    +    
    if (FALSE) { +plot3d(kcs20) # draw a 3D selection e.g. around tip of vertical lobe when ready -find.neuron(db=kcs20) +find.neuron(db=kcs20) # would return 9 neurons # make a standalone selection function -vertical_lobe=select3d() -find.neuron(vertical_lobe, db=kcs20) +vertical_lobe=select3d() +find.neuron(vertical_lobe, db=kcs20) # use base::Negate function to invert the selection function # i.e. choose neurons that do not overlap the selection region -find.neuron(Negate(vertical_lobe), db=kcs20) -# }
    +find.neuron(Negate(vertical_lobe), db=kcs20) +} +
    - +
    -

    Site built with pkgdown.

    +

    Site built with pkgdown 1.6.1.

    + + + + + diff --git a/docs/reference/find.soma.html b/docs/reference/find.soma.html index 614f8072..bf9015d1 100644 --- a/docs/reference/find.soma.html +++ b/docs/reference/find.soma.html @@ -1,6 +1,6 @@ - + @@ -8,25 +8,46 @@ Find neurons with soma inside 3D selection box (usually drawn in rgl window) — find.soma • nat + - + - - + + + + + + + - + + + + + + + + - - - + + + + + + + + + + - + + + - +
    +
    -
    +
    - +

    Find neurons with soma inside 3D selection box (usually drawn in rgl window)

    - +
    -
    find.soma(sel3dfun = select3d(), indices = names(db),
    -  db = getOption("nat.default.neuronlist"), invert = FALSE,
    -  rval = c("names", "neuronlist", "data.frame"))
    - -

    Arguments

    +
    find.soma(
    +  sel3dfun = select3d(),
    +  indices = names(db),
    +  db = getOption("nat.default.neuronlist"),
    +  invert = FALSE,
    +  rval = c("names", "neuronlist", "data.frame")
    +)
    + +

    Arguments

    @@ -121,7 +155,7 @@

    Ar

    +the neuronlist. Defaults to options('nat.default.neuronlist').

    @@ -133,49 +167,44 @@

    Ar

    db

    neuronlist to search. Can also be a character vector naming -the neuronlist. Defaults to options('nat.default.neuronlist').

    invert

    What to return (character vector, default='names')

    - +

    Value

    Character vector of names of selected neurons

    -

    Details

    Can work on neuronlists containing neuron objects or neuronlists whose attached data.frame contains soma positions specified in columns called X,Y,Z .

    -

    See also

    -

    select3d, subset.neuronlist, find.neuron

    - +
    - +
    -

    Site built with pkgdown.

    +

    Site built with pkgdown 1.6.1.

    + + + + + diff --git a/docs/reference/flip.html b/docs/reference/flip.html index 27374fe8..8b014212 100644 --- a/docs/reference/flip.html +++ b/docs/reference/flip.html @@ -1,6 +1,6 @@ - + @@ -8,25 +8,46 @@ Flip an array, matrix or vector about an axis — flip • nat + - + - - + + + + + + + - + + + + + + + + - - - + + + + + + + + + + - + + + - +
    +
    -
    +
    - +

    Flip an array, matrix or vector about an axis

    - +
    -
    flip(x, ...)
    +    
    flip(x, ...)
     
     # S3 method for array
    -flip(x, flipdim = "X", ...)
    - -

    Arguments

    +flip(x, flipdim = "X", ...)
    + +

    Arguments

    @@ -125,38 +155,39 @@

    Ar dimensions 1, 2, 3.

    - +

    Details

    Note that dimensions 1 and 2 for R matrices will be rows and columns, respectively, which does not map easily onto the intuition of a 2D image matrix where the X axis would typically be thought of as running from left to right on the page and the Y axis would run from top to bottom.

    -
    - +
    -

    Site built with pkgdown.

    +

    Site built with pkgdown 1.6.1.

    + + + + + diff --git a/docs/reference/get-set-neuronlist-data.frame.html b/docs/reference/get-set-neuronlist-data.frame.html index 2438f984..020163bc 100644 --- a/docs/reference/get-set-neuronlist-data.frame.html +++ b/docs/reference/get-set-neuronlist-data.frame.html @@ -1,6 +1,6 @@ - + @@ -8,25 +8,50 @@ Get or set the attached data.frame of a neuronlist — as.data.frame.neuronlist • nat + - + - - + + + + + + + - + + + + + + + + - - - + + + + + + + + + + - + + + - +
    +
    -
    +
    - +

    For as.data.frame, when there is no attached data.frame the result will be a data.frame with 0 columns but an appropriate number of rows, named by -the objects in the neuronlist. - - data.frame<- methods set the data frame attached to an +the objects in the neuronlist.

    +

    data.frame<- methods set the data frame attached to an object. At present this is only used for neuronlist objects.

    - +
    # S3 method for neuronlist
    -as.data.frame(x, row.names = names(x),
    -  optional = FALSE, ...)
    +as.data.frame(x, row.names = names(x), optional = FALSE, ...)
     
    -data.frame(x) <- value
    +data.frame(x) <- value
     
     # S3 method for neuronlist
    -data.frame(x) <- value
    - -

    Arguments

    +data.frame(x) <- value + +

    Arguments

    @@ -134,7 +166,7 @@

    Ar

    - @@ -142,7 +174,7 @@

    Ar

    ...

    additional arguments passed to data.frame (see +

    additional arguments passed to data.frame (see examples)

    The new data.frame to be attached to x

    - +

    Value

    for as.data.frame.neuronlist, a data.frame with @@ -150,14 +182,13 @@

    Value

    the attached data.frame, when present.

    for data.frame<-.neuronlist, a neuronlist with the attached data.frame.

    -

    See also

    -

    data.frame, neuronlist

    - +

    Examples

    -
    head(as.data.frame(kcs20))
    #> gene_name Name idid soma_side +
    #> gene_name Name idid soma_side #> FruMARCM-M001205_seg002 FruMARCM-M001205_seg002 fru-M-500112 1024 L #> GadMARCM-F000122_seg001 GadMARCM-F000122_seg001 Gad1-F-900005 10616 L #> GadMARCM-F000050_seg001 GadMARCM-F000050_seg001 Gad1-F-100010 8399 R @@ -179,7 +210,8 @@

    Examp #> FruMARCM-F000270_seg001 FruMARCM-F000270_seg001 64 1331 ab #> FruMARCM-F001115_seg002 FruMARCM-F001115_seg002 44 795 ab

    # add additional variables -str(as.data.frame(kcs20, i=seq(kcs20), abc=LETTERS[seq(kcs20)]))
    #> 'data.frame': 20 obs. of 16 variables: +str(as.data.frame(kcs20, i=seq(kcs20), abc=LETTERS[seq(kcs20)])) +
    #> 'data.frame': 20 obs. of 16 variables: #> $ gene_name: chr "FruMARCM-M001205_seg002" "GadMARCM-F000122_seg001" "GadMARCM-F000050_seg001" "GadMARCM-F000142_seg002" ... #> $ Name : chr "fru-M-500112" "Gad1-F-900005" "Gad1-F-100010" "Gad1-F-300043" ... #> $ idid : num 1024 10616 8399 10647 9758 ... @@ -195,10 +227,11 @@

    Examp #> $ idx : int 156 1519 1132 1535 1331 795 268 1265 898 190 ... #> $ type : Factor w/ 3 levels "ab","apbp","gamma": 3 3 1 2 1 1 1 2 2 1 ... #> $ i : int 1 2 3 4 5 6 7 8 9 10 ... -#> $ abc : Factor w/ 20 levels "A","B","C","D",..: 1 2 3 4 5 6 7 8 9 10 ...

    # stop character columns being turned into factors -newdf <- as.data.frame(kcs20, i=seq(kcs20), abc=LETTERS[seq(kcs20)], - stringsAsFactors=FALSE) -str(newdf)
    #> 'data.frame': 20 obs. of 16 variables: +#> $ abc : chr "A" "B" "C" "D" ...
    # stop character columns being turned into factors +newdf <- as.data.frame(kcs20, i=seq(kcs20), abc=LETTERS[seq(kcs20)], + stringsAsFactors=FALSE) +str(newdf) +
    #> 'data.frame': 20 obs. of 16 variables: #> $ gene_name: chr "FruMARCM-M001205_seg002" "GadMARCM-F000122_seg001" "GadMARCM-F000050_seg001" "GadMARCM-F000142_seg002" ... #> $ Name : chr "fru-M-500112" "Gad1-F-900005" "Gad1-F-100010" "Gad1-F-300043" ... #> $ idid : num 1024 10616 8399 10647 9758 ... @@ -214,34 +247,33 @@

    Examp #> $ idx : int 156 1519 1132 1535 1331 795 268 1265 898 190 ... #> $ type : Factor w/ 3 levels "ab","apbp","gamma": 3 3 1 2 1 1 1 2 2 1 ... #> $ i : int 1 2 3 4 5 6 7 8 9 10 ... -#> $ abc : chr "A" "B" "C" "D" ...

    data.frame(kcs20)=newdf
    +#> $ abc : chr "A" "B" "C" "D" ...
    data.frame(kcs20)=newdf +
    - +
    -

    Site built with pkgdown.

    +

    Site built with pkgdown 1.6.1.

    + + + + + diff --git a/docs/reference/graph.nodes.html b/docs/reference/graph.nodes.html index f928109b..32a2643e 100644 --- a/docs/reference/graph.nodes.html +++ b/docs/reference/graph.nodes.html @@ -1,6 +1,6 @@ - + @@ -8,25 +8,46 @@ Return root, end, or branchpoints of an igraph object — graph.nodes • nat + - + - - + + + + + + + - + + + + + + + + - - - + + + + + + + + + + - + + + - +
    +
    -
    +
    - +

    Return root, end, or branchpoints of an igraph object

    - +
    + +
    graph.nodes(
    +  x,
    +  type = c("root", "end", "branch"),
    +  original.ids = "label",
    +  exclude.isolated = TRUE
    +)
    -
    graph.nodes(x, type = c("root", "end", "branch"), original.ids = "label",
    -  exclude.isolated = TRUE)
    - -

    Arguments

    +

    Arguments

    @@ -127,35 +161,36 @@

    Ar (default)

    - +

    Details

    Note that the graph must be directed in order to return a root point

    -
    - +
    -

    Site built with pkgdown.

    +

    Site built with pkgdown 1.6.1.

    + + + + + diff --git a/docs/reference/im3d-coords.html b/docs/reference/im3d-coords.html index cc55ec6a..5ede07ea 100644 --- a/docs/reference/im3d-coords.html +++ b/docs/reference/im3d-coords.html @@ -1,6 +1,6 @@ - + @@ -8,25 +8,47 @@ Interconvert pixel and physical coordinates — im3d-coords • nat + - + - - + + + + + + + - + + + + + + + + - - - + + + + + + + + + + - + + + - +
    +
    -
    +
    - -

    xyzpos converts pixel coordinates to physical coordinates +

    +

    xyzpos converts pixel coordinates to physical coordinates

    +

    ijkpos converts physical coordinates to pixel coordinates

    +
    - ijkpos converts physical coordinates to pixel coordinates

    - +
    xyzpos(d, ijk)
     
    -    
    xyzpos(d, ijk)
    +ijkpos(d, xyz, roundToNearestPixel = TRUE)
    -ijkpos(d, xyz, roundToNearestPixel = TRUE)
    - -

    Arguments

    +

    Arguments

    @@ -129,55 +159,59 @@

    Ar nearest integer value (i.e. nearest pixel). default: TRUE

    - +

    Value

    Nx3 matrix of physica l or pixel coordinates

    -

    See also

    -

    ind2coord

    -

    Other im3d: as.im3d, - boundingbox, im3d-io, - im3d, imexpand.grid, - imslice, is.im3d, - mask, origin, - projection, threshold, - unmask, voxdims

    - +

    ind2coord

    +

    Other im3d: +as.im3d(), +boundingbox(), +im3d-io, +im3d(), +imexpand.grid(), +imslice(), +is.im3d(), +mask(), +origin(), +projection(), +threshold(), +unmask(), +voxdims()

    Examples

    # make an emty im3d -d=im3d(,dim=c(20,30,40),origin=c(10,20,30),voxdims=c(1,2,3)) +d=im3d(,dim=c(20,30,40),origin=c(10,20,30),voxdims=c(1,2,3)) # check round trip for origin -stopifnot(all.equal(ijkpos(d,xyzpos(d,c(1,1,1))), c(1,1,1)))
    +stopifnot(all.equal(ijkpos(d,xyzpos(d,c(1,1,1))), c(1,1,1))) +
    - +
    -

    Site built with pkgdown.

    +

    Site built with pkgdown 1.6.1.

    + + + + + diff --git a/docs/reference/im3d-io.html b/docs/reference/im3d-io.html index 4d528820..1b5a871c 100644 --- a/docs/reference/im3d-io.html +++ b/docs/reference/im3d-io.html @@ -1,6 +1,6 @@ - + @@ -8,25 +8,46 @@ Read/Write calibrated 3D blocks of image data — im3d-io • nat + - + - - + + + + + + + - + + + + + + + + - - - + + + + + + + + + + - + + + - +
    +
    -
    +
    - +

    Read/Write calibrated 3D blocks of image data

    - +
    + +
    read.im3d(
    +  file,
    +  ReadData = TRUE,
    +  SimplifyAttributes = FALSE,
    +  ReadByteAsRaw = FALSE,
    +  ...
    +)
     
    -    
    read.im3d(file, ReadData = TRUE, SimplifyAttributes = FALSE,
    -  ReadByteAsRaw = FALSE, ...)
    +write.im3d(x, file, format = NULL, ...)
    -write.im3d(x, file, format = NULL, ...)
    - -

    Arguments

    +

    Arguments

    @@ -125,7 +160,7 @@

    Ar

    - @@ -145,12 +180,11 @@

    Ar file extension. See getformatwriter for details.

    ReadByteAsRaw

    Whether to read byte values as R raw +

    Whether to read byte values as R raw arrays. These occupy 1/4 memory but arithmetic is less convenient. (default: FALSE)

    - +

    Value

    For read.im3d an objecting inheriting from base array and im3d classes.

    -

    Details

    Currently only nrrd and amira formats are implemented. Furthermore @@ -159,54 +193,56 @@

    Details

    The core attributes of an im3d object are BoundingBox, origin, x, y , z where x, y, z are the locations of samples in the x, y and z image axes (which are assumed to be orthogonsl).

    -

    See also

    -

    read.nrrd, read.amiramesh - write.nrrd, getformatwriter

    -

    Other im3d: as.im3d, - boundingbox, im3d-coords, - im3d, imexpand.grid, - imslice, is.im3d, - mask, origin, - projection, threshold, - unmask, voxdims

    - +

    Examples

    -
    # NOT RUN {
    +    
    if (FALSE) { # read attributes of vaa3d raw file -read.im3d("L1DS1_crop_straight.raw", ReadData = F, chan=2) -# }
    +read.im3d("L1DS1_crop_straight.raw", ReadData = F, chan=2) +} +
    - +
    -

    Site built with pkgdown.

    +

    Site built with pkgdown 1.6.1.

    + + + + + diff --git a/docs/reference/im3d.html b/docs/reference/im3d.html index 16d6e792..d076c182 100644 --- a/docs/reference/im3d.html +++ b/docs/reference/im3d.html @@ -1,6 +1,6 @@ - + @@ -8,25 +8,51 @@ Construct an im3d object representing 3D image data, densities etc — im3d • nat + - + - - + + + + + + + - + + + + + + + + - - - + + + + + + + + + + - + + + - +
    +
    -
    +
    - +

    im3d objects consist of a data array with attributes defining the spatial positions at which the voxels are located. There should always be a BoundingBox attribute which defines the physical extent of the volume in the same manner as the Amira 3D visualisation and analysis software. This corresponds to the node centers option in the NRRD format.

    - +
    -
    im3d(x = numeric(0), dims = NULL, voxdims = NULL, origin = NULL,
    -  BoundingBox = NULL, bounds = NULL, ...)
    - -

    Arguments

    +
    im3d(
    +  x = numeric(0),
    +  dims = NULL,
    +  voxdims = NULL,
    +  origin = NULL,
    +  BoundingBox = NULL,
    +  bounds = NULL,
    +  ...
    +)
    + +

    Arguments

    @@ -123,7 +165,7 @@

    Ar or as an im3d object, whose attributes will provide defaults for dims, origin, BoundingBox, bounds arguments. The default (dims=NULL) will result in dims being set to x if -x is an im3d object or dim(x) otherwise.

    +x is an im3d object or dim(x) otherwise.

    @@ -143,54 +185,56 @@

    Ar

    voxdims

    Additional attributes such as units or materials

    - +

    Value

    An array with additional class im3d

    -

    Details

    We follow Amira's convention of setting the bounding box equal to voxel dimension (rather than 0) for any dimension with only 1 voxel.

    -

    See also

    -

    Other im3d: as.im3d, - boundingbox, im3d-coords, - im3d-io, imexpand.grid, - imslice, is.im3d, - mask, origin, - projection, threshold, - unmask, voxdims

    - +

    Other im3d: +as.im3d(), +boundingbox(), +im3d-coords, +im3d-io, +imexpand.grid(), +imslice(), +is.im3d(), +mask(), +origin(), +projection(), +threshold(), +unmask(), +voxdims()

    - +
    -

    Site built with pkgdown.

    +

    Site built with pkgdown 1.6.1.

    + + + + + diff --git a/docs/reference/image.im3d.html b/docs/reference/image.im3d.html index 25a6f5a8..1c5a6f1c 100644 --- a/docs/reference/image.im3d.html +++ b/docs/reference/image.im3d.html @@ -1,6 +1,6 @@ - + @@ -8,25 +8,46 @@ Method to plot spatially calibrated image arrays — image.im3d • nat + - + - - + + + + + + + - + + + + + + + + - - - + + + + + + + + + + - + + + - +
    +
    -
    +
    - +

    Method to plot spatially calibrated image arrays

    - +
    # S3 method for im3d
    -image(x, xlim = NULL, ylim = NULL, zlim = NULL,
    -  plotdims = NULL, flipdims = "y", filled.contour = FALSE, asp = 1,
    -  axes = FALSE, xlab = NULL, ylab = NULL, nlevels = 20,
    -  levels = pretty(zlim, nlevels + 1),
    -  color.palette = colorRampPalette(c("navy", "cyan", "yellow", "red")),
    -  col = color.palette(length(levels) - 1), useRaster = NULL, ...)
    - -

    Arguments

    +image( + x, + xlim = NULL, + ylim = NULL, + zlim = NULL, + plotdims = NULL, + flipdims = "y", + filled.contour = FALSE, + asp = 1, + axes = FALSE, + xlab = NULL, + ylab = NULL, + nlevels = 20, + levels = pretty(zlim, nlevels + 1), + color.palette = colorRampPalette(c("navy", "cyan", "yellow", "red")), + col = color.palette(length(levels) - 1), + useRaster = NULL, + ... +) + +

    Arguments

    @@ -134,7 +177,7 @@

    Ar

    +vector). Defaults to c('x','y')

    @@ -143,8 +186,8 @@

    Ar

    - + @@ -176,24 +219,24 @@

    Ar

    - + - +dev.capabilities to see if raster images are supported.

    - - +
    plotdims

    Which dimensions of 3D im3d object to plot (character -vector). Defaults to c('x','y')

    flipdims
    filled.contour

    Whether to use a filled.contour plot -instead of a regular image plot.

    Whether to use a filled.contour plot +instead of a regular image plot.

    asp
    col

    a list of colors such as that generated by rainbow, -heat.colors, topo.colors, -terrain.colors or similar functions.

    a list of colors such as that generated by rainbow, +heat.colors, topo.colors, +terrain.colors or similar functions.

    useRaster

    Whether to use rasterImage to plot images as a +

    Whether to use rasterImage to plot images as a bitmap (much faster for large images). default useRaster=NULL checks -dev.capabilities to see if raster images are supported.

    graphical parameters for plot or -image may also be passed as arguments to this +

    ...

    graphical parameters for plot or +image may also be passed as arguments to this function.

    - +

    Value

    A list with elements:

    @@ -205,40 +248,40 @@

    Value

  • colors A character vector of colours

  • -

    Examples

    -
    # NOT RUN {
    -LHMask=read.im3d(system.file('tests/testthat/testdata/nrrd/LHMask.nrrd',package='nat'))
    -image(imslice(LHMask,10), asp=TRUE)
    +    
    if (FALSE) { +LHMask=read.im3d(system.file('tests/testthat/testdata/nrrd/LHMask.nrrd',package='nat')) +image(imslice(LHMask,10), asp=TRUE) # useRaster is appreciably quicker in most cases -image(imslice(LHMask,10), asp=TRUE, useRaster=TRUE) -# }
    +image(imslice(LHMask,10), asp=TRUE, useRaster=TRUE) +} +
    - +
    -

    Site built with pkgdown.

    +

    Site built with pkgdown 1.6.1.

    + + + + + diff --git a/docs/reference/imexpand.grid.html b/docs/reference/imexpand.grid.html index 3488d12a..6c56b1df 100644 --- a/docs/reference/imexpand.grid.html +++ b/docs/reference/imexpand.grid.html @@ -1,6 +1,6 @@ - + @@ -8,25 +8,46 @@ Convert locations of im3d voxel grid into XYZ coordinates — imexpand.grid • nat + - + - - + + + + + + + - + + + + + + + + - - - + + + + + + + + + + - + + + - +
    +
    -
    +
    - +

    Convert locations of im3d voxel grid into XYZ coordinates

    - +
    -
    imexpand.grid(d)
    - -

    Arguments

    +
    imexpand.grid(d)
    + +

    Arguments

    @@ -112,26 +142,32 @@

    Ar

    An im3d object

    - +

    Value

    Nx3 matrix of image coordinates

    -

    See also

    -

    expand.grid

    -

    Other im3d: as.im3d, - boundingbox, im3d-coords, - im3d-io, im3d, - imslice, is.im3d, - mask, origin, - projection, threshold, - unmask, voxdims

    - +

    expand.grid

    +

    Other im3d: +as.im3d(), +boundingbox(), +im3d-coords, +im3d-io, +im3d(), +imslice(), +is.im3d(), +mask(), +origin(), +projection(), +threshold(), +unmask(), +voxdims()

    Examples

    -
    d=im3d(,dim=c(2,3,2),origin=c(10,20,30),voxdims=c(1,2,3)) -imexpand.grid(d)
    #> [,1] [,2] [,3] +
    d=im3d(,dim=c(2,3,2),origin=c(10,20,30),voxdims=c(1,2,3)) +imexpand.grid(d) +
    #> [,1] [,2] [,3] #> [1,] 10 20 30 #> [2,] 11 20 30 #> [3,] 10 22 30 @@ -145,32 +181,30 @@

    Examp #> [11,] 10 24 33 #> [12,] 11 24 33

    - +
    -

    Site built with pkgdown.

    +

    Site built with pkgdown 1.6.1.

    + + + + + diff --git a/docs/reference/imscalebar.html b/docs/reference/imscalebar.html index 34bdcbd8..6bfd6a15 100644 --- a/docs/reference/imscalebar.html +++ b/docs/reference/imscalebar.html @@ -1,6 +1,6 @@ - + @@ -8,25 +8,46 @@ Make a scalebar to accompany an image.im3d plot — imscalebar • nat + - + - - + + + + + + + - + + + + + + + + - - - + + + + + + + + + + - + + + - +
    +
    -
    +
    - +

    Make a scalebar to accompany an image.im3d plot

    - +
    -
    imscalebar(levels, col, nlevels = NULL, zlim = NULL, horizontal = TRUE,
    -  lab = "Density", mar = c(4, 2, 2, 2) + 0.1, border = NULL, ...)
    - -

    Arguments

    +
    imscalebar(
    +  levels,
    +  col,
    +  nlevels = NULL,
    +  zlim = NULL,
    +  horizontal = TRUE,
    +  lab = "Density",
    +  mar = c(4, 2, 2, 2) + 0.1,
    +  border = NULL,
    +  ...
    +)
    + +

    Arguments

    @@ -142,48 +181,51 @@

    Ar

    - - +
    border

    Color for rectangle border (see rect's +

    Color for rectangle border (see rect's border argument for details).

    ...

    Additional arguments for plot

    - +

    Examples

    -
    # NOT RUN {
    -LHMask=read.im3d(system.file('tests/testthat/testdata/nrrd/LHMask.nrrd',package='nat'))
    -op=par(no.readonly = TRUE)
    -layout(matrix(c(1, 2), ncol = 2L), widths = c(1, 0.2))
    -rval=image(imslice(LHMask,10), asp=TRUE)
    -imscalebar(rval)
    -par(op)
    -# }
    +
    if (FALSE) { +LHMask=read.im3d(system.file('tests/testthat/testdata/nrrd/LHMask.nrrd',package='nat')) +op=par(no.readonly = TRUE) +layout(matrix(c(1, 2), ncol = 2L), widths = c(1, 0.2)) +rval=image(imslice(LHMask,10), asp=TRUE) +imscalebar(rval) +par(op) +} +
    - +
    -

    Site built with pkgdown.

    +

    Site built with pkgdown 1.6.1.

    + + + + + diff --git a/docs/reference/imslice.html b/docs/reference/imslice.html index 4538f7d7..02c1403a 100644 --- a/docs/reference/imslice.html +++ b/docs/reference/imslice.html @@ -1,6 +1,6 @@ - + @@ -8,25 +8,46 @@ Slice out a 3D subarray (or 2d matrix) from a 3D image array — imslice • nat + - + - - + + + + + + + - + + + + + + + + - - - + + + + + + + + + + - + + + - +
    +
    -
    +
    - +

    Slice out a 3D subarray (or 2d matrix) from a 3D image array

    - +
    -
    imslice(x, slice, slicedim = "z", drop = TRUE)
    - -

    Arguments

    +
    imslice(x, slice, slicedim = "z", drop = TRUE)
    + +

    Arguments

    @@ -126,48 +156,53 @@

    Ar conveting 3D array to 2d matrix.

    - +

    Details

    Note the sample locations stored in the x,y,z attributes will be updated appropriately. FIXME: Should we also update bounding box?

    -

    See also

    -

    Other im3d: as.im3d, - boundingbox, im3d-coords, - im3d-io, im3d, - imexpand.grid, is.im3d, - mask, origin, - projection, threshold, - unmask, voxdims

    - +

    Other im3d: +as.im3d(), +boundingbox(), +im3d-coords, +im3d-io, +im3d(), +imexpand.grid(), +is.im3d(), +mask(), +origin(), +projection(), +threshold(), +unmask(), +voxdims()

    - +
    -

    Site built with pkgdown.

    +

    Site built with pkgdown 1.6.1.

    + + + + + diff --git a/docs/reference/ind2coord.html b/docs/reference/ind2coord.html index 2d25fcbc..9bb23468 100644 --- a/docs/reference/ind2coord.html +++ b/docs/reference/ind2coord.html @@ -1,6 +1,6 @@ - + @@ -8,25 +8,49 @@ Find XYZ coords corresponding to 1D indices into a 3D image — ind2coord • nat + - + - - + + + + + + + - + + + + + + + + - - - + + + + + + + + + + - + + + - +
    +
    -
    +
    - +

    If you have an image-like object and you want to turn it into a matrix of 3D coords then you need ind2coord. For the reverse operation we offer as.im3d.matrix which allows you to turn a matrix of 3D coordinates into an im3d image object.

    - +
    -
    ind2coord(inds, ...)
    +    
    ind2coord(inds, ...)
     
     # S3 method for default
    -ind2coord(inds, dims, voxdims, origin, ...)
    +ind2coord(inds, dims, voxdims, origin, ...)
     
     # S3 method for array
    -ind2coord(inds, voxdims = NULL, origin = NULL, ...)
    +ind2coord(inds, voxdims = NULL, origin = NULL, ...)
     
     # S3 method for im3d
    -ind2coord(inds, voxdims = NULL, origin = NULL, ...)
    - -

    Arguments

    +ind2coord(inds, voxdims = NULL, origin = NULL, ...)
    + +

    Arguments

    @@ -141,36 +174,37 @@

    Ar

    the origin.

    - +

    See also

    -

    coord2ind, sub2ind, - xyzpos, as.im3d.matrix

    - +
    - +
    -

    Site built with pkgdown.

    +

    Site built with pkgdown 1.6.1.

    + + + + + diff --git a/docs/reference/index.html b/docs/reference/index.html index e42083fc..a94b8075 100644 --- a/docs/reference/index.html +++ b/docs/reference/index.html @@ -1,6 +1,6 @@ - + @@ -8,25 +8,45 @@ Function reference • nat + - + - - + + + + + + + - + + + + + + + + - - - + + + + + + + + + - + + + - +
    +
    -
    -
    +
    +
    -
    - +
    - - - - + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -

    Package Help

    -

    Provides an overview of key functions and classes

    -
    -

    -

    Analyse 3D biological image data especially neurons

    -

    Neurons (traced)

    -

    Functions for working with traced neurons (fully connected tree structures)

    -
    -

    neuron is.neuron as.neuron

    -

    neuron: class to represent traced neurons

    -

    read.neuron

    -

    Read a single neuron from a file

    -

    write.neuron

    -

    Write out a neuron in any of the file formats we know about

    -

    plot

    -

    Plot a 2D projection of a neuron

    -

    subset

    -

    Subset neuron by keeping only vertices that match given conditions

    -

    prune

    -

    prune an object by removing points near (or far) from a target object

    -

    prune_vertices prune_edges

    -

    Prune selected vertices or edges from a neuron

    -

    -

    Arithmetic for neuron coordinates

    -

    scale

    -

    Scale and centre neuron 3D coordinates

    -

    resample

    -

    Resample an object with a new spacing

    -

    smooth_neuron smooth_segment_gauss

    -

    Smooth the 3D coordinates of a neuron skeleton

    -

    potential_synapses

    -

    Calculate number of potential synapses between two neurons

    -

    normalise_swc

    -

    Normalise an SWC format block of neuron morphology data

    -

    Neurons (as graphs)

    -

    Functions for working with the graph structure of neurons

    -
    -

    ngraph as.ngraph

    -

    ngraph: a graph to encode a neuron's connectivity

    -

    graph.nodes

    -

    Return root, end, or branchpoints of an igraph object

    -

    prune_strahler

    -

    Prune a neuron by removing segments with a given Strahler order

    -

    rootpoints branchpoints endpoints

    -

    Return the root or branch points of a neuron or graph

    -

    seglengths

    -

    Calculate length of all segments in neuron

    -

    seglist as.seglist

    -

    Make/convert neuron connectivity information into a seglist object

    -

    seglist2swc

    -

    Recalculate Neurons's SWCData using SegList and point information

    -

    segmentgraph

    -

    Return a simplified segment graph for a neuron

    -

    spine

    -

    Compute the longest path (aka spine or backbone) of a neuron

    -

    strahler_order

    -

    Find the Strahler order of each point in a neuron

    -

    Skeletonised Neurons (dotprops aka vector cloud)

    -

    Functions for working with skeletonised neurons consisting of unconnected vectors rather than a fully connected tree.

    -
    -

    is.dotprops as.dotprops dotprops

    -

    dotprops: Neurons as point clouds with tangent vectors (but no connectivity)

    -

    subset

    -

    Subset points in dotprops object that match given conditions

    -

    -

    Arithmetic for dotprops objects

    -

    Collections of Neurons (neuronlists)

    -

    Functions for working with collections of neurons, which are packaged as neuronlist objects with an attached data.frame containing metadata.

    -
    -

    neuronlist

    -

    Create a neuronlist from zero or more neurons

    -

    read.neurons

    -

    Read one or more neurons from file to a neuronlist in memory

    -

    write.neurons

    -

    Write neurons from a neuronlist object to individual files, or a zip archive

    -

    nlapply nmapply

    -

    lapply and mapply for neuronlists (with optional parallelisation)

    -

    plot

    -

    2D plots of the elements in a neuronlist, optionally using a subset +

    +

    Package Help

    +

    Provides an overview of key functions and classes

    +
    +

    nat-package

    +

    Analyse 3D biological image data especially neurons

    +

    Neurons (traced)

    +

    Functions for working with traced neurons (fully connected tree structures)

    +
    +

    neuron() is.neuron() as.neuron()

    +

    neuron: class to represent traced neurons

    +

    read.neuron()

    +

    Read a single neuron from a file

    +

    write.neuron()

    +

    Write out a neuron in any of the file formats we know about

    +

    plot(<neuron>)

    +

    Plot a 2D projection of a neuron

    +

    subset(<neuron>)

    +

    Subset neuron by keeping only vertices that match given conditions

    +

    prune()

    +

    prune an object by removing points near (or far) from a target object

    +

    prune_vertices() prune_edges()

    +

    Prune selected vertices or edges from a neuron

    +

    `*`(<neuron>) `+`(<neuron>) `-`(<neuron>) `/`(<neuron>)

    +

    Arithmetic for neuron coordinates

    +

    scale(<neuron>) scale(<dotprops>)

    +

    Scale and centre neuron 3D coordinates

    +

    resample()

    +

    Resample an object with a new spacing

    +

    smooth_neuron() smooth_segment_gauss()

    +

    Smooth the 3D coordinates of a neuron skeleton

    +

    potential_synapses()

    +

    Calculate number of potential synapses between two neurons

    +

    normalise_swc()

    +

    Normalise an SWC format block of neuron morphology data

    +

    Neurons (as graphs)

    +

    Functions for working with the graph structure of neurons

    +
    +

    ngraph() as.ngraph()

    +

    ngraph: a graph to encode a neuron's connectivity

    +

    graph.nodes()

    +

    Return root, end, or branchpoints of an igraph object

    +

    prune_strahler()

    +

    Prune a neuron by removing segments with a given Strahler order

    +

    rootpoints() branchpoints() endpoints()

    +

    Return the root or branch points of a neuron or graph

    +

    seglengths()

    +

    Calculate length of all segments in neuron

    +

    seglist() as.seglist()

    +

    Make/convert neuron connectivity information into a seglist object

    +

    seglist2swc()

    +

    Recalculate Neurons's SWCData using SegList and point information

    +

    segmentgraph()

    +

    Return a simplified segment graph for a neuron

    +

    spine()

    +

    Compute the longest path (aka spine or backbone) of a neuron

    +

    strahler_order()

    +

    Find the Strahler order of each point in a neuron

    +

    Skeletonised Neurons (dotprops aka vector cloud)

    +

    Functions for working with skeletonised neurons consisting of unconnected vectors rather than a fully connected tree.

    +
    +

    is.dotprops() as.dotprops() dotprops()

    +

    dotprops: Neurons as point clouds with tangent vectors (but no connectivity)

    +

    subset(<dotprops>)

    +

    Subset points in dotprops object that match given conditions

    +

    `*`(<dotprops>) `+`(<dotprops>) `-`(<dotprops>) `/`(<dotprops>)

    +

    Arithmetic for dotprops objects

    +

    Collections of Neurons (neuronlists)

    +

    Functions for working with collections of neurons, which are packaged as neuronlist objects with an attached data.frame containing metadata.

    +
    +

    neuronlist()

    +

    Create a neuronlist from zero or more neurons

    +

    read.neurons()

    +

    Read one or more neurons from file to a neuronlist in memory

    +

    write.neurons()

    +

    Write neurons from a neuronlist object to individual files, or a zip archive

    +

    nlapply() nmapply()

    +

    lapply and mapply for neuronlists (with optional parallelisation)

    +

    plot(<neuronlist>)

    +

    2D plots of the elements in a neuronlist, optionally using a subset expression

    -

    plot3d

    -

    3D plots of the elements in a neuronlist, optionally using a subset +

    +

    plot3d(<neuronlist>) plot3d(<character>)

    +

    3D plots of the elements in a neuronlist, optionally using a subset expression

    -

    subset

    -

    Subset neuronlist returning either new neuronlist or names of chosen neurons

    -

    summary

    -

    Summary statistics for neurons (e.g. cable length, number of nodes)

    -

    as.neuronlist

    -

    Make a list of neurons that can be used for coordinate plotting/analysis

    -

    c

    -

    Combine multiple neuronlists into a single list

    -

    as.data.frame data.frame<-

    -

    Get or set the attached data.frame of a neuronlist

    -

    is.neuronlist

    -

    Test objects of neuronlist class to store multiple neurons

    -

    -

    Arithmetic for neuron coordinates applied to neuronlists

    -

    -

    Methods for working with the dataframe attached to a neuronlist

    -

    Collections of Neurons with Remote Data (neuronlistfh)

    -

    Functions for working with collections of neurons where the data will be dynamically loaded into memory from disk and/or downloaded from a remote site.

    -
    -

    neuronlistfh is.neuronlistfh as.neuronlistfh

    -

    neuronlistfh - List of neurons loaded on demand from disk or remote website

    -

    read.neuronlistfh

    -

    Read a local, or remote, neuronlistfh object saved to a file.

    -

    write.neuronlistfh

    -

    Write out a neuronlistfh object to an RDS file

    -

    remotesync

    -

    Synchronise a remote object

    -

    as.neuronlist

    -

    convert neuronlistfh to a regular (in memory) neuronlist

    -

    -

    Extract from neuronlistfh object or its attached data.frame

    -

    Surfaces and Landmarks (hxsurf, mesh3d)

    -

    Functions for working with surface data, either in a class hxsurf modeled on Amira’s representation of surfaces or the rgl::mesh3d class.

    -
    -

    read.hxsurf

    -

    Read Amira surface (aka HxSurface or HyperSurface) files into hxsurf object

    -

    write.hxsurf

    -

    Write Amira surface (aka HxSurface or HyperSurface) into .surf file.

    -

    read.landmarks write.landmarks

    -

    Generic functions to read/write landmarks in any supported format

    -

    plot3d

    -

    Plot amira surface objects in 3D using rgl

    -

    subset

    -

    Subset hxsurf object to specified regions

    -

    as.hxsurf

    -

    Convert an object to a nat hxsurf object

    -

    as.mesh3d

    -

    Convert an object to an rgl mesh3d

    -

    pointsinside

    -

    Find which points of an object are inside a surface

    -

    3D Plotting of objects

    -

    Functions to help plot neurons and surfaces in 3D and to review and identify objects by interactive selection.

    -
    -

    -

    plot3d methods for different nat objects

    -

    nopen3d

    -

    Open customised rgl window

    -

    nview3d

    -

    Set the 3D viewpoint of an RGL window using anatomical terms

    -

    npop3d

    -

    Remove plotted neurons or other 3D objects

    -

    pan3d

    -

    Some useful extensions / changes to rgl defaults

    -

    find.neuron

    -

    Find neurons within a 3D selection box (usually drawn in rgl window)

    -

    find.soma

    -

    Find neurons with soma inside 3D selection box (usually drawn in rgl window)

    -

    nlscan

    -

    Scan through a set of neurons, individually plotting each one in 3D

    -

    plot3d

    -

    Plot a bounding box in 3D

    -

    plot3d

    -

    3D plots of dotprops objects using rgl package

    -

    plot3d

    -

    Plot amira surface objects in 3D using rgl

    -

    plot3d

    -

    Plot neurons in 3D using rgl library

    -

    plot3d

    -

    Plot the domain of a CMTK registration

    -

    Object transformation

    -

    Generic strategies for transforming 3D objects/images a

    -
    -

    xform

    -

    Transform the 3D location of objects such as neurons

    -

    mirror

    -

    Mirror 3D object about a given axis, optionally using a warping registration

    -

    xyzmatrix xyzmatrix<-

    -

    Get and assign coordinates for classes containing 3D vertex data

    -

    nvertices

    -

    Find the number of vertices in an object (or each element of a neuronlist)

    -

    reglist invert_reglist c

    -

    A simple wrapper class for multiple transformations

    -

    xformimage

    -

    Transform image files using a registration or affine matrix

    -

    xformpoints

    -

    Transform 3D points using a registration, affine matrix or function

    -

    simplify_reglist

    -

    Simplify a registration list

    -

    Images (im3d)

    -

    Functions for working with 3d image volumes

    -
    -

    im3d

    -

    Construct an im3d object representing 3D image data, densities etc

    -

    read.im3d write.im3d

    -

    Read/Write calibrated 3D blocks of image data

    -

    as.im3d

    -

    Convert a suitable object to an im3d object.

    -

    is.im3d

    -

    Test if an object is of class im3d

    -

    imslice

    -

    Slice out a 3D subarray (or 2d matrix) from a 3D image array

    -

    image

    -

    Method to plot spatially calibrated image arrays

    -

    imscalebar

    -

    Make a scalebar to accompany an image.im3d plot

    -

    flip

    -

    Flip an array, matrix or vector about an axis

    -

    projection

    -

    Make 2D (orthogonal) projection of 3D image data

    -

    threshold

    -

    Threshold an object, typically to produce a mask

    -

    mask

    -

    Mask an object, typically to produce a copy with some values zeroed out

    -

    unmask

    -

    Make im3d image array containing values at locations defined by a mask

    -

    clampmax

    -

    Return function that finds maximum of its inputs within a clamping range

    -

    boundingbox boundingbox<-

    -

    Get the bounding box of an im3d volume or other compatible object

    -

    origin

    -

    Return the space origin of a 3D image object

    -

    voxdims

    -

    Return voxel dimensions of an object

    -

    nrrd.voxdims

    -

    Return voxel dimensions (by default absolute voxel dimensions)

    -

    xyzpos ijkpos

    -

    Interconvert pixel and physical coordinates

    -

    coord2ind

    -

    Find 1D indices into a 3D image given spatial coordinates

    -

    ind2coord

    -

    Find XYZ coords corresponding to 1D indices into a 3D image

    -

    sub2ind

    -

    Find 1D index given n-dimensional indices

    -

    imexpand.grid

    -

    Convert locations of im3d voxel grid into XYZ coordinates

    -

    materials

    -

    Extract or set the materials for an object

    -

    CMTK Registration

    -

    Functions to interface to the CMTK image registration suite

    -
    -

    cmtk.bindir

    -

    Return path to directory containing CMTK binaries

    -

    cmtk.version

    -

    Return cmtk version or test for presence of at least a specific version

    -

    cmtkparams2affmat

    -

    Compose homogeneous affine matrix from CMTK registration parameters

    -

    affmat2cmtkparams

    -

    Decompose homogeneous affine matrix to CMTK registration parameters

    -

    cmtk.dof2mat

    -

    Convert CMTK registration to homogeneous affine matrix with dof2mat

    -

    cmtk.mat2dof

    -

    Use CMTK mat2dof to convert homogeneous affine matrix into CMTK registration

    -

    cmtk.extract_affine

    -

    Extract affine registration from CMTK registration file or in-memory list

    -

    cmtk.reformatx

    -

    Reformat an image with a CMTK registration using the reformatx tool

    -

    cmtk.statistics

    -

    Calculate image statistics for a nrrd or other CMTK compatible file

    -

    cmtk.targetvolume

    -

    Defines a target volume for a CMTK reformatx operation

    -

    cmtkreg as.cmtkreg is.cmtkreg

    -

    Create and test cmtkreg objects that specify path to a CMTK registration

    -

    cmtkreglist

    -

    Make in-memory CMTK registration list from affine matrix or CMTK parameters

    -

    cmtk.call cmtk.system2

    -

    Utility function to create and run calls to CMTK commandline tools

    -

    Sample Data

    -

    Sample data objects (neurons, surfaces)

    -
    -

    -

    Cell07PNs: 40 Sample Projection Neurons from Jefferis, Potter et al 2007

    -

    -

    List of 20 Kenyon Cells from Chiang et al 2011 converted to dotprops objects

    -

    -

    Surface object (hxsurf) for the left mushroom body in FCWB template space

    -

    Generic Functions

    -

    Generic versions of base functions for which we provide specialised methods for nat objects.

    -
    -

    intersect

    -

    Find the intersection of two collections of objects

    -

    setdiff

    -

    Find the (asymmetric) difference between two collections of objects

    -

    -

    Subset methods for different nat objects

    -

    union

    -

    Find the union of two collections of objects

    -

    Utility Functions

    -

    Functions primarily intended for developer use

    -
    -

    ndigest

    -

    Calculated normalised digest value for an object

    -

    all.equal

    -

    all.equal method tailored to dotprops objects

    -

    all.equal

    -

    Check equality on data and key attributes of im3d objects

    -

    all.equal

    -

    Check equality on key fields of neuron object

    -

    File formats

    -

    Support for different formats. It is generally recommended to use more generic functions such as read.neuron(s) rather than these functions.

    -
    -

    fileformats registerformat getformatreader getformatwriter

    -

    Set or return list of registered file formats that we can read

    -

    read.cmtk

    -

    Read CMTK TypedStream file to a list in memory

    -

    read.cmtkreg

    -

    Read a CMTK format registration

    -

    read.morphml

    -

    Return parsed XML or R list versions of a NeuroML file

    -

    read.neuron.fiji

    -

    Read a neuron saved by Fiji's Simple Neurite Tracer Plugin

    -

    read.neuron.neuroml

    -

    Read one or more neurons from a NeuroML v1 file

    -

    read.neuron.swc read.ngraph.swc

    -

    Read a neuron in swc file format

    -

    read.nrrd read.nrrd.header

    -

    Read nrrd file into an array in memory

    -

    read.vaa3draw

    -

    Read Vaa3d format image data

    -

    read.amiramesh read.amiramesh.header

    -

    Read AmiraMesh data in binary or ascii format

    -

    write.amiramesh

    -

    Write a 3D data object to an amiramesh format file

    -

    write.cmtk

    -

    Write a suitable list to a CMTK TypedStream file on disk

    -

    write.cmtkreg

    -

    Write out CMTK registration list to folder

    -

    write.nrrd write.nrrd.header write.nrrd.header.for.file

    -

    Write data and metadata to NRRD file or create a detached NRRD (nhdr) file.

    -

    write.vtk

    -

    Write object to VTK file

    -

    amiratype

    -

    Return the type of an amiramesh file on disk or a parsed header

    -

    is.amiramesh

    -

    Check if file is amiramesh format

    -

    is.fijitraces

    -

    Check whether a file is in Fiji's simple neurite tracer format

    -

    is.neuroml

    -

    Check whether a file is in NeuroML format

    -

    is.nrrd

    -

    Check if a file is a NRRD file

    -

    is.swc

    -

    Test if a file is an SWC format neuron

    -

    is.vaa3draw

    -

    Check if a file is in the raw image format used by Hanchuan Peng's Vaa3D

    -
    + + + +

    subset(<neuronlist>)

    + +

    Subset neuronlist returning either new neuronlist or names of chosen neurons

    + + + +

    summary(<neuronlist>) summary(<neuron>) summary(<dotprops>)

    + +

    Summary statistics for neurons (e.g. cable length, number of nodes)

    + + + +

    as.neuronlist()

    + +

    Make a list of neurons that can be used for coordinate plotting/analysis

    + + + +

    c(<neuronlist>)

    + +

    Combine multiple neuronlists into a single list

    + + + +

    as.data.frame(<neuronlist>) `data.frame<-`()

    + +

    Get or set the attached data.frame of a neuronlist

    + + + +

    is.neuronlist()

    + +

    Test objects of neuronlist class to store multiple neurons

    + + + +

    `*`(<neuronlist>) `+`(<neuronlist>) `-`(<neuronlist>) `/`(<neuronlist>)

    + +

    Arithmetic for neuron coordinates applied to neuronlists

    + + + +

    `[`(<neuronlist>) `[<-`(<neuronlist>) droplevels(<neuronlist>) with(<neuronlist>) head(<neuronlist>) tail(<neuronlist>)

    + +

    Methods for working with the dataframe attached to a neuronlist

    + + + + +

    Collections of Neurons with Remote Data (neuronlistfh)

    +

    Functions for working with collections of neurons where the data will be dynamically loaded into memory from disk and/or downloaded from a remote site.

    + + + + + + + + + + +

    neuronlistfh() is.neuronlistfh() as.neuronlistfh()

    + +

    neuronlistfh - List of neurons loaded on demand from disk or remote website

    + + + +

    read.neuronlistfh()

    + +

    Read a local, or remote, neuronlistfh object saved to a file.

    + + + +

    write.neuronlistfh()

    + +

    Write out a neuronlistfh object to an RDS file

    + + + +

    remotesync()

    + +

    Synchronise a remote object

    + + + +

    as.neuronlist(<neuronlistfh>)

    + +

    convert neuronlistfh to a regular (in memory) neuronlist

    + + + +

    `[`(<neuronlistfh>)

    + +

    Extract from neuronlistfh object or its attached data.frame

    + + + + +

    Surfaces and Landmarks (hxsurf, mesh3d)

    +

    Functions for working with surface data, either in a class hxsurf modeled on Amira’s representation of surfaces or the rgl::mesh3d class.

    + + + + + + + + + + +

    read.hxsurf()

    + +

    Read Amira surface (aka HxSurface or HyperSurface) files into hxsurf object

    + + + +

    write.hxsurf()

    + +

    Write Amira surface (aka HxSurface or HyperSurface) into .surf file.

    + + + +

    read.landmarks() write.landmarks()

    + +

    Generic functions to read/write landmarks in any supported format

    + + + +

    plot3d(<hxsurf>)

    + +

    Plot amira surface objects in 3D using rgl

    + + + +

    subset(<hxsurf>)

    + +

    Subset hxsurf object to specified regions

    + + + +

    as.hxsurf()

    + +

    Convert an object to a nat hxsurf object

    + + + +

    as.mesh3d(<ashape3d>) as.mesh3d(<hxsurf>)

    + +

    Convert an object to an rgl mesh3d

    + + + +

    pointsinside()

    + +

    Find which points of an object are inside a surface

    + + + + +

    3D Plotting of objects

    +

    Functions to help plot neurons and surfaces in 3D and to review and identify objects by interactive selection.

    + + + + + + + + + + +

    plot3d

    + +

    plot3d methods for different nat objects

    + + + +

    nopen3d()

    + +

    Open customised rgl window

    + + + +

    nview3d()

    + +

    Set the 3D viewpoint of an RGL window using anatomical terms

    + + + +

    npop3d()

    + +

    Remove plotted neurons or other 3D objects

    + + + +

    pan3d()

    + +

    Some useful extensions / changes to rgl defaults

    + + + +

    find.neuron()

    + +

    Find neurons within a 3D selection box (usually drawn in rgl window)

    + + + +

    find.soma()

    + +

    Find neurons with soma inside 3D selection box (usually drawn in rgl window)

    + + + +

    nlscan()

    + +

    Scan through a set of neurons, individually plotting each one in 3D

    + + + +

    plot3d(<boundingbox>)

    + +

    Plot a bounding box in 3D

    + + + +

    plot3d(<dotprops>)

    + +

    3D plots of dotprops objects using rgl package

    + + + +

    plot3d(<hxsurf>)

    + +

    Plot amira surface objects in 3D using rgl

    + + + +

    plot3d(<neuron>)

    + +

    Plot neurons in 3D using rgl library

    + + + +

    plot3d(<cmtkreg>)

    + +

    Plot the domain of a CMTK registration

    + + + + +

    Object transformation

    +

    Generic strategies for transforming 3D objects/images a

    + + + + + + + + + + +

    xform()

    + +

    Transform the 3D location of objects such as neurons

    + + + +

    mirror()

    + +

    Mirror 3D object about a given axis, optionally using a warping registration

    + + + +

    xyzmatrix() `xyzmatrix<-`()

    + +

    Get and assign coordinates for classes containing 3D vertex data

    + + + +

    nvertices()

    + +

    Find the number of vertices in an object (or each element of a neuronlist)

    + + + +

    reglist() invert_reglist() c(<reglist>)

    + +

    A simple wrapper class for multiple transformations

    + + + +

    xformimage()

    + +

    Transform image files using a registration or affine matrix

    + + + +

    xformpoints()

    + +

    Transform 3D points using a registration, affine matrix or function

    + + + +

    simplify_reglist()

    + +

    Simplify a registration list

    + + + + +

    Images (im3d)

    +

    Functions for working with 3d image volumes

    + + + + + + + + + + +

    im3d()

    + +

    Construct an im3d object representing 3D image data, densities etc

    + + + +

    read.im3d() write.im3d()

    + +

    Read/Write calibrated 3D blocks of image data

    + + + +

    as.im3d()

    + +

    Convert a suitable object to an im3d object.

    + + + +

    is.im3d()

    + +

    Test if an object is of class im3d

    + + + +

    imslice()

    + +

    Slice out a 3D subarray (or 2d matrix) from a 3D image array

    + + + +

    image(<im3d>)

    + +

    Method to plot spatially calibrated image arrays

    + + + +

    imscalebar()

    + +

    Make a scalebar to accompany an image.im3d plot

    + + + +

    flip()

    + +

    Flip an array, matrix or vector about an axis

    + + + +

    projection()

    + +

    Make 2D (orthogonal) projection of 3D image data

    + + + +

    threshold()

    + +

    Threshold an object, typically to produce a mask

    + + + +

    mask()

    + +

    Mask an object, typically to produce a copy with some values zeroed out

    + + + +

    unmask()

    + +

    Make im3d image array containing values at locations defined by a mask

    + + + +

    clampmax()

    + +

    Return function that finds maximum of its inputs within a clamping range

    + + + +

    boundingbox() `boundingbox<-`()

    + +

    Get the bounding box of an im3d volume or other compatible object

    + + + +

    origin()

    + +

    Return the space origin of a 3D image object

    + + + +

    voxdims()

    + +

    Return voxel dimensions of an object

    + + + +

    nrrd.voxdims()

    + +

    Return voxel dimensions (by default absolute voxel dimensions)

    + + + +

    xyzpos() ijkpos()

    + +

    Interconvert pixel and physical coordinates

    + + + +

    coord2ind()

    + +

    Find 1D indices into a 3D image given spatial coordinates

    + + + +

    ind2coord()

    + +

    Find XYZ coords corresponding to 1D indices into a 3D image

    + + + +

    sub2ind()

    + +

    Find 1D index given n-dimensional indices

    + + + +

    imexpand.grid()

    + +

    Convert locations of im3d voxel grid into XYZ coordinates

    + + + +

    materials()

    + +

    Extract or set the materials for an object

    + + + + +

    CMTK Registration

    +

    Functions to interface to the CMTK image registration suite

    + + + + + + + + + + +

    cmtk.bindir()

    + +

    Return path to directory containing CMTK binaries

    + + + +

    cmtk.version()

    + +

    Return cmtk version or test for presence of at least a specific version

    + + + +

    cmtkparams2affmat()

    + +

    Compose homogeneous affine matrix from CMTK registration parameters

    + + + +

    affmat2cmtkparams()

    + +

    Decompose homogeneous affine matrix to CMTK registration parameters

    + + + +

    cmtk.dof2mat()

    + +

    Convert CMTK registration to homogeneous affine matrix with dof2mat

    + + + +

    cmtk.mat2dof()

    + +

    Use CMTK mat2dof to convert homogeneous affine matrix into CMTK registration

    + + + +

    cmtk.extract_affine()

    + +

    Extract affine registration from CMTK registration file or in-memory list

    + + + +

    cmtk.reformatx()

    + +

    Reformat an image with a CMTK registration using the reformatx tool

    + + + +

    cmtk.statistics()

    + +

    Calculate image statistics for a nrrd or other CMTK compatible file

    + + + +

    cmtk.targetvolume()

    + +

    Defines a target volume for a CMTK reformatx operation

    + + + +

    cmtkreg() as.cmtkreg() is.cmtkreg()

    + +

    Create and test cmtkreg objects that specify path to a CMTK registration

    + + + +

    cmtkreglist()

    + +

    Make in-memory CMTK registration list from affine matrix or CMTK parameters

    + + + +

    cmtk.call() cmtk.system2()

    + +

    Utility function to create and run calls to CMTK commandline tools

    + + + + +

    Sample Data

    +

    Sample data objects (neurons, surfaces)

    + + + + + + + + + + +

    Cell07PNs

    + +

    Cell07PNs: 40 Sample Projection Neurons from Jefferis, Potter et al 2007

    + + + +

    kcs20

    + +

    List of 20 Kenyon Cells from Chiang et al 2011 converted to dotprops objects

    + + + +

    MBL.surf

    + +

    Surface object (hxsurf) for the left mushroom body in FCWB template space

    + + + + +

    Generic Functions

    +

    Generic versions of base functions for which we provide specialised methods for nat objects.

    + + + + + + + + + + +

    intersect()

    + +

    Find the intersection of two collections of objects

    + + + +

    setdiff()

    + +

    Find the (asymmetric) difference between two collections of objects

    + + + +

    subset

    + +

    Subset methods for different nat objects

    + + + +

    union()

    + +

    Find the union of two collections of objects

    + + + + +

    Utility Functions

    +

    Functions primarily intended for developer use

    + + + + + + + + + + +

    ndigest()

    + +

    Calculated normalised digest value for an object

    + + + +

    all.equal(<dotprops>)

    + +

    all.equal method tailored to dotprops objects

    + + + +

    all.equal(<im3d>)

    + +

    Check equality on data and key attributes of im3d objects

    + + + +

    all.equal(<neuron>)

    + +

    Check equality on key fields of neuron object

    + + + + +

    File formats

    +

    Support for different formats. It is generally recommended to use more generic functions such as read.neuron(s) rather than these functions.

    + + + + + + + + + + +

    fileformats() registerformat() getformatreader() getformatwriter()

    + +

    Set or return list of registered file formats that we can read

    + + + +

    read.cmtk()

    + +

    Read CMTK TypedStream file to a list in memory

    + + + +

    read.cmtkreg()

    + +

    Read a CMTK format registration

    + + + +

    read.morphml()

    + +

    Return parsed XML or R list versions of a NeuroML file

    + + + +

    read.neuron.fiji()

    + +

    Read a neuron saved by Fiji's Simple Neurite Tracer Plugin

    + + + +

    read.neuron.neuroml()

    + +

    Read one or more neurons from a NeuroML v1 file

    + + + +

    read.neuron.swc() read.ngraph.swc()

    + +

    Read a neuron in swc file format

    + + + +

    read.nrrd() read.nrrd.header()

    + +

    Read nrrd file into an array in memory

    + + + +

    read.vaa3draw()

    + +

    Read Vaa3d format image data

    + + + +

    read.amiramesh() read.amiramesh.header()

    + +

    Read AmiraMesh data in binary or ascii format

    + + + +

    write.amiramesh()

    + +

    Write a 3D data object to an amiramesh format file

    + + + +

    write.cmtk()

    + +

    Write a suitable list to a CMTK TypedStream file on disk

    + + + +

    write.cmtkreg()

    + +

    Write out CMTK registration list to folder

    + + + +

    write.nrrd() write.nrrd.header() write.nrrd.header.for.file()

    + +

    Write data and metadata to NRRD file or create a detached NRRD (nhdr) file.

    + + + +

    write.vtk()

    + +

    Write object to VTK file

    + + + +

    amiratype()

    + +

    Return the type of an amiramesh file on disk or a parsed header

    + + + +

    is.amiramesh()

    + +

    Check if file is amiramesh format

    + + + +

    is.fijitraces()

    + +

    Check whether a file is in Fiji's simple neurite tracer format

    + + + +

    is.neuroml()

    + +

    Check whether a file is in NeuroML format

    + + + +

    is.nrrd()

    + +

    Check if a file is a NRRD file

    + + + +

    is.swc()

    + +

    Test if a file is an SWC format neuron

    + + + +

    is.vaa3draw()

    + +

    Check if a file is in the raw image format used by Hanchuan Peng's Vaa3D

    + + +
    - +
    -

    Site built with pkgdown.

    +

    Site built with pkgdown 1.6.1.

    + + + + + diff --git a/docs/reference/intersect.html b/docs/reference/intersect.html index b432d741..fe90e54a 100644 --- a/docs/reference/intersect.html +++ b/docs/reference/intersect.html @@ -1,6 +1,6 @@ - + @@ -8,25 +8,46 @@ Find the intersection of two collections of objects — intersect • nat + - + - - + + + + + + + - + + + + + + + + - - - + + + + + + + + + + - + + + - +
    +
    -
    +
    - +

    Find the intersection of two collections of objects

    - +
    -
    intersect(x, y, ...)
    +    
    intersect(x, y, ...)
     
     # S3 method for default
    -intersect(x, y, ...)
    +intersect(x, y, ...)
     
     # S3 method for neuronlist
    -intersect(x, y, ...)
    - -

    Arguments

    +intersect(x, y, ...)
    + +

    Arguments

    @@ -126,49 +156,44 @@

    Ar

    additional arguments passed to methods

    - +

    Value

    A collection of the same mode as x that contains all elements of x that are also present in y.

    -

    Details

    Note that intersect.default calls base::intersect to ensure consistent behaviour for regular vectors.

    -

    See also

    -

    intersect

    - +
    - +
    -

    Site built with pkgdown.

    +

    Site built with pkgdown 1.6.1.

    + + + + + diff --git a/docs/reference/is.amiramesh.html b/docs/reference/is.amiramesh.html index 55e6f830..dbc3f2de 100644 --- a/docs/reference/is.amiramesh.html +++ b/docs/reference/is.amiramesh.html @@ -1,6 +1,6 @@ - + @@ -8,25 +8,46 @@ Check if file is amiramesh format — is.amiramesh • nat + - + - - + + + + + + + - + + + + + + + + - - - + + + + + + + + + + - + + + - +
    +
    -
    +
    - +

    Check if file is amiramesh format

    - +
    -
    is.amiramesh(f = NULL, bytes = NULL)
    - -

    Arguments

    +
    is.amiramesh(f = NULL, bytes = NULL)
    + +

    Arguments

    @@ -118,50 +148,47 @@

    Ar single file (used in preference to reading file f).

    - +

    Value

    logical

    -

    Details

    Tries to be as fast as possible by reading only first 11 bytes and checking if they equal to "# AmiraMesh" or (deprecated) "# HyperMesh".

    -

    See also

    -

    Other amira: amiratype, - read.amiramesh, read.hxsurf, - write.hxsurf

    - +

    Other amira: +amiratype(), +read.amiramesh(), +read.hxsurf(), +write.hxsurf()

    - +
    -

    Site built with pkgdown.

    +

    Site built with pkgdown 1.6.1.

    + + + + + diff --git a/docs/reference/is.fijitraces.html b/docs/reference/is.fijitraces.html index c3b06bfa..ae4378dd 100644 --- a/docs/reference/is.fijitraces.html +++ b/docs/reference/is.fijitraces.html @@ -1,6 +1,6 @@ - + @@ -8,25 +8,47 @@ Check whether a file is in Fiji's simple neurite tracer format — is.fijitraces • nat + - + - - + + + + + + + - + + + + + + + + - - - + + + + + + + + + + - + + + - +
    +
    -
    +
    - +

    This will check a file on disk to see if it is in Fiji's simple neurite tracer XML format.

    - +
    + +
    is.fijitraces(f, bytes = NULL)
    -
    is.fijitraces(f, bytes = NULL)
    - -

    Arguments

    +

    Arguments

    @@ -117,37 +148,38 @@

    Ar

    optional raw vector of bytes used for prechecks

    - +

    Details

    Some prechecks (optionally taking place on a supplied raw vector of bytes) should weed out nearly all true negatives and identify many true positives without having to read/parse the file header.

    -
    - +
    -

    Site built with pkgdown.

    +

    Site built with pkgdown 1.6.1.

    + + + + + diff --git a/docs/reference/is.im3d.html b/docs/reference/is.im3d.html index 7f3629a2..ca0e5387 100644 --- a/docs/reference/is.im3d.html +++ b/docs/reference/is.im3d.html @@ -1,6 +1,6 @@ - + @@ -8,25 +8,46 @@ Test if an object is of class im3d — is.im3d • nat + - + - - + + + + + + + - + + + + + + + + - - - + + + + + + + + + + - + + + - +
    +
    -
    +
    - +

    Test if an object is of class im3d

    - +
    -
    is.im3d(x)
    - -

    Arguments

    +
    is.im3d(x)
    + +

    Arguments

    @@ -112,47 +142,52 @@

    Ar

    Object to test

    - +

    Value

    logical

    -

    See also

    -

    Other im3d: as.im3d, - boundingbox, im3d-coords, - im3d-io, im3d, - imexpand.grid, imslice, - mask, origin, - projection, threshold, - unmask, voxdims

    - +

    Other im3d: +as.im3d(), +boundingbox(), +im3d-coords, +im3d-io, +im3d(), +imexpand.grid(), +imslice(), +mask(), +origin(), +projection(), +threshold(), +unmask(), +voxdims()

    - +
    -

    Site built with pkgdown.

    +

    Site built with pkgdown 1.6.1.

    + + + + + diff --git a/docs/reference/is.neuroml.html b/docs/reference/is.neuroml.html index a322183d..258adf0b 100644 --- a/docs/reference/is.neuroml.html +++ b/docs/reference/is.neuroml.html @@ -1,6 +1,6 @@ - + @@ -8,25 +8,49 @@ Check whether a file is in NeuroML format — is.neuroml • nat + - + - - + + + + + + + - + + + + + + + + - - - + + + + + + + + + + - + + + - +
    +
    -
    +
    - +

    This will check a file on disk to see if it is in NeuroML format. Some prechecks (optionally taking place on a supplied raw vector of bytes) should weed out nearly all true negatives and identify many true positives without having to read/parse the file header.

    - +
    -
    is.neuroml(f, bytes = NULL)
    - -

    Arguments

    +
    is.neuroml(f, bytes = NULL)
    + +

    Arguments

    @@ -119,29 +152,33 @@

    Ar

    optional raw vector of bytes used for prechecks

    - -
    - +
    +
    -

    Site built with pkgdown.

    +

    Site built with pkgdown 1.6.1.

    + + + + + diff --git a/docs/reference/is.neuronlist.html b/docs/reference/is.neuronlist.html index ebea8f4f..e4cb89e1 100644 --- a/docs/reference/is.neuronlist.html +++ b/docs/reference/is.neuronlist.html @@ -1,6 +1,6 @@ - + @@ -8,25 +8,46 @@ Test objects of neuronlist class to store multiple neurons — is.neuronlist • nat + - + - - + + + + + + + - + + + + + + + + - - - + + + + + + + + + + - + + + - +
    +
    -
    +
    - +

    Tests if object is a neuronlist.

    - +
    -
    is.neuronlist(x)
    - -

    Arguments

    +
    is.neuronlist(x)
    + +

    Arguments

    @@ -112,52 +142,50 @@

    Ar

    the object to test

    - +

    Value

    A logical indicating whether the object is a neuronlist.

    -

    Details

    is.neuronlist uses a relaxed definition to cope with older lists of neurons that do not have a class attribute of neuronlist.

    -

    See also

    -

    Other neuronlist: *.neuronlist, - neuronlist-dataframe-methods, - neuronlistfh, neuronlist, - nlapply, read.neurons, - write.neurons

    - +
    - +
    -

    Site built with pkgdown.

    +

    Site built with pkgdown 1.6.1.

    + + + + + diff --git a/docs/reference/is.nrrd.html b/docs/reference/is.nrrd.html index 9ba74ba1..982cce0d 100644 --- a/docs/reference/is.nrrd.html +++ b/docs/reference/is.nrrd.html @@ -1,6 +1,6 @@ - + @@ -8,25 +8,46 @@ Check if a file is a NRRD file — is.nrrd • nat + - + - - + + + + + + + - + + + + + + + + - - - + + + + + + + + + + - + + + - +
    +
    -
    +
    - +

    Check if a file is a NRRD file

    - +
    + +
    is.nrrd(f = NULL, bytes = NULL, ReturnVersion = FALSE, TrustSuffix = FALSE)
    -
    is.nrrd(f = NULL, bytes = NULL, ReturnVersion = FALSE,
    -  TrustSuffix = FALSE)
    - -

    Arguments

    +

    Arguments

    @@ -129,37 +158,38 @@

    Ar NRRD

    - +

    Details

    Note that multiple files can be checked when a character vector of length > 1 is provided, but only one file can be checked when a raw byte array is provided.

    -
    - +
    -

    Site built with pkgdown.

    +

    Site built with pkgdown 1.6.1.

    + + + + + diff --git a/docs/reference/is.swc.html b/docs/reference/is.swc.html index ab06b6d6..5c75c33a 100644 --- a/docs/reference/is.swc.html +++ b/docs/reference/is.swc.html @@ -1,6 +1,6 @@ - + @@ -8,25 +8,46 @@ Test if a file is an SWC format neuron — is.swc • nat + - + - - + + + + + + + - + + + + + + + + - - - + + + + + + + + + + - + + + - +
    +
    -
    +
    - +

    Test if a file is an SWC format neuron

    - +
    -
    is.swc(f, TrustSuffix = TRUE)
    - -

    Arguments

    +
    is.swc(f, TrustSuffix = TRUE)
    + +

    Arguments

    @@ -117,50 +147,45 @@

    Ar NRRD

    - +

    Value

    logical value

    -

    Details

    Note that this test is somewhat expensive compared with the other file tests since SWC files do not have a consistent magic value. It therefore often has to read and parse the first few lines of the file in order to determine whether they are consistent with the SWC format.

    -

    See also

    -

    read.neuron

    - +
    - +
    -

    Site built with pkgdown.

    +

    Site built with pkgdown 1.6.1.

    + + + + + diff --git a/docs/reference/is.vaa3draw.html b/docs/reference/is.vaa3draw.html index 39387b32..1fc22f4d 100644 --- a/docs/reference/is.vaa3draw.html +++ b/docs/reference/is.vaa3draw.html @@ -1,6 +1,6 @@ - + @@ -8,25 +8,47 @@ Check if a file is in the raw image format used by Hanchuan Peng's Vaa3D — is.vaa3draw • nat + - + - - + + + + + + + - + + + + + + + + - - - + + + + + + + + + + - + + + - +
    +
    -
    +
    - +

    See http://www.vaa3d.org/ - https://svn.janelia.org/penglab/projects/vaa3d/trunk/imagej_io/v3draw_io_imagej/raw_reader.java

    - + https://github.com/Vaa3D/v3d_external/blob/master/imagej_io/v3draw_io_imagej/raw_reader.java

    +
    + +
    is.vaa3draw(f, bytes = NULL)
    -
    is.vaa3draw(f, bytes = NULL)
    - -

    Arguments

    +

    Arguments

    @@ -119,37 +150,38 @@

    Ar single file (used in preference to reading file f).

    - +

    Details

    Note that multiple files can be checked when a character vector of length > 1 is provided, but only one file can be checked when a raw byte array is provided.

    -
    - +
    -

    Site built with pkgdown.

    +

    Site built with pkgdown 1.6.1.

    + + + + + diff --git a/docs/reference/kcs20.html b/docs/reference/kcs20.html index 556a39a1..15819cd0 100644 --- a/docs/reference/kcs20.html +++ b/docs/reference/kcs20.html @@ -1,6 +1,6 @@ - + @@ -8,25 +8,50 @@ List of 20 Kenyon Cells from Chiang et al 2011 converted to dotprops objects — kcs20 • nat + - + - - + + + + + + + - + + + + + + + + - - - + + + + + + + + + + - + + + - +
    +
    -
    +
    - +

    This R list (which has additional class neuronlist) contains 20 skeletonized Drosophila Kenyon cells as dotprops objects. Original data is due to Chiang et al. 2011, who have generously shared their raw data at http://flycircuit.tw. Image registration and further processing was carried out by Greg Jefferis.

    - +
    + + -

    References

    [1] Chiang A.S., Lin C.Y., Chuang C.C., Chang H.M., Hsieh C.H., @@ -115,18 +150,18 @@

    R Chen J.Y., et al. (2011). Three-dimensional reconstruction of brain-wide wiring networks in Drosophila at single-cell resolution. Curr Biol 21 (1), 1--11.

    -

    See also

    -

    head.neuronlist, with.neuronlist, +

    Examples

    -
    head(kcs20)
    #> gene_name Name idid soma_side +
    head(kcs20) +
    #> gene_name Name idid soma_side #> FruMARCM-M001205_seg002 FruMARCM-M001205_seg002 fru-M-500112 1024 L #> GadMARCM-F000122_seg001 GadMARCM-F000122_seg001 Gad1-F-900005 10616 L #> GadMARCM-F000050_seg001 GadMARCM-F000050_seg001 Gad1-F-100010 8399 R @@ -146,37 +181,41 @@

    Examp #> GadMARCM-F000050_seg001 GadMARCM-F000050_seg001 57 1132 ab #> GadMARCM-F000142_seg002 GadMARCM-F000142_seg002 71 1535 apbp #> FruMARCM-F000270_seg001 FruMARCM-F000270_seg001 64 1331 ab -#> FruMARCM-F001115_seg002 FruMARCM-F001115_seg002 44 795 ab

    table(with(kcs20, type))
    #> +#> FruMARCM-F001115_seg002 FruMARCM-F001115_seg002 44 795 ab
    table(with(kcs20, type)) +
    #> #> ab apbp gamma -#> 10 3 7
    #> glX -#> 2
    # see plot3d.neuronlist documentation for more details -
    plot3d(kcs20, col=type)
    +#> 10 3 7
    #> glX +#> 2
    # see plot3d.neuronlist documentation for more details +# \donttest{ +plot3d(kcs20, col=type) +# } +
    - +
    -

    Site built with pkgdown.

    +

    Site built with pkgdown 1.6.1.

    + + + + + diff --git a/docs/reference/mask-1.png b/docs/reference/mask-1.png index fc86989e..cd8a0790 100644 Binary files a/docs/reference/mask-1.png and b/docs/reference/mask-1.png differ diff --git a/docs/reference/mask-2.png b/docs/reference/mask-2.png index af4efb49..9107b64b 100644 Binary files a/docs/reference/mask-2.png and b/docs/reference/mask-2.png differ diff --git a/docs/reference/mask-3.png b/docs/reference/mask-3.png index 609d586f..0a33525a 100644 Binary files a/docs/reference/mask-3.png and b/docs/reference/mask-3.png differ diff --git a/docs/reference/mask-4.png b/docs/reference/mask-4.png deleted file mode 100644 index 50162498..00000000 Binary files a/docs/reference/mask-4.png and /dev/null differ diff --git a/docs/reference/mask-6.png b/docs/reference/mask-6.png deleted file mode 100644 index 859b2c5a..00000000 Binary files a/docs/reference/mask-6.png and /dev/null differ diff --git a/docs/reference/mask.html b/docs/reference/mask.html index 3d605008..a043f84c 100644 --- a/docs/reference/mask.html +++ b/docs/reference/mask.html @@ -1,6 +1,6 @@ - + @@ -8,25 +8,46 @@ Mask an object, typically to produce a copy with some values zeroed out — mask • nat + - + - - + + + + + + + - + + + + + + + + - - - + + + + + + + + + + - + + + - +
    +
    -
    +
    - +

    Mask an object, typically to produce a copy with some values zeroed out

    - +
    -
    mask(x, ...)
    +    
    mask(x, ...)
     
     # S3 method for im3d
    -mask(x, mask, levels = NULL, rval = c("im3d", "values"),
    -  invert = FALSE, ...)
    - -

    Arguments

    +mask(x, mask, levels = NULL, rval = c("im3d", "values"), invert = FALSE, ...)
    + +

    Arguments

    @@ -116,7 +145,7 @@

    Ar

    - + @@ -139,63 +168,66 @@

    Ar

    Object to be masked

    ...

    Additional arguments passed to methods

    Whether to invert the voxel selection (default FALSE)

    - +

    Value

    an oject with attributes matching x and elements with value - as.vector(TRUE, mode=mode) i.e. TRUE, 1, 0x01 and - as.vector(FALSE, mode=mode) i.e. FALSE, 0, 0x00 as + as.vector(TRUE, mode=mode) i.e. TRUE, 1, 0x01 and + as.vector(FALSE, mode=mode) i.e. FALSE, 0, 0x00 as appropriate.

    A copy of x with

    -

    Details

    -

    Note that mask.im3d passes … arguments on to im3d

    - +

    Note that mask.im3d passes ... arguments on to im3d

    See also

    -

    Other im3d: as.im3d, - boundingbox, im3d-coords, - im3d-io, im3d, - imexpand.grid, imslice, - is.im3d, origin, - projection, threshold, - unmask, voxdims

    - +

    Other im3d: +as.im3d(), +boundingbox(), +im3d-coords, +im3d-io, +im3d(), +imexpand.grid(), +imslice(), +is.im3d(), +origin(), +projection(), +threshold(), +unmask(), +voxdims()

    Examples

    -
    x=im3d(array(rnorm(1000),dim=c(10,10,10)), BoundingBox=c(20,200,100,200,200,300)) -m=array(1:5,dim=c(10,10,10)) -image(x[,,1])
    image(mask(x, mask=m, levels=1)[,,1])
    image(mask(x, mask=m, levels=1:2)[,,1])
    +
    x=im3d(array(rnorm(1000),dim=c(10,10,10)), BoundingBox=c(20,200,100,200,200,300)) +m=array(1:5,dim=c(10,10,10)) +image(x[,,1]) +
    image(mask(x, mask=m, levels=1)[,,1]) +
    image(mask(x, mask=m, levels=1:2)[,,1]) +
    - +
    -

    Site built with pkgdown.

    +

    Site built with pkgdown 1.6.1.

    + + + + + diff --git a/docs/reference/materials.html b/docs/reference/materials.html index 271af5be..67f4fece 100644 --- a/docs/reference/materials.html +++ b/docs/reference/materials.html @@ -1,6 +1,6 @@ - + @@ -8,25 +8,49 @@ Extract or set the materials for an object — materials • nat + - + - - + + + + + + + - + + + + + + + + - - - + + + + + + + + + + - + + + - +
    +
    -
    +
    - -

    Extract or set the materials for an object - - materials.character will read the materials from an im3d - compatible image file on disk. - - materials.hxsurf will extract the materials from an +

    +

    materials.character will read the materials from an im3d + compatible image file on disk.

    +

    materials.hxsurf will extract the materials from an hxsurf object

    - +
    -
    materials(x, ...)
    +    
    materials(x, ...)
     
     # S3 method for default
    -materials(x, ...)
    +materials(x, ...)
     
     # S3 method for character
    -materials(x, ...)
    +materials(x, ...)
     
     # S3 method for hxsurf
    -materials(x, ...)
    - -

    Arguments

    +materials(x, ...)
    + +

    Arguments

    @@ -128,15 +158,14 @@

    Ar disk.

    - +
    ...

    additional parameters passed to methods (presently ignored)

    - +

    Value

    A data.frame with columns name, id, col

    -

    Details

    Note that the id column will be the 1-indexed order that the @@ -145,42 +174,41 @@

    Details

    Presently only amiramesh images are supported since they have a standardised way of encoding labels, whereas nrrds would have to use key-value pairs according to some ad hoc convention.

    -

    See also

    -

    Other hxsurf: as.hxsurf, - as.mesh3d, plot3d.hxsurf, - read.hxsurf, subset.hxsurf, - write.hxsurf

    - +
    - +
    -

    Site built with pkgdown.

    +

    Site built with pkgdown 1.6.1.

    + + + + + diff --git a/docs/reference/mirror.html b/docs/reference/mirror.html index fed9f34c..b6aeefc2 100644 --- a/docs/reference/mirror.html +++ b/docs/reference/mirror.html @@ -1,6 +1,6 @@ - + @@ -8,25 +8,48 @@ Mirror 3D object about a given axis, optionally using a warping registration — mirror • nat + - + - - + + + + + + + - + + + + + + + + - - - + + + + + + + + + + - + + + - +
    +
    -
    +
    - +

    mirroring with a warping registration can be used to account - e.g. for the asymmetry between brain hemispheres. - - mirror.character handles images on disk

    - + e.g. for the asymmetry between brain hemispheres.

    +

    mirror.character handles images on disk

    +
    -
    mirror(x, ...)
    +    
    mirror(x, ...)
     
     # S3 method for character
    -mirror(x, output, mirrorAxisSize = NULL, target = x,
    -  ...)
    +mirror(x, output, mirrorAxisSize = NULL, target = x, ...)
     
     # S3 method for default
    -mirror(x, mirrorAxisSize, mirrorAxis = c("X", "Y", "Z"),
    -  warpfile = NULL, transform = c("warp", "affine", "flip"), ...)
    +mirror(
    +  x,
    +  mirrorAxisSize,
    +  mirrorAxis = c("X", "Y", "Z"),
    +  warpfile = NULL,
    +  transform = c("warp", "affine", "flip"),
    +  ...
    +)
     
     # S3 method for neuronlist
    -mirror(x, subset = NULL, OmitFailures = NA, ...)
    - -

    Arguments

    +mirror(x, subset = NULL, OmitFailures = NA, ...)
    + +

    Arguments

    @@ -177,11 +213,10 @@

    Ar details.

    - +

    Value

    Object with transformed points

    -

    Details

    The mirrorAxisSize argument can be specified in 3 ways for @@ -191,68 +226,73 @@

    Details
  • the boundingbox for the 3D data to be mirrored: the relevant axis specified by mirrorAxis will be extracted.

  • -

    This function is agnostic re node vs cell data, but for node data + +

    This function is agnostic re node vs cell data, but for node data BoundingBox should be supplied while for cell, it should be bounds. See boundingbox for details of BoundingBox vs bounds.

    See nlapply for details of the subset and OmitFailures arguments.

    -

    See also

    -

    xform, boundingbox - nlapply

    - +

    Examples

    -
    #> glX -#> 3
    x=Cell07PNs[[1]] -mx=mirror(x,168)
    plot3d(x,col='red') -plot3d(mx,col='green')
    +
    #> glX +#> 3
    x=Cell07PNs[[1]] +mx=mirror(x,168) +# \donttest{ +plot3d(x,col='red') +plot3d(mx,col='green') +# } + # also works with dotprops objects -clear3d() -y=kcs20[[1]] -my=mirror(y,mirrorAxisSize=564.2532,transform='flip')
    plot3d(y, col='red') -plot3d(my, col='green')
    -
    # NOT RUN { +clear3d() +y=kcs20[[1]] +my=mirror(y,mirrorAxisSize=564.2532,transform='flip') +# \donttest{ +plot3d(y, col='red') +plot3d(my, col='green') +# } + +if (FALSE) { ## Example with an image # note that we must specify an output image (obviously) but that as a # convenience mirror calculates the mirrorAxisSize for us -mirror('myimage.nrrd', output='myimage-mirrored.nrrd', - warpfile='myimage_mirror.list') +mirror('myimage.nrrd', output='myimage-mirrored.nrrd', + warpfile='myimage_mirror.list') # Simple flip along a different axis -mirror('myimage.nrrd', output='myimage-flipped.nrrd', mirrorAxis="Y", - transform='flip') -# }
    +mirror('myimage.nrrd', output='myimage-flipped.nrrd', mirrorAxis="Y", + transform='flip') +} +
    - +
    -

    Site built with pkgdown.

    +

    Site built with pkgdown 1.6.1.

    + + + + + diff --git a/docs/reference/nat-package.html b/docs/reference/nat-package.html index 69c4f996..b5566687 100644 --- a/docs/reference/nat-package.html +++ b/docs/reference/nat-package.html @@ -1,6 +1,6 @@ - + @@ -8,25 +8,47 @@ Analyse 3D biological image data especially neurons — nat-package • nat + - + - - + + + + + + + - + + + + + + + + - - - + + + + + + + + + + - + + + - +
    +
    -
    +
    - -

    nat provides tools to read, analyse, plot, transform and convert +

    +

    nat provides tools to read, analyse, plot, transform and convert neuroanatomical data, especially representations of neurons.

    - +
    + + -

    Neuron Objects

    -

    At present there are 2 main representations of - neuronal data:

    +

    At present there are 2 main representations of + neuronal data:

      -
    • neuron objects contain one or more connected trees +

    • neuron objects contain one or more connected trees that make up a neuron

    • -
    • dotprops objects can contain one (or more) neurons - represented as points and tangent vectors in which the connectivity +

    • dotprops objects can contain one (or more) neurons + represented as points and tangent vectors in which the connectivity information has been discarded

    -

    The subset function has both subset.neuron and - subset.dotprops methods, which can be used to keep (or - reject) specified vertices within a neuron e.g. by spatial constraints. - subset.neuron will look after the tree structure of neurons - in these circumstances.

    -

    neuron objects containing connected trees can be converted to - ngraph objects, a lightweight wrapper around the - igraph library's 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 as.neuron - function can convert ngraph objects back to neurons or - selected vertex indices can be used to subset a neuron with + +

    The subset function has both subset.neuron and + subset.dotprops methods, which can be used to keep (or + reject) specified vertices within a neuron e.g. by spatial constraints. + subset.neuron will look after the tree structure of neurons + in these circumstances.

    +

    neuron objects containing connected trees can be converted to + ngraph objects, a lightweight wrapper around the + igraph library's 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 as.neuron + function can convert ngraph objects back to neurons or + selected vertex indices can be used to subset a neuron with subset.neuron.

    -

    Collections of Neurons

    -

    Neurons can be collected as - neuronlist objects, which contain multiple - neuron or dotprops objects along with an attached - dataframe of metadata. The metadata can be accessed and manipulated using - the myneuronlist[i,j] notation (see - neuronlist-dataframe-methods).

    -

    Neurons can be read in to a neuronlist using read.neurons or - written out using write.neurons with support for many of the - most common formats including swc.

    -

    Metadata can be used to colour or subset the neurons during plotting (see - plot3d.neuronlist and subset.neuronlist). - Interactive 3D selection of neurons in a neuronlist is also possible using - find.neuron (which makes use of rgl's select3d - function.

    -

    neuronlist objects also provide additional functionality to - streamline arithmetic (e.g. scaling all the points in all neurons see - *.neuronlist) and transformations (see Transformations - section below and xform). Arbitrary functions can be applied - to each individual neuron can be applied using the nlapply - function, which also provides options for progress bars and simple +

    Neurons can be collected as + neuronlist objects, which contain multiple + neuron or dotprops objects along with an attached + dataframe of metadata. The metadata can be accessed and manipulated using + the myneuronlist[i,j] notation (see + neuronlist-dataframe-methods).

    +

    Neurons can be read in to a neuronlist using read.neurons or + written out using write.neurons with support for many of the + most common formats including swc.

    +

    Metadata can be used to colour or subset the neurons during plotting (see + plot3d.neuronlist and subset.neuronlist). + Interactive 3D selection of neurons in a neuronlist is also possible using + find.neuron (which makes use of rgl's select3d + function.

    +

    neuronlist objects also provide additional functionality to + streamline arithmetic (e.g. scaling all the points in all neurons see + *.neuronlist) and transformations (see Transformations + section below and xform). Arbitrary functions can be applied + to each individual neuron can be applied using the nlapply + function, which also provides options for progress bars and simple parallelisation.

    -

    Transformations

    -

    neuron or dotprops - objects can be transformed from e.g. sample to template brain space using - affine or non-rigid registrations, typically calculated with the open - source CMTK package available at www.nitrc.org/projects/cmtk/, see - ?cmtk for installation details. The function xform has - methods to deal with a variety of types of interest.

    - +

    neuron or dotprops + objects can be transformed from e.g. sample to template brain space using + affine or non-rigid registrations, typically calculated with the open + source CMTK package available at + https://www.nitrc.org/projects/cmtk/, see ?cmtk for + installation details. The function xform has methods to deal + with a variety of types of interest.

    3D Image Data

    -

    In addition to data types defined by unstructured - collections of 3D vertices such as neuron, - dotprops and hxsurf objects nat provides the - im3d class to handle image/density data on a regular grid. - I/O is handled by read.im3d and write.im3d, - which are currently implemented for the amiramesh and nrrd file formats; - there is also read only access to the vaa3d raw - format.

    -

    Spatial information can be queried with voxdims, +

    In addition to data types defined by unstructured + collections of 3D vertices such as neuron, + dotprops and hxsurf objects nat provides the + im3d class to handle image/density data on a regular grid. + I/O is handled by read.im3d and write.im3d, + which are currently implemented for the amiramesh and nrrd file formats; + there is also read only access to the vaa3d + raw format.

    +

    Spatial information can be queried with voxdims, boundingbox and ijkpos, xyzpos - methods. You can convert between voxel data and coordinate (vertex) -based - representations using the following functions:

    + methods. You can convert between voxel data and coordinate (vertex) -based + representations using the following functions:

      -
    • as.im3d The as.im3d.matrix method converts XYZ +

    • as.im3d The as.im3d.matrix method converts XYZ coordinates to an im3d image volume

    • -
    • ind2coord Find XYZ coordinates of specified voxels of +

    • ind2coord Find XYZ coordinates of specified voxels of an im3d image volume

    • -
    • dotprops The dotprops.im3d method converts an - im3d object to a dotprops format neuron, i.e. a cloud of +

    • dotprops The dotprops.im3d method converts an + im3d object to a dotprops format neuron, i.e. a cloud of unconnected segments.

    - +

    Surface Data

    -

    nat can read, write, transform and subset - surface (mesh) objects defined by Amira's HxSurface class. See +

    nat can read, write, transform and subset + surface (mesh) objects defined by Amira's HxSurface class. See read.hxsurf and links therein. In addition hxsurf objects can - be converted to the mesh3d format, which provides a link - to the rgl package and also to packages for - morphometrics and sophisticated mesh manipulation such as - Morpho and + be converted to the mesh3d format, which provides a link + to the rgl package and also to packages for + morphometrics and sophisticated mesh manipulation such as + Morpho and Rvcg.

    -

    rgl Package

    -

    nat uses the rgl +

    nat uses the rgl package extensively for 3D visualisation. rgl's core function is to provide - interactive visualisation (usually in an X11 window depending on OpenGL - - and therefore on a graphics card or OpenGL software emulator) but recently - significant functionality for static snapshots and embedding results in + interactive visualisation (usually in an X11 window depending on OpenGL - + and therefore on a graphics card or OpenGL software emulator) but recently + significant functionality for static snapshots and embedding results in reports such as web pages has been added. With this in mind, Duncan Murdoch - has added the rgl.useNULL option. As of nat 1.8.0, - options(rgl.useNULL=TRUE) will be set before nat is loaded in - non-interactive R sessions. If you want to use nat in interactive - environments where X11 is not available, you may want to set - options(rgl.useNULL=TRUE) manually before loading nat.

    - + has added the rgl.useNULL option. As of nat 1.8.0, + options(rgl.useNULL=TRUE) will be set before nat is loaded in + non-interactive R sessions. If you want to use nat in interactive + environments where X11 is not available, you may want to set + options(rgl.useNULL=TRUE) manually before loading nat.

    File Formats

    -

    nat supports multiple input and output data - formats for the object classes. There is a registry-based mechanism which - allows support for reading or writing specific file formats (see +

    nat supports multiple input and output data + formats for the object classes. There is a registry-based mechanism which + allows support for reading or writing specific file formats (see fileformats) to be plugged in to reasonably generic functions - such as read.neurons. It is perfectly possible for other R - packages or end users to extend the supported list of file types by + such as read.neurons. It is perfectly possible for other R + packages or end users to extend the supported list of file types by registering new read/write or identification functions.

    -

    Package Options

    The following options can be set to specify default - behaviour.

    + behaviour.

      -
    • nat.cmtk.bindir Location of CMTK binaries. See +

    • nat.cmtk.bindir Location of CMTK binaries. See cmtk.bindir

    • nat.default.neuronlist A character string naming a neuronlist to use with the plot3d.character method

    • -
    • nat.progress The default progress reporter to use with - nlapply. See create_progress_bar for - possible values. When unset is equivalent to special value 'auto'. +

    • nat.progress The default progress reporter to use with + nlapply. See create_progress_bar for + possible values. When unset is equivalent to special value 'auto'. To suppress altogether, use nat.progress="none".

    -

    In addition there is one read-only option:

    - +
    -

    Site built with pkgdown.

    +

    Site built with pkgdown 1.6.1.

    + + + + + diff --git a/docs/reference/ndigest.html b/docs/reference/ndigest.html index afecf7db..1a5df757 100644 --- a/docs/reference/ndigest.html +++ b/docs/reference/ndigest.html @@ -1,6 +1,6 @@ - + @@ -8,25 +8,50 @@ Calculated normalised digest value for an object — ndigest • nat + - + - - + + + + + + + - + + + + + + + + - - - + + + + + + + + + + - + + + - +
    +
    -
    +
    - +

    The normalised digest should exclude any fields or attributes irrelevant to the core contents of the object (e.g. timestamps, absolute location of the input files on disk etc). In theory then, this value should be constant for the same data regardless of the particular machine on which the digest is being computed.

    - +
    -
    ndigest(x, ...)
    +    
    ndigest(x, ...)
     
     # S3 method for neuronlistfh
    -ndigest(x, ...)
    +ndigest(x, ...)
     
     # S3 method for dotprops
    -ndigest(x, absoluteVectors = TRUE, ...)
    +ndigest(x, absoluteVectors = TRUE, ...)
     
     # S3 method for neuron
    -ndigest(x, fieldsToExclude = c("InputFileName", "CreatedAt",
    -  "NodeName", "InputFileStat", "InputFileMD5"), ...)
    - -

    Arguments

    +ndigest( + x, + fieldsToExclude = c("InputFileName", "CreatedAt", "NodeName", "InputFileStat", + "InputFileMD5"), + ... +)
    + +

    Arguments

    @@ -140,24 +178,23 @@

    Ar

    Character vector naming the neuron fields to exclude

    - +

    Value

    A character string containing the digest of the supplied object computed by digest.

    -

    Details

    ndigest.neuronlistfh only considers the keyfilemap and df (metadata data.frame) when computing the hash value. See - neuronlistfh for the significance of these two fields. - ndigest.dotprops ignores any mtime or file + neuronlistfh for the significance of these two fields.

    +

    ndigest.dotprops ignores any mtime or file attributes. It also converts tangent vectors to absolute values (when absoluteVectors=TRUE) because the direction vectors are computed using an eigenvector decomposition where the sign of the eigenvector is essentially random and subject to small numerical instabilities. Therefore - it does not usually make sense to rely on the value of vect exactly. - ndigest.neuron ignores the following fields:

    + it does not usually make sense to rely on the value of vect exactly.

    +

    ndigest.neuron ignores the following fields:

    • InputFileName

    • CreatedAt

    • @@ -165,45 +202,41 @@

      Details
    • InputFileStat

    • InputFileMD5

    - +

    See also

    -

    digest - all.equal.dotprops - all.equal.neuron

    - +

    Examples

    -
    stopifnot(all.equal(ndigest(kcs20[[1]]), "4c045b0343938259cd9986494fc1c2b0"))
    +
    stopifnot(all.equal(ndigest(kcs20[[1]]), "4c045b0343938259cd9986494fc1c2b0")) +
    - +
    -

    Site built with pkgdown.

    +

    Site built with pkgdown 1.6.1.

    + + + + + diff --git a/docs/reference/neuron-1.png b/docs/reference/neuron-1.png index 359d61fe..f631373b 100644 Binary files a/docs/reference/neuron-1.png and b/docs/reference/neuron-1.png differ diff --git a/docs/reference/neuron-10.png b/docs/reference/neuron-10.png deleted file mode 100644 index 6a7c6146..00000000 Binary files a/docs/reference/neuron-10.png and /dev/null differ diff --git a/docs/reference/neuron-12.png b/docs/reference/neuron-12.png deleted file mode 100644 index 903cdf7c..00000000 Binary files a/docs/reference/neuron-12.png and /dev/null differ diff --git a/docs/reference/neuron-2.png b/docs/reference/neuron-2.png index 21f6f8c7..5048e1d1 100644 Binary files a/docs/reference/neuron-2.png and b/docs/reference/neuron-2.png differ diff --git a/docs/reference/neuron-3.png b/docs/reference/neuron-3.png index a5301102..b01ed431 100644 Binary files a/docs/reference/neuron-3.png and b/docs/reference/neuron-3.png differ diff --git a/docs/reference/neuron-4.png b/docs/reference/neuron-4.png index dc75c2a2..cd031976 100644 Binary files a/docs/reference/neuron-4.png and b/docs/reference/neuron-4.png differ diff --git a/docs/reference/neuron-5.png b/docs/reference/neuron-5.png index 309deee5..b6cc07e8 100644 Binary files a/docs/reference/neuron-5.png and b/docs/reference/neuron-5.png differ diff --git a/docs/reference/neuron-6.png b/docs/reference/neuron-6.png index 8fa2084f..39031bd3 100644 Binary files a/docs/reference/neuron-6.png and b/docs/reference/neuron-6.png differ diff --git a/docs/reference/neuron-7.png b/docs/reference/neuron-7.png index 334c95b9..c723b436 100644 Binary files a/docs/reference/neuron-7.png and b/docs/reference/neuron-7.png differ diff --git a/docs/reference/neuron-8.png b/docs/reference/neuron-8.png deleted file mode 100644 index c8c7b995..00000000 Binary files a/docs/reference/neuron-8.png and /dev/null differ diff --git a/docs/reference/neuron-arithmetic.html b/docs/reference/neuron-arithmetic.html index 07b341c8..22ec9f0f 100644 --- a/docs/reference/neuron-arithmetic.html +++ b/docs/reference/neuron-arithmetic.html @@ -1,6 +1,6 @@ - + @@ -8,25 +8,48 @@ Arithmetic for neuron coordinates — *.neuron • nat + - + - - + + + + + + + - + + + + + + + + - - - + + + + + + + + + + - + + + - +
    +
    -
    +
    - +

    If x is a 1-vector or a 3-vector, multiply xyz only If x is a 4-vector, multiply xyz and diameter by that TODO Figure out how to document arithemtic functions in one go

    - +
    # S3 method for neuron
     *(n, x)
    @@ -115,8 +147,8 @@ 

    Arithmetic for neuron coordinates

    # S3 method for neuron /(n, x)
    - -

    Arguments

    + +

    Arguments

    @@ -128,48 +160,45 @@

    Ar

    (a numeric vector to multiply neuron coords in neuron)

    - +

    Value

    modified neuron

    -

    See also

    -

    neuron

    - +

    neuron

    Examples

    -
    n1<-Cell07PNs[[1]]*2 -n2<-Cell07PNs[[1]]*c(2,2,2,1) -stopifnot(all.equal(n1,n2)) -n3<-Cell07PNs[[1]]*c(2,2,4)
    +
    n1<-Cell07PNs[[1]]*2 +n2<-Cell07PNs[[1]]*c(2,2,2,1) +stopifnot(all.equal(n1,n2)) +n3<-Cell07PNs[[1]]*c(2,2,4) +
    - +
    -

    Site built with pkgdown.

    +

    Site built with pkgdown 1.6.1.

    + + + + + diff --git a/docs/reference/neuron.html b/docs/reference/neuron.html index a6d18348..98dcf50d 100644 --- a/docs/reference/neuron.html +++ b/docs/reference/neuron.html @@ -1,6 +1,6 @@ - + @@ -8,25 +8,55 @@ neuron: class to represent traced neurons — neuron • nat + - + - - + + + + + + + - + + + + + + + + - - - + + + + + + + + + + - + + + - +
    +
    -
    +
    - -

    neuron makes a neuron object from appropriate variables. - - is.neuron will check if an object looks like a neuron. - - as.neuron will convert a suitable object to a neuron - - as.neuron.data.frame expects a block of SWC format data - - as.neuron.ngraph converts a graph (typically an - ngraph object) to a neuron - - as.neuron.igraph will convert an ngraph compatible - igraph object into a neuron. - - as.neuron.default will add class "neuron" to a neuron-like +

    +

    neuron makes a neuron object from appropriate variables.

    +

    is.neuron will check if an object looks like a neuron.

    +

    as.neuron will convert a suitable object to a neuron

    +

    as.neuron.data.frame expects a block of SWC format data

    +

    as.neuron.ngraph converts a graph (typically an + ngraph object) to a neuron

    +

    as.neuron.igraph will convert an ngraph compatible + igraph object into a neuron.

    +

    as.neuron.default will add class "neuron" to a neuron-like object.

    - +
    -
    neuron(d, NumPoints = nrow(d), StartPoint, BranchPoints = integer(),
    -  EndPoints, SegList, SubTrees = NULL, InputFileName = NULL,
    -  NeuronName = NULL, ..., MD5 = TRUE)
    +    
    neuron(
    +  d,
    +  NumPoints = nrow(d),
    +  StartPoint,
    +  BranchPoints = integer(),
    +  EndPoints,
    +  SegList,
    +  SubTrees = NULL,
    +  InputFileName = NULL,
    +  NeuronName = NULL,
    +  ...,
    +  MD5 = TRUE
    +)
     
    -is.neuron(x, Strict = FALSE)
    +is.neuron(x, Strict = FALSE)
     
    -as.neuron(x, ...)
    +as.neuron(x, ...)
     
     # S3 method for data.frame
    -as.neuron(x, ...)
    +as.neuron(x, ...)
     
     # S3 method for ngraph
    -as.neuron(x, vertexData = NULL, origin = NULL,
    -  Verbose = FALSE, ...)
    +as.neuron(x, vertexData = NULL, origin = NULL, Verbose = FALSE, ...)
     
     # S3 method for igraph
    -as.neuron(x, ...)
    +as.neuron(x, ...)
     
     # S3 method for default
    -as.neuron(x, ...)
    - -

    Arguments

    +as.neuron(x, ...)
    + +

    Arguments

    @@ -208,13 +250,12 @@

    Ar

    Whether to be verbose (default: FALSE)

    - +

    Value

    A list with elements: (NumPoints,StartPoint,BranchPoints,EndPoints,nTrees,NumSegs,SegList, [SubTrees]) NB SubTrees will only be present when nTrees>1.

    -

    Details

    neuron objects consist of a list containing multiple fields describing the 3D @@ -240,35 +281,38 @@

    Details

    When the graph vertices have a label attribute derived from PointNo, the origin is assumed to be specified with respect to the vertex labels rather than the raw vertex ids.

    -

    See also

    -

    neuronlist - graph.dfs, as.seglist

    -

    Other neuron: ngraph, - plot.neuron, - potential_synapses, prune, - resample, rootpoints, - spine, subset.neuron

    - +

    neuronlist

    +

    graph.dfs, as.seglist

    +

    Other neuron: +ngraph(), +plot.neuron(), +potential_synapses(), +prune(), +resample(), +rootpoints(), +spine(), +subset.neuron()

    Examples

    ## See help for functions listed in See Also for more detailed examples ## Basic properties # a sample neuron -n = Cell07PNs[[1]] +n = Cell07PNs[[1]] # inspect its internal structure -str(n)
    #> List of 24 +str(n) +
    #> List of 24 #> $ CellType : chr "DA1" #> $ NeuronName : chr "EBH11R" -#> $ InputFileName:Class 'AsIs' chr "/GD/projects/PN2/TransformedTraces/DA1/EBH11R.tasc" +#> $ InputFileName: 'AsIs' chr "/GD/projects/PN2/TransformedTraces/DA1/EBH11R.tasc" #> $ CreatedAt : POSIXt[1:1], format: "2006-01-17 15:21:14" #> $ NodeName : Named chr "jefferis.joh.cam.ac.uk" #> ..- attr(*, "names")= chr "nodename" #> $ InputFileStat:'data.frame': 1 obs. of 10 variables: #> ..$ size : num 15379 #> ..$ isdir : logi FALSE -#> ..$ mode :Class 'octmode' int 420 +#> ..$ mode : 'octmode' int 644 #> ..$ mtime : POSIXt[1:1], format: "2006-01-12 00:52:01" #> ..$ ctime : POSIXt[1:1], format: "2006-01-12 00:52:01" #> ..$ atime : POSIXt[1:1], format: "2006-01-17 15:21:14" @@ -277,7 +321,7 @@

    Examp #> ..$ uname : chr "jefferis" #> ..$ grname: chr "jefferis" #> $ InputFileMD5 : Named chr "fcacee3f874cbe2c6ad96214e6fee337" -#> ..- attr(*, "names")=Class 'AsIs' chr "/GD/projects/PN2/TransformedTraces/DA1/EBH11R.tasc" +#> ..- attr(*, "names")= 'AsIs' chr "/GD/projects/PN2/TransformedTraces/DA1/EBH11R.tasc" #> $ NumPoints : int 180 #> $ StartPoint : num 1 #> $ BranchPoints : num [1:16] 34 48 51 75 78 95 98 99 108 109 ... @@ -346,14 +390,16 @@

    Examp #> $ NumMBBranches: num 2 #> $ AxonLHEP : num 72 #> - attr(*, "class")= chr [1:2] "neuron" "list"

    # summary of 3D points -summary(xyzmatrix(n))
    #> X Y Z +summary(xyzmatrix(n)) +
    #> X Y Z #> Min. :186.9 Min. : 90.36 Min. : 88.2 #> 1st Qu.:225.6 1st Qu.: 97.56 1st Qu.:103.4 #> Median :258.4 Median :102.70 Median :112.9 #> Mean :249.4 Mean :104.03 Mean :120.9 #> 3rd Qu.:277.7 3rd Qu.:109.04 3rd Qu.:139.0 #> Max. :289.5 Max. :132.71 Max. :157.3
    # identify 3d location of endpoints -xyzmatrix(n)[endpoints(n),]
    #> X Y Z +xyzmatrix(n)[endpoints(n),] +
    #> X Y Z #> 1 186.8660 132.70932 88.20393 #> 42 224.7067 109.86362 153.58749 #> 59 229.6343 92.30637 157.29700 @@ -374,8 +420,10 @@

    Examp #> 180 289.5364 111.96014 109.18281

    ## Other methods # plot -plot(n)
    # all methods for neuron objects -methods(class = 'neuron')
    #> [1] - * / + +plot(n) +
    # all methods for neuron objects +methods(class = 'neuron') +
    #> [1] - * / + #> [5] all.equal as.neuron as.ngraph as.seglist #> [9] boundingbox branchpoints dotprops endpoints #> [13] ndigest nvertices plot plot3d @@ -385,19 +433,24 @@

    Examp #> see '?methods' for accessing help and source code

    ## Neurons as graphs # convert to graph and find longest paths by number of nodes -ng=as.ngraph(n) -hist(igraph::distances(ng))
    # ... or in distances microns -ngw=as.ngraph(n, weights=TRUE) -hist(igraph::distances(ngw))
    +ng=as.ngraph(n) +hist(igraph::distances(ng)) +
    # ... or in distances microns +ngw=as.ngraph(n, weights=TRUE) +hist(igraph::distances(ngw)) +
    # converting back and forth between neurons and graphs -g=as.ngraph(Cell07PNs[[1]]) -gstem=igraph::induced.subgraph(g, 1:10) +g=as.ngraph(Cell07PNs[[1]]) +gstem=igraph::induced.subgraph(g, 1:10) # this is fine -plot(gstem)
    plot(as.neuron(gstem))
    +plot(gstem) +
    plot(as.neuron(gstem)) +
    # but if you had an undirected graph -ug=igraph::as.undirected(gstem) +ug=igraph::as.undirected(gstem) # you get a warning because there is no explicit origin for the graph -as.neuron(ug)
    #> Warning: No valid origin found! Using first endpoint as origin
    #> $NumPoints +as.neuron(ug) +
    #> Warning: No valid origin found! Using first endpoint as origin
    #> $NumPoints #> [1] 10 #> #> $StartPoint @@ -438,37 +491,35 @@

    Examp #> attr(,"class") #> [1] "neuron" "list"

    # If you need finer control of the conversion process -gstem2=as.ngraph(ug, root = 10) -plot(gstem2)
    plot(as.neuron(gstem2))
    +gstem2=as.ngraph(ug, root = 10) +plot(gstem2) +
    plot(as.neuron(gstem2)) +
    - +
    -

    Site built with pkgdown.

    +

    Site built with pkgdown 1.6.1.

    + + + + + diff --git a/docs/reference/neuronlist-arithmetic.html b/docs/reference/neuronlist-arithmetic.html index e567a544..1c1ee06c 100644 --- a/docs/reference/neuronlist-arithmetic.html +++ b/docs/reference/neuronlist-arithmetic.html @@ -1,6 +1,6 @@ - + @@ -8,25 +8,48 @@ Arithmetic for neuron coordinates applied to neuronlists — *.neuronlist • nat + - + - - + + + + + + + - + + + + + + + + - - - + + + + + + + + + + - + + + - +
    +
    -
    +
    - +

    If x is one number or 3-vector, multiply coordinates by that If x is a 4-vector, multiply xyz and diameter TODO Figure out how to document arithemtic functions in one go

    - +
    # S3 method for neuronlist
     *(x, y)
    @@ -115,8 +147,8 @@ 

    Arithmetic for neuron coordinates applied to neuronlists

    # S3 method for neuronlist /(x, y)
    - -

    Arguments

    + +

    Arguments

    @@ -128,49 +160,49 @@

    Ar

    (a numeric vector to multiply coords in neuronlist members)

    - +

    Value

    modified neuronlist

    -

    See also

    -

    Other neuronlist: is.neuronlist, - neuronlist-dataframe-methods, - neuronlistfh, neuronlist, - nlapply, read.neurons, - write.neurons

    - +

    Examples

    -
    mn2<-Cell07PNs[1:10]*2
    +
    mn2<-Cell07PNs[1:10]*2 +
    - +
    -

    Site built with pkgdown.

    +

    Site built with pkgdown 1.6.1.

    + + + + + diff --git a/docs/reference/neuronlist-dataframe-methods.html b/docs/reference/neuronlist-dataframe-methods.html index a1d90260..22074f23 100644 --- a/docs/reference/neuronlist-dataframe-methods.html +++ b/docs/reference/neuronlist-dataframe-methods.html @@ -1,6 +1,6 @@ - + @@ -8,25 +8,57 @@ Methods for working with the dataframe attached to a neuronlist — neuronlist-dataframe-methods • nat + - + - - + + + + + + + - + + + + + + + + - - - + + + + + + + + + + - + + + - +
    +
    -
    +
    - +

    [.neuronlist and [<-.neuronlist behave like the corresponding base methods ([.data.frame, [<-.data.frame) allowing extraction or replacement of parts of the data.frame attached to - the neuronlist. - - droplevels Remove redundant factor levels in dataframe - attached to neuronlist - - with Evaluate expression in the context of dataframe - attached to a neuronlist - - head Return the first part of data.frame attached to - neuronlist - - tail Return the last part of data.frame attached to + the neuronlist.

    +

    droplevels Remove redundant factor levels in dataframe + attached to neuronlist

    +

    with Evaluate expression in the context of dataframe + attached to a neuronlist

    +

    head Return the first part of data.frame attached to neuronlist

    - +

    tail Return the last part of data.frame attached to + neuronlist

    +
    # S3 method for neuronlist
     [(x, i, j, drop)
     
     # S3 method for neuronlist
    -[(x, i, j) <- value
    +[(x, i, j) <- value
     
     # S3 method for neuronlist
     droplevels(x, except = NULL, ...)
    @@ -134,8 +171,8 @@ 

    Methods for working with the dataframe attached to a neuronlist

    # S3 method for neuronlist tail(x, ...)
    - -

    Arguments

    + +

    Arguments

    @@ -146,7 +183,7 @@

    Ar

    +as.integer. See [.data.frame for details.

    @@ -178,33 +215,37 @@

    Ar

    i, j

    elements to extract or replace. Numeric or character or, for [ only, empty. Numeric values are coerced to integer as if by -as.integer. See [.data.frame for details.

    drop

    The expression to evaluate

    - +

    Value

    the attached dataframe with levels dropped (NB not the neuronlist)

    -

    See also

    -

    [.data.frame, @seealso [<-.data.frame - droplevels - with - head - tail

    -

    Other neuronlist: *.neuronlist, - is.neuronlist, neuronlistfh, - neuronlist, nlapply, - read.neurons, write.neurons

    - +

    [.data.frame, @seealso [<-.data.frame

    +

    droplevels

    +

    with

    +

    head

    +

    tail

    +

    Other neuronlist: +*.neuronlist(), +is.neuronlist(), +neuronlistfh(), +neuronlist(), +nlapply(), +read.neurons(), +write.neurons()

    Examples

    ## treat kcs20 as data.frame -kcs20[1, ]
    #> gene_name Name idid soma_side +kcs20[1, ] +
    #> gene_name Name idid soma_side #> FruMARCM-M001205_seg002 FruMARCM-M001205_seg002 fru-M-500112 1024 L #> flipped Driver Gender X Y Z #> FruMARCM-M001205_seg002 FALSE fru-Gal4 M 361.4849 95.0448 84.10259 #> exemplar cluster idx type -#> FruMARCM-M001205_seg002 FruMARCM-M001205_seg002 9 156 gamma
    kcs20[1:3, ]
    #> gene_name Name idid soma_side +#> FruMARCM-M001205_seg002 FruMARCM-M001205_seg002 9 156 gamma
    kcs20[1:3, ] +
    #> gene_name Name idid soma_side #> FruMARCM-M001205_seg002 FruMARCM-M001205_seg002 fru-M-500112 1024 L #> GadMARCM-F000122_seg001 GadMARCM-F000122_seg001 Gad1-F-900005 10616 L #> GadMARCM-F000050_seg001 GadMARCM-F000050_seg001 Gad1-F-100010 8399 R @@ -215,7 +256,8 @@

    Examp #> exemplar cluster idx type #> FruMARCM-M001205_seg002 FruMARCM-M001205_seg002 9 156 gamma #> GadMARCM-F000122_seg001 GadMARCM-F000122_seg001 70 1519 gamma -#> GadMARCM-F000050_seg001 GadMARCM-F000050_seg001 57 1132 ab

    kcs20[, 1:4]
    #> gene_name Name idid soma_side +#> GadMARCM-F000050_seg001 GadMARCM-F000050_seg001 57 1132 ab
    kcs20[, 1:4] +
    #> gene_name Name idid soma_side #> FruMARCM-M001205_seg002 FruMARCM-M001205_seg002 fru-M-500112 1024 L #> GadMARCM-F000122_seg001 GadMARCM-F000122_seg001 Gad1-F-900005 10616 L #> GadMARCM-F000050_seg001 GadMARCM-F000050_seg001 Gad1-F-100010 8399 R @@ -235,9 +277,11 @@

    Examp #> GadMARCM-F000071_seg001 GadMARCM-F000071_seg001 Gad1-F-300023 10541 R #> FruMARCM-M000115_seg001 FruMARCM-M000115_seg001 fru-M-100014 2389 L #> GadMARCM-F000442_seg002 GadMARCM-F000442_seg002 Gad1-F-700033 9569 R -#> FruMARCM-F001929_seg001 FruMARCM-F001929_seg001 fru-F-400181 4694 L

    kcs20[, 'soma_side']
    #> [1] L L R L L R R R R R R R R L R R R L R L +#> FruMARCM-F001929_seg001 FruMARCM-F001929_seg001 fru-F-400181 4694 L
    kcs20[, 'soma_side'] +
    #> [1] L L R L L R R R R R R R R L R R R L R L #> Levels: L M R
    # alternative to as.data.frame(kcs20) -kcs20[, ]
    #> gene_name Name idid soma_side +kcs20[, ] +
    #> gene_name Name idid soma_side #> FruMARCM-M001205_seg002 FruMARCM-M001205_seg002 fru-M-500112 1024 L #> GadMARCM-F000122_seg001 GadMARCM-F000122_seg001 Gad1-F-900005 10616 L #> GadMARCM-F000050_seg001 GadMARCM-F000050_seg001 Gad1-F-100010 8399 R @@ -301,9 +345,10 @@

    Examp #> GadMARCM-F000442_seg002 GadMARCM-F000442_seg002 62 1277 gamma #> FruMARCM-F001929_seg001 FruMARCM-F001929_seg001 36 610 ab

    ## can also set columns -kcs13=kcs20[1:3] -kcs13[,'side']=as.character(kcs13[,'soma_side']) -head(kcs13)
    #> gene_name Name idid soma_side +kcs13=kcs20[1:3] +kcs13[,'side']=as.character(kcs13[,'soma_side']) +head(kcs13) +
    #> gene_name Name idid soma_side #> FruMARCM-M001205_seg002 FruMARCM-M001205_seg002 fru-M-500112 1024 L #> GadMARCM-F000122_seg001 GadMARCM-F000122_seg001 Gad1-F-900005 10616 L #> GadMARCM-F000050_seg001 GadMARCM-F000050_seg001 Gad1-F-100010 8399 R @@ -315,17 +360,20 @@

    Examp #> FruMARCM-M001205_seg002 FruMARCM-M001205_seg002 9 156 gamma L #> GadMARCM-F000122_seg001 GadMARCM-F000122_seg001 70 1519 gamma L #> GadMARCM-F000050_seg001 GadMARCM-F000050_seg001 57 1132 ab R

    # or parts of columns -kcs13[1,'soma_side']='R' -kcs13['FruMARCM-M001205_seg002','soma_side']='L' +kcs13[1,'soma_side']='R' +kcs13['FruMARCM-M001205_seg002','soma_side']='L' # remove a column -kcs13[,'side']=NULL -all.equal(kcs13, kcs20[1:3])
    #> [1] TRUE
    +kcs13[,'side']=NULL +all.equal(kcs13, kcs20[1:3]) +
    #> [1] TRUE
    # can even replace the whole data.frame like this -kcs13[,]=kcs13[,] -all.equal(kcs13, kcs20[1:3])
    #> [1] TRUE
    +kcs13[,]=kcs13[,] +all.equal(kcs13, kcs20[1:3]) +
    #> [1] TRUE
    ## get row/column names of attached data.frame # (unfortunately implementing ncol/nrow is challenging) -rownames(kcs20)
    #> [1] "FruMARCM-M001205_seg002" "GadMARCM-F000122_seg001" +rownames(kcs20) +
    #> [1] "FruMARCM-M001205_seg002" "GadMARCM-F000122_seg001" #> [3] "GadMARCM-F000050_seg001" "GadMARCM-F000142_seg002" #> [5] "FruMARCM-F000270_seg001" "FruMARCM-F001115_seg002" #> [7] "FruMARCM-M001051_seg002" "GadMARCM-F000423_seg001" @@ -334,36 +382,35 @@

    Examp #> [13] "FruMARCM-F000706_seg001" "FruMARCM-M000842_seg002" #> [15] "FruMARCM-F001494_seg002" "FruMARCM-F000188_seg001" #> [17] "GadMARCM-F000071_seg001" "FruMARCM-M000115_seg001" -#> [19] "GadMARCM-F000442_seg002" "FruMARCM-F001929_seg001"

    colnames(kcs20)
    #> [1] "gene_name" "Name" "idid" "soma_side" "flipped" "Driver" +#> [19] "GadMARCM-F000442_seg002" "FruMARCM-F001929_seg001"
    colnames(kcs20) +
    #> [1] "gene_name" "Name" "idid" "soma_side" "flipped" "Driver" #> [7] "Gender" "X" "Y" "Z" "exemplar" "cluster" #> [13] "idx" "type"
    - +
    -

    Site built with pkgdown.

    +

    Site built with pkgdown 1.6.1.

    + + + + + diff --git a/docs/reference/neuronlist.html b/docs/reference/neuronlist.html index 4629c1b7..72e511b4 100644 --- a/docs/reference/neuronlist.html +++ b/docs/reference/neuronlist.html @@ -1,6 +1,6 @@ - + @@ -8,25 +8,55 @@ Create a neuronlist from zero or more neurons — neuronlist • nat + - + - - + + + + + + + - + + + + + + + + - - - + + + + + + + + + + - + + + - +
    +
    -
    +
    - +

    neuronlist objects consist of a list of neuron objects - (usually of class neuron or dotprops) along + (usually of class neuron or dotprops) along with an optional attached dataframe containing information about the neurons. neuronlist objects can be indexed using their name or the number of the neuron like a regular list. Both the list itself and the attached data.frame must have the same unique (row)names. If the - [ operator is used to index the list, the attached dataframe will + [ operator is used to index the list, the attached dataframe will also be subsetted.

    It is perfectly acceptable not to pass any parameters, generating an empty neuronlist

    - +
    -
    neuronlist(..., DATAFRAME = NULL)
    - -

    Arguments

    +
    neuronlist(..., DATAFRAME = NULL)
    + +

    Arguments

    @@ -126,34 +165,36 @@

    Ar containing information about each neuron.

    - +

    Value

    A new neuronlist object.

    -

    See also

    -

    as.data.frame.neuronlist, - neuronlist-dataframe-methods, neuron, - dotprops

    -

    Other neuronlist: *.neuronlist, - is.neuronlist, - neuronlist-dataframe-methods, - neuronlistfh, nlapply, - read.neurons, write.neurons

    - +

    Examples

    # generate an empty neuronlist -nl=neuronlist() +nl=neuronlist() # slice an existing neuronlist with regular indexing -kcs5=kcs20[1:5] +kcs5=kcs20[1:5] # extract a single neuron from a neuronlist -n1=Cell07PNs[[1]] +n1=Cell07PNs[[1]] # list all methods for neuronlist objects -methods(class='neuronlist')
    #> [1] - [ [<- * +methods(class='neuronlist') +
    #> [1] - [ [<- * #> [5] / + as.data.frame as.neuronlistfh #> [9] c data.frame<- dimnames dotprops #> [13] droplevels head intersect mirror @@ -163,32 +204,30 @@

    Examp #> [29] xyzmatrix xyzmatrix<- #> see '?methods' for accessing help and source code

    - +
    -

    Site built with pkgdown.

    +

    Site built with pkgdown 1.6.1.

    + + + + + diff --git a/docs/reference/neuronlistfh.html b/docs/reference/neuronlistfh.html index b8079474..7ed46c37 100644 --- a/docs/reference/neuronlistfh.html +++ b/docs/reference/neuronlistfh.html @@ -1,6 +1,6 @@ - + @@ -8,25 +8,62 @@ neuronlistfh - List of neurons loaded on demand from disk or remote website — neuronlistfh • nat + - + - - + + + + + + + - + + + + + + + + - - - + + + + + + + + + + - + + + - +
    +
    -
    +
    - +

    neuronlistfh objects consist of a list of neuron objects along with an optional attached dataframe containing information about the neurons. In contrast to neuronlist objects the neurons are not @@ -110,29 +156,32 @@

    neuronlistfh - List of neurons loaded on demand from disk or remote website< filehash, data.frame and keyfilemap. End users will not typically use this function to make a neuronlistfh. They will usually read them using read.neuronlistfh and sometimes - create them by using as.neuronlistfh on a neuronlist object. - - is.neuronlistfh test if an object is a neuronlistfh - - as.neuronlistfh generic function to convert an object to - neuronlistfh - - as.neuronlistfh.neuronlist converts a regular neuronlist + create them by using as.neuronlistfh on a neuronlist object.

    +

    is.neuronlistfh test if an object is a neuronlistfh

    +

    as.neuronlistfh generic function to convert an object to + neuronlistfh

    +

    as.neuronlistfh.neuronlist converts a regular neuronlist to one backed by a filehash object with an on disk representation

    - +

    -
    neuronlistfh(db, df, keyfilemap, hashmap = 1000L)
    +    
    neuronlistfh(db, df, keyfilemap, hashmap = 1000L)
     
    -is.neuronlistfh(nl)
    +is.neuronlistfh(nl)
     
    -as.neuronlistfh(x, df, ...)
    +as.neuronlistfh(x, df, ...)
     
     # S3 method for neuronlist
    -as.neuronlistfh(x, df = attr(x, "df"), dbdir = NULL,
    -  dbClass = c("RDS", "RDS2"), remote = NULL, WriteObjects = c("yes", "no",
    -  "missing"), ...)
    - -

    Arguments

    +as.neuronlistfh( + x, + df = attr(x, "df"), + dbdir = NULL, + dbClass = c("RDS", "RDS2"), + remote = NULL, + WriteObjects = c("yes", "no", "missing"), + ... +)
    + +

    Arguments

    @@ -192,13 +241,12 @@

    Ar existing objects will not be overwritten. Default "yes".

    - +

    Value

    a neuronlistfh object which is a character vector with classes neuronlistfh, neuronlist and attributes db, df. See Implementation details.

    -

    Implementation details

    neuronlistfh objects are a hybrid between @@ -235,13 +283,15 @@

    See also

    -

    filehash-class

    -

    Other neuronlistfh: [.neuronlistfh, - read.neuronlistfh, - remotesync, - write.neuronlistfh

    -

    Other neuronlist: *.neuronlist, - is.neuronlist, - neuronlist-dataframe-methods, - neuronlist, nlapply, - read.neurons, write.neurons

    - +

    Examples

    -
    # NOT RUN {
    -kcnl=read.neuronlistfh('http://jefferislab.org/si/nblast/flycircuit/kcs20.rds',
    -'path/to/my/project/folder')
    +    
    if (FALSE) { +kcnl=read.neuronlistfh('http://jefferislab.org/si/nblast/flycircuit/kcs20.rds', +'path/to/my/project/folder') # this will automatically download the neurons from the web the first time # it is run -plot3d(kcnl) -# }# NOT RUN { +plot3d(kcnl) +} +if (FALSE) { # create neuronlistfh object backed by filehash with one file per neuron # by convention we create a subfolder called data in which the objects live -kcs20fh=as.neuronlistfh(kcs20, dbdir='/path/to/my/kcdb/data') -plot3d(subset(kcs20fh,type=='gamma')) +kcs20fh=as.neuronlistfh(kcs20, dbdir='/path/to/my/kcdb/data') +plot3d(subset(kcs20fh,type=='gamma')) # ... and, again by convention, save the neuronlisfh object next to filehash # backing database -write.neuronlistfh(kcs20fh, file='/path/to/my/kcdb/kcdb.rds') +write.neuronlistfh(kcs20fh, file='/path/to/my/kcdb/kcdb.rds') # in a new session -read.neuronlistfh("/path/to/my/kcdb/kcdb.rds") -plot3d(subset(kcs20fh, type=='gamma')) -# }
    +read.neuronlistfh("/path/to/my/kcdb/kcdb.rds") +plot3d(subset(kcs20fh, type=='gamma')) +} +
    - +
    -

    Site built with pkgdown.

    +

    Site built with pkgdown 1.6.1.

    + + + + + diff --git a/docs/reference/ngraph.html b/docs/reference/ngraph.html index 7bf94b8d..9e4158a4 100644 --- a/docs/reference/ngraph.html +++ b/docs/reference/ngraph.html @@ -1,6 +1,6 @@ - + @@ -8,25 +8,53 @@ ngraph: a graph to encode a neuron's connectivity — ngraph • nat + - + - - + + + + + + + - + + + + + + + + - - - + + + + + + + + + + - + + + - +
    +
    -
    +
    - +

    the ngraph class contains a (completely general) graph representation of a neuron's connectivity in an igraph object. It may additionally contain vertex label or position data. See details.

    -

    ngraph() creates an ngraph from edge and vertex information. - - as.ngraph converts an object to an ngraph - - as.ngraph.dataframe construct ngraph from a data.frame - containing SWC format data - - as.ngraph.neuron construct ngraph from a neuron

    - +

    ngraph() creates an ngraph from edge and vertex information.

    +

    as.ngraph converts an object to an ngraph

    +

    as.ngraph.dataframe construct ngraph from a data.frame + containing SWC format data

    +

    as.ngraph.neuron construct ngraph from a neuron

    +
    -
    ngraph(el, vertexlabels, xyz = NULL, diam = NULL, directed = TRUE,
    -  weights = FALSE, vertex.attributes = NULL, graph.attributes = NULL)
    +    
    ngraph(
    +  el,
    +  vertexlabels,
    +  xyz = NULL,
    +  diam = NULL,
    +  directed = TRUE,
    +  weights = FALSE,
    +  vertex.attributes = NULL,
    +  graph.attributes = NULL
    +)
     
    -as.ngraph(x, ...)
    +as.ngraph(x, ...)
     
     # S3 method for data.frame
    -as.ngraph(x, directed = TRUE, ...)
    +as.ngraph(x, directed = TRUE, ...)
     
     # S3 method for neuron
    -as.ngraph(x, directed = TRUE, method = c("swc", "seglist"),
    -  ...)
    - -

    Arguments

    +as.ngraph(x, directed = TRUE, method = c("swc", "seglist"), ...)
    + +

    Arguments

    @@ -161,7 +202,7 @@

    Ar

    +graph. See set.vertex.attribute for details.

    @@ -177,18 +218,16 @@

    Ar neuronal connectivity to generate graph.

    List of named attributes to be added to the graph. The elements of vertex.attributes must be vectors whose length is compatible with the number of elements in the -graph. See set.vertex.attribute for details.

    x
    - +

    Value

    an igraph object with additional class ngraph, having a vertex for each entry in vertexlabels, each vertex having a label attribute. All vertices are included whether connected or not.

    -

    Details

    Note that the as.ngraph.neuron method always keeps the original vertex labels (a.k.a. PointNo) as read in from the original file.

    -

    Connectivity

    We make the following assumptions about neurons coming @@ -199,76 +238,74 @@

    <
  • The edge list which defines connectivity specifies edges using pairs of vertex labels, _not_ raw vertex ids.

  • -

    We make no attempt to determine the root points at this stage.

    + +

    We make no attempt to determine the root points at this stage.

    The raw vertex ids in the graph will be in the order of vertexlabels and can therefore be used to index a block of vertex coordinates. The vertexlabels will be stored using the vertex attribute label

    When the graph is directed (default) the edges will be from the root to the other tips of the neuron.

    -

    Morphology

    The morphology of the neuron is encoded by the combination of connectivity information (i.e. the graph) and spatial data encoded as the 3D position and diameter of each vertex. Position information is stored as vertex attributes X, Y, and Z.

    -

    See also

    -

    igraph, set.vertex.attribute, +

    igraph, set.vertex.attribute, subset.neuron for example of graph-based manipulation of a neuron.

    -

    Other neuron: neuron, - plot.neuron, - potential_synapses, prune, - resample, rootpoints, - spine, subset.neuron

    - +

    Other neuron: +neuron(), +plot.neuron(), +potential_synapses(), +prune(), +resample(), +rootpoints(), +spine(), +subset.neuron()

    Examples

    -
    g=as.ngraph(Cell07PNs[[1]]) -library(igraph)
    #> +
    g=as.ngraph(Cell07PNs[[1]]) +library(igraph) +
    #> #> Attaching package: ‘igraph’
    #> The following object is masked from ‘package:nat’: #> -#> union
    #> The following objects are masked from ‘package:stats’: +#> union
    #> The following object is masked from ‘package:testthat’: +#> +#> compare
    #> The following objects are masked from ‘package:stats’: #> #> decompose, spectrum
    #> The following object is masked from ‘package:base’: #> #> union
    # check that vertex attributes of graph match X position -all.equal(V(g)$X, Cell07PNs[[1]]$d$X)
    #> [1] TRUE
    +all.equal(V(g)$X, Cell07PNs[[1]]$d$X) +
    #> [1] TRUE
    - +
    -

    Site built with pkgdown.

    +

    Site built with pkgdown 1.6.1.

    + + + + + diff --git a/docs/reference/nlapply.html b/docs/reference/nlapply.html index 81016efa..6c778f7e 100644 --- a/docs/reference/nlapply.html +++ b/docs/reference/nlapply.html @@ -1,6 +1,6 @@ - + @@ -8,25 +8,50 @@ lapply and mapply for neuronlists (with optional parallelisation) — nlapply • nat + - + - - + + + + + + + - + + + + + + + + - - - + + + + + + + + + + - + + + - +
    +
    -
    +
    - +

    versions of lapply and mapply that look after the class and attached dataframe of neuronlist objects. nlapply can apply a function to only a subset of elements in the input neuronlist. - Internally nlapply uses plyr::llply thereby enabling progress + Internally nlapply uses plyr::llply thereby enabling progress bars and simple parallelisation (see plyr section and examples).

    - +
    -
    nlapply(X, FUN, ..., subset = NULL, OmitFailures = NA,
    -  .progress = getOption("nat.progress", default = "auto"))
    +    
    nlapply(
    +  X,
    +  FUN,
    +  ...,
    +  subset = NULL,
    +  OmitFailures = NA,
    +  .progress = getOption("nat.progress", default = "auto")
    +)
     
    -nmapply(FUN, X, ..., MoreArgs = NULL, SIMPLIFY = FALSE, USE.NAMES = TRUE,
    -  subset = NULL, OmitFailures = NA)
    - -

    Arguments

    +nmapply( + FUN, + X, + ..., + MoreArgs = NULL, + SIMPLIFY = FALSE, + USE.NAMES = TRUE, + subset = NULL, + OmitFailures = NA +)
    + +

    Arguments

    @@ -143,10 +191,10 @@

    Ar

    @@ -157,20 +205,18 @@

    Ar

    + the simplify argument of sapply.

    - +
    .progress

    Character vector specifying the type of progress bar (see -create_progress_bar for options.) The default value of +create_progress_bar for options.) The default value of "auto" shows a progress bar in interactive use when there are >=10 elements in X. The default value can be overridden for the current -session by setting the value of options(nat.progressbar) (see +session by setting the value of options(nat.progressbar) (see examples).

    SIMPLIFY

    logical or character string; attempt to reduce the result to a vector, matrix or higher dimensional array; see - the simplify argument of sapply.

    USE.NAMES

    logical; use names if the first … argument has - names, or if it is a character vector, use that character vector as - the names.

    logical; use the names of the first ... argument, or + if that is an unnamed character vector, use that vector as the names.

    - +

    Value

    A neuronlist

    -

    Details

    When OmitFailures is not NA, FUN will be @@ -180,8 +226,7 @@

    Details return values for which FUN evaluated successfully. When OmitFailures=FALSE, "try-error" objects will be left in place. In either of the last 2 cases error messages will not be printed because the - call is wrapped as try(expr, silent=TRUE).

    - + call is wrapped as try(expr, silent=TRUE).

    plyr

    The arguments of most interest from plyr are:

    @@ -193,9 +238,10 @@

    plyr

  • .parallel set to TRUE for parallelisation after registering a parallel backend (see below).

  • .paropts Additional arguments for parallel computation. See - llply for details.

  • + llply for details.

    -

    Before using parallel code within an R session you must register a suitable + +

    Before using parallel code within an R session you must register a suitable parallel backend. The simplest example is the multicore option provided by the doMC package that is suitable for a spreading computational load across multiple cores on a single machine. An example is provided below.

    @@ -203,89 +249,95 @@

    plyr

    time. You may want to start a potentially long-running job with the progress bar option and then abort and re-run with .parallel=TRUE if it looks likely to take a very long time.

    -

    See also

    -

    lapply - mapply

    -

    Other neuronlist: *.neuronlist, - is.neuronlist, - neuronlist-dataframe-methods, - neuronlistfh, neuronlist, - read.neurons, write.neurons

    - +

    Examples

    ## nlapply example -kcs.reduced=nlapply(kcs20,function(x) subset(x,sample(nrow(x$points),50))) -open3d()
    #> glX -#> 4
    plot3d(kcs.reduced,col='red', lwd=2) -plot3d(kcs20,col='grey') -rgl.close()
    # NOT RUN { +kcs.reduced=nlapply(kcs20,function(x) subset(x,sample(nrow(x$points),50))) +open3d() +
    #> glX +#> 4
    plot3d(kcs.reduced,col='red', lwd=2) +plot3d(kcs20,col='grey') +rgl.close() + +if (FALSE) { # example of using plyr's .inform argument for debugging error conditions -xx=nlapply(Cell07PNs, prune_strahler) +xx=nlapply(Cell07PNs, prune_strahler) # oh dear there was an error, let's get some details about the neuron # that caused the problem -xx=nlapply(Cell07PNs, prune_strahler, .inform=TRUE) -# }
    -
    # NOT RUN { +xx=nlapply(Cell07PNs, prune_strahler, .inform=TRUE) +} + +if (FALSE) { ## nlapply example with plyr ## dotprops.neuronlist uses nlapply under the hood ## the .progress and .parallel arguments are passed straight to -system.time(d1<-dotprops(kcs20,resample=1,k=5,.progress='text')) +system.time(d1<-dotprops(kcs20,resample=1,k=5,.progress='text')) ## plyr+parallel -library(doMC) +library(doMC) # can also specify cores e.g. registerDoMC(cores=4) -registerDoMC() -system.time(d2<-dotprops(kcs20,resample=1,k=5,.parallel=TRUE)) -stopifnot(all.equal(d1,d2)) -# }
    +registerDoMC() +system.time(d2<-dotprops(kcs20,resample=1,k=5,.parallel=TRUE)) +stopifnot(all.equal(d1,d2)) +} + ## nmapply example # flip first neuron in X, second in Y and 3rd in Z -xyzflip=nmapply(mirror, kcs20[1:3], mirrorAxis = c("X","Y","Z"), - mirrorAxisSize=c(400,20,30))
    open3d()
    #> glX -#> 5
    plot3d(kcs20[1:3]) -plot3d(xyzflip) -rgl.close()
    -
    # NOT RUN { +xyzflip=nmapply(mirror, kcs20[1:3], mirrorAxis = c("X","Y","Z"), + mirrorAxisSize=c(400,20,30)) +# \donttest{ +open3d() +
    #> glX +#> 5
    plot3d(kcs20[1:3]) +plot3d(xyzflip) +rgl.close() +# } + +if (FALSE) { ## Override default progress bar behaviour via options -sl=nlapply(Cell07PNs, FUN = seglengths) -options(nat.progress='none') -sl=nlapply(Cell07PNs, FUN = seglengths) -options(nat.progress=NULL) -sl=nlapply(Cell07PNs, FUN = seglengths) -# } +sl=nlapply(Cell07PNs, FUN = seglengths) +options(nat.progress='none') +sl=nlapply(Cell07PNs, FUN = seglengths) +options(nat.progress=NULL) +sl=nlapply(Cell07PNs, FUN = seglengths) +} +
    - +
    -

    Site built with pkgdown.

    +

    Site built with pkgdown 1.6.1.

    + + + + + diff --git a/docs/reference/nlscan.html b/docs/reference/nlscan.html index c7b4c3ff..de3c6b96 100644 --- a/docs/reference/nlscan.html +++ b/docs/reference/nlscan.html @@ -1,6 +1,6 @@ - + @@ -8,25 +8,47 @@ Scan through a set of neurons, individually plotting each one in 3D — nlscan • nat + - + - - + + + + + + + - + + + + + + + + - - - + + + + + + + + + + - + + + - +
    +
    -
    +
    - +

    Can also choose to select specific neurons along the way and navigate forwards and backwards.

    - +
    -
    nlscan(neurons, db = NULL, col = "red", Verbose = T, Wait = T,
    -  sleep = 0.1, extrafun = NULL, selected_file = NULL,
    -  selected_col = "green", yaml = TRUE, ...)
    - -

    Arguments

    +
    nlscan(
    +  neurons,
    +  db = NULL,
    +  col = "red",
    +  Verbose = T,
    +  Wait = T,
    +  sleep = 0.1,
    +  extrafun = NULL,
    +  selected_file = NULL,
    +  selected_col = "green",
    +  yaml = TRUE,
    +  ...
    +)
    + +

    Arguments

    @@ -167,74 +208,73 @@

    Ar

    extra arguments to pass to plot3d.

    - +

    Value

    A character vector of names of any selected neurons, of length 0 if none selected.

    -

    See also

    -

    plot3d.character, plot3d.neuronlist

    - +

    Examples

    -
    # NOT RUN {
    +    
    if (FALSE) { # scan a neuronlist -nlscan(kcs20) +nlscan(kcs20) # using neuron names -nlscan(names(kcs20), db=kcs20) +nlscan(names(kcs20), db=kcs20) # equivalently using a default neuron list -options(nat.default.neuronlist='kcs20') -nlscan(names(kcs20)) -# }
    # scan without waiting -nlscan(kcs20[1:4], Wait=FALSE, sleep=0)
    #> Current neuron: FruMARCM-M001205_seg002 ( 1 / 4 ) +options(nat.default.neuronlist='kcs20') +nlscan(names(kcs20)) +} +# scan without waiting +nlscan(kcs20[1:4], Wait=FALSE, sleep=0) +
    #> Current neuron: FruMARCM-M001205_seg002 ( 1 / 4 ) #> Current neuron: GadMARCM-F000122_seg001 ( 2 / 4 ) #> Current neuron: GadMARCM-F000050_seg001 ( 3 / 4 ) -#> Current neuron: GadMARCM-F000142_seg002 ( 4 / 4 )
    #> NULL
    # NOT RUN { +#> Current neuron: GadMARCM-F000142_seg002 ( 4 / 4 )
    #> NULL
    if (FALSE) { # could select e.g. the gamma neurons with unbranched axons -gammas=nlscan(kcs20) -clear3d() -plot3d(kcs20[gammas]) +gammas=nlscan(kcs20) +clear3d() +plot3d(kcs20[gammas]) # plot surface model of brain first # nb depends on package only available on github -devtools::install_github(username = "jefferislab/nat.flybrains") -library(nat.flybrains) -plot3d(FCWB) +devtools::install_github(username = "jefferislab/nat.flybrains") +library(nat.flybrains) +plot3d(FCWB) # could select e.g. the gamma neurons with unbranched axons -gammas=nlscan(kcs20) -clear3d() -plot3d(kcs20[gammas]) -# }
    +gammas=nlscan(kcs20) +clear3d() +plot3d(kcs20[gammas]) +} +
    - +
    -

    Site built with pkgdown.

    +

    Site built with pkgdown 1.6.1.

    + + + + + diff --git a/docs/reference/nopen3d.html b/docs/reference/nopen3d.html index 905caf5a..8a22f2c4 100644 --- a/docs/reference/nopen3d.html +++ b/docs/reference/nopen3d.html @@ -1,6 +1,6 @@ - + @@ -8,25 +8,47 @@ Open customised rgl window — nopen3d • nat + - + - - + + + + + + + - + + + + + + + + - - - + + + + + + + + + + - + + + - +
    +
    -
    +
    - +

    Pan with right button (Ctrl+click), zoom with middle (Alt/Meta+click) button. Defaults to a white background and orthogonal projection (FOV=0)

    - +
    -
    nopen3d(bgcol = "white", FOV = 0, ...)
    - -

    Arguments

    +
    nopen3d(bgcol = "white", FOV = 0, ...)
    + +

    Arguments

    @@ -121,48 +152,43 @@

    Ar

    additional options passed to open3d

    - +

    Value

    current rgl device

    -

    Details

    Note that sometimes (parts of) objects seem to disappear after panning and zooming. See help for pan3d.

    -

    See also

    -

    open3d,pan3d

    - +

    open3d,pan3d

    - +
    -

    Site built with pkgdown.

    +

    Site built with pkgdown 1.6.1.

    + + + + + diff --git a/docs/reference/normalise_swc.html b/docs/reference/normalise_swc.html index 8f9fa481..45d2e659 100644 --- a/docs/reference/normalise_swc.html +++ b/docs/reference/normalise_swc.html @@ -1,6 +1,6 @@ - + @@ -8,25 +8,46 @@ Normalise an SWC format block of neuron morphology data — normalise_swc • nat + - + - - + + + + + + + - + + + + + + + + - - - + + + + + + + + + + - + + + - +
    +
    -
    +
    - +

    Normalise an SWC format block of neuron morphology data

    - - -
    normalise_swc(x, requiredColumns = c("PointNo", "Label", "X", "Y", "Z", "W",
    -  "Parent"), ifMissing = c("usedefaults", "warning", "stop"),
    -  includeExtraCols = TRUE, defaultValue = list(PointNo = seq.int(nrow(x)),
    -  Label = 2L, X = NA_real_, Y = NA_real_, Z = NA_real_, W = NA_real_, Parent =
    -  NA_integer_))
    - -

    Arguments

    +
    + +
    normalise_swc(
    +  x,
    +  requiredColumns = c("PointNo", "Label", "X", "Y", "Z", "W", "Parent"),
    +  ifMissing = c("usedefaults", "warning", "stop"),
    +  includeExtraCols = TRUE,
    +  defaultValue = list(PointNo = seq.int(nrow(x)), Label = 2L, X = NA_real_, Y =
    +    NA_real_, Z = NA_real_, W = NA_real_, Parent = NA_integer_)
    +)
    + +

    Arguments

    @@ -134,49 +167,44 @@

    Ar columns

    - +

    Value

    A data.frame containing the normalised block of SWC data with standard columns in standard order.

    -

    Details

    Note that row.names of the resultant data.frame will be set to NULL so that they have completely standard values.

    -

    See also

    -

    as.neuron.data.frame, seglist2swc

    - +
    - +
    -

    Site built with pkgdown.

    +

    Site built with pkgdown 1.6.1.

    + + + + + diff --git a/docs/reference/npop3d.html b/docs/reference/npop3d.html index fe764456..75c910fe 100644 --- a/docs/reference/npop3d.html +++ b/docs/reference/npop3d.html @@ -1,6 +1,6 @@ - + @@ -8,25 +8,47 @@ Remove plotted neurons or other 3D objects — npop3d • nat + - + - - + + + + + + + - + + + + + + + + - - - + + + + + + + + + + - + + + - +
    +
    -
    +
    - +

    The normal usage will not specify x in which case the last neurons plotted by plot3d.neuronlist or any of its friends will be removed.

    - +
    + +
    npop3d(x, slow = FALSE, type = "shapes")
    -
    npop3d(x, slow = FALSE, type = "shapes")
    - -

    Arguments

    +

    Arguments

    @@ -121,35 +152,36 @@

    Ar

    Type of objects to remove see pop3d.

    - +

    See also

    -

    pop3d, plot3d.neuronlist

    - +
    - +
    -

    Site built with pkgdown.

    +

    Site built with pkgdown 1.6.1.

    + + + + + diff --git a/docs/reference/nrrd.voxdims.html b/docs/reference/nrrd.voxdims.html index 751cd7a0..9d0f6dee 100644 --- a/docs/reference/nrrd.voxdims.html +++ b/docs/reference/nrrd.voxdims.html @@ -1,6 +1,6 @@ - + @@ -8,25 +8,46 @@ Return voxel dimensions (by default absolute voxel dimensions) — nrrd.voxdims • nat + - + - - + + + + + + + - + + + + + + + + - - - + + + + + + + + + + - + + + - +
    +
    -
    +
    - +

    Return voxel dimensions (by default absolute voxel dimensions)

    - +
    -
    nrrd.voxdims(file, ReturnAbsoluteDims = TRUE)
    - -

    Arguments

    +
    nrrd.voxdims(file, ReturnAbsoluteDims = TRUE)
    + +

    Arguments

    @@ -117,54 +147,48 @@

    Ar if there are any negative space directions

    - +

    Value

    numeric vector of voxel dimensions (NA_real_ when missing) of length equal to the image dimension.

    -

    Details

    NB Can handle off diagonal terms in space directions matrix, BUT assumes that space direction vectors are orthogonal.

    Will produce a warning if no valid dimensions can be found.

    -

    See also

    -

    read.nrrd.header

    - - -
    - +
    +
    -

    Site built with pkgdown.

    +

    Site built with pkgdown 1.6.1.

    + + + + + diff --git a/docs/reference/nvertices.html b/docs/reference/nvertices.html index 2588272e..119cf3e3 100644 --- a/docs/reference/nvertices.html +++ b/docs/reference/nvertices.html @@ -1,6 +1,6 @@ - + @@ -8,25 +8,46 @@ Find the number of vertices in an object (or each element of a neuronlist) — nvertices • nat + - + - - + + + + + + + - + + + + + + + + - - - + + + + + + + + + + - + + + - +
    +
    -
    +
    - +

    Find the number of vertices in an object (or each element of a neuronlist)

    - +
    -
    nvertices(x, ...)
    +    
    nvertices(x, ...)
     
     # S3 method for default
    -nvertices(x, ...)
    +nvertices(x, ...)
     
     # S3 method for neuronlist
    -nvertices(x, ...)
    - -

    Arguments

    +nvertices(x, ...)
    + +

    Arguments

    @@ -122,15 +152,16 @@

    Ar

    Additional arguments passed to methods (currently ignored)

    - +

    Value

    an integer number of vertices (or a vector of length equal to a neuronlist)

    -

    Examples

    -
    nvertices(Cell07PNs[[1]])
    #> [1] 180
    nvertices(kcs20)
    #> FruMARCM-M001205_seg002 GadMARCM-F000122_seg001 GadMARCM-F000050_seg001 +
    nvertices(Cell07PNs[[1]]) +
    #> [1] 180
    nvertices(kcs20) +
    #> FruMARCM-M001205_seg002 GadMARCM-F000122_seg001 GadMARCM-F000050_seg001 #> 284 297 374 #> GadMARCM-F000142_seg002 FruMARCM-F000270_seg001 FruMARCM-F001115_seg002 #> 355 369 401 @@ -145,30 +176,30 @@

    Examp #> GadMARCM-F000442_seg002 FruMARCM-F001929_seg001 #> 506 490

    - +
    -

    Site built with pkgdown.

    +

    Site built with pkgdown 1.6.1.

    + + + + + diff --git a/docs/reference/nview3d.html b/docs/reference/nview3d.html index 58e79c55..a6bc09af 100644 --- a/docs/reference/nview3d.html +++ b/docs/reference/nview3d.html @@ -1,6 +1,6 @@ - + @@ -8,25 +8,46 @@ Set the 3D viewpoint of an RGL window using anatomical terms — nview3d • nat + - + - - + + + + + + + - + + + + + + + + - - - + + + + + + + + + + - + + + - +
    +
    -
    +
    - +

    Set the 3D viewpoint of an RGL window using anatomical terms

    - +
    -
    nview3d(viewpoint = c("frontal", "anterior", "dorsal", "ventral", "posterior",
    -  "left", "right", "oblique_right", "oblique_left"), FOV = 0,
    -  extramat = NULL, ...)
    - -

    Arguments

    +
    nview3d(
    +  viewpoint = c("frontal", "anterior", "dorsal", "ventral", "posterior", "left",
    +    "right", "oblique_right", "oblique_left"),
    +  FOV = 0,
    +  extramat = NULL,
    +  ...
    +)
    + +

    Arguments

    @@ -116,7 +150,7 @@

    Ar

    +par3d for details).

    @@ -125,49 +159,51 @@

    Ar

    - +
    FOV

    The Field of View (defaults to 0 => orthographic projection) (see -par3d for details).

    extramat
    ...

    additional arguments passed to par3d

    additional arguments passed to par3d

    - +

    See also

    -

    nopen3d, view3d

    - +

    nopen3d, view3d

    Examples

    -
    plot3d(kcs20, soma=TRUE) -nview3d('frontal') -nview3d('ant') -nview3d() -nview3d('posterior') -nview3d('oblique_right') +
    # \donttest{ +plot3d(kcs20, soma=TRUE) +nview3d('frontal') +nview3d('ant') +nview3d() +nview3d('posterior') +nview3d('oblique_right') # a slightly oblique frontal view -nview3d('frontal', extramat=rotationMatrix(pi/10, 1, 1, 0))
    +nview3d('frontal', extramat=rotationMatrix(pi/10, 1, 1, 0)) +# } +
    - +
    -

    Site built with pkgdown.

    +

    Site built with pkgdown 1.6.1.

    + + + + + diff --git a/docs/reference/origin.html b/docs/reference/origin.html index 23b5044a..9f3ddd09 100644 --- a/docs/reference/origin.html +++ b/docs/reference/origin.html @@ -1,6 +1,6 @@ - + @@ -8,25 +8,48 @@ Return the space origin of a 3D image object — origin • nat + - + - - + + + + + + + - + + + + + + + + - - - + + + + + + + + + + - + + + - +
    +
    -
    +
    - +

    Defined as the first coordinates (x,y,z) of the bounding box, which in turn matches the nrrd definition of the location of the "centre" of the first voxel.

    - +
    + +
    origin(x, ...)
    -
    origin(x, ...)
    - -

    Arguments

    +

    Arguments

    @@ -115,45 +147,53 @@

    Ar boundingbox.

    - +
    ...

    Additional arguments passed to boundingbox

    - +

    See also

    -

    Other im3d: as.im3d, - boundingbox, im3d-coords, - im3d-io, im3d, - imexpand.grid, imslice, - is.im3d, mask, - projection, threshold, - unmask, voxdims

    - +

    Other im3d: +as.im3d(), +boundingbox(), +im3d-coords, +im3d-io, +im3d(), +imexpand.grid(), +imslice(), +is.im3d(), +mask(), +projection(), +threshold(), +unmask(), +voxdims()

    - +
    -

    Site built with pkgdown.

    +

    Site built with pkgdown 1.6.1.

    + + + + + diff --git a/docs/reference/pan3d.html b/docs/reference/pan3d.html index 9e2cdb79..3721dc3c 100644 --- a/docs/reference/pan3d.html +++ b/docs/reference/pan3d.html @@ -1,6 +1,6 @@ - + @@ -8,25 +8,46 @@ Some useful extensions / changes to rgl defaults — pan3d • nat + - + - - + + + + + + + - + + + + + + + + - - - + + + + + + + + + + - + + + - +
    +
    -
    +
    - +

    Set up pan call back for current rgl device

    - +
    -
    pan3d(button)
    - -

    Arguments

    +
    pan3d(button)
    + +

    Arguments

    @@ -112,7 +142,7 @@

    Ar

    Integer from 1 to 3 indicating mouse button

    - +

    Details

    Copied verbatim from ?rgl.setMouseCallbacks for rgl version 0.92.892 Mouse @@ -120,48 +150,44 @@

    Details

    Note that sometimes (parts of) objects seem to disappear after panning and zooming. The example in rgl.setMouseCallbacks from which this is copied includes a note that "this doesn't play well with rescaling"

    -

    See also

    -

    rgl.setMouseCallbacks

    - +

    rgl.setMouseCallbacks

    +

    Author

    + +

    Duncan Murdoch

    Examples

    -
    # NOT RUN {
    - open3d()
    - pan3d(2)
    -# }
    +
    if (FALSE) { + open3d() + pan3d(2) +} +
    - +
    -

    Site built with pkgdown.

    +

    Site built with pkgdown 1.6.1.

    + + + + + diff --git a/docs/reference/plot.neuron-1.png b/docs/reference/plot.neuron-1.png index 3d6c451e..be835dd1 100644 Binary files a/docs/reference/plot.neuron-1.png and b/docs/reference/plot.neuron-1.png differ diff --git a/docs/reference/plot.neuron-10.png b/docs/reference/plot.neuron-10.png deleted file mode 100644 index 5cef3109..00000000 Binary files a/docs/reference/plot.neuron-10.png and /dev/null differ diff --git a/docs/reference/plot.neuron-2.png b/docs/reference/plot.neuron-2.png index c13c5b91..fd3cdfc7 100644 Binary files a/docs/reference/plot.neuron-2.png and b/docs/reference/plot.neuron-2.png differ diff --git a/docs/reference/plot.neuron-3.png b/docs/reference/plot.neuron-3.png index b9d085bd..0485f146 100644 Binary files a/docs/reference/plot.neuron-3.png and b/docs/reference/plot.neuron-3.png differ diff --git a/docs/reference/plot.neuron-4.png b/docs/reference/plot.neuron-4.png index 8d467018..67394735 100644 Binary files a/docs/reference/plot.neuron-4.png and b/docs/reference/plot.neuron-4.png differ diff --git a/docs/reference/plot.neuron-5.png b/docs/reference/plot.neuron-5.png deleted file mode 100644 index 25aeff31..00000000 Binary files a/docs/reference/plot.neuron-5.png and /dev/null differ diff --git a/docs/reference/plot.neuron-8.png b/docs/reference/plot.neuron-8.png deleted file mode 100644 index 19dfff25..00000000 Binary files a/docs/reference/plot.neuron-8.png and /dev/null differ diff --git a/docs/reference/plot.neuron.html b/docs/reference/plot.neuron.html index 5cbae9b4..a4a81d54 100644 --- a/docs/reference/plot.neuron.html +++ b/docs/reference/plot.neuron.html @@ -1,6 +1,6 @@ - + @@ -8,25 +8,46 @@ Plot a 2D projection of a neuron — plot.neuron • nat + - + - - + + + + + + + - + + + + + + + + - - - + + + + + + + + + + - + + + - +
    +
    -
    +
    - +

    Plot a 2D projection of a neuron

    - +
    # S3 method for neuron
    -plot(x, WithLine = TRUE, WithNodes = TRUE,
    -  WithAllPoints = FALSE, WithText = FALSE, PlotSubTrees = TRUE,
    -  soma = FALSE, PlotAxes = c("XY", "YZ", "XZ", "ZY"), axes = TRUE,
    -  asp = 1, main = x$NeuronName, sub = NULL, xlim = NULL, ylim = NULL,
    -  AxisDirections = c(1, -1, 1), add = FALSE, col = NULL, PointAlpha = 1,
    -  tck = NA, lwd = par("lwd"), boundingbox = NULL, ...)
    - -

    Arguments

    +plot( + x, + WithLine = TRUE, + WithNodes = TRUE, + WithAllPoints = FALSE, + WithText = FALSE, + PlotSubTrees = TRUE, + soma = FALSE, + PlotAxes = c("XY", "YZ", "XZ", "ZY"), + axes = TRUE, + asp = 1, + main = x$NeuronName, + sub = NULL, + xlim = NULL, + ylim = NULL, + AxisDirections = c(1, -1, 1), + add = FALSE, + col = NULL, + PointAlpha = 1, + tck = NA, + lwd = par("lwd"), + boundingbox = NULL, + ... +) + +

    Arguments

    @@ -155,7 +203,7 @@

    Ar

    - + @@ -177,7 +225,7 @@

    Ar

    @@ -214,11 +262,10 @@

    Ar

    asp

    the y/x aspect ratio, see plot.window.

    the y/x aspect ratio, see plot.window.

    mainAxisDirections

    the directions for the axes. By default, R uses the bottom-left for the origin, whilst most graphics software uses the -top-left. The default value of c(1, -1, 1) makes the produced plot +top-left. The default value of c(1, -1, 1) makes the produced plot consistent with the latter.

    additional arguments passed to plot

    - +

    Value

    list of plotted points (invisibly)

    -

    Details

    This functions sets the axis ranges based on the chosen @@ -230,53 +277,58 @@

    Details This is achieved by reversing the y axis of the 2D plot when the second data axis is the Y axis of the 3D data. Other settings can be achieved by modfiying the AxisDirections argument.

    -

    See also

    -

    plot3d.neuron

    -

    Other neuron: neuron, ngraph, - potential_synapses, prune, - resample, rootpoints, - spine, subset.neuron

    - +

    Examples

    # Draw first example neuron -plot(Cell07PNs[[1]])
    # Overlay second example neuron -plot(Cell07PNs[[2]], add=TRUE)
    # Clear the current plot and draw the third neuron from a different view -plot(Cell07PNs[[3]], PlotAxes="YZ")
    # Just plot the end points for the fourth example neuron -plot(Cell07PNs[[4]], WithNodes=FALSE)
    # Plot with soma (of default radius) -plot(Cell07PNs[[4]], WithNodes=FALSE, soma=TRUE)
    # Plot with soma of defined radius -plot(Cell07PNs[[4]], WithNodes=FALSE, soma=1.25)
    +plot(Cell07PNs[[1]]) +
    # Overlay second example neuron +plot(Cell07PNs[[2]], add=TRUE) +
    # Clear the current plot and draw the third neuron from a different view +plot(Cell07PNs[[3]], PlotAxes="YZ") +
    # Just plot the end points for the fourth example neuron +plot(Cell07PNs[[4]], WithNodes=FALSE) +
    # Plot with soma (of default radius) +plot(Cell07PNs[[4]], WithNodes=FALSE, soma=TRUE) +
    # Plot with soma of defined radius +plot(Cell07PNs[[4]], WithNodes=FALSE, soma=1.25) +
    - +
    -

    Site built with pkgdown.

    +

    Site built with pkgdown 1.6.1.

    + + + + + diff --git a/docs/reference/plot.neuronlist-1.png b/docs/reference/plot.neuronlist-1.png index 6cea4ab5..3b0331f2 100644 Binary files a/docs/reference/plot.neuronlist-1.png and b/docs/reference/plot.neuronlist-1.png differ diff --git a/docs/reference/plot.neuronlist-2.png b/docs/reference/plot.neuronlist-2.png index 683e4c36..0ce2282b 100644 Binary files a/docs/reference/plot.neuronlist-2.png and b/docs/reference/plot.neuronlist-2.png differ diff --git a/docs/reference/plot.neuronlist-3.png b/docs/reference/plot.neuronlist-3.png index 6c9184e5..1f979959 100644 Binary files a/docs/reference/plot.neuronlist-3.png and b/docs/reference/plot.neuronlist-3.png differ diff --git a/docs/reference/plot.neuronlist-4.png b/docs/reference/plot.neuronlist-4.png index 6b1eb4a5..76e246d6 100644 Binary files a/docs/reference/plot.neuronlist-4.png and b/docs/reference/plot.neuronlist-4.png differ diff --git a/docs/reference/plot.neuronlist-6.png b/docs/reference/plot.neuronlist-6.png deleted file mode 100644 index cee20463..00000000 Binary files a/docs/reference/plot.neuronlist-6.png and /dev/null differ diff --git a/docs/reference/plot.neuronlist-8.png b/docs/reference/plot.neuronlist-8.png deleted file mode 100644 index e74a921e..00000000 Binary files a/docs/reference/plot.neuronlist-8.png and /dev/null differ diff --git a/docs/reference/plot.neuronlist.html b/docs/reference/plot.neuronlist.html index 68c4760d..1c52be1a 100644 --- a/docs/reference/plot.neuronlist.html +++ b/docs/reference/plot.neuronlist.html @@ -1,6 +1,6 @@ - + @@ -9,25 +9,48 @@ 2D plots of the elements in a neuronlist, optionally using a subset expression — plot.neuronlist • nat + - + - - + + + + + + + - + + + + + + + + - - - + + + + + + + + + + - + + + - +
    +
    -
    +
    - +

    2D plots of the elements in a neuronlist, optionally using a subset expression

    - +
    # S3 method for neuronlist
    -plot(x, subset = NULL, col = NULL, colpal = rainbow,
    -  add = NULL, boundingbox = NULL, ..., SUBSTITUTE = TRUE)
    - -

    Arguments

    +plot( + x, + subset = NULL, + col = NULL, + colpal = rainbow, + add = NULL, + boundingbox = NULL, + ..., + SUBSTITUTE = TRUE +) + +

    Arguments

    @@ -155,12 +195,11 @@

    Ar use only, when calling from another function.

    x

    a neuron list or, for plot3d.character, a character vector of neuron names. The default neuronlist used by plot3d.character can be set by -using options(nat.default.neuronlist='mylist'). See +using options(nat.default.neuronlist='mylist'). See ?nat for details.

    - +

    Value

    list of values of plot with subsetted dataframe as attribute 'df'

    -

    Details

    The col and subset parameters are evaluated in the context of the @@ -170,48 +209,46 @@

    Details this will be used as catch-all default value (see examples).

    If col evaluates to a factor and colpal is a function then it will be used to generate colours with the same number of levels as are used in col.

    -

    See also

    -

    nat-package, plot3d.neuronlist

    - +

    Examples

    # plot 4 cells -plot(Cell07PNs[1:4])
    # modify some default plot arguments -plot(Cell07PNs[1:4], ylim=c(140,75), main='First 4 neurons')
    # plot one class of neurons in red and all the others in grey -plot(Cell07PNs, col=Glomerulus, colpal=c(DA1='red', 'grey'), WithNodes=FALSE)
    # subset operation -plot(Cell07PNs, subset=Glomerulus%in%c("DA1", "DP1m"), col=Glomerulus, - ylim=c(140,75), WithNodes=FALSE)
    +plot(Cell07PNs[1:4]) +
    # modify some default plot arguments +plot(Cell07PNs[1:4], ylim=c(140,75), main='First 4 neurons') +
    # plot one class of neurons in red and all the others in grey +plot(Cell07PNs, col=Glomerulus, colpal=c(DA1='red', 'grey'), WithNodes=FALSE) +
    # subset operation +plot(Cell07PNs, subset=Glomerulus%in%c("DA1", "DP1m"), col=Glomerulus, + ylim=c(140,75), WithNodes=FALSE) +
    - +
    -

    Site built with pkgdown.

    +

    Site built with pkgdown 1.6.1.

    + + + + + diff --git a/docs/reference/plot3d.boundingbox.html b/docs/reference/plot3d.boundingbox.html index 47d893aa..6c09448c 100644 --- a/docs/reference/plot3d.boundingbox.html +++ b/docs/reference/plot3d.boundingbox.html @@ -1,6 +1,6 @@ - + @@ -8,25 +8,46 @@ Plot a bounding box in 3D — plot3d.boundingbox • nat + - + - - + + + + + + + - + + + + + + + + - - - + + + + + + + + + + - + + + - +
    +
    -
    +
    - +

    Plot a bounding box in 3D

    - +
    # S3 method for boundingbox
    -plot3d(x, ...)
    - -

    Arguments

    +plot3d(x, ...) + +

    Arguments

    @@ -114,68 +144,69 @@

    Ar

    - +
    ...

    additional arguments to pass to segments3d.

    additional arguments to pass to segments3d.

    - +

    Value

    A list of RGL object IDs.

    -

    See also

    -

    boundingbox

    - +

    Examples

    # find the bounding box of all the neurons in a list -boundingbox(kcs20)
    #> [,1] [,2] [,3] +boundingbox(kcs20) +
    #> [,1] [,2] [,3] #> [1,] 284.5940 24.1869 21.4379 #> [2,] 404.6951 122.9557 102.8015 #> attr(,"class") -#> [1] "boundingbox"
    boundingbox(kcs20[1:3])
    #> [,1] [,2] [,3] +#> [1] "boundingbox"
    boundingbox(kcs20[1:3]) +
    #> [,1] [,2] [,3] #> [1,] 285.0244 25.2430 21.4379 #> [2,] 390.7747 114.6351 98.3324 #> attr(,"class") -#> [1] "boundingbox"
    # plot those neurons -plot3d(kcs20) +#> [1] "boundingbox"
    # \donttest{ +# plot those neurons +plot3d(kcs20) # ... with their bounding box -plot3d(boundingbox(kcs20)) +plot3d(boundingbox(kcs20)) -plot3d(kcs20) +plot3d(kcs20) # plot bounding box (in matching colours) for each neuron # NB makes use of nlapply/neuronlist in slightly unsusual context - # plot3d.neuronlist can cope with lists containing anything with # a valid plot3d method. -plot3d(nlapply(kcs20,boundingbox))
    +plot3d(nlapply(kcs20,boundingbox)) +# } +
    - +
    -

    Site built with pkgdown.

    +

    Site built with pkgdown 1.6.1.

    + + + + + diff --git a/docs/reference/plot3d.cmtkreg.html b/docs/reference/plot3d.cmtkreg.html index a31d5641..6b2d0e81 100644 --- a/docs/reference/plot3d.cmtkreg.html +++ b/docs/reference/plot3d.cmtkreg.html @@ -1,6 +1,6 @@ - + @@ -8,25 +8,46 @@ Plot the domain of a CMTK registration — plot3d.cmtkreg • nat + - + - - + + + + + + + - + + + + + + + + - - - + + + + + + + + + + - + + + - +
    +
    -
    +
    - +

    Plot the domain of a CMTK registration

    - +
    # S3 method for cmtkreg
    -plot3d(x, ...)
    - -

    Arguments

    +plot3d(x, ...) + +

    Arguments

    @@ -115,54 +145,54 @@

    Ar

    - +
    ...

    Additional arguments passed to plot3d

    Additional arguments passed to plot3d

    - +

    See also

    -

    cmtkreg, read.cmtkreg, - plot3d

    - +

    Examples

    -
    # NOT RUN {
    -testdatadir=system.file("tests/testthat/testdata/cmtk", package="nat")
    -regpath=file.path(testdatadir,'FCWB_JFRC2_01_warp_level-01.list/')
    -plot3d(cmtkreg(regpath))
    +    
    if (FALSE) { +testdatadir=system.file("tests/testthat/testdata/cmtk", package="nat") +regpath=file.path(testdatadir,'FCWB_JFRC2_01_warp_level-01.list/') +plot3d(cmtkreg(regpath)) # or read registration into memory if you want to work with it -reg=read.cmtkreg(regpath) +reg=read.cmtkreg(regpath) # nb calling plot3d.cmtkreg directly (rather than using the generic plot3d) # is considered bad style but read.cmtkreg returns a plain list # so method dispatch will fail -nat:::plot3d.cmtkreg(reg) -# }
    +nat:::plot3d.cmtkreg(reg) +} +
    - +
    -

    Site built with pkgdown.

    +

    Site built with pkgdown 1.6.1.

    + + + + + diff --git a/docs/reference/plot3d.dotprops.html b/docs/reference/plot3d.dotprops.html index 88b1aca6..4c864547 100644 --- a/docs/reference/plot3d.dotprops.html +++ b/docs/reference/plot3d.dotprops.html @@ -1,6 +1,6 @@ - + @@ -8,25 +8,46 @@ 3D plots of dotprops objects using rgl package — plot3d.dotprops • nat + - + - - + + + + + + + - + + + + + + + + - - - + + + + + + + + + + - + + + - +
    +
    -
    +
    - +

    3D plots of dotprops objects using rgl package

    - +
    # S3 method for dotprops
    -plot3d(x, scalevecs = 1, alpharange = NULL,
    -  color = "black", PlotPoints = FALSE, PlotVectors = TRUE,
    -  UseAlpha = FALSE, ...)
    - -

    Arguments

    +plot3d( + x, + scalevecs = 1, + alpharange = NULL, + color = "black", + PlotPoints = FALSE, + PlotVectors = TRUE, + UseAlpha = FALSE, + ... +) + +

    Arguments

    @@ -123,7 +160,7 @@

    Ar

    +dotprops for definition of alpha.

    @@ -146,11 +183,10 @@

    Ar segments3d

    alpharange

    Restrict plotting to points with alpha values in this range to plot (default: null => all points). See -dotprops for definition of alpha.

    color
    - +

    Value

    invisible list of results of rgl plotting commands

    -

    Details

    Tangent vectors are plotted by segments3d and centered on the @@ -161,50 +197,48 @@

    Details passed to segments3d so that the result is that each vector is coloured uniformly according to color (since segments3d expects 2 colours for each line segment, blending them if they are different).

    -

    See also

    -

    dotprops, plot3d, points3d, - segments3d

    - +

    Examples

    -
    open3d()
    #> glX -#> 6
    plot3d(kcs20[[1]]) -clear3d() -plot3d(kcs20[[1]],col='red') -clear3d() -plot3d(kcs20[[1]],col='red',lwd=2) -plot3d(kcs20[[2]],col='green',lwd=2)
    +
    # \donttest{ +open3d() +
    #> glX +#> 6
    plot3d(kcs20[[1]]) +clear3d() +plot3d(kcs20[[1]],col='red') +clear3d() +plot3d(kcs20[[1]],col='red',lwd=2) +plot3d(kcs20[[2]],col='green',lwd=2) +# } +
    - +
    -

    Site built with pkgdown.

    +

    Site built with pkgdown 1.6.1.

    + + + + + diff --git a/docs/reference/plot3d.html b/docs/reference/plot3d.html index dad94266..99fe05a6 100644 --- a/docs/reference/plot3d.html +++ b/docs/reference/plot3d.html @@ -1,6 +1,6 @@ - + @@ -8,25 +8,48 @@ plot3d methods for different nat objects — plot3d • nat + - + - - + + + + + + + - + + + + + + + + - - - + + + + + + + + + + - + + + - +
    +
    -
    +
    - +

    These methods enable nat objects including neuronlists and dotprops objects to be plotted in 3D. See the help for each individual method for details along with the help for the generic in the rgl package.

    - +
    + + -

    See also

    -

    plot3d, plot3d.boundingbox, +

    Examples

    # all known plot3d methods -methods("plot3d")
    #> [1] plot3d.boundingbox plot3d.character plot3d.cmtkreg -#> [4] plot3d.default* plot3d.deldir* plot3d.dotprops -#> [7] plot3d.function* plot3d.hxsurf plot3d.mesh3d* -#> [10] plot3d.neuron plot3d.neuronlist plot3d.rglbackground* -#> [13] plot3d.rglbboxdeco* plot3d.rglobject* plot3d.rglscene* -#> [16] plot3d.rglsubscene* +methods("plot3d") +
    #> [1] plot3d.ashape3d* plot3d.boundingbox* plot3d.character* +#> [4] plot3d.cmtkreg* plot3d.default* plot3d.deldir* +#> [7] plot3d.dotprops* plot3d.formula* plot3d.function* +#> [10] plot3d.hxsurf* plot3d.lm* plot3d.mesh3d* +#> [13] plot3d.neuron* plot3d.neuronlist* plot3d.rglbackground* +#> [16] plot3d.rglbboxdeco* plot3d.rglobject* plot3d.rglscene* +#> [19] plot3d.rglsubscene* plot3d.rglWebGL* plot3d.tri* +#> [22] plot3d.triSht* #> see '?methods' for accessing help and source code
    # up to date list of all plot3d nethods in this package -intersect(methods("plot3d"), ls(asNamespace("nat")))
    #> [1] "plot3d.boundingbox" "plot3d.character" "plot3d.cmtkreg" +intersect(methods("plot3d"), ls(asNamespace("nat"))) +
    #> [1] "plot3d.boundingbox" "plot3d.character" "plot3d.cmtkreg" #> [4] "plot3d.dotprops" "plot3d.hxsurf" "plot3d.neuron" #> [7] "plot3d.neuronlist"
    - +
    -

    Site built with pkgdown.

    +

    Site built with pkgdown 1.6.1.

    + + + + + diff --git a/docs/reference/plot3d.hxsurf.html b/docs/reference/plot3d.hxsurf.html index 1b648e9a..23876a68 100644 --- a/docs/reference/plot3d.hxsurf.html +++ b/docs/reference/plot3d.hxsurf.html @@ -1,6 +1,6 @@ - + @@ -8,25 +8,46 @@ Plot amira surface objects in 3D using rgl — plot3d.hxsurf • nat + - + - - + + + + + + + - + + + + + + + + - - - + + + + + + + + + + - + + + - +
    +
    -
    +
    - +

    Plot amira surface objects in 3D using rgl

    - +
    # S3 method for hxsurf
    -plot3d(x, materials = NULL, col = NULL, ...)
    - -

    Arguments

    +plot3d(x, materials = NULL, col = NULL, ...) + +

    Arguments

    @@ -114,7 +144,7 @@

    Ar

    - @@ -129,51 +159,58 @@

    Ar

    materials

    Character vector or regex naming materials to +

    Character vector or regex naming materials to plot (defaults to all materials in x). See subset.hxsurf.

    Additional arguments passed to

    - +

    See also

    -

    read.hxsurf

    -

    Other hxsurf: as.hxsurf, - as.mesh3d, materials, - read.hxsurf, subset.hxsurf, - write.hxsurf

    - +

    Examples

    -
    plot3d(kcs20) -plot3d(MBL.surf)
    # plot only vertical lobe -clear3d() -plot3d(MBL.surf, materials="VL", alpha=0.3) +
    plot3d(kcs20) +plot3d(MBL.surf) + +# \donttest{ +# plot only vertical lobe +clear3d() +plot3d(MBL.surf, materials="VL", alpha=0.3) # everything except vertical lobe -clear3d() -plot3d(MBL.surf, alpha=0.3, - materials=grep("VL", MBL.surf$RegionList, value = TRUE, invert = TRUE))
    +clear3d() +plot3d(MBL.surf, alpha=0.3, + materials=grep("VL", MBL.surf$RegionList, value = TRUE, invert = TRUE)) +# } +
    - +
    -

    Site built with pkgdown.

    +

    Site built with pkgdown 1.6.1.

    + + + + + diff --git a/docs/reference/plot3d.neuron.html b/docs/reference/plot3d.neuron.html index 878bc62b..6d2f30e9 100644 --- a/docs/reference/plot3d.neuron.html +++ b/docs/reference/plot3d.neuron.html @@ -1,6 +1,6 @@ - + @@ -8,25 +8,46 @@ Plot neurons in 3D using rgl library — plot3d.neuron • nat + - + - - + + + + + + + - + + + + + + + + - - - + + + + + + + + + + - + + + - +
    +
    -
    +
    - +

    Plot neurons in 3D using rgl library

    - +
    # S3 method for neuron
    -plot3d(x, WithLine = TRUE, NeuronNames = FALSE,
    -  WithNodes = TRUE, WithAllPoints = FALSE, WithText = FALSE,
    -  PlotSubTrees = TRUE, add = TRUE, col = NULL, soma = FALSE, ...)
    - -

    Arguments

    +plot3d( + x, + WithLine = TRUE, + NeuronNames = FALSE, + WithNodes = TRUE, + WithAllPoints = FALSE, + WithText = FALSE, + PlotSubTrees = TRUE, + add = TRUE, + col = NULL, + soma = FALSE, + ... +) + +

    Arguments

    @@ -161,68 +201,66 @@

    Ar

    Additional arguments passed to rgl::lines3d

    - +

    Value

    list of rgl plotting ids (invisibly) separated into lines, points, texts according to plot element. See - rgl::plot3d for details.

    - + rgl::plot3d for details.

    Details

    Note that when WithText=TRUE, the numeric identifiers plotted are raw indices into the x$d array of the neuron, not the values of the PointNo column.

    -

    See also

    -

    plot3d.neuronlist, plot3d.dotprops, - nat::plot3d, rgl::plot3d

    - +

    Examples

    # A new plot would have been opened if required -open3d()
    #> glX -#> 7
    plot3d(Cell07PNs[[1]],col='red') -plot3d(Cell07PNs[[2]],col='green')
    # clear the current plot -clear3d() -plot3d(Cell07PNs[[2]],col='blue',add=FALSE) +open3d() +
    #> glX +#> 7
    plot3d(Cell07PNs[[1]],col='red') +plot3d(Cell07PNs[[2]],col='green') +# \donttest{ +# clear the current plot +clear3d() +plot3d(Cell07PNs[[2]],col='blue',add=FALSE) # plot the number of all nodes -clear3d() -plot3d(Cell07PNs[[2]],col='red',WithText=TRUE,add=FALSE) +clear3d() +plot3d(Cell07PNs[[2]],col='red',WithText=TRUE,add=FALSE) # include cell bodies -plot3d(Cell07PNs[3:4], col='red', soma=TRUE) -plot3d(Cell07PNs[5], col='red', soma=3) -rgl.close()
    +plot3d(Cell07PNs[3:4], col='red', soma=TRUE) +plot3d(Cell07PNs[5], col='red', soma=3) +rgl.close() +# } +
    - +
    -

    Site built with pkgdown.

    +

    Site built with pkgdown 1.6.1.

    + + + + + diff --git a/docs/reference/plot3d.neuronlist.html b/docs/reference/plot3d.neuronlist.html index 1dea4b31..46f4ee89 100644 --- a/docs/reference/plot3d.neuronlist.html +++ b/docs/reference/plot3d.neuronlist.html @@ -1,6 +1,6 @@ - + @@ -9,25 +9,48 @@ 3D plots of the elements in a neuronlist, optionally using a subset expression — plot3d.neuronlist • nat + - + - - + + + + + + + - + + + + + + + + - - - + + + + + + + + + + - + + + - +
    +
    -
    +
    - -

    3D plots of the elements in a neuronlist, optionally using a subset -expression - - plot3d.character is a convenience method intended for +

    +

    plot3d.character is a convenience method intended for exploratory work on the command line.

    - +
    # S3 method for neuronlist
    -plot3d(x, subset = NULL, col = NULL,
    -  colpal = rainbow, skipRedraw = ifelse(interactive(), 200L, TRUE),
    -  WithNodes = FALSE, soma = FALSE, ..., SUBSTITUTE = TRUE)
    +plot3d(
    +  x,
    +  subset = NULL,
    +  col = NULL,
    +  colpal = rainbow,
    +  skipRedraw = ifelse(interactive(), 200L, TRUE),
    +  WithNodes = FALSE,
    +  soma = FALSE,
    +  ...,
    +  SUBSTITUTE = TRUE
    +)
     
     # S3 method for character
    -plot3d(x, db = NULL, ...)
    - -

    Arguments

    +plot3d(x, db = NULL, ...) + +

    Arguments

    @@ -174,12 +211,11 @@

    Ar options('nat.default.neuronlist')

    x

    a neuron list or, for plot3d.character, a character vector of neuron names. The default neuronlist used by plot3d.character can be set by -using options(nat.default.neuronlist='mylist'). See +using options(nat.default.neuronlist='mylist'). See ?nat for details. nat-package.

    - +

    Value

    list of values of plot3d with subsetted dataframe as attribute 'df'

    -

    Details

    The col and subset parameters are evaluated in the context of the @@ -206,69 +242,69 @@

    Details

    plot3d.character will check if options('nat.default.neuronlist') has been set and then use x as an identifier to find a neuron in that neuronlist.

    -

    See also

    -

    nat-package

    - +

    Examples

    -
    open3d()
    #> glX -#> 8
    plot3d(kcs20,type=='gamma',col='green')
    clear3d() -plot3d(kcs20,col=type) -plot3d(Cell07PNs,Glomerulus=="DA1",col='red') -plot3d(Cell07PNs,Glomerulus=="VA1d",col='green') +
    open3d() +
    #> glX +#> 8
    plot3d(kcs20,type=='gamma',col='green') +# \donttest{ +clear3d() +plot3d(kcs20,col=type) +plot3d(Cell07PNs,Glomerulus=="DA1",col='red') +plot3d(Cell07PNs,Glomerulus=="VA1d",col='green') # Note use of default colour for non DA1 neurons -plot3d(Cell07PNs,col=Glomerulus, colpal=c(DA1='red', 'grey')) +plot3d(Cell07PNs,col=Glomerulus, colpal=c(DA1='red', 'grey')) # a subset expression -plot3d(Cell07PNs,Glomerulus%in%c("DA1",'VA1d'), - col=c("red","green")[factor(Glomerulus)]) +plot3d(Cell07PNs,Glomerulus%in%c("DA1",'VA1d'), + col=c("red","green")[factor(Glomerulus)]) # the same but not specifying colours explicitly -plot3d(Cell07PNs,Glomerulus%in%c("DA1",'VA1d'),col=Glomerulus)
    # NOT RUN { +plot3d(Cell07PNs,Glomerulus%in%c("DA1",'VA1d'),col=Glomerulus) +# } +if (FALSE) { ## more complex colouring strategies for a larger neuron set # see https://github.com/jefferis/frulhns for details -library(frulhns) +library(frulhns) # notice the sexually dimorphic projection patterns for these neurons -plot3d(jkn,cluster=='aSP-f' &shortGenotype=='JK1029', - col=sex,colpal=c(male='green',female='magenta')) +plot3d(jkn,cluster=='aSP-f' &shortGenotype=='JK1029', + col=sex,colpal=c(male='green',female='magenta')) ## colour neurons of a class by input resistance -jkn.aspg=subset(jkn, cluster=='aSP-g') +jkn.aspg=subset(jkn, cluster=='aSP-g') # NB this comes in as a factor -Ri=with(jkn.aspg,as.numeric(as.character(Ri..GOhm.))) +Ri=with(jkn.aspg,as.numeric(as.character(Ri..GOhm.))) # the matlab jet palette -jet.colors<-colorRampPalette(c('navy','cyan','yellow','red')) -plot3d(jkn.aspg,col=cut(Ri,20),colpal=jet.colors) -# }
    +jet.colors<-colorRampPalette(c('navy','cyan','yellow','red')) +plot3d(jkn.aspg,col=cut(Ri,20),colpal=jet.colors) +} +
    - +
    -

    Site built with pkgdown.

    +

    Site built with pkgdown 1.6.1.

    + + + + + diff --git a/docs/reference/pointsinside.html b/docs/reference/pointsinside.html index e01977cd..5091d021 100644 --- a/docs/reference/pointsinside.html +++ b/docs/reference/pointsinside.html @@ -1,6 +1,6 @@ - + @@ -8,25 +8,46 @@ Find which points of an object are inside a surface — pointsinside • nat + - + - - + + + + + + + - + + + + + + + + - - - + + + + + + + + + + - + + + - +
    +
    -
    +
    - +

    Find which points of an object are inside a surface

    - +
    -
    pointsinside(x, surf, ...)
    +    
    pointsinside(x, surf, ...)
     
     # S3 method for default
    -pointsinside(x, surf, ..., rval = c("logical", "distance",
    -  "mesh3d"))
    - -

    Arguments

    +pointsinside(x, surf, ..., rval = c("logical", "distance", "mesh3d"))
    + +

    Arguments

    @@ -130,17 +159,16 @@

    Ar

    what to return.

    - +

    Value

    A vector of logical values or distances (positive inside, negative outside) equal to the number of points in x or the mesh3d object - returned by Rvcg::vcgClostKD.

    - + returned by Rvcg::vcgClostKD.

    Details

    Note that hxsurf surface objects will be converted to - mesh3d before being passed to Rvcg::vcgClostKD, so if you are + mesh3d before being passed to Rvcg::vcgClostKD, so if you are testing repeatedly against the same surface, it may make sense to pre-convert.

    pointsinside depends on the face normals for each face pointing out @@ -149,82 +177,86 @@

    Details normal for a face by permuting the vertices (i.e. 1,2,3 -> 1,3,2). If you find for a given surface that points are outside when you expect them to be inside then the face normals are probably all the wrong way round. You can - invert them yourself or use the Morpho::invertFaces function to fix + invert them yourself or use the Morpho::invertFaces function to fix this.

    If you find that some points but not all points are not behaving as you would expect, then it may be that some faces are not coherently oriented. - The Rvcg::vcgClean function can sometimes be used to + The Rvcg::vcgClean function can sometimes be used to correct the orientation of the faces. Fixing more problematic cases may be possible by generating a new surface using - alphashape3d::ashape3d (see examples).

    - + alphashape3d::ashape3d (see examples).

    Examples

    -
    # check if the vertices in these neurons are inside the mushroom body calyx +
    # \donttest{ +# check if the vertices in these neurons are inside the mushroom body calyx # surface object -inout=pointsinside(kcs20, surf=subset(MBL.surf, "MB_CA_L")) -table(inout)
    #> inout +inout=pointsinside(kcs20, surf=subset(MBL.surf, "MB_CA_L")) +table(inout) +
    #> inout #> FALSE TRUE #> 6457 2064
    # be a bit more lenient and include points less than 5 microns from surface -MBCAL=subset(MBL.surf, "MB_CA_L") -inout5=pointsinside(kcs20, surf=MBCAL, rval='distance') > -5 -table(inout5)
    #> inout5 +MBCAL=subset(MBL.surf, "MB_CA_L") +inout5=pointsinside(kcs20, surf=MBCAL, rval='distance') > -5 +table(inout5) +
    #> inout5 #> FALSE TRUE -#> 5604 2917
    # show which points are in or out +#> 5604 2917
    +# show which points are in or out # Hmm seems like there are a few red points in the vertical lobe # that are well outside the calyx -points3d(xyzmatrix(kcs20), col=ifelse(inout5, 'red', 'black')) -plot3d(MBL.surf, alpha=.3) +points3d(xyzmatrix(kcs20), col=ifelse(inout5, 'red', 'black')) +plot3d(MBL.surf, alpha=.3) # Let's try to make an alphashape for the mesh to clean it up -library(alphashape3d) -MBCAL.as=ashape3d(xyzmatrix(MBCAL), alpha = 10) +library(alphashape3d) +MBCAL.as=ashape3d(xyzmatrix(MBCAL), alpha = 10) # Plotting the points, we can see that is much better behaved -points3d(xyzmatrix(kcs20), - col=ifelse(pointsinside(kcs20, MBCAL.as), 'red', 'black'))
    -
    # NOT RUN { +points3d(xyzmatrix(kcs20), + col=ifelse(pointsinside(kcs20, MBCAL.as), 'red', 'black')) +# } + +if (FALSE) { # Show the face normals for a surface -if(require('Morpho')) { +if(require('Morpho')) { # convert to a mesh3d object used by rgl and Morpho packge - MBCAL.mesh=as.mesh3d(subset(MBL.surf, "MB_CA_L")) - fn=facenormals(MBCAL.mesh) - wire3d(MBCAL.mesh) + MBCAL.mesh=as.mesh3d(subset(MBL.surf, "MB_CA_L")) + fn=facenormals(MBCAL.mesh) + wire3d(MBCAL.mesh) # show that the normals point out of the object - plotNormals(fn, long=5, col='red') - + plotNormals(fn, long=5, col='red') + # invert the faces of the mesh and show that normals point in - MBCAL.inv=invertFaces(MBCAL.mesh) - plotNormals(facenormals(MBCAL.inv), long=5, col='cyan') -} -# }
    + MBCAL.inv=invertFaces(MBCAL.mesh) + plotNormals(facenormals(MBCAL.inv), long=5, col='cyan') +} +} +
    - +
    -

    Site built with pkgdown.

    +

    Site built with pkgdown 1.6.1.

    + + + + + diff --git a/docs/reference/potential_synapses.html b/docs/reference/potential_synapses.html index a896337f..c955ff2c 100644 --- a/docs/reference/potential_synapses.html +++ b/docs/reference/potential_synapses.html @@ -1,6 +1,6 @@ - + @@ -8,25 +8,46 @@ Calculate number of potential synapses between two neurons — potential_synapses • nat + - + - - + + + + + + + - + + + + + + + + - - - + + + + + + + + + + - + + + - +
    +
    -
    +
    - +

    This implements the method of Stepanyants and Chklovskii

    - +
    -
    potential_synapses(a, b, s, ...)
    +    
    potential_synapses(a, b, s, ...)
     
     # S3 method for neuronlist
    -potential_synapses(a, b, s, ...)
    +potential_synapses(a, b, s, ...)
     
     # S3 method for neuron
    -potential_synapses(a, b, s, sigma = s, bounds,
    -  method = c("direct", "approx"), ...)
    +potential_synapses(
    +  a,
    +  b,
    +  s,
    +  sigma = s,
    +  bounds,
    +  method = c("direct", "approx"),
    +  ...
    +)
     
     # S3 method for dotprops
    -potential_synapses(a, b, s, sigma = s, seglength = 1,
    -  bounds = NULL, method = c("direct", "approx"), ...)
    - -

    Arguments

    +potential_synapses( + a, + b, + s, + sigma = s, + seglength = 1, + bounds = NULL, + method = c("direct", "approx"), + ... +)
    + +

    Arguments

    @@ -147,72 +192,72 @@

    Ar

    how long to consider each distance between points.

    - +

    Details

    -

    Note that potential_synapses.neuronlist uses - nlapply to process its first argument (a). This - enables progress bars, robustness to errors and simple parallel execution. - See the nlapply examples for further details of these - arguments in action.

    -

    For this reason if you have two neuronlists of unequal sizes, it is +

    Note that potential_synapses.neuronlist uses + nlapply to process its first argument (a). This + enables progress bars, robustness to errors and simple parallel execution. + See the nlapply examples for further details of these + arguments in action.

    +

    For this reason if you have two neuronlists of unequal sizes, it is recommended to put the larger one in argument a.

    -

    References

    Neurogeometry and potential synaptic connectivity. Stepanyants A, - Chklovskii DB. Trends Neurosci. 2005 Jul;28(7):387-94. - http://dx.doi.org/10.1016/j.tins.2005.05.006

    - + Chklovskii DB. Trends Neurosci. 2005 Jul;28(7):387-94. + doi: 10.1016/j.tins.2005.05.006

    See also

    -

    Other neuron: neuron, ngraph, - plot.neuron, prune, - resample, rootpoints, - spine, subset.neuron

    - +

    Other neuron: +neuron(), +ngraph(), +plot.neuron(), +prune(), +resample(), +rootpoints(), +spine(), +subset.neuron()

    Examples

    -
    potential_synapses(Cell07PNs[1], Cell07PNs[1:3], s=2)
    #> EBH11R +
    potential_synapses(Cell07PNs[1], Cell07PNs[1:3], s=2) +
    #> EBH11R #> EBH11R 902 #> EBH20L 219 -#> EBH20R 192
    # NOT RUN { -# if you have many neurons to calculate you should get a progress bar -potential_synapses(Cell07PNs[1:10], Cell07PNs[11:20], s=2) +#> EBH20R 192
    if (FALSE) { +# if you have many neurons to calculate you should get a progress bar +potential_synapses(Cell07PNs[1:10], Cell07PNs[11:20], s=2) # you can also use parallel execution, here over 7 cores # doMC::registerDoMC(7) -potential_synapses(Cell07PNs[1:10], Cell07PNs[11:20], s=2, .parallel=TRUE) -# }
    +potential_synapses(Cell07PNs[1:10], Cell07PNs[11:20], s=2, .parallel=TRUE) +} +
    - +
    -

    Site built with pkgdown.

    +

    Site built with pkgdown 1.6.1.

    + + + + + diff --git a/docs/reference/projection.html b/docs/reference/projection.html index 15cb2c50..a6e9607b 100644 --- a/docs/reference/projection.html +++ b/docs/reference/projection.html @@ -1,6 +1,6 @@ - + @@ -8,25 +8,46 @@ Make 2D (orthogonal) projection of 3D image data — projection • nat + - + - - + + + + + + + - + + + + + + + + - - - + + + + + + + + + + - + + + - +
    +
    -
    +
    - +

    Make 2D (orthogonal) projection of 3D image data

    - +
    -
    projection(a, projdim = "z", projfun = c("integrate", "mean", "sum"),
    -  na.rm = T, mask = NULL, ...)
    - -

    Arguments

    +
    projection(
    +  a,
    +  projdim = "z",
    +  projfun = c("integrate", "mean", "sum"),
    +  na.rm = T,
    +  mask = NULL,
    +  ...
    +)
    + +

    Arguments

    @@ -136,69 +172,74 @@

    Ar

    Additional arguments for projfun

    - +

    Details

    Note that projfun must have an argument na.rm like the - S3 Summary groupGeneric functions such as sum, min + S3 Summary groupGeneric functions such as sum, min etc.

    Note also that the BoundingBox of a 2d projection is not well-defined for the axis along which the projection was made. Presently both the evaluation location and the BoundingBox extremes are set to 0 after a projection is made but FIXME this is not completely satisfactory. Perhaps defining this to be NA or the midpoint of the orginal axis would be better justified.

    -

    See also

    -

    groupGeneric, clampmax

    -

    Other im3d: as.im3d, - boundingbox, im3d-coords, - im3d-io, im3d, - imexpand.grid, imslice, - is.im3d, mask, - origin, threshold, - unmask, voxdims

    - +

    Examples

    -
    # NOT RUN {
    -LHMask=read.im3d(system.file('tests/testthat/testdata/nrrd/LHMask.nrrd',package='nat'))
    -d=unmask(rnorm(sum(LHMask),mean=5,sd=5),LHMask)
    -op=par(mfrow=c(1,2))
    -rval=image(projection(d,projfun=max))
    -image(projection(d,projfun=clampmax(0,10)),zlim=rval$zlim)
    -par(op)
    -# }# NOT RUN {
    -LHMask=read.im3d(system.file('tests/testthat/testdata/nrrd/LHMask.nrrd',package='nat'))
    -image(projection(LHMask),asp=TRUE)
    -# }
    +
    if (FALSE) { +LHMask=read.im3d(system.file('tests/testthat/testdata/nrrd/LHMask.nrrd',package='nat')) +d=unmask(rnorm(sum(LHMask),mean=5,sd=5),LHMask) +op=par(mfrow=c(1,2)) +rval=image(projection(d,projfun=max)) +image(projection(d,projfun=clampmax(0,10)),zlim=rval$zlim) +par(op) +} +if (FALSE) { +LHMask=read.im3d(system.file('tests/testthat/testdata/nrrd/LHMask.nrrd',package='nat')) +image(projection(LHMask),asp=TRUE) +} +
    - +
    -

    Site built with pkgdown.

    +

    Site built with pkgdown 1.6.1.

    + + + + + diff --git a/docs/reference/prune.html b/docs/reference/prune.html index bf44722b..f6bf9152 100644 --- a/docs/reference/prune.html +++ b/docs/reference/prune.html @@ -1,6 +1,6 @@ - + @@ -8,25 +8,46 @@ prune an object by removing points near (or far) from a target object — prune • nat + - + - - + + + + + + + - + + + + + + + + - - - + + + + + + + + + + - + + + - +
    +
    -
    +
    - +

    prune an object by removing points near (or far) from a target object

    - +
    -
    prune(x, target, ...)
    +    
    prune(x, target, ...)
     
     # S3 method for neuron
    -prune(x, target, ...)
    +prune(x, target, ...)
     
     # S3 method for dotprops
    -prune(x, target, ...)
    +prune(x, target, ...)
     
     # S3 method for neuronlist
    -prune(x, target, ...)
    +prune(x, target, ...)
     
     # S3 method for default
    -prune(x, target, maxdist, keep = c("near", "far"),
    -  return.indices = FALSE, ...)
    - -

    Arguments

    +prune(x, target, maxdist, keep = c("near", "far"), return.indices = FALSE, ...)
    + +

    Arguments

    @@ -148,62 +177,77 @@

    Ar than the 3D object/points (default FALSE)

    - +

    Details

    prune.neuron depends on a more basic function prune_vertices and is also related to subset.neuron.

    -

    See also

    -

    prune_strahler, spine, - prune_vertices - subset.neuron - subset.dotprops

    -

    Other neuron: neuron, ngraph, - plot.neuron, - potential_synapses, resample, - rootpoints, spine, - subset.neuron

    - +

    Examples

    -
    ## prune single neurons -
    plot3d(kcs20[[1]],col='blue') -plot3d(kcs20[[2]],col='red')
    # prune neuron 2 down to points that are close to neuron 1 -neuron2_close=prune(kcs20[[2]], target=kcs20[[1]], maxdist=10)
    plot3d(neuron2_close, col='cyan', lwd=3)
    neuron2_far=prune(kcs20[[2]], target=kcs20[[1]], maxdist=10, keep='far')
    plot3d(neuron2_far, col='magenta', lwd=3)
    +
    ## prune single neurons +# \donttest{ +plot3d(kcs20[[1]],col='blue') +plot3d(kcs20[[2]],col='red') +# } +# prune neuron 2 down to points that are close to neuron 1 +neuron2_close=prune(kcs20[[2]], target=kcs20[[1]], maxdist=10) +# \donttest{ +plot3d(neuron2_close, col='cyan', lwd=3) +# } +neuron2_far=prune(kcs20[[2]], target=kcs20[[1]], maxdist=10, keep='far') +# \donttest{ +plot3d(neuron2_far, col='magenta', lwd=3) +# } + ## Prune a neuron with a neuronlist -pruned=prune(kcs20[[11]], kcs20[setdiff(1:20, 11)], maxdist=8)
    plot3d(pruned, col='red', lwd=3) -plot3d(kcs20[[11]], col='green', lwd=3) -plot3d(kcs20,col='grey')
    +pruned=prune(kcs20[[11]], kcs20[setdiff(1:20, 11)], maxdist=8) +# \donttest{ +plot3d(pruned, col='red', lwd=3) +plot3d(kcs20[[11]], col='green', lwd=3) +plot3d(kcs20,col='grey') +# } +
    - +
    -

    Site built with pkgdown.

    +

    Site built with pkgdown 1.6.1.

    + + + + + diff --git a/docs/reference/prune_strahler-1.png b/docs/reference/prune_strahler-1.png index 080dc450..3d49dddb 100644 Binary files a/docs/reference/prune_strahler-1.png and b/docs/reference/prune_strahler-1.png differ diff --git a/docs/reference/prune_strahler-4.png b/docs/reference/prune_strahler-4.png deleted file mode 100644 index e3032096..00000000 Binary files a/docs/reference/prune_strahler-4.png and /dev/null differ diff --git a/docs/reference/prune_strahler.html b/docs/reference/prune_strahler.html index 3c183726..96c07a1c 100644 --- a/docs/reference/prune_strahler.html +++ b/docs/reference/prune_strahler.html @@ -1,6 +1,6 @@ - + @@ -8,25 +8,46 @@ Prune a neuron by removing segments with a given Strahler order — prune_strahler • nat + - + - - + + + + + + + - + + + + + + + + - - - + + + + + + + + + + - + + + - +
    +
    -
    +
    - +

    Prune a neuron by removing segments with a given Strahler order

    - +
    -
    prune_strahler(x, orderstoprune = 1:2, ...)
    - -

    Arguments

    +
    prune_strahler(x, orderstoprune = 1:2, ...)
    + +

    Arguments

    @@ -121,52 +151,51 @@

    Ar

    Additional arguments passed to as.neuron.data.frame

    - +

    Value

    The pruned neuron

    -

    See also

    -

    strahler_order, spine, for finding the +

    strahler_order, spine, for finding the longest path in a neuron, prune for subsetting dotprops style neurons by spatial proximity, as.neuron.data.frame, which is used to generate the new - neuron.

    - + neuron.

    Examples

    -
    x=Cell07PNs[[1]] -pruned12=prune_strahler(x) -pruned1=prune_strahler(x, 1) -plot(x)
    plot(pruned1, lwd=3, col='blue', add=TRUE)
    plot(pruned12, lwd=3, col='red', add=TRUE)
    +
    x=Cell07PNs[[1]] +pruned12=prune_strahler(x) +pruned1=prune_strahler(x, 1) +plot(x) +
    plot(pruned1, lwd=3, col='blue', add=TRUE) +
    plot(pruned12, lwd=3, col='red', add=TRUE) +
    - +
    -

    Site built with pkgdown.

    +

    Site built with pkgdown 1.6.1.

    + + + + + diff --git a/docs/reference/prune_vertices-1.png b/docs/reference/prune_vertices-1.png index 77a6a761..fbd2cab8 100644 Binary files a/docs/reference/prune_vertices-1.png and b/docs/reference/prune_vertices-1.png differ diff --git a/docs/reference/prune_vertices-3.png b/docs/reference/prune_vertices-3.png deleted file mode 100644 index d400adc7..00000000 Binary files a/docs/reference/prune_vertices-3.png and /dev/null differ diff --git a/docs/reference/prune_vertices.html b/docs/reference/prune_vertices.html index 160ec4b7..f6f34a3b 100644 --- a/docs/reference/prune_vertices.html +++ b/docs/reference/prune_vertices.html @@ -1,6 +1,6 @@ - + @@ -8,25 +8,47 @@ Prune selected vertices or edges from a neuron — prune_vertices • nat + - + - - + + + + + + + - + + + + + + + + - - - + + + + + + + + + + - + + + - +
    +
    -
    +
    - -

    prune_vertices removes vertices from a neuron +

    +

    prune_vertices removes vertices from a neuron

    +

    prune_edges removes edges (and any unreferenced vertices)

    +
    - prune_edges removes edges (and any unreferenced vertices)

    - +
    prune_vertices(x, verticestoprune, invert = FALSE, ...)
     
    -    
    prune_vertices(x, verticestoprune, invert = FALSE, ...)
    +prune_edges(x, edges, invert = FALSE, ...)
    -prune_edges(x, edges, invert = FALSE, ...)
    - -

    Arguments

    +

    Arguments

    @@ -135,14 +165,13 @@

    Ar specifying a single edge defined by its raw edge id, ii) an integer vector defining a path of raw vertex ids or iii) an igraph.es edge sequence --- see detaiuls and the P and path arguments -of igraph::E.

    +of igraph::E.

    - +

    Value

    A pruned neuron

    -

    Details

    These are relatively low-level functions and you will probably want @@ -163,58 +192,55 @@

    Details a matrix or vector the direction of each individual edge in this path is ignored. So if your neuron has edges 2->1 2->3 3->4 then an edge sequence 1:3 would successfully delete 2 edges.

    -

    See also

    -

    as.neuron.ngraph, subset.neuron, - prune.neuron

    - +

    Examples

    -
    n=prune_vertices(Cell07PNs[[1]], 1:25) +
    n=prune_vertices(Cell07PNs[[1]], 1:25) # original neuron -plot(Cell07PNs[[1]])
    # with pruned neuron superimposed -plot(n, col='green', lwd=3, add=TRUE)
    +plot(Cell07PNs[[1]]) +
    # with pruned neuron superimposed +plot(n, col='green', lwd=3, add=TRUE) +
    # use the PointNo field (= the original id from an SWC file) -n2=prune_vertices(n, match(26:30, n$d$PointNo)) -y=prune_edges(Cell07PNs[[1]], edges=1:25) +n2=prune_vertices(n, match(26:30, n$d$PointNo)) +y=prune_edges(Cell07PNs[[1]], edges=1:25) # remove the spine of a neuron -spine_ids=spine(Cell07PNs[[1]], rval='ids') -pruned=prune_edges(Cell07PNs[[1]], spine_ids) +spine_ids=spine(Cell07PNs[[1]], rval='ids') +pruned=prune_edges(Cell07PNs[[1]], spine_ids) # NB this is subtly different from this, which removes vertices along the # spine *even* if they are part of an edge that is outside the spine. -pruned2=prune_vertices(Cell07PNs[[1]], spine_ids)
    +pruned2=prune_vertices(Cell07PNs[[1]], spine_ids) +
    - +
    -

    Site built with pkgdown.

    +

    Site built with pkgdown 1.6.1.

    + + + + + diff --git a/docs/reference/read.cmtk.html b/docs/reference/read.cmtk.html index 9e2659f1..4e034c06 100644 --- a/docs/reference/read.cmtk.html +++ b/docs/reference/read.cmtk.html @@ -1,6 +1,6 @@ - + @@ -8,25 +8,48 @@ Read CMTK TypedStream file to a list in memory — read.cmtk • nat + - + - - + + + + + + + - + + + + + + + + - - - + + + + + + + + + + - + + + - +
    +
    -
    +
    - +

    This function is primarily of developer interest. End users will typically want to use more specialised functions for reading registrations and landmarks.

    - +
    + +
    read.cmtk(con, CheckLabel = TRUE)
    -
    read.cmtk(con, CheckLabel = TRUE)
    - -

    Arguments

    +

    Arguments

    @@ -119,7 +151,7 @@

    Ar (default TRUE)

    - +

    Details

    This is the default format used by CMTK for registration, studylist, @@ -128,39 +160,39 @@

    Details spline warp component of a CMTK nonrigid registrartion.

    Note that if an open connection is passed to read.cmtk the version number of the CMTK TypedStream will not be checked or recorded.

    -

    See also

    -

    Other cmtk-io: cmtk.extract_affine, - read.cmtkreg, write.cmtkreg, - write.cmtk

    - +
    - +
    -

    Site built with pkgdown.

    +

    Site built with pkgdown 1.6.1.

    + + + + + diff --git a/docs/reference/read.cmtkreg.html b/docs/reference/read.cmtkreg.html index 3ed4ee63..daf7b1c1 100644 --- a/docs/reference/read.cmtkreg.html +++ b/docs/reference/read.cmtkreg.html @@ -1,6 +1,6 @@ - + @@ -8,25 +8,46 @@ Read a CMTK format registration — read.cmtkreg • nat + - + - - + + + + + + + - + + + + + + + + - - - + + + + + + + + + + - + + + - +
    +
    -
    +
    - +

    Read a CMTK format registration

    - +
    + +
    read.cmtkreg(filename, ReturnRegistrationOnly = FALSE, ...)
    -
    read.cmtkreg(filename, ReturnRegistrationOnly = FALSE, ...)
    - -

    Arguments

    +

    Arguments

    @@ -121,37 +151,40 @@

    Ar

    Additional arguments passed to read.cmtk

    - +

    See also

    -

    Other cmtk-io: cmtk.extract_affine, - read.cmtk, write.cmtkreg, - write.cmtk

    - +
    - +
    -

    Site built with pkgdown.

    +

    Site built with pkgdown 1.6.1.

    + + + + + diff --git a/docs/reference/read.hxsurf.html b/docs/reference/read.hxsurf.html index ddab76a1..ee6857a6 100644 --- a/docs/reference/read.hxsurf.html +++ b/docs/reference/read.hxsurf.html @@ -1,6 +1,6 @@ - + @@ -8,25 +8,46 @@ Read Amira surface (aka HxSurface or HyperSurface) files into hxsurf object — read.hxsurf • nat + - + - - + + + + + + + - + + + + + + + + - - - + + + + + + + + + + - + + + - +
    +
    -
    +
    - +

    Read Amira surface (aka HxSurface or HyperSurface) files into hxsurf object

    - +
    + +
    read.hxsurf(
    +  filename,
    +  RegionNames = NULL,
    +  RegionChoice = "both",
    +  FallbackRegionCol = "grey",
    +  Verbose = FALSE
    +)
    -
    read.hxsurf(filename, RegionNames = NULL, RegionChoice = "both",
    -  FallbackRegionCol = "grey", Verbose = FALSE)
    - -

    Arguments

    +

    Arguments

    @@ -132,7 +167,7 @@

    Ar

    Print status messages during parsing when TRUE

    - +

    Value

    A list with S3 class hxsurf with elements

      @@ -143,10 +178,9 @@

      Value

    • RegionList Character vector of region names (should match names of Regions element)

    • RegionColourList Character vector specifying default colour to plot - each region in R's rgb format

    • + each region in R's rgb format

    -

    Details

    Note that when RegionChoice="both" or @@ -164,52 +198,52 @@

    Details

    As a rule of thumb, stick with RegionChoice="both". If you get more regions than you wanted, then try switching to RegionChoice="Inner" or RegionChoice="Outer".

    -

    See also

    -

    plot3d.hxsurf, rgb

    -

    Other amira: amiratype, - is.amiramesh, read.amiramesh, - write.hxsurf

    -

    Other hxsurf: as.hxsurf, - as.mesh3d, materials, - plot3d.hxsurf, subset.hxsurf, - write.hxsurf

    - +

    Examples

    -
    # NOT RUN {
    -read.hxsurf("my.surf", RegionChoice="both")
    -# }
    +
    if (FALSE) { +read.hxsurf("my.surf", RegionChoice="both") +} +
    - +
    -

    Site built with pkgdown.

    +

    Site built with pkgdown 1.6.1.

    + + + + + diff --git a/docs/reference/read.landmarks.html b/docs/reference/read.landmarks.html index 026b2d03..c4134f93 100644 --- a/docs/reference/read.landmarks.html +++ b/docs/reference/read.landmarks.html @@ -1,6 +1,6 @@ - + @@ -8,25 +8,46 @@ Generic functions to read/write landmarks in any supported format — read.landmarks • nat + - + - - + + + + + + + - + + + + + + + + - - - + + + + + + + + + + - + + + - +
    +
    -
    +
    - +

    Generic functions to read/write landmarks in any supported format

    - +
    + +
    read.landmarks(f, ...)
     
    -    
    read.landmarks(f, ...)
    +write.landmarks(
    +  x,
    +  file,
    +  format = "amiralandmarks",
    +  ext = NULL,
    +  Force = FALSE,
    +  MakeDir = TRUE,
    +  ...
    +)
    -write.landmarks(x, file, format = "amiralandmarks", ext = NULL, - Force = FALSE, MakeDir = TRUE, ...)
    - -

    Arguments

    +

    Arguments

    @@ -153,37 +190,35 @@

    Ar

    Whether to create directory implied by file argument.

    - +

    Value

    for read.landmarks a matrix or list of additional class landmarks, where the rownames specify the names of each landmark if available.

    For write.landmarks the path to the written file, invisibly.

    -

    Details

    Presently the supported formats are

    -

    See examples section for how to produce a listing of all currently + +

    See examples section for how to produce a listing of all currently available formats with fileformats.

    -

    Paired landmarks

    Only the amiralandmarks format supports the use of paired landmarks

    -

    See also

    -

    fileformats

    - +

    Examples

    ## Listing of supported fileformats for landmarks -fileformats(class = 'landmarks', rval = "info")
    #> format class ext read write magic +fileformats(class = 'landmarks', rval = "info") +
    #> format class ext read write magic #> 1 amiralandmarks landmarks .landmarkAscii TRUE TRUE TRUE #> 2 amiralandmarks landmarks .landmarkBin TRUE TRUE TRUE #> 3 amiralandmarks landmarks .am TRUE TRUE TRUE @@ -191,54 +226,51 @@

    Examp #> 5 cmtklandmarks landmarks .landmarks TRUE TRUE TRUE #> 6 fijilandmarks landmarks .points TRUE TRUE TRUE

    ## round trip tests -m=matrix(rnorm(6), ncol=3) -rownames(m)=c("nose", "ear") -f=write.landmarks(m, file='knee', format='cmtk') -read.landmarks(f)
    #> [,1] [,2] [,3] -#> nose -1.117033 -0.4420909 -0.7190785 -#> ear -2.339310 0.1766739 1.7054692 +m=matrix(rnorm(6), ncol=3) +rownames(m)=c("nose", "ear") +f=write.landmarks(m, file='knee', format='cmtk') +read.landmarks(f) +
    #> [,1] [,2] [,3] +#> nose 1.2144373 0.1955005 -1.34589486 +#> ear 0.7838219 -0.1034411 -0.05945999 #> attr(,"class") -#> [1] "landmarks" "matrix"
    +#> [1] "landmarks" "matrix" "array"
    # write in amira format which does not support named landmarks -f2=write.landmarks(m, file='knee', format='amira') -read.landmarks(f2)
    #> [,1] [,2] [,3] -#> [1,] -1.117033 -0.4420909 -0.7190785 -#> [2,] -2.339310 0.1766739 1.7054692 +f2=write.landmarks(m, file='knee', format='amira') +read.landmarks(f2) +
    #> [,1] [,2] [,3] +#> [1,] 1.2144373 0.1955005 -1.34589486 +#> [2,] 0.7838219 -0.1034411 -0.05945999 #> attr(,"class") -#> [1] "landmarks" "matrix"
    +#> [1] "landmarks" "matrix" "array"
    # clean up -unlink(c(f,f2))
    +unlink(c(f,f2)) +
    - +
    -

    Site built with pkgdown.

    +

    Site built with pkgdown 1.6.1.

    + + + + + diff --git a/docs/reference/read.morphml.html b/docs/reference/read.morphml.html index f05345d8..88bb10e2 100644 --- a/docs/reference/read.morphml.html +++ b/docs/reference/read.morphml.html @@ -1,6 +1,6 @@ - + @@ -8,25 +8,50 @@ Return parsed XML or R list versions of a NeuroML file — read.morphml • nat + - + - - + + + + + + + - + + + + + + + + - - - + + + + + + + + + + - + + + - +
    +
    -
    +
    - +

    read.morphml is designed to expose the full details of the morphology information in a NeuroML file either as a parsed XML structure processed by the XML package or as an extensively processed R list object. To obtain a neuron object use read.neuron.neuroml.

    - +
    + +
    read.morphml(f, ..., ReturnXML = FALSE)
    -
    read.morphml(f, ..., ReturnXML = FALSE)
    - -

    Arguments

    +

    Arguments

    +xmlParse for details).

    - + @@ -127,13 +161,12 @@

    Ar ReturnXML=FALSE, the default.

    f

    Path to a file on disk or a remote URL (see -xmlParse for details).

    ...

    Additional arguments passed to xmlParse

    Additional arguments passed to xmlParse

    ReturnXML
    - +

    Value

    Either an R list of S3 class containing one morphml_cell object for every cell in the NeuroML document or an object of class XMLDocument when ReturnXML=TRUE.

    -

    Details

    NeuroML files consist of an XML tree containing one more or more @@ -146,45 +179,38 @@

    Details provides as much information as possible from the segments and cables trees in two R data.frames. The latter option will inevitably drop some information, but will probably be more convenient for most purposes.

    -

    References

    -

    http://www.neuroml.org/specifications

    - +

    https://neuroml.org/specifications

    See also

    -

    link[XML]{xmlParse}, read.neuron.neuroml

    - +

    link[XML]{xmlParse}, read.neuron.neuroml

    - +
    -

    Site built with pkgdown.

    +

    Site built with pkgdown 1.6.1.

    + + + + + diff --git a/docs/reference/read.neuron.fiji.html b/docs/reference/read.neuron.fiji.html index 97e304db..685e11ef 100644 --- a/docs/reference/read.neuron.fiji.html +++ b/docs/reference/read.neuron.fiji.html @@ -1,6 +1,6 @@ - + @@ -8,25 +8,46 @@ Read a neuron saved by Fiji's Simple Neurite Tracer Plugin — read.neuron.fiji • nat + - + - - + + + + + + + - + + + + + + + + - - - + + + + + + + + + + - + + + - +
    +
    -
    +
    - +

    Read a neuron saved by Fiji's Simple Neurite Tracer Plugin

    - +
    -
    read.neuron.fiji(f, ..., simplify = TRUE, Verbose = FALSE)
    - -

    Arguments

    +
    read.neuron.fiji(f, ..., simplify = TRUE, Verbose = FALSE)
    + +

    Arguments

    @@ -113,7 +143,7 @@

    Ar

    - + @@ -125,43 +155,41 @@

    Ar

    ...

    Additional arguments passed to xmlParse.

    Additional arguments passed to xmlParse.

    simplify

    Whether to print status messages during parsing.

    - +

    Details

    This is an XML based format so parsing it depends on installation of the suggested XML package.

    -

    References

    -

    http://fiji.sc/Simple_Neurite_Tracer - http://fiji.sc/Simple_Neurite_Tracer:_.traces_File_Format

    - +

    https://imagej.net/plugins/simple-neurite-tracer/ + https://imagej.net/plugins/snt/traces-file-format

    - +
    -

    Site built with pkgdown.

    +

    Site built with pkgdown 1.6.1.

    + + + + + diff --git a/docs/reference/read.neuron.html b/docs/reference/read.neuron.html index 06bd97fa..6fac14ce 100644 --- a/docs/reference/read.neuron.html +++ b/docs/reference/read.neuron.html @@ -1,6 +1,6 @@ - + @@ -8,25 +8,46 @@ Read a single neuron from a file — read.neuron • nat + - + - - + + + + + + + - + + + + + + + + - - - + + + + + + + + + + - + + + - +
    +
    -
    +
    - +

    Read a single neuron from a file

    - +
    -
    read.neuron(f, format = NULL, class = c("neuron", "ngraph"), ...)
    - -

    Arguments

    +
    read.neuron(f, format = NULL, class = c("neuron", "ngraph"), ...)
    + +

    Arguments

    - - - @@ -128,84 +158,79 @@

    Ar

    f

    Path to file. This can be a URL, in which case the file is +

    Path to file. This can be a URL, in which case the file is downloaded to a temporary location before reading.

    format

    The file format of the neuron. When format=NULL, the -default, read.neuron will infer the file format from the extension +

    The file format of the neuron. When format=NULL, the +default, read.neuron will infer the file format from the extension or file header (aka magic) using the fileformats registry.

    class

    The class of the returned object - presently either +

    The class of the returned object - presently either "neuron" or "ngraph"

    additional arguments passed to format-specific readers

    - +

    Details

    -

    This function will handle neuron and dotprops objects - saved in R .rds or .rda format by default. Additional file formats can be - registered using fileformats.

    -

    At the moment the following formats are supported using file readers +

    This function will handle neuron and dotprops objects + saved in R .rds or .rda format by default. Additional file formats can be + registered using fileformats.

    +

    At the moment the following formats are supported using file readers already included with the nat package:

      -
    • swc See read.neuron.swc. SWC files can also - return an ngraph object containing the neuron structure in a - (permissive) general graph format that also contains the 3D positions for +

    • swc See read.neuron.swc. SWC files can also + return an ngraph object containing the neuron structure in a + (permissive) general graph format that also contains the 3D positions for each vertex.

    • neuroml See read.neuron.neuroml

    • fijitraces See read.neuron.fiji. The file format - used by the Simple Neurite + used by the Simple Neurite Tracer plugin of Fiji/ImageJ.

    • -
    • hxlineset,hxskel Two distinct fileformats used by Amira. - hxlineset is the generic one, hxskel is used by the +

    • hxlineset,hxskel Two distinct fileformats used by Amira. + hxlineset is the generic one, hxskel is used by the hxskeletonize extension of Schmitt and Evers (see refs).

    • -
    • rda,rds Native R cross-platform binary formats (see - load, readRDS). Note that RDS only contains a single +

    • rda,rds Native R cross-platform binary formats (see + load, readRDS). Note that RDS only contains a single unnamed neuron, whereas rda contains one or more named neurons.

    - +

    References

    -

    Schmitt, S. and Evers, J. F. and Duch, C. and Scholz, M. and - Obermayer, K. (2004). New methods for the computer-assisted 3-D - reconstruction of neurons from confocal image stacks. Neuroimage 4, - 1283--98. - doi:10.1016/j.neuroimage.2004.06.047

    - +

    Schmitt, S. and Evers, J. F. and Duch, C. and Scholz, M. and + Obermayer, K. (2004). New methods for the computer-assisted 3-D + reconstruction of neurons from confocal image stacks. Neuroimage 4, + 1283--98. + doi: 10.1016/j.neuroimage.2004.06.047

    See also

    -

    write.neuron, read.neurons, - fileformats

    - +

    Examples

    -
    # NOT RUN {
    +    
    if (FALSE) { # note that we override the default NeuronName field -n=read.neuron(system.file("tests/testthat/testdata","neuron","EBT7R.CNG.swc",package='nat'), - NeuronName="EBT7R") +n=read.neuron(system.file("tests/testthat/testdata","neuron","EBT7R.CNG.swc",package='nat'), + NeuronName="EBT7R") # use a function to set the NeuronName field -n3=read.neuron(system.file("tests/testthat/testdata","neuron","EBT7R.CNG.swc",package='nat'), - NeuronName=function(x) sub("\\..*","",x)) +n3=read.neuron(system.file("tests/testthat/testdata","neuron","EBT7R.CNG.swc",package='nat'), + NeuronName=function(x) sub("\\..*","",x)) # show the currently registered file formats that we can read -fileformats(class='neuron', read=TRUE) -# }
    +fileformats(class='neuron', read=TRUE) +} +
    - +
    -

    Site built with pkgdown.

    +

    Site built with pkgdown 1.6.1.

    + + + + + diff --git a/docs/reference/read.neuron.neuroml.html b/docs/reference/read.neuron.neuroml.html index 50c32765..269655a7 100644 --- a/docs/reference/read.neuron.neuroml.html +++ b/docs/reference/read.neuron.neuroml.html @@ -1,6 +1,6 @@ - + @@ -8,25 +8,46 @@ Read one or more neurons from a NeuroML v1 file — read.neuron.neuroml • nat + - + - - + + + + + + + - + + + + + + + + - - - + + + + + + + + + + - + + + - +
    +
    -
    +
    - +

    Read one or more neurons from a NeuroML v1 file

    - +
    -
    read.neuron.neuroml(f, ..., AlwaysReturnNeuronList = FALSE)
    - -

    Arguments

    +
    read.neuron.neuroml(f, ..., AlwaysReturnNeuronList = FALSE)
    + +

    Arguments

    @@ -114,56 +144,51 @@

    Ar

    +xmlParse)

    ...

    Additional arguments passed to read.morphml (and on to -xmlParse)

    AlwaysReturnNeuronList

    See Value section (default FALSE)

    - +

    Value

    When the XML file contains only 1 cell and AlwaysReturnNeuronList=FALSE, a neuron object, otherwise a neuronlist containing one or more neurons.

    -

    References

    -

    http://www.neuroml.org/specifications

    - +

    https://neuroml.org/specifications

    See also

    -

    read.morphml

    - +
    - +
    -

    Site built with pkgdown.

    +

    Site built with pkgdown 1.6.1.

    + + + + + diff --git a/docs/reference/read.neuron.swc.html b/docs/reference/read.neuron.swc.html index 1a8462ff..51315ffe 100644 --- a/docs/reference/read.neuron.swc.html +++ b/docs/reference/read.neuron.swc.html @@ -1,6 +1,6 @@ - + @@ -8,25 +8,50 @@ Read a neuron in swc file format — read.neuron.swc • nat + - + - - + + + + + + + - + + + + + + + + - - - + + + + + + + + + + - + + + - +
    +
    -
    +
    - +

    read.neuron.swc reads an SWC file on disk into a fully - parsed neuron representation. - - read.ngraph.swc reads an SWC file on disk into the more + parsed neuron representation.

    +

    read.ngraph.swc reads an SWC file on disk into the more generic (and forgiving) ngraph representation which provides - a bridge to the igraph library.

    - + a bridge to the igraph library.

    +
    -
    read.neuron.swc(f, ...)
    +    
    read.neuron.swc(f, ...)
     
    -read.ngraph.swc(f, weights = FALSE, directed = TRUE, ...)
    - -

    Arguments

    +read.ngraph.swc(f, weights = FALSE, directed = TRUE, ...)
    + +

    Arguments

    @@ -135,7 +168,7 @@

    Ar

    Whether the resultant graph should be directed (default TRUE)

    - +

    Details

    These functions will accept SWC neurons with multiple trees and @@ -143,45 +176,40 @@

    Details accept SWC files with cycles.

    These functions would normally be called from read.neuron(s) rather than used directly.

    -

    SWC Format

    According to - http://research.mssm.edu/cnic/swc.html SWC file format has a + http://www.neuronland.org/NLMorphologyConverter/MorphologyFormats/SWC/Spec.html SWC file format has a radius not a diameter specification

    -

    See also

    -

    is.swc

    - +
    - +
    -

    Site built with pkgdown.

    +

    Site built with pkgdown 1.6.1.

    + + + + + diff --git a/docs/reference/read.neuronlistfh.html b/docs/reference/read.neuronlistfh.html index 7cac3e7c..e0249397 100644 --- a/docs/reference/read.neuronlistfh.html +++ b/docs/reference/read.neuronlistfh.html @@ -1,6 +1,6 @@ - + @@ -8,25 +8,46 @@ Read a local, or remote, neuronlistfh object saved to a file. — read.neuronlistfh • nat + - + - - + + + + + + + - + + + + + + + + - - - + + + + + + + + + + - + + + - +
    +
    -
    +
    - +

    Read a local, or remote, neuronlistfh object saved to a file.

    - +
    -
    read.neuronlistfh(file, localdir = NULL, update = FALSE, ...)
    - -

    Arguments

    +
    read.neuronlistfh(file, localdir = NULL, update = FALSE, ...)
    + +

    Arguments

    @@ -129,7 +159,7 @@

    Ar

    Extra arguments to pass to download.file.

    - +

    Details

    When reading a remote neuronlistfh object, it is downloaded @@ -153,7 +183,8 @@

    Details
  • \path\to\localdir\data\5b58e040ee35f3bcc6023fb7836c842e

  • \path\to\localdir\data\... etc

  • -

    Given this arrangment, the data directory should always be at a fixed + +

    Given this arrangment, the data directory should always be at a fixed location with respect to the saved neuronlistfh object and this is enforced on download and the default behaviour on read and write. However it does remain possible (if not recommended) to site the neuronlistfh and filehash @@ -161,39 +192,39 @@

    Details object specified by file does not have a filehash database with a valid dir slot and there is no 'data' directory adjacent to the neuronlistfh object, an error will result.

    -

    See also

    -

    Other neuronlistfh: [.neuronlistfh, - neuronlistfh, remotesync, - write.neuronlistfh

    - +

    Other neuronlistfh: +[.neuronlistfh(), +neuronlistfh(), +remotesync(), +write.neuronlistfh()

    - +
    -

    Site built with pkgdown.

    +

    Site built with pkgdown 1.6.1.

    + + + + + diff --git a/docs/reference/read.neurons.html b/docs/reference/read.neurons.html index 41ee00c7..8efa95bc 100644 --- a/docs/reference/read.neurons.html +++ b/docs/reference/read.neurons.html @@ -1,6 +1,6 @@ - + @@ -8,25 +8,46 @@ Read one or more neurons from file to a neuronlist in memory — read.neurons • nat + - + - - + + + + + + + - + + + + + + + + - - - + + + + + + + + + + - + + + - +
    +
    -
    +
    - +

    Read one or more neurons from file to a neuronlist in memory

    - +
    + +
    read.neurons(
    +  paths,
    +  pattern = NULL,
    +  neuronnames = basename,
    +  format = NULL,
    +  nl = NULL,
    +  df = NULL,
    +  OmitFailures = TRUE,
    +  SortOnUpdate = FALSE,
    +  ...
    +)
    -
    read.neurons(paths, pattern = NULL, neuronnames = basename, format = NULL,
    -  nl = NULL, df = NULL, OmitFailures = TRUE, SortOnUpdate = FALSE, ...)
    - -

    Arguments

    +

    Arguments

    - @@ -152,11 +191,10 @@

    Ar

    paths

    Paths to neuron input files or a directory containing -neurons or a neuronlistfh object, or a zip +neurons or a neuronlistfh object, or a zip archive containing multiple neurons.

    pattern

    If paths is a directory, regex that file +

    If paths is a directory, regex that file names must match.

    Additional arguements to passed to read.neuron methods

    - +

    Value

    neuronlist object containing the neurons

    -

    Details

    This function will cope with the same set of file formats offered by @@ -178,70 +216,68 @@

    Details is generated. If SortOnUpdate is TRUE then updating an existing neuronlist should result in a new neuronlist with ordering identical to reading all neurons from scratch.

    -

    See also

    -

    read.neuron, write.neurons, +

    read.neuron, write.neurons, fileformats

    -

    Other neuronlist: *.neuronlist, - is.neuronlist, - neuronlist-dataframe-methods, - neuronlistfh, neuronlist, - nlapply, write.neurons

    - +

    Other neuronlist: +*.neuronlist(), +is.neuronlist(), +neuronlist-dataframe-methods, +neuronlistfh(), +neuronlist(), +nlapply(), +write.neurons()

    Examples

    -
    # NOT RUN {
    +    
    if (FALSE) { ## Read C. elegans neurons from OpenWorm github repository -vds=paste0("VD", 1:13) -vdurls=paste0("https://raw.githubusercontent.com/openworm/CElegansNeuroML/", - "103d500e066125688aa7ac5eac7e9b2bb4490561/CElegans/generatedNeuroML/",vds, - ".morph.xml") -vdnl=read.neurons(vdurls, neuronnames=vds) -plot3d(vdnl) +vds=paste0("VD", 1:13) +vdurls=paste0("https://raw.githubusercontent.com/openworm/CElegansNeuroML/", + "103d500e066125688aa7ac5eac7e9b2bb4490561/CElegans/generatedNeuroML/",vds, + ".morph.xml") +vdnl=read.neurons(vdurls, neuronnames=vds) +plot3d(vdnl) ## The same, but this time add some metadata to neuronlist # fetch table of worm neurons from wormbase -library(rvest) -nlurl="http://wormatlas.org/neurons/Individual%20Neurons/Neuronframeset.html" -wormneurons = html_table(html(nlurl), fill=TRUE)[[4]] -vddf=subset(wormneurons, Neuron%in%vds) -rownames(vddf)=vddf$Neuron +library(rvest) +nlurl="http://wormatlas.org/neurons/Individual%20Neurons/Neuronframeset.html" +wormneurons = html_table(html(nlurl), fill=TRUE)[[4]] +vddf=subset(wormneurons, Neuron%in%vds) +rownames(vddf)=vddf$Neuron # attach metadata to neuronlist -vdnl=read.neurons(vdurls, neuronnames=vds, df=vddf) +vdnl=read.neurons(vdurls, neuronnames=vds, df=vddf) # use metadata to plot a subset of neurons -clear3d() -plot3d(vdnl, grepl("P[1-6].app", Lineage)) -# }
    +clear3d() +plot3d(vdnl, grepl("P[1-6].app", Lineage)) +} +
    - +
    -

    Site built with pkgdown.

    +

    Site built with pkgdown 1.6.1.

    + + + + + diff --git a/docs/reference/read.nrrd.html b/docs/reference/read.nrrd.html index 23a93927..dcffff6c 100644 --- a/docs/reference/read.nrrd.html +++ b/docs/reference/read.nrrd.html @@ -1,6 +1,6 @@ - + @@ -8,25 +8,47 @@ Read nrrd file into an array in memory — read.nrrd • nat + - + - - + + + + + + + - + + + + + + + + - - - + + + + + + + + + + - + + + - +
    +
    -
    +
    - +

    Read nrrd file into an array in memory

    Read the (text) header of a NRRD format file

    - +
    -
    read.nrrd(file, origin = NULL, ReadData = TRUE, AttachFullHeader = TRUE,
    -  Verbose = FALSE, ReadByteAsRaw = c("unsigned", "all", "none"))
    +    
    read.nrrd(
    +  file,
    +  origin = NULL,
    +  ReadData = TRUE,
    +  AttachFullHeader = TRUE,
    +  Verbose = FALSE,
    +  ReadByteAsRaw = c("unsigned", "all", "none")
    +)
     
    -read.nrrd.header(file, Verbose = FALSE)
    - -

    Arguments

    +read.nrrd.header(file, Verbose = FALSE)
    + +

    Arguments

    @@ -139,13 +176,12 @@

    Ar integer vector.

    - +

    Value

    An array object, optionally with attributes from the nrrd header.

    A list with elements for the key nrrd header fields

    -

    Details

    read.nrrd reads data into a raw array. If you wish to @@ -155,39 +191,35 @@

    Details

    ReadByteAsRaw=unsigned (the default) only reads unsigned byte data as a raw array. This saves quite a bit of space and still allows data to be used for logical indexing.

    -

    See also

    -

    write.nrrd, read.im3d

    - +
    - +
    -

    Site built with pkgdown.

    +

    Site built with pkgdown 1.6.1.

    + + + + + diff --git a/docs/reference/read.vaa3draw.html b/docs/reference/read.vaa3draw.html index e75f14ee..9fd6b664 100644 --- a/docs/reference/read.vaa3draw.html +++ b/docs/reference/read.vaa3draw.html @@ -1,6 +1,6 @@ - + @@ -8,25 +8,46 @@ Read Vaa3d format image data — read.vaa3draw • nat + - + - - + + + + + + + - + + + + + + + + - - - + + + + + + + + + + - + + + - +
    +
    -
    +
    - +

    Read Vaa3d format image data

    - +
    + +
    read.vaa3draw(f, ReadData = TRUE, Verbose = FALSE, ReadByteAsRaw = FALSE)
    -
    read.vaa3draw(f, ReadData = TRUE, Verbose = FALSE, ReadByteAsRaw = FALSE)
    - -

    Arguments

    +

    Arguments

    @@ -125,29 +155,33 @@

    Ar raw rather than 4 byte interegers.

    - -
    - +
    +
    -

    Site built with pkgdown.

    +

    Site built with pkgdown 1.6.1.

    + + + + + diff --git a/docs/reference/reglist.html b/docs/reference/reglist.html index fa093aa5..a75a5d2f 100644 --- a/docs/reference/reglist.html +++ b/docs/reference/reglist.html @@ -1,6 +1,6 @@ - + @@ -8,25 +8,62 @@ A simple wrapper class for multiple transformations — reglist • nat + - + - - + + + + + + + - + + + + + + + + - - - + + + + + + + + + + - + + + - +
    +
    -
    +
    - +

    A reglist is read as a set of transformations to be applied sequentially starting with the first element, then applying the second transformation to the result of the first and so on. Each individual @@ -112,22 +158,20 @@

    A simple wrapper class for multiple transformations

    is used to avoid a direct equivalence with inversion - many registration tools use the term inverse for directions that one might naively think of as as the natural direction of the transformation (see - xformpoints.cmtkreg for discussion). - - invert_reglist inverts a reglist object - - c.reglist combines multiple reglists into a single + xformpoints.cmtkreg for discussion).

    +

    invert_reglist inverts a reglist object

    +

    c.reglist combines multiple reglists into a single reglist.

    - +
    -
    reglist(..., swap = NULL)
    +    
    reglist(..., swap = NULL)
     
    -invert_reglist(x)
    +invert_reglist(x)
     
     # S3 method for reglist
    -c(..., recursive = FALSE)
    - -

    Arguments

    +c(..., recursive = FALSE)
    + +

    Arguments

    @@ -149,71 +193,66 @@

    Ar

    Presently ignored

    - +

    Details

    The swap argument is provided as a convenience, but an attribute 'swap' can also be set directly on each registration.

    -

    Inversion

    invert_reglist takes a minimal approach to inversion. It reverses the order of the individual elements of the registration and tags each of them with a swap attribute (or changes the value of the attribute if it already exists)

    -

    See also

    -

    xform - c

    - +

    Examples

    -
    I=diag(4) -S=I -diag(S)=c(1, 2, 3, 1) -rl=reglist(S, I) -rli=invert_reglist(rl) +
    I=diag(4) +S=I +diag(S)=c(1, 2, 3, 1) +rl=reglist(S, I) +rli=invert_reglist(rl) ## We can check the inversion by simplifying -m=simplify_reglist(rl)[[1]] -mi=simplify_reglist(rli)[[1]] +m=simplify_reglist(rl)[[1]] +mi=simplify_reglist(rli)[[1]] # NB solve will invert a homogeneous affine matrix -all.equal(m, solve(mi))
    #> [1] TRUE
    I=diag(4) -S=I -diag(S)=c(1, 2, 3, 1) -rl=reglist(S, I) -rl2=c(rl, 'path/to/my/reg.list') -rl3=c(reglist('path/to/my/reg.list'), rl)
    +all.equal(m, solve(mi)) +
    #> [1] TRUE
    I=diag(4) +S=I +diag(S)=c(1, 2, 3, 1) +rl=reglist(S, I) +rl2=c(rl, 'path/to/my/reg.list') +rl3=c(reglist('path/to/my/reg.list'), rl) +
    - +
    -

    Site built with pkgdown.

    +

    Site built with pkgdown 1.6.1.

    + + + + + diff --git a/docs/reference/remotesync.html b/docs/reference/remotesync.html index 6f0f7918..7f23ba3a 100644 --- a/docs/reference/remotesync.html +++ b/docs/reference/remotesync.html @@ -1,6 +1,6 @@ - + @@ -8,25 +8,46 @@ Synchronise a remote object — remotesync • nat + - + - - + + + + + + + - + + + + + + + + - - - + + + + + + + + + + - + + + - +
    +
    -
    +
    - +

    Synchronise a remote object

    - +
    -
    remotesync(x, remote = attr(x, "remote"), download.missing = TRUE,
    -  delete.extra = FALSE, ...)
    +    
    remotesync(
    +  x,
    +  remote = attr(x, "remote"),
    +  download.missing = TRUE,
    +  delete.extra = FALSE,
    +  ...
    +)
     
     # S3 method for neuronlistfh
    -remotesync(x, remote = attr(x, "remote"),
    -  download.missing = FALSE, delete.extra = FALSE, indices = NULL,
    -  update.object = TRUE, ...)
    - -

    Arguments

    +remotesync( + x, + remote = attr(x, "remote"), + download.missing = FALSE, + delete.extra = FALSE, + indices = NULL, + update.object = TRUE, + ... +)
    + +

    Arguments

    @@ -130,7 +171,7 @@

    Ar

    - + @@ -145,55 +186,53 @@

    Ar object has not been renamed after it was downloaded.

    Whether to delete objects (default TRUE)

    ...

    Additional arguments passed to methods

    - +

    Value

    The updated neuronlistfh object (invisibly)

    -

    See also

    -

    Other neuronlistfh: [.neuronlistfh, - neuronlistfh, - read.neuronlistfh, - write.neuronlistfh

    - +

    Examples

    -
    # NOT RUN {
    -kcs20=read.neuronlistfh('http://flybrain.mrc-lmb.cam.ac.uk/si/nblast/flycircuit/kcs20.rds')
    +    
    if (FALSE) { +kcs20=read.neuronlistfh('http://flybrain.mrc-lmb.cam.ac.uk/si/nblast/flycircuit/kcs20.rds') # update object from the web -kcs20=remotesync(kcs20) +kcs20=remotesync(kcs20) # download all neurons with significant innervation of the vertical lobe -mbvl_neurons=subset(kcs20, (MB_VL_R+MB_VL_L)>200, rval='names') -kcs20=remotesync(kcs20, indices=mbvl_neurons, download.missing=TRUE) -# }
    +mbvl_neurons=subset(kcs20, (MB_VL_R+MB_VL_L)>200, rval='names') +kcs20=remotesync(kcs20, indices=mbvl_neurons, download.missing=TRUE) +} +
    - +
    -

    Site built with pkgdown.

    +

    Site built with pkgdown 1.6.1.

    + + + + + diff --git a/docs/reference/resample.html b/docs/reference/resample.html index 4dfe96ff..28a0fa05 100644 --- a/docs/reference/resample.html +++ b/docs/reference/resample.html @@ -1,6 +1,6 @@ - + @@ -8,25 +8,47 @@ Resample an object with a new spacing — resample • nat + - + - - + + + + + + + - + + + + + + + + - - - + + + + + + + + + + - + + + - +
    +
    -
    +
    - +

    Resample an object with a new spacing

    resample a neuron with a new spacing

    - +
    -
    resample(x, ...)
    +    
    resample(x, ...)
     
     # S3 method for neuron
    -resample(x, stepsize, ...)
    - -

    Arguments

    +resample(x, stepsize, ...)
    + +

    Arguments

    @@ -124,49 +155,51 @@

    Ar

    The new spacing along the tracing

    - +

    Details

    resample.neuron Floating point columns including X,Y,Z,W will be interpolated using linear interpolation, while integer or factor columns - will be interpolated using constant interpolation. See approx + will be interpolated using constant interpolation. See approx for details.

    -

    See also

    -

    approx, seglengths

    -

    Other neuron: neuron, ngraph, - plot.neuron, - potential_synapses, prune, - rootpoints, spine, - subset.neuron

    - +
    - +
    -

    Site built with pkgdown.

    +

    Site built with pkgdown 1.6.1.

    + + + + + diff --git a/docs/reference/rootpoints.html b/docs/reference/rootpoints.html index b87db6db..e57ff96c 100644 --- a/docs/reference/rootpoints.html +++ b/docs/reference/rootpoints.html @@ -1,6 +1,6 @@ - + @@ -8,25 +8,46 @@ Return the root or branch points of a neuron or graph — rootpoints • nat + - + - - + + + + + + + - + + + + + + + + - - - + + + + + + + + + + - + + + - +
    +
    -
    +
    - +

    A neuron may have multiple subtrees and therefore multiple roots

    -

    Return the branchpoints of a neuron or graph

    - +
    -
    rootpoints(x, ...)
    +    
    rootpoints(x, ...)
     
     # S3 method for default
    -rootpoints(x, ...)
    +rootpoints(x, ...)
     
     # S3 method for neuron
    -rootpoints(x, subtrees = 1, ...)
    +rootpoints(x, subtrees = 1, ...)
     
     # S3 method for igraph
    -rootpoints(x, ...)
    +rootpoints(x, ...)
     
    -branchpoints(x, ...)
    +branchpoints(x, ...)
     
     # S3 method for default
    -branchpoints(x, ...)
    +branchpoints(x, ...)
     
     # S3 method for neuron
    -branchpoints(x, subtrees = 1, ...)
    +branchpoints(x, subtrees = 1, ...)
     
     # S3 method for igraph
    -branchpoints(x, ...)
    +branchpoints(x, ...)
     
    -endpoints(x, ...)
    +endpoints(x, ...)
     
     # S3 method for neuron
    -endpoints(x, subtrees = 1, ...)
    +endpoints(x, subtrees = 1, ...)
     
     # S3 method for igraph
    -endpoints(x, ...)
    +endpoints(x, ...)
     
     # S3 method for default
    -endpoints(x, ...)
    - -

    Arguments

    +endpoints(x, ...)
    + +

    Arguments

    @@ -154,52 +183,51 @@

    Ar multiple unconnected subtrees.

    - +

    Value

    Integer point number of root/branch point

    -

    Details

    branchpoints.neuron returns a list if more than one subtree is specified

    -

    See also

    -

    Other neuron: neuron, ngraph, - plot.neuron, - potential_synapses, prune, - resample, spine, - subset.neuron

    - +

    Other neuron: +neuron(), +ngraph(), +plot.neuron(), +potential_synapses(), +prune(), +resample(), +spine(), +subset.neuron()

    - +
    -

    Site built with pkgdown.

    +

    Site built with pkgdown 1.6.1.

    + + + + + diff --git a/docs/reference/scale.neuron.html b/docs/reference/scale.neuron.html index a9d80863..e68a183d 100644 --- a/docs/reference/scale.neuron.html +++ b/docs/reference/scale.neuron.html @@ -1,6 +1,6 @@ - + @@ -8,25 +8,47 @@ Scale and centre neuron 3D coordinates — scale.neuron • nat + - + - - + + + + + + + - + + + + + + + + - - - + + + + + + + + + + - + + + - +
    +
    -
    +
    - -

    Scale and centre neuron 3D coordinates

    -

    note that scale.dotprops recalculates the tangent vectors - after scaling the 3D coords. See dotprops for details.

    - +
    +

    note that scale.dotprops recalculates the tangent vectors + after scaling the 3D coords. See dotprops for details.

    +
    # S3 method for neuron
    -scale(x, center = TRUE, scale = TRUE)
    +scale(x, center = TRUE, scale = TRUE)
     
     # S3 method for dotprops
    -scale(x, center = TRUE, scale = TRUE)
    - -

    Arguments

    +scale(x, center = TRUE, scale = TRUE) + +

    Arguments

    @@ -126,54 +156,48 @@

    Ar

    3-vector used to divide x,y,z coords

    - +

    Value

    neuron with scaled coordinates

    -

    Details

    If scale=TRUE, the neuron will be rescaled to unit sd in each axis. If center=TRUE, the neuron will be centred around the axis - means. See base::scale.default for additional details.

    - + means. See base::scale.default for additional details.

    See also

    -

    scale.default, *.neuron

    - +

    Examples

    -
    n1.scaledown=scale(Cell07PNs[[1]],scale=c(2,2,3)) -n1.scaleup=scale(Cell07PNs[[1]],scale=1/c(2,2,3))
    +
    n1.scaledown=scale(Cell07PNs[[1]],scale=c(2,2,3)) +n1.scaleup=scale(Cell07PNs[[1]],scale=1/c(2,2,3)) +
    - +
    -

    Site built with pkgdown.

    +

    Site built with pkgdown 1.6.1.

    + + + + + diff --git a/docs/reference/seglengths-1.png b/docs/reference/seglengths-1.png index 9a9e2a56..ed7d3567 100644 Binary files a/docs/reference/seglengths-1.png and b/docs/reference/seglengths-1.png differ diff --git a/docs/reference/seglengths-4.png b/docs/reference/seglengths-4.png deleted file mode 100644 index d4520af4..00000000 Binary files a/docs/reference/seglengths-4.png and /dev/null differ diff --git a/docs/reference/seglengths.html b/docs/reference/seglengths.html index a19b15c1..ff8c41fa 100644 --- a/docs/reference/seglengths.html +++ b/docs/reference/seglengths.html @@ -1,6 +1,6 @@ - + @@ -8,25 +8,46 @@ Calculate length of all segments in neuron — seglengths • nat + - + - - + + + + + + + - + + + + + + + + - - - + + + + + + + + + + - + + + - +
    +
    -
    +
    - +

    Calculate length of all segments in neuron

    - +
    + +
    seglengths(x, all = FALSE, flatten = TRUE, sumsegment = TRUE)
    -
    seglengths(x, all = FALSE, flatten = TRUE, sumsegment = TRUE)
    - -

    Arguments

    +

    Arguments

    @@ -128,57 +158,52 @@

    Ar individual edge in the segment.

    - +

    Value

    A vector of lengths for each segment or when sumsegment=FALSE a list of vectors

    -

    Details

    A segment is an ubranched portion of neurite consisting of at least one vertex joined by edges.Only segments in x$SegList will be calculated unless all=TRUE. Segments containing only one point will have 0 length.

    -

    See also

    -

    as.seglist.neuron

    - +

    Examples

    -
    summary(seglengths(Cell07PNs[[1]]))
    #> Min. 1st Qu. Median Mean 3rd Qu. Max. -#> 0.6273 2.1631 4.4999 9.0053 9.8379 84.1981
    hist(unlist(seglengths(Cell07PNs[[1]], sumsegment = FALSE)), - br=20, main='histogram of edge lengths', xlab='edge lengths /microns')
    +
    summary(seglengths(Cell07PNs[[1]])) +
    #> Min. 1st Qu. Median Mean 3rd Qu. Max. +#> 0.6273 2.1631 4.4999 9.0053 9.8379 84.1981
    hist(unlist(seglengths(Cell07PNs[[1]], sumsegment = FALSE)), + br=20, main='histogram of edge lengths', xlab='edge lengths /microns') +
    - +
    -

    Site built with pkgdown.

    +

    Site built with pkgdown 1.6.1.

    + + + + + diff --git a/docs/reference/seglist.html b/docs/reference/seglist.html index b2f5fca4..2a8063fe 100644 --- a/docs/reference/seglist.html +++ b/docs/reference/seglist.html @@ -1,6 +1,6 @@ - + @@ -8,25 +8,56 @@ Make/convert neuron connectivity information into a seglist object — seglist • nat + - + - - + + + + + + + - + + + + + + + + - - - + + + + + + + + + + - + + + - +
    +
    -
    +
    - +

    seglist makes a seglist object from a list of integer vectors of raw vertex ids. As a convenience if a vector of numeric ids are - passed these are assumed to specify a neuron with 1 segment. - - as.seglist.neuron will extract the seglist from a neuron, + passed these are assumed to specify a neuron with 1 segment.

    +

    as.seglist.neuron will extract the seglist from a neuron, optionally extracting all subtrees (all=TRUE) and (in this case) flattening the list into a single hierarchy when flatten=TRUE. n.b. when all=TRUE but flatten=FALSE the result will always be a list of seglist objects (even if the neuron has - only one subtree i.e. is fully connected). - - as.seglist.igraph will convert a fully connected acyclic + only one subtree i.e. is fully connected).

    +

    as.seglist.igraph will convert a fully connected acyclic ngraph or igraph object into a seglist consisting of exactly one subtree.

    - +
    -
    seglist(...)
    +    
    seglist(...)
     
    -as.seglist(x, ...)
    +as.seglist(x, ...)
     
     # S3 method for neuron
    -as.seglist(x, all = FALSE, flatten = FALSE, ...)
    +as.seglist(x, all = FALSE, flatten = FALSE, ...)
     
     # S3 method for igraph
    -as.seglist(x, origin = NULL, Verbose = FALSE, ...)
    - -

    Arguments

    +as.seglist(x, origin = NULL, Verbose = FALSE, ...)
    + +

    Arguments

    @@ -153,12 +191,11 @@

    Ar

    Whether to print progress updates to console (default FALSE)

    - +

    Value

    A list with additional class seglist.

    a list with one entry for each unbranched segment.

    -

    Details

    see neuron for further information about seglists.

    @@ -168,44 +205,39 @@

    Details id of the current graph. The returned seglist will also contain these original vertex ids.

    The head of the first segment in the seglist will be the origin.

    -

    See also

    -

    neuron - ngraph,igraph

    - +

    Examples

    -
    sl=seglist(c(1:2),c(2:6))
    +
    sl=seglist(c(1:2),c(2:6)) +
    - +
    -

    Site built with pkgdown.

    +

    Site built with pkgdown 1.6.1.

    + + + + + diff --git a/docs/reference/seglist2swc.html b/docs/reference/seglist2swc.html index 8cdac615..273a4a42 100644 --- a/docs/reference/seglist2swc.html +++ b/docs/reference/seglist2swc.html @@ -1,6 +1,6 @@ - + @@ -8,25 +8,47 @@ Recalculate Neurons's SWCData using SegList and point information — seglist2swc • nat + - + - - + + + + + + + - + + + + + + + + - - - + + + + + + + + + + - + + + - +
    +
    -
    +
    - +

    Uses the SegList field (indices into point array) to recalculate point numbers and parent points for SWC data field (d).

    - +
    + +
    seglist2swc(x, d, RecalculateParents = TRUE, ...)
    -
    seglist2swc(x, d, RecalculateParents = TRUE, ...)
    - -

    Arguments

    +

    Arguments

    @@ -125,11 +156,10 @@

    Ar

    Additional arguments passed to normalise_swc

    - +

    Value

    A neuron if x was a neuron otherwise dataframe of swc data

    -

    Details

    If any columns are missing then they are set to default values by @@ -138,41 +168,38 @@

    Details
  • Label = 0 (unknown)

  • W NA_real

  • -

    Note that each numeric entry in the incoming SegList is a raw index into + +

    Note that each numeric entry in the incoming SegList is a raw index into the block of vertex data defined by d.

    -

    See also

    -

    as.neuron.data.frame, normalise_swc, neuron

    - +
    - +
    -

    Site built with pkgdown.

    +

    Site built with pkgdown 1.6.1.

    + + + + + diff --git a/docs/reference/segmentgraph-1.png b/docs/reference/segmentgraph-1.png index f4f27e4f..b9edd822 100644 Binary files a/docs/reference/segmentgraph-1.png and b/docs/reference/segmentgraph-1.png differ diff --git a/docs/reference/segmentgraph-4.png b/docs/reference/segmentgraph-4.png deleted file mode 100644 index 0922b0cd..00000000 Binary files a/docs/reference/segmentgraph-4.png and /dev/null differ diff --git a/docs/reference/segmentgraph.html b/docs/reference/segmentgraph.html index bcd1404b..6744cab6 100644 --- a/docs/reference/segmentgraph.html +++ b/docs/reference/segmentgraph.html @@ -1,6 +1,6 @@ - + @@ -8,25 +8,46 @@ Return a simplified segment graph for a neuron — segmentgraph • nat + - + - - + + + + + + + - + + + + + + + + - - - + + + + + + + + + + - + + + - +
    +
    -
    +
    - +

    Return a simplified segment graph for a neuron

    - +
    -
    segmentgraph(x, weights = TRUE, segids = FALSE, exclude.isolated = FALSE,
    -  include.xyz = FALSE, reverse.edges = FALSE)
    - -

    Arguments

    +
    segmentgraph(
    +  x,
    +  weights = TRUE,
    +  segids = FALSE,
    +  exclude.isolated = FALSE,
    +  include.xyz = FALSE,
    +  reverse.edges = FALSE
    +)
    + +

    Arguments

    @@ -137,13 +173,12 @@

    Ar FALSE)

    - +

    Value

    igraph object containing only nodes of neuron keeping original labels (x$d$PointNo => V(g)$label) and vertex indices (1:nrow(x$d) => V(g)$vid).

    -

    Details

    The resultant graph will contain all branch and endpoints of the @@ -151,80 +186,79 @@

    Details present, the SubTrees field (containing multiple SegLists for each isolated graph in the neuron). Each edge in the output graph will match one segment in the original SegList.

    -

    Examples

    -
    sg=segmentgraph(Cell07PNs[[1]]) -str(sg)
    #> List of 10 +
    sg=segmentgraph(Cell07PNs[[1]]) +str(sg) +
    #> List of 10 #> $ :List of 1 -#> ..$ :Class 'igraph.vs' atomic [1:1] 2 -#> .. .. ..- attr(*, "env")=<weakref> -#> .. .. ..- attr(*, "graph")= chr "2f00f7c0-2a1f-4057-a025-4c8ebf445a8f" +#> ..$ : 'igraph.vs' int 2 +#> .. ..- attr(*, "env")=<weakref> +#> .. ..- attr(*, "graph")= chr "47e05c76-14fb-45fb-ac57-f7536c87d519" #> $ :List of 1 -#> ..$ :Class 'igraph.vs' atomic [1:2] 3 4 -#> .. .. ..- attr(*, "env")=<weakref> -#> .. .. ..- attr(*, "graph")= chr "2f00f7c0-2a1f-4057-a025-4c8ebf445a8f" +#> ..$ : 'igraph.vs' int [1:2] 3 4 +#> .. ..- attr(*, "env")=<weakref> +#> .. ..- attr(*, "graph")= chr "47e05c76-14fb-45fb-ac57-f7536c87d519" #> $ :List of 1 -#> ..$ :Class 'igraph.vs' atomic (0) -#> .. .. ..- attr(*, "env")=<weakref> -#> .. .. ..- attr(*, "graph")= chr "2f00f7c0-2a1f-4057-a025-4c8ebf445a8f" +#> ..$ : 'igraph.vs' int(0) +#> .. ..- attr(*, "env")=<weakref> +#> .. ..- attr(*, "graph")= chr "47e05c76-14fb-45fb-ac57-f7536c87d519" #> $ :List of 1 -#> ..$ :Class 'igraph.vs' atomic [1:2] 5 8 -#> .. .. ..- attr(*, "env")=<weakref> -#> .. .. ..- attr(*, "graph")= chr "2f00f7c0-2a1f-4057-a025-4c8ebf445a8f" +#> ..$ : 'igraph.vs' int [1:2] 5 8 +#> .. ..- attr(*, "env")=<weakref> +#> .. ..- attr(*, "graph")= chr "47e05c76-14fb-45fb-ac57-f7536c87d519" #> $ :List of 1 -#> ..$ :Class 'igraph.vs' atomic [1:2] 6 7 -#> .. .. ..- attr(*, "env")=<weakref> -#> .. .. ..- attr(*, "graph")= chr "2f00f7c0-2a1f-4057-a025-4c8ebf445a8f" +#> ..$ : 'igraph.vs' int [1:2] 6 7 +#> .. ..- attr(*, "env")=<weakref> +#> .. ..- attr(*, "graph")= chr "47e05c76-14fb-45fb-ac57-f7536c87d519" #> $ :List of 1 -#> ..$ :Class 'igraph.vs' atomic (0) -#> .. .. ..- attr(*, "env")=<weakref> -#> .. .. ..- attr(*, "graph")= chr "2f00f7c0-2a1f-4057-a025-4c8ebf445a8f" +#> ..$ : 'igraph.vs' int(0) +#> .. ..- attr(*, "env")=<weakref> +#> .. ..- attr(*, "graph")= chr "47e05c76-14fb-45fb-ac57-f7536c87d519" #> $ :List of 1 -#> ..$ :Class 'igraph.vs' atomic (0) -#> .. .. ..- attr(*, "env")=<weakref> -#> .. .. ..- attr(*, "graph")= chr "2f00f7c0-2a1f-4057-a025-4c8ebf445a8f" +#> ..$ : 'igraph.vs' int(0) +#> .. ..- attr(*, "env")=<weakref> +#> .. ..- attr(*, "graph")= chr "47e05c76-14fb-45fb-ac57-f7536c87d519" #> $ :List of 1 -#> ..$ :Class 'igraph.vs' atomic [1:2] 9 12 -#> .. .. ..- attr(*, "env")=<weakref> -#> .. .. ..- attr(*, "graph")= chr "2f00f7c0-2a1f-4057-a025-4c8ebf445a8f" +#> ..$ : 'igraph.vs' int [1:2] 9 12 +#> .. ..- attr(*, "env")=<weakref> +#> .. ..- attr(*, "graph")= chr "47e05c76-14fb-45fb-ac57-f7536c87d519" #> $ :List of 1 -#> ..$ :Class 'igraph.vs' atomic [1:2] 10 11 -#> .. .. ..- attr(*, "env")=<weakref> -#> .. .. ..- attr(*, "graph")= chr "2f00f7c0-2a1f-4057-a025-4c8ebf445a8f" +#> ..$ : 'igraph.vs' int [1:2] 10 11 +#> .. ..- attr(*, "env")=<weakref> +#> .. ..- attr(*, "graph")= chr "47e05c76-14fb-45fb-ac57-f7536c87d519" #> $ :List of 1 -#> ..$ :Class 'igraph.vs' atomic (0) -#> .. .. ..- attr(*, "env")=<weakref> -#> .. .. ..- attr(*, "graph")= chr "2f00f7c0-2a1f-4057-a025-4c8ebf445a8f" -#> - attr(*, "class")= chr "igraph"
    library(igraph) -plot(sg, edge.arrow.size=.4, vertex.size=10)
    +#> ..$ : 'igraph.vs' int(0) +#> .. ..- attr(*, "env")=<weakref> +#> .. ..- attr(*, "graph")= chr "47e05c76-14fb-45fb-ac57-f7536c87d519" +#> - attr(*, "class")= chr "igraph"
    library(igraph) +plot(sg, edge.arrow.size=.4, vertex.size=10) +
    - +
    -

    Site built with pkgdown.

    +

    Site built with pkgdown 1.6.1.

    + + + + + diff --git a/docs/reference/setdiff.html b/docs/reference/setdiff.html index e11b504b..73392133 100644 --- a/docs/reference/setdiff.html +++ b/docs/reference/setdiff.html @@ -1,6 +1,6 @@ - + @@ -8,25 +8,46 @@ Find the (asymmetric) difference between two collections of objects — setdiff • nat + - + - - + + + + + + + - + + + + + + + + - - - + + + + + + + + + + - + + + - +
    +
    -
    +
    - +

    Find the (asymmetric) difference between two collections of objects

    - +
    -
    setdiff(x, y, ...)
    +    
    setdiff(x, y, ...)
     
     # S3 method for default
    -setdiff(x, y, ...)
    +setdiff(x, y, ...)
     
     # S3 method for neuronlist
    -setdiff(x, y, ...)
    - -

    Arguments

    +setdiff(x, y, ...)
    + +

    Arguments

    @@ -126,51 +156,46 @@

    Ar

    additional arguments passed to methods

    - +

    Value

    A collection of the same mode as x that contains all elements of x that are not present in y.

    -

    Details

    Note that setdiff.default calls base::setdiff to ensure consistent behaviour for regular vectors.

    As a convenience setdiff.neuronlist allows y, the second collection, to be a character vector of names.

    -

    See also

    -

    setdiff

    - +
    - +
    -

    Site built with pkgdown.

    +

    Site built with pkgdown 1.6.1.

    + + + + + diff --git a/docs/reference/simplify_reglist.html b/docs/reference/simplify_reglist.html index 32c715af..c051b09c 100644 --- a/docs/reference/simplify_reglist.html +++ b/docs/reference/simplify_reglist.html @@ -1,6 +1,6 @@ - + @@ -8,25 +8,46 @@ Simplify a registration list — simplify_reglist • nat + - + - - + + + + + + + - + + + + + + + + - - - + + + + + + + + + + - + + + - +
    +
    -
    +
    - +

    Simplify a registration list

    - +
    -
    simplify_reglist(reg, as.cmtk = NULL)
    - -

    Arguments

    +
    simplify_reglist(reg, as.cmtk = NULL)
    + +

    Arguments

    @@ -121,7 +151,7 @@

    Ar See details.

    - +

    Details

    This function

      @@ -130,41 +160,40 @@

      Details
    • optionally converts all registrations to CMTK on disk registrations when possible.

    -

    Note that if any of the registrations are in CMTK format, the default + +

    Note that if any of the registrations are in CMTK format, the default behaviour is to try to convert all of the other registrations into CMTK format to enable them to be passed to CMTK in a single command. If as.cmtk=TRUE then there will be an error if this is not possible.

    -

    See also

    -

    reglist, xform, cmtkreg

    - +
    - +
    -

    Site built with pkgdown.

    +

    Site built with pkgdown 1.6.1.

    + + + + + diff --git a/docs/reference/smooth_neuron-1.png b/docs/reference/smooth_neuron-1.png index 0f4c1632..0362b46f 100644 Binary files a/docs/reference/smooth_neuron-1.png and b/docs/reference/smooth_neuron-1.png differ diff --git a/docs/reference/smooth_neuron-3.png b/docs/reference/smooth_neuron-3.png deleted file mode 100644 index d8c92408..00000000 Binary files a/docs/reference/smooth_neuron-3.png and /dev/null differ diff --git a/docs/reference/smooth_neuron.html b/docs/reference/smooth_neuron.html index fcb8d6e6..9c5e8834 100644 --- a/docs/reference/smooth_neuron.html +++ b/docs/reference/smooth_neuron.html @@ -1,6 +1,6 @@ - + @@ -8,25 +8,46 @@ Smooth the 3D coordinates of a neuron skeleton — smooth_neuron • nat + - + - - + + + + + + + - + + + + + + + + - - - + + + + + + + + + + - + + + - +
    +
    -
    +
    - +

    smooth_neuron smooths a neuron.

    - +
    -
    smooth_neuron(n, method = c("gauss", "spline"), ...)
    +    
    smooth_neuron(n, method = c("gauss", "spline"), ...)
     
    -smooth_segment_gauss(xyz, sigma, ...)
    - -

    Arguments

    +smooth_segment_gauss(xyz, sigma, ...)
    + +

    Arguments

    @@ -131,43 +161,47 @@

    Ar has the same spatial units as the object being smoothed)

    - +

    Value

    A new neuron with smoothed 3d coordinates

    -

    Examples

    -
    ns=smooth_neuron(Cell07PNs[[1]], sigma=2) +
    ns=smooth_neuron(Cell07PNs[[1]], sigma=2) # plot in 2D zooming in on axon terminals -plot(Cell07PNs[[1]], col='grey', xlim=c(260,290), ylim=c(115,90))
    plot(ns, col='red', add=TRUE)
    # 3D plot -plot3d(Cell07PNs[[1]], col='grey') -plot3d(ns, col='red')
    +plot(Cell07PNs[[1]], col='grey', xlim=c(260,290), ylim=c(115,90)) +
    plot(ns, col='red', add=TRUE) +
    # \donttest{ +# 3D plot +plot3d(Cell07PNs[[1]], col='grey') +plot3d(ns, col='red') +# } +
    - +
    -

    Site built with pkgdown.

    +

    Site built with pkgdown 1.6.1.

    + + + + + diff --git a/docs/reference/spine.html b/docs/reference/spine.html index 3ccc972f..1e67795a 100644 --- a/docs/reference/spine.html +++ b/docs/reference/spine.html @@ -1,6 +1,6 @@ - + @@ -8,25 +8,46 @@ Compute the longest path (aka spine or backbone) of a neuron — spine • nat + - + - - + + + + + + + - + + + + + + + + - - - + + + + + + + + + + - + + + - +
    +
    -
    +
    - +

    Compute the longest path (aka spine or backbone) of a neuron

    - +
    + +
    spine(
    +  n,
    +  UseStartPoint = FALSE,
    +  SpatialWeights = TRUE,
    +  invert = FALSE,
    +  rval = c("neuron", "length", "ids")
    +)
    -
    spine(n, UseStartPoint = FALSE, SpatialWeights = TRUE, invert = FALSE,
    -  rval = c("neuron", "length", "ids"))
    - -

    Arguments

    +

    Arguments

    @@ -134,7 +169,7 @@

    Ar 'neuron', 'length' or 'ids'. See Value section.

    - +

    Value

    Either

      @@ -143,56 +178,66 @@

      Value

    • an integer vector of raw point indices (when rval="ids").

    -

    See also

    -

    diameter, - shortest.paths, prune_strahler for +

    diameter, + shortest.paths, prune_strahler for removing lower order branches from a neuron, prune for removing parts of a neuron by spatial criteria.

    -

    Other neuron: neuron, ngraph, - plot.neuron, - potential_synapses, prune, - resample, rootpoints, - subset.neuron

    - +

    Other neuron: +neuron(), +ngraph(), +plot.neuron(), +potential_synapses(), +prune(), +resample(), +rootpoints(), +subset.neuron()

    Examples

    -
    pn.spine=spine(Cell07PNs[[1]])
    plot3d(Cell07PNs[[1]]) -plot3d(pn.spine, lwd=4, col='black')
    # just extract length -spine(Cell07PNs[[1]], rval='length')
    #> [1] 186.0859
    # same result since StartPoint is included in longest path -spine(Cell07PNs[[1]], rval='length', UseStartPoint=TRUE)
    #> [1] 186.0859
    +
    pn.spine=spine(Cell07PNs[[1]]) +# \donttest{ +plot3d(Cell07PNs[[1]]) +plot3d(pn.spine, lwd=4, col='black') +# } +# just extract length +spine(Cell07PNs[[1]], rval='length') +
    #> [1] 186.0859
    # same result since StartPoint is included in longest path +spine(Cell07PNs[[1]], rval='length', UseStartPoint=TRUE) +
    #> [1] 186.0859
    # extract everything but the spine -antispine=spine(Cell07PNs[[1]], invert=TRUE)
    plot3d(Cell07PNs[[1]]) -plot3d(antispine, lwd=4, col='red')
    +antispine=spine(Cell07PNs[[1]], invert=TRUE) +# \donttest{ +plot3d(Cell07PNs[[1]]) +plot3d(antispine, lwd=4, col='red') +# } +
    - +
    -

    Site built with pkgdown.

    +

    Site built with pkgdown 1.6.1.

    + + + + + diff --git a/docs/reference/strahler_order.html b/docs/reference/strahler_order.html index 6b34369e..6b5f9244 100644 --- a/docs/reference/strahler_order.html +++ b/docs/reference/strahler_order.html @@ -1,6 +1,6 @@ - + @@ -8,25 +8,49 @@ Find the Strahler order of each point in a neuron — strahler_order • nat + - + - - + + + + + + + - + + + + + + + + - - - + + + + + + + + + + - + + + - +
    +
    -
    +
    - +

    The Strahler order will be 1 for each tip segment and then 1 + the maximum of the Strahler order of each parent segment for internal segments. Branch points will have the Strahler order of the closest segment to the root of which they are part.

    - +
    + +
    strahler_order(x)
    -
    strahler_order(x)
    - -

    Arguments

    +

    Arguments

    @@ -115,7 +148,7 @@

    Ar

    A neuron

    - +

    Value

    A list containing

      @@ -124,7 +157,6 @@

      Value

      neuron

    -

    Details

    It is vital that the root of the neuron is valid since this @@ -132,47 +164,40 @@

    Details present the function is not defined for neurons with multiple subtrees.

    Internally, this function uses segmentgraph to find a reduced segmentgraph for the neuron.

    -

    References

    https://en.wikipedia.org/wiki/Strahler_number

    -

    See also

    -

    prune_strahler, a segmentgraph (a form +

    prune_strahler, a segmentgraph (a form of ngraph) representation is used to calculate the Strahler - order.

    - + order.

    - +
    -

    Site built with pkgdown.

    +

    Site built with pkgdown 1.6.1.

    + + + + + diff --git a/docs/reference/sub-.neuronlistfh.html b/docs/reference/sub-.neuronlistfh.html index 7765a51c..9b65a3e1 100644 --- a/docs/reference/sub-.neuronlistfh.html +++ b/docs/reference/sub-.neuronlistfh.html @@ -1,6 +1,6 @@ - + @@ -8,25 +8,48 @@ Extract from neuronlistfh object or its attached data.frame — [.neuronlistfh • nat + - + - - + + + + + + + - + + + + + + + + - - - + + + + + + + + + + - + + + - +
    +
    -
    +
    - +

    [.neuronlistfh extracts either a sublist from a neuronlistfh (converting it to a regular in memory list in the process) or its attached data.frame.

    - +
    # S3 method for neuronlistfh
     [(x, i, j, drop)
    - -

    Arguments

    + +

    Arguments

    @@ -118,7 +150,7 @@

    Ar

    +[.data.frame.

    @@ -127,37 +159,37 @@

    Ar column is left, but not to drop if only one row is left.

    i, j

    elements to extract or replace. Numeric, logical or character or, for the [ get method, empty. See details and the help for -[.data.frame.

    drop
    - +

    Value

    A new in-memory neuronlist or when using two subscripts, a data.frame - see examples.

    -

    Details

    Note that if i is a numeric or logical indexing vector, it will be converted internally to a vector of names by using the (sorted) names of the objects in x (i.e. names(x)[i])

    -

    See also

    -

    neuronlistfh, [.neuronlist, - [.data.frame, [<-.data.frame,

    -

    Other neuronlistfh: neuronlistfh, - read.neuronlistfh, - remotesync, - write.neuronlistfh

    - +

    neuronlistfh, [.neuronlist, + [.data.frame, [<-.data.frame,

    +

    Other neuronlistfh: +neuronlistfh(), +read.neuronlistfh(), +remotesync(), +write.neuronlistfh()

    Examples

    # make a test neuronlistfh backed by a temporary folder on disk -tf=tempfile('kcs20fh') -kcs20fh<-as.neuronlistfh(kcs20, dbdir=tf) +tf=tempfile('kcs20fh') +kcs20fh<-as.neuronlistfh(kcs20, dbdir=tf) # get first neurons as an in memory neuronlist -class(kcs20fh[1:3])
    #> [1] "neuronlist" "list"
    +class(kcs20fh[1:3]) +
    #> [1] "neuronlist" "list"
    # extract attached data.frame -str(kcs20fh[,])
    #> 'data.frame': 20 obs. of 14 variables: +str(kcs20fh[,]) +
    #> 'data.frame': 20 obs. of 14 variables: #> $ gene_name: chr "FruMARCM-M001205_seg002" "GadMARCM-F000122_seg001" "GadMARCM-F000050_seg001" "GadMARCM-F000142_seg002" ... #> $ Name : chr "fru-M-500112" "Gad1-F-900005" "Gad1-F-100010" "Gad1-F-300043" ... #> $ idid : num 1024 10616 8399 10647 9758 ... @@ -172,44 +204,43 @@

    Examp #> $ cluster : int 9 70 57 71 64 44 16 61 52 12 ... #> $ idx : int 156 1519 1132 1535 1331 795 268 1265 898 190 ... #> $ type : Factor w/ 3 levels "ab","apbp","gamma": 3 3 1 2 1 1 1 2 2 1 ...

    # or part of the data.frame -str(kcs20fh[1:2,1:3])
    #> 'data.frame': 2 obs. of 3 variables: +str(kcs20fh[1:2,1:3]) +
    #> 'data.frame': 2 obs. of 3 variables: #> $ gene_name: chr "FruMARCM-M001205_seg002" "GadMARCM-F000122_seg001" #> $ Name : chr "fru-M-500112" "Gad1-F-900005" #> $ idid : num 1024 10616
    # data.frame assignment (this one changes nothing) -kcs20fh[1:2,'gene_name'] <- kcs20fh[1:2,'gene_name'] +kcs20fh[1:2,'gene_name'] <- kcs20fh[1:2,'gene_name'] # clean up -unlink(tf, recursive=TRUE)
    -
    - +
    +
    +
    -

    Site built with pkgdown.

    +

    Site built with pkgdown 1.6.1.

    + + + + + diff --git a/docs/reference/sub2ind.html b/docs/reference/sub2ind.html index 98f77273..f329dcc2 100644 --- a/docs/reference/sub2ind.html +++ b/docs/reference/sub2ind.html @@ -1,6 +1,6 @@ - + @@ -8,25 +8,46 @@ Find 1D index given n-dimensional indices — sub2ind • nat + - + - - + + + + + + + - + + + + + + + + - - - + + + + + + + + + + - + + + - +
    +
    -
    +
    - +

    Emulates the MATLAB function sub2ind.

    - +
    + +
    sub2ind(dims, indices)
    -
    sub2ind(dims, indices)
    - -

    Arguments

    +

    Arguments

    @@ -116,29 +146,33 @@

    Ar

    vector of n-dimensional indices.

    - -
    - +
    +
    -

    Site built with pkgdown.

    +

    Site built with pkgdown 1.6.1.

    + + + + + diff --git a/docs/reference/subset.dotprops.html b/docs/reference/subset.dotprops.html index f22bd833..1c7c51df 100644 --- a/docs/reference/subset.dotprops.html +++ b/docs/reference/subset.dotprops.html @@ -1,6 +1,6 @@ - + @@ -8,25 +8,46 @@ Subset points in dotprops object that match given conditions — subset.dotprops • nat + - + - - + + + + + + + - + + + + + + + + - - - + + + + + + + + + + - + + + - +
    +
    -
    +
    - +

    Subset points in dotprops object that match given conditions

    - +
    # S3 method for dotprops
    -subset(x, subset, invert = FALSE, ...)
    - -

    Arguments

    +subset(x, subset, invert = FALSE, ...) + +

    Arguments

    @@ -126,11 +156,10 @@

    Ar

    Additional parameters (currently ignored)

    - +

    Value

    subsetted dotprops object

    -

    Details

    subset defines either logical or numeric indices, in which @@ -138,78 +167,78 @@

    Details etc OR a function (which is called with the 3D points array and returns T/F. OR an expression vector).

    -

    See also

    -

    prune.dotprops, subset.neuron

    - +

    prune.dotprops, subset.neuron

    Examples

    ## subset using indices ... -dp=kcs20[[10]] -dp1=subset(dp, 1:50) +dp=kcs20[[10]] +dp1=subset(dp, 1:50) # ... or an expression -dp2=subset(dp, alpha>0.7) -front=subset(dp, points[,'Z']<40) +dp2=subset(dp, alpha>0.7) +front=subset(dp, points[,'Z']<40) # use a helper function -between=function(x, lower, upper) x>=lower & x<=upper -middle=middle=subset(dp, between(points[,'Z'], 40, 60)) +between=function(x, lower, upper) x>=lower & x<=upper +middle=middle=subset(dp, between(points[,'Z'], 40, 60)) + +# plot results in 3D +# \donttest{ +plot3d(front, col='red') +plot3d(middle, col='green') +plot3d(dp, col='blue') +# } + +if (FALSE) { -# plot results in 3D
    plot3d(front, col='red') -plot3d(middle, col='green') -plot3d(dp, col='blue')
    -
    # NOT RUN { ## subset using an selection function -s3d=select3d() -dp1=subset(dp, s3d(points)) +s3d=select3d() +dp1=subset(dp, s3d(points)) # special case of previous version -dp2=subset(dp, s3d) +dp2=subset(dp, s3d) # keep the points that were removed from dp2 -dp2.not=subset(dp, s3d, invert=TRUE) +dp2.not=subset(dp, s3d, invert=TRUE) # (another way of doing the same thing) -dp2.not=subset(dp, Negate(s3d)) -stopifnot(all.equal(dp1, dp2)) -dp2=subset(dp, alpha>0.5 & s3d(pointd)) -dp3=subset(dp, 1:10) +dp2.not=subset(dp, Negate(s3d)) +stopifnot(all.equal(dp1, dp2)) +dp2=subset(dp, alpha>0.5 & s3d(pointd)) +dp3=subset(dp, 1:10) ## subset each dotprops object in a whole neuronlist -plot3d(kcs20) -s3d=select3d() -kcs20.partial = nlapply(kcs20, subset, s3d) -clear3d() -plot3d(kcs20.partial, col='red') -plot3d(kcs20, col='grey') -# }
    +plot3d(kcs20) +s3d=select3d() +kcs20.partial = nlapply(kcs20, subset, s3d) +clear3d() +plot3d(kcs20.partial, col='red') +plot3d(kcs20, col='grey') +} +
    - +
    -

    Site built with pkgdown.

    +

    Site built with pkgdown 1.6.1.

    + + + + + diff --git a/docs/reference/subset.html b/docs/reference/subset.html index 1488ef41..fc5336a0 100644 --- a/docs/reference/subset.html +++ b/docs/reference/subset.html @@ -1,6 +1,6 @@ - + @@ -8,25 +8,48 @@ Subset methods for different nat objects — subset • nat + - + - - + + + + + + + - + + + + + + + + - - - + + + + + + + + + + - + + + - +
    +
    -
    +
    - +

    These methods enable subsets of some nat objects including neurons and neuronlists to be obtained. See the help for each individual method for details.

    - +
    + + -

    See also

    -

    subset.neuron, subset.dotprops, - subset.hxsurf, subset.neuronlist

    - +
    - +
    -

    Site built with pkgdown.

    +

    Site built with pkgdown 1.6.1.

    + + + + + diff --git a/docs/reference/subset.hxsurf.html b/docs/reference/subset.hxsurf.html index 4eb26f48..1d78a39d 100644 --- a/docs/reference/subset.hxsurf.html +++ b/docs/reference/subset.hxsurf.html @@ -1,6 +1,6 @@ - + @@ -8,25 +8,46 @@ Subset hxsurf object to specified regions — subset.hxsurf • nat + - + - - + + + + + + + - + + + + + + + + - - - + + + + + + + + + + - + + + - +
    +
    -
    +
    - +

    Subset hxsurf object to specified regions

    - +
    # S3 method for hxsurf
    -subset(x, subset = NULL, drop = TRUE, rval = c("hxsurf",
    -  "names"), ...)
    - -

    Arguments

    +subset(x, subset = NULL, drop = TRUE, rval = c("hxsurf", "names"), ...) + +

    Arguments

    @@ -116,7 +145,7 @@

    Ar

    +regex if of length 1 and no fixed match.

    @@ -133,54 +162,57 @@

    Ar

    subset

    Character vector specifying regions to keep. Interpreted as -regex if of length 1 and no fixed match.

    drop

    Additional parameters (currently ignored)

    - +

    Value

    subsetted hxsurf object

    -

    See also

    -

    Other hxsurf: as.hxsurf, - as.mesh3d, materials, - plot3d.hxsurf, read.hxsurf, - write.hxsurf

    - +

    Other hxsurf: +as.hxsurf(), +as.mesh3d(), +materials(), +plot3d.hxsurf(), +read.hxsurf(), +write.hxsurf()

    Examples

    # plot only vertical lobe -vertical_lobe=subset(MBL.surf, "VL")
    plot3d(vertical_lobe, alpha=0.3) -plot3d(kcs20) +vertical_lobe=subset(MBL.surf, "VL") +# \donttest{ +plot3d(vertical_lobe, alpha=0.3) +plot3d(kcs20) # there is also a shortcut for this -clear3d() -plot3d(MBL.surf, "VL", alpha=0.3)
    +clear3d() +plot3d(MBL.surf, "VL", alpha=0.3) +# } +
    - +
    -

    Site built with pkgdown.

    +

    Site built with pkgdown 1.6.1.

    + + + + + diff --git a/docs/reference/subset.neuron-1.png b/docs/reference/subset.neuron-1.png index 2ec583c8..6674e9e7 100644 Binary files a/docs/reference/subset.neuron-1.png and b/docs/reference/subset.neuron-1.png differ diff --git a/docs/reference/subset.neuron-5.png b/docs/reference/subset.neuron-5.png deleted file mode 100644 index 83a52423..00000000 Binary files a/docs/reference/subset.neuron-5.png and /dev/null differ diff --git a/docs/reference/subset.neuron.html b/docs/reference/subset.neuron.html index d5b9ca30..847c086d 100644 --- a/docs/reference/subset.neuron.html +++ b/docs/reference/subset.neuron.html @@ -1,6 +1,6 @@ - + @@ -8,25 +8,46 @@ Subset neuron by keeping only vertices that match given conditions — subset.neuron • nat + - + - - + + + + + + + - + + + + + + + + - - - + + + + + + + + + + - + + + - +
    +
    -
    +
    - +

    Subset neuron by keeping only vertices that match given conditions

    - +
    # S3 method for neuron
    -subset(x, subset, invert = FALSE, ...)
    - -

    Arguments

    +subset(x, subset, invert = FALSE, ...) + +

    Arguments

    @@ -127,11 +157,10 @@

    Ar

    Additional parameters (passsed on to prune_vertices)

    - +

    Value

    subsetted neuron

    -

    Details

    subset defines which vertices of the neuron to keep and is @@ -146,109 +175,113 @@

    Details neuron. This can therefore refer e.g. to the X,Y,Z location of vertices in the neuron.

    - +

    See also

    -

    prune.neuron, prune_vertices, +

    Examples

    -
    n=Cell07PNs[[1]] +
    n=Cell07PNs[[1]] # keep vertices if their X location is > 2000 -n1=subset(n, X>200) +n1=subset(n, X>200) # diameter of neurite >1 -n2=subset(n, W>1) +n2=subset(n, W>1) # first 50 nodes -n3=subset(n, 1:50) +n3=subset(n, 1:50) # everything but first 50 nodes -n4=subset(n, 1:50, invert=TRUE) +n4=subset(n, 1:50, invert=TRUE) ## subset neuron by graph structure # first plot neuron and show the point that we will use to divide the neuron -n=Cell07PNs[[1]] -plot(n)
    # this neuron has a tag defining a point at which the neuron enters a brain +n=Cell07PNs[[1]] +plot(n) +
    # this neuron has a tag defining a point at which the neuron enters a brain # region (AxonLHEP = Axon Lateral Horn Entry Point) -points(t(xyzmatrix(n)[n$AxonLHEP, 1:2]), pch=19, cex=2.5)
    +points(t(xyzmatrix(n)[n$AxonLHEP, 1:2]), pch=19, cex=2.5) +
    # now find the points downstream (distal) of that with respect to the root -ng=as.ngraph(n) +ng=as.ngraph(n) # use a depth first search -distal_points=igraph::graph.dfs(ng, root=n$AxonLHEP, unreachable=FALSE, - neimode='out')$order -distal_tree=subset(n, distal_points) -plot(distal_tree, add=TRUE, col='red', lwd=2)
    +distal_points=igraph::graph.dfs(ng, root=n$AxonLHEP, unreachable=FALSE, + neimode='out')$order +distal_tree=subset(n, distal_points) +plot(distal_tree, add=TRUE, col='red', lwd=2) +
    # Find proximal tree as well # nb this does not include the AxonLHEP itself as defined here -proximal_points=setdiff(igraph::V(ng), distal_points) -proximal_tree=subset(n, proximal_points) -plot(proximal_tree, add=TRUE, col='blue', lwd=2)
    -
    # NOT RUN { +proximal_points=setdiff(igraph::V(ng), distal_points) +proximal_tree=subset(n, proximal_points) +plot(proximal_tree, add=TRUE, col='blue', lwd=2) +
    +if (FALSE) { ## subset using interactively defined spatial regions -plot3d(n) +plot3d(n) # nb you can save this select3d object using save or saveRDS functions # for future non-interactive use -s3d=select3d() -n4=subset(n, s3d(xyzmatrix(n))) +s3d=select3d() +n4=subset(n, s3d(xyzmatrix(n))) # special case of previous version -n5=subset(n, s3d) -stopifnot(all.equal(n4,n5)) +n5=subset(n, s3d) +stopifnot(all.equal(n4,n5)) # keep the points that were removed from n1 -n4.not=subset(n,Negate(s3d)) +n4.not=subset(n,Negate(s3d)) # vertices with x position > 100 and inside the selector function -n6=subset(n,X>100 & s3d(X,Y,Z)) +n6=subset(n,X>100 & s3d(X,Y,Z)) ## subset each neuron object in a whole neuronlist -n10=Cell07PNs[1:10] -plot3d(n10, lwd=0.5, col='grey') -n10.crop = nlapply(n10, subset, X>250) -plot3d(n10.crop, col='red') +n10=Cell07PNs[1:10] +plot3d(n10, lwd=0.5, col='grey') +n10.crop = nlapply(n10, subset, X>250) +plot3d(n10.crop, col='red') ## subset a neuron using a surface -library(nat.flybrains) +library(nat.flybrains) # extract left lateral horn surface and convert to mesh3d -lh=as.mesh3d(subset(IS2NP.surf, "LH_L")) +lh=as.mesh3d(subset(IS2NP.surf, "LH_L")) # subset neuron with this surface -x=subset(Cell07PNs[[1]], function(x) pointsinside(x, lh)) -shade3d(lh, alpha=0.3) -plot3d(x, lwd=3, col='blue') +x=subset(Cell07PNs[[1]], function(x) pointsinside(x, lh)) +shade3d(lh, alpha=0.3) +plot3d(x, lwd=3, col='blue') # Now find the parts of the neuron outside the surface -y=subset(Cell07PNs[[1]], function(x) Negate(pointsinside)(x, lh)) -plot3d(y, col='red', lwd=2) -# }
    +y=subset(Cell07PNs[[1]], function(x) Negate(pointsinside)(x, lh)) +plot3d(y, col='red', lwd=2) +} +
    - +
    -

    Site built with pkgdown.

    +

    Site built with pkgdown 1.6.1.

    + + + + + diff --git a/docs/reference/subset.neuronlist.html b/docs/reference/subset.neuronlist.html index 18131af1..6bb29c78 100644 --- a/docs/reference/subset.neuronlist.html +++ b/docs/reference/subset.neuronlist.html @@ -1,6 +1,6 @@ - + @@ -8,25 +8,46 @@ Subset neuronlist returning either new neuronlist or names of chosen neurons — subset.neuronlist • nat + - + - - + + + + + + + - + + + + + + + + - - - + + + + + + + + + + - + + + - +
    +
    -
    +
    - +

    Subset neuronlist returning either new neuronlist or names of chosen neurons

    - +
    # S3 method for neuronlist
    -subset(x, subset, filterfun, rval = c("neuronlist",
    -  "names", "data.frame"), ...)
    - -

    Arguments

    +subset( + x, + subset, + filterfun, + rval = c("neuronlist", "names", "data.frame"), + ... +) + +

    Arguments

    @@ -132,12 +167,11 @@

    Ar

    additional arguments passed to filterfun

    - +

    Value

    A neuronlist, character vector of names or the attached data.frame according to the value of rval

    -

    Details

    The subset expression should evaluate to one of

      @@ -145,7 +179,8 @@

      Details
    • logical vector

    • vector of numeric indices

    -

    Any missing names are dropped with a warning. The filterfun + +

    Any missing names are dropped with a warning. The filterfun expression is wrapped in a try. Neurons returning an error will be dropped with a warning.

    You may also be interested in find.neuron, which enables @@ -153,25 +188,24 @@

    Details subset.neuron, subset.dotprops methods exist: these are used to remove points from neurons (rather than to remove neurons from neuronlists).

    -

    See also

    -

    neuronlist, find.neuron, - subset.data.frame, subset.neuron, subset.dotprops

    - +

    Examples

    -
    da1pns=subset(Cell07PNs,Glomerulus=='DA1') -with(da1pns,stopifnot(all(Glomerulus=='DA1'))) -gammas=subset(kcs20,type=='gamma') -with(gammas,stopifnot(all(type=='gamma'))) +
    da1pns=subset(Cell07PNs,Glomerulus=='DA1') +with(da1pns,stopifnot(all(Glomerulus=='DA1'))) +gammas=subset(kcs20,type=='gamma') +with(gammas,stopifnot(all(type=='gamma'))) # define a function that checks whether a neuron has points in a region in # space, specifically the tip of the mushroom body alpha' lobe -aptip<-function(x) {xyz=xyzmatrix(x);any(xyz[,'X']>350 & xyz[,'Y']<40)} +aptip<-function(x) {xyz=xyzmatrix(x);any(xyz[,'X']>350 & xyz[,'Y']<40)} # this should identify the alpha'/beta' kenyon cells only -apbps=subset(kcs20,filterfun=aptip) +apbps=subset(kcs20,filterfun=aptip) # look at which neurons are present in the subsetted neuronlist -head(apbps)
    #> gene_name Name idid soma_side +head(apbps) +
    #> gene_name Name idid soma_side #> GadMARCM-F000142_seg002 GadMARCM-F000142_seg002 Gad1-F-300043 10647 L #> GadMARCM-F000423_seg001 GadMARCM-F000423_seg001 Gad1-F-300107 9541 R #> ChaMARCM-F000586_seg002 ChaMARCM-F000586_seg002 Cha-F-300150 7113 R @@ -183,50 +217,48 @@

    Examp #> GadMARCM-F000142_seg002 GadMARCM-F000142_seg002 71 1535 apbp #> GadMARCM-F000423_seg001 GadMARCM-F000423_seg001 61 1265 apbp #> ChaMARCM-F000586_seg002 ChaMARCM-F000586_seg002 52 898 apbp

    # combine global variables with dataframe columns -odds=rep(c(TRUE,FALSE),10) -stopifnot(all.equal(subset(kcs20,type=='gamma' & odds), - subset(kcs20,type=='gamma' & rep(c(TRUE,FALSE),10))))
    # NOT RUN { +odds=rep(c(TRUE,FALSE),10) +stopifnot(all.equal(subset(kcs20,type=='gamma' & odds), + subset(kcs20,type=='gamma' & rep(c(TRUE,FALSE),10)))) +if (FALSE) { # make a 3D selection function using interactive rgl::select3d() function -s3d=select3d() +s3d=select3d() # Apply a 3D search function to the first 100 neurons in the neuronlist dataset -subset(dps[1:100],filterfun=function(x) {sum(s3d(xyzmatrix(x)))>0}, - rval='names') +subset(dps[1:100],filterfun=function(x) {sum(s3d(xyzmatrix(x)))>0}, + rval='names') # combine a search by metadata, neuropil location and 3D location -subset(dps, Gender=="M" & rAL>1000, function(x) sum(s3d(x))>0, rval='name') +subset(dps, Gender=="M" & rAL>1000, function(x) sum(s3d(x))>0, rval='name') # The same but specifying indices directly, which can be considerably faster # when neuronlist is huge and memory is in short supply -subset(dps, names(dps)[1:100],filterfun=function(x) {sum(s3d(xyzmatrix(x)))>0}, - rval='names') -# }
    +subset(dps, names(dps)[1:100],filterfun=function(x) {sum(s3d(xyzmatrix(x)))>0}, + rval='names') +} +
    - +
    -

    Site built with pkgdown.

    +

    Site built with pkgdown 1.6.1.

    + + + + + diff --git a/docs/reference/summary.neuron.html b/docs/reference/summary.neuron.html index 325bfc45..02e37a48 100644 --- a/docs/reference/summary.neuron.html +++ b/docs/reference/summary.neuron.html @@ -1,6 +1,6 @@ - + @@ -8,25 +8,50 @@ Summary statistics for neurons (e.g. cable length, number of nodes) — summary.neuronlist • nat + - + - - + + + + + + + - + + + + + + + + - - - + + + + + + + + + + - + + + - +
    +
    -
    +
    - +

    summary.neuronlist computes tree statistics for all the - neurons in a neuronlist object - - summary.neuron computes statistics for individual neurons - - summary.dotprops computes statistics for individual + neurons in a neuronlist object

    +

    summary.neuron computes statistics for individual neurons

    +

    summary.dotprops computes statistics for individual neurons in dotprops format. Note the veclength argument.

    - +
    # S3 method for neuronlist
    -summary(object, ..., include.attached.dataframe = FALSE)
    +summary(object, ..., include.attached.dataframe = FALSE)
     
     # S3 method for neuron
    -summary(object, ...)
    +summary(object, ...)
     
     # S3 method for dotprops
    -summary(object, veclength = 1, ...)
    - -

    Arguments

    +summary(object, veclength = 1, ...) + +

    Arguments

    @@ -140,7 +172,7 @@

    Ar length estimate can be made.

    - +

    Value

    A data.frame summarising the tree properties of the neuron @@ -153,15 +185,14 @@

    Value

  • cable.length

  • -

    See also

    -

    seglengths

    - +

    Examples

    # summary for a whole neuronlist -summary(Cell07PNs)
    #> root nodes segments branchpoints endpoints cable.length +summary(Cell07PNs) +
    #> root nodes segments branchpoints endpoints cable.length #> EBH11R 1 180 33 16 18 297.1763 #> EBH20L 1 200 26 12 15 327.0929 #> EBH20R 1 199 25 12 14 347.6153 @@ -202,47 +233,49 @@

    Examp #> VA20R 1 160 21 10 12 215.0711 #> VB37L 1 162 14 6 9 218.7555 #> VB58L 1 154 17 8 10 231.9512

    # including the attached data.frame with additional metadata -head(summary(Cell07PNs, include.attached.dataframe = FALSE))
    #> root nodes segments branchpoints endpoints cable.length +head(summary(Cell07PNs, include.attached.dataframe = FALSE)) +
    #> root nodes segments branchpoints endpoints cable.length #> EBH11R 1 180 33 16 18 297.1763 #> EBH20L 1 200 26 12 15 327.0929 #> EBH20R 1 199 25 12 14 347.6153 #> EBI12L 1 169 23 11 13 294.4680 #> EBI22R 1 160 27 13 15 303.0150 #> EBJ23L 1 156 28 13 16 292.3298
    # for a single regular format neuron -summary(Cell07PNs[[1]])
    #> root nodes segments branchpoints endpoints cable.length +summary(Cell07PNs[[1]]) +
    #> root nodes segments branchpoints endpoints cable.length #> 1 1 180 33 16 18 297.1763
    # for a single dotprops format neuron -summary(kcs20[[1]])
    #> nodes cable.length +summary(kcs20[[1]]) +
    #> nodes cable.length #> 1 284 284
    # specify a different estimate for the cable length associated with a single # point in the neuron -summary(kcs20[[1]], veclength=1.2)
    #> nodes cable.length +summary(kcs20[[1]], veclength=1.2) +
    #> nodes cable.length #> 1 284 340.8
    - +
    -

    Site built with pkgdown.

    +

    Site built with pkgdown 1.6.1.

    + + + + + diff --git a/docs/reference/threshold.html b/docs/reference/threshold.html index e586ccc7..ee60096b 100644 --- a/docs/reference/threshold.html +++ b/docs/reference/threshold.html @@ -1,6 +1,6 @@ - + @@ -8,25 +8,46 @@ Threshold an object, typically to produce a mask — threshold • nat + - + - - + + + + + + + - + + + + + + + + - - - + + + + + + + + + + - + + + - +
    +
    -
    +
    - +

    Threshold an object, typically to produce a mask

    - +
    -
    threshold(x, ...)
    +    
    threshold(x, ...)
     
     # S3 method for im3d
    -threshold(x, threshold = 0, mode = c("logical", "integer",
    -  "raw", "numeric"), ...)
    - -

    Arguments

    +threshold( + x, + threshold = 0, + mode = c("logical", "integer", "raw", "numeric"), + ... +)
    + +

    Arguments

    @@ -116,7 +150,7 @@

    Ar

    - + @@ -128,64 +162,65 @@

    Ar

    +vector

    Object to be thresholded

    ...

    Additional arguments passed to methods

    mode

    The storage mode of the resultant object (see -vector

    - +

    Value

    an oject with attributes matching x and elements with value - as.vector(TRUE, mode=mode) i.e. TRUE, 1, 0x01 and - as.vector(FALSE, mode=mode) i.e. FALSE, 0, 0x00 as + as.vector(TRUE, mode=mode) i.e. TRUE, 1, 0x01 and + as.vector(FALSE, mode=mode) i.e. FALSE, 0, 0x00 as appropriate.

    -

    Details

    -

    Note that threshold.im3d passes … arguments on to im3d

    - +

    Note that threshold.im3d passes ... arguments on to im3d

    See also

    -

    Other im3d: as.im3d, - boundingbox, im3d-coords, - im3d-io, im3d, - imexpand.grid, imslice, - is.im3d, mask, - origin, projection, - unmask, voxdims

    - +

    Other im3d: +as.im3d(), +boundingbox(), +im3d-coords, +im3d-io, +im3d(), +imexpand.grid(), +imslice(), +is.im3d(), +mask(), +origin(), +projection(), +unmask(), +voxdims()

    Examples

    -
    x=im3d(rnorm(1000),dims=c(10,10,10), BoundingBox=c(20,200,100,200,200,300)) -stopifnot(all.equal(threshold(x, 0), threshold(x, x>0)))
    +
    x=im3d(rnorm(1000),dims=c(10,10,10), BoundingBox=c(20,200,100,200,200,300)) +stopifnot(all.equal(threshold(x, 0), threshold(x, x>0))) +
    - +
    -

    Site built with pkgdown.

    +

    Site built with pkgdown 1.6.1.

    + + + + + diff --git a/docs/reference/union.html b/docs/reference/union.html index 432d7fe6..f88a193b 100644 --- a/docs/reference/union.html +++ b/docs/reference/union.html @@ -1,6 +1,6 @@ - + @@ -8,25 +8,46 @@ Find the union of two collections of objects — union • nat + - + - - + + + + + + + - + + + + + + + + - - - + + + + + + + + + + - + + + - +
    +
    -
    +
    - +

    Find the union of two collections of objects

    - +
    -
    union(x, y, ...)
    +    
    union(x, y, ...)
     
     # S3 method for default
    -union(x, y, ...)
    +union(x, y, ...)
     
     # S3 method for neuronlist
    -union(x, y, ...)
    - -

    Arguments

    +union(x, y, ...)
    + +

    Arguments

    @@ -126,49 +156,44 @@

    Ar

    additional arguments passed to methods

    - +

    Value

    A collection of the same mode as x that contains all unique elements of x and y.

    -

    Details

    Note that union.default calls base::union to ensure consistent behaviour for regular vectors.

    -

    See also

    -

    union

    - +
    - +
    -

    Site built with pkgdown.

    +

    Site built with pkgdown 1.6.1.

    + + + + + diff --git a/docs/reference/unmask.html b/docs/reference/unmask.html index 71ac510f..865f099d 100644 --- a/docs/reference/unmask.html +++ b/docs/reference/unmask.html @@ -1,6 +1,6 @@ - + @@ -8,25 +8,46 @@ Make im3d image array containing values at locations defined by a mask — unmask • nat + - + - - + + + + + + + - + + + + + + + + - - - + + + + + + + + + + - + + + - +
    +
    -
    +
    - +

    Make im3d image array containing values at locations defined by a mask

    - +
    + +
    unmask(
    +  x,
    +  mask,
    +  default = NA,
    +  attributes. = attributes(mask),
    +  copyAttributes = TRUE
    +)
    -
    unmask(x, mask, default = NA, attributes. = attributes(mask),
    -  copyAttributes = TRUE)
    - -

    Arguments

    +

    Arguments

    @@ -132,72 +167,73 @@

    Ar from the mask to the returned object. default: TRUE

    - +

    Value

    A new im3d object with attributes/dimensions defined by mask and values from x. If copyAttributes is FALSE, then it will have mode of x and length of mask but no other attributes.

    -

    Details

    The values in x will be placed into a grid defined by the dimensions of the mask in the order defined by the standard R linear - subscripting of arrays (see e.g. arrayInd).

    - + subscripting of arrays (see e.g. arrayInd).

    See also

    -

    Other im3d: as.im3d, - boundingbox, im3d-coords, - im3d-io, im3d, - imexpand.grid, imslice, - is.im3d, mask, - origin, projection, - threshold, voxdims

    - +

    Other im3d: +as.im3d(), +boundingbox(), +im3d-coords, +im3d-io, +im3d(), +imexpand.grid(), +imslice(), +is.im3d(), +mask(), +origin(), +projection(), +threshold(), +voxdims()

    Examples

    -
    # NOT RUN {
    +    
    if (FALSE) { # read in a mask -LHMask=read.im3d(system.file('tests/testthat/testdata/nrrd/LHMask.nrrd', package='nat')) +LHMask=read.im3d(system.file('tests/testthat/testdata/nrrd/LHMask.nrrd', package='nat')) # pick out all the non zero values -inmask=LHMask[LHMask!=0] +inmask=LHMask[LHMask!=0] # fill the non-zero elements of the mask with a vector that iterates over the # values 0:9 -stripes=unmask(seq(inmask)%%10, LHMask) +stripes=unmask(seq(inmask)%%10, LHMask) # make an image from one slice of that result array -image(imslice(stripes,11), asp=TRUE) -# }
    +image(imslice(stripes,11), asp=TRUE) +} +
    - +
    -

    Site built with pkgdown.

    +

    Site built with pkgdown 1.6.1.

    + + + + + diff --git a/docs/reference/voxdims.html b/docs/reference/voxdims.html index 174c5151..f66b71d7 100644 --- a/docs/reference/voxdims.html +++ b/docs/reference/voxdims.html @@ -1,6 +1,6 @@ - + @@ -8,25 +8,47 @@ Return voxel dimensions of an object — voxdims • nat + - + - - + + + + + + + - + + + + + + + + - - - + + + + + + + + + + - + + + - +
    +
    -
    +
    - +

    This would properly be thought of as the voxel spacing when voxels are assumed not to have a physical extent (only a location).

    - +
    -
    voxdims(x, ...)
    +    
    voxdims(x, ...)
     
     # S3 method for im3d
    -voxdims(x, ...)
    +voxdims(x, ...)
     
     # S3 method for character
    -voxdims(x, ...)
    +voxdims(x, ...)
     
     # S3 method for default
    -voxdims(x, dims, ...)
    - -

    Arguments

    +voxdims(x, dims, ...)
    + +

    Arguments

    @@ -132,55 +163,57 @@

    Ar matrix.

    - +

    Value

    A numeric vector of length 3, NA when missing.

    -

    Details

    We follow Amira's convention of returning a voxel dimension equal to the bounding box size (rather than 0) for any dimension with only 1 voxel.

    -

    See also

    -

    boundingbox

    -

    Other im3d: as.im3d, - boundingbox, im3d-coords, - im3d-io, im3d, - imexpand.grid, imslice, - is.im3d, mask, - origin, projection, - threshold, unmask

    - +
    - +
    -

    Site built with pkgdown.

    +

    Site built with pkgdown 1.6.1.

    + + + + + diff --git a/docs/reference/write.amiramesh.html b/docs/reference/write.amiramesh.html index b91293af..973c64da 100644 --- a/docs/reference/write.amiramesh.html +++ b/docs/reference/write.amiramesh.html @@ -1,6 +1,6 @@ - + @@ -8,25 +8,46 @@ Write a 3D data object to an amiramesh format file — write.amiramesh • nat + - + - - + + + + + + + - + + + + + + + + - - - + + + + + + + + + + - + + + - +
    +
    -
    +
    - +

    Write a 3D data object to an amiramesh format file

    - +
    -
    write.amiramesh(x, file, enc = c("binary", "raw", "text", "hxzip"),
    -  dtype = c("float", "byte", "short", "ushort", "int", "double"),
    -  endian = .Platform$endian, WriteNrrdHeader = FALSE)
    - -

    Arguments

    +
    write.amiramesh(
    +  x,
    +  file,
    +  enc = c("binary", "raw", "text", "hxzip"),
    +  dtype = c("float", "byte", "short", "ushort", "int", "double"),
    +  endian = .Platform$endian,
    +  WriteNrrdHeader = FALSE
    +)
    + +

    Arguments

    @@ -138,52 +173,49 @@

    Ar details.

    - +

    Details

    Note that only 'raw' or 'text' format data can accommodate a detached NRRD format header since Amira's HxZip format is subtly different from NRRD's gzip encoding. There is a full description of the deteached NRRD format in the help for write.nrrd.

    -

    See also

    -

    .Platform, read.amiramesh, write.nrrd

    - +

    Examples

    -
    d=array(rnorm(1000), c(10, 10, 10)) -tf=tempfile(fileext='.am') -write.amiramesh(im3d(d, voxdims=c(0.5,0.5,1)), file=tf, WriteNrrdHeader=TRUE) -d2=read.nrrd(paste(tf, sep='', '.nhdr')) -all.equal(d, d2, tol=1e-6)
    #> [1] "Attributes: < Length mismatch: comparison on first 1 components >"
    +
    d=array(rnorm(1000), c(10, 10, 10)) +tf=tempfile(fileext='.am') +write.amiramesh(im3d(d, voxdims=c(0.5,0.5,1)), file=tf, WriteNrrdHeader=TRUE) +d2=read.nrrd(paste(tf, sep='', '.nhdr')) +all.equal(d, d2, tol=1e-6) +
    #> [1] "Attributes: < Length mismatch: comparison on first 1 components >"
    - +
    -

    Site built with pkgdown.

    +

    Site built with pkgdown 1.6.1.

    + + + + + diff --git a/docs/reference/write.cmtk.html b/docs/reference/write.cmtk.html index 1bc4c7c9..2f7acb1c 100644 --- a/docs/reference/write.cmtk.html +++ b/docs/reference/write.cmtk.html @@ -1,6 +1,6 @@ - + @@ -8,25 +8,48 @@ Write a suitable list to a CMTK TypedStream file on disk — write.cmtk • nat + - + - - + + + + + + + - + + + + + + + + - - - + + + + + + + + + + - + + + - +
    +
    -
    +
    - +

    This is probaly only of interest to developers. End users will probably wish to use more specific functions such as write.cmtkreg for writing out registrations.

    - +
    + +
    write.cmtk(l, con, gzip = FALSE, version = NA_character_)
    -
    write.cmtk(l, con, gzip = FALSE, version = NA_character_)
    - -

    Arguments

    +

    Arguments

    @@ -127,44 +159,44 @@

    Ar specified in the version attribute of l.

    - +

    Details

    NB a version specified on the command line overrides one encoded as an attribute in the input list.

    -

    See also

    -

    Other cmtk-io: cmtk.extract_affine, - read.cmtkreg, read.cmtk, - write.cmtkreg

    - +
    - +
    -

    Site built with pkgdown.

    +

    Site built with pkgdown 1.6.1.

    + + + + + diff --git a/docs/reference/write.cmtkreg.html b/docs/reference/write.cmtkreg.html index 98d9fb91..03fc8661 100644 --- a/docs/reference/write.cmtkreg.html +++ b/docs/reference/write.cmtkreg.html @@ -1,6 +1,6 @@ - + @@ -8,25 +8,46 @@ Write out CMTK registration list to folder — write.cmtkreg • nat + - + - - + + + + + + + - + + + + + + + + - - - + + + + + + + + + + - + + + - +
    +
    -
    +
    - +

    Write out CMTK registration list to folder

    - +
    -
    write.cmtkreg(reglist, foldername, version = "2.4")
    - -

    Arguments

    +
    write.cmtkreg(reglist, foldername, version = "2.4")
    + +

    Arguments

    @@ -120,7 +150,7 @@

    Ar

    CMTK version for registration (default 2.4)

    - +

    Details

    Note that transformation in the forward direction (i.e. sample->ref) @@ -134,39 +164,39 @@

    Details writing the TYPEDSTREAM as version 2.4. The R code in this package implements both the new and old compose/decompose functions, using the new by default.

    -

    See also

    -

    Other cmtk-io: cmtk.extract_affine, - read.cmtkreg, read.cmtk, - write.cmtk

    - +
    - +
    -

    Site built with pkgdown.

    +

    Site built with pkgdown 1.6.1.

    + + + + + diff --git a/docs/reference/write.hxsurf.html b/docs/reference/write.hxsurf.html index e990a100..2f16189c 100644 --- a/docs/reference/write.hxsurf.html +++ b/docs/reference/write.hxsurf.html @@ -1,6 +1,6 @@ - + @@ -8,25 +8,46 @@ Write Amira surface (aka HxSurface or HyperSurface) into .surf file. — write.hxsurf • nat + - + - - + + + + + + + - + + + + + + + + - - - + + + + + + + + + + - + + + - +
    +
    -
    +
    - +

    Write Amira surface (aka HxSurface or HyperSurface) into .surf file.

    - +
    -
    write.hxsurf(surf, filename)
    - -

    Arguments

    +
    write.hxsurf(surf, filename)
    + +

    Arguments

    @@ -116,48 +146,51 @@

    Ar

    character vector defining path to file.

    - +

    Value

    -

    NULL or integer status from close.

    - +

    NULL or integer status from close.

    See also

    -

    plot3d.hxsurf,read.hxsurf, rgb

    -

    Other amira: amiratype, - is.amiramesh, read.amiramesh, - read.hxsurf

    -

    Other hxsurf: as.hxsurf, - as.mesh3d, materials, - plot3d.hxsurf, read.hxsurf, - subset.hxsurf

    - +
    - +
    -

    Site built with pkgdown.

    +

    Site built with pkgdown 1.6.1.

    + + + + + diff --git a/docs/reference/write.neuron.html b/docs/reference/write.neuron.html index 2f9fba7e..76c442b6 100644 --- a/docs/reference/write.neuron.html +++ b/docs/reference/write.neuron.html @@ -1,6 +1,6 @@ - + @@ -8,25 +8,50 @@ Write out a neuron in any of the file formats we know about — write.neuron • nat + - + - - + + + + + + + - + + + + + + + + - - - + + + + + + + + + + - + + + - +
    +
    -
    +
    - +

    If file is not specified the neuron's InputFileName field will be checked (for a dotprops object it will be the 'file' attribute). If this is missing there will be an error. If dir is specified it will be combined with basename(file). If file is specified but format is not, it will be inferred from file's extension.

    - +
    -
    write.neuron(n, file = NULL, dir = NULL, format = NULL, ext = NULL,
    -  Force = FALSE, MakeDir = TRUE, ...)
    - -

    Arguments

    +
    write.neuron(
    +  n,
    +  file = NULL,
    +  dir = NULL,
    +  format = NULL,
    +  ext = NULL,
    +  Force = FALSE,
    +  MakeDir = TRUE,
    +  ...
    +)
    + +

    Arguments

    @@ -149,62 +191,57 @@

    Ar

    Additional arguments passed to selected writer function

    - +

    Value

    return value

    -

    Details

    Note that if file does not have an extension then the default extension for the specified format will be appended. This behaviour can be suppressed by setting ext=NA.

    -

    See also

    -

    write.neuron, fileformats, - saveRDS

    - +

    write.neuron, fileformats, + saveRDS

    Examples

    # show the currently registered file formats that we can write -fileformats(class='neuron', write=TRUE)
    #> [1] "hxlineset" "hxskel" "rds" "swc" "vtk"
    # NOT RUN { -write.neuron(Cell07PNs[[1]], file='myneuron.swc') +fileformats(class='neuron', write=TRUE) +
    #> [1] "hxlineset" "hxskel" "rds" "swc" "vtk"
    if (FALSE) { +write.neuron(Cell07PNs[[1]], file='myneuron.swc') # writes out "myneuron.swc" in SWC format -write.neuron(Cell07PNs[[1]], format = 'hxlineset', file='myneuron.amiramesh') +write.neuron(Cell07PNs[[1]], format = 'hxlineset', file='myneuron.amiramesh') # writes out "myneuron.amiramesh" in Amira hxlineset format -write.neuron(Cell07PNs[[1]], format = 'hxlineset', file='myneuron') +write.neuron(Cell07PNs[[1]], format = 'hxlineset', file='myneuron') # writes out "myneuron.am" in Amira hxlineset format -# } +} +
    - +
    -

    Site built with pkgdown.

    +

    Site built with pkgdown 1.6.1.

    + + + + + diff --git a/docs/reference/write.neuronlistfh.html b/docs/reference/write.neuronlistfh.html index b7baf3f4..3afa9153 100644 --- a/docs/reference/write.neuronlistfh.html +++ b/docs/reference/write.neuronlistfh.html @@ -1,6 +1,6 @@ - + @@ -8,25 +8,46 @@ Write out a neuronlistfh object to an RDS file — write.neuronlistfh • nat + - + - - + + + + + + + - + + + + + + + + - - - + + + + + + + + + + - + + + - +
    +
    -
    +
    - +

    Write out a neuronlistfh object to an RDS file

    - +
    -
    write.neuronlistfh(x, file = attr(x, "file"), overwrite = FALSE, ...)
    - -

    Arguments

    +
    write.neuronlistfh(x, file = attr(x, "file"), overwrite = FALSE, ...)
    + +

    Arguments

    @@ -120,11 +150,11 @@

    Ar

    - +

    Whether to overwrite an existing file

    ...

    Additional paramaters passed to saveRDS

    - +

    Details

    This function writes the main neuronlistfh object to disk, but makes @@ -141,40 +171,40 @@

    Details read.neuronlistfh) then this will be removed before the file is saved (since the file attribute must be set on read to ensure that we know exactly which file on disk was the source of the object in memory).

    -

    See also

    -

    saveRDS

    -

    Other neuronlistfh: [.neuronlistfh, - neuronlistfh, - read.neuronlistfh, remotesync

    - +

    saveRDS

    +

    Other neuronlistfh: +[.neuronlistfh(), +neuronlistfh(), +read.neuronlistfh(), +remotesync()

    - +
    -

    Site built with pkgdown.

    +

    Site built with pkgdown 1.6.1.

    + + + + + diff --git a/docs/reference/write.neurons.html b/docs/reference/write.neurons.html index 8d83b094..0542bd5e 100644 --- a/docs/reference/write.neurons.html +++ b/docs/reference/write.neurons.html @@ -1,6 +1,6 @@ - + @@ -8,25 +8,46 @@ Write neurons from a neuronlist object to individual files, or a zip archive — write.neurons • nat + - + - - + + + + + + + - + + + + + + + + - - - + + + + + + + + + + - + + + - +
    +
    -
    +
    - +

    Write neurons from a neuronlist object to individual files, or a zip archive

    - +
    + +
    write.neurons(
    +  nl,
    +  dir,
    +  format = NULL,
    +  subdir = NULL,
    +  INDICES = names(nl),
    +  files = NULL,
    +  Force = FALSE,
    +  ...
    +)
    -
    write.neurons(nl, dir, format = NULL, subdir = NULL, INDICES = names(nl),
    -  files = NULL, Force = FALSE, ...)
    - -

    Arguments

    +

    Arguments

    @@ -145,86 +183,82 @@

    Ar

    Additional arguments passed to write.neuron

    - +

    Value

    the path to the output file(s), absolute when this is a zip file.

    -

    Details

    See write.neuron for details of how to specify the file format/extension/name of the output files and how to establish what output file formats are available. A zip archive of files can be written by specifying a value of dir that ends in .zip.

    -

    See also

    -

    write.neuron, read.neurons, +

    write.neuron, read.neurons, fileformats

    -

    Other neuronlist: *.neuronlist, - is.neuronlist, - neuronlist-dataframe-methods, - neuronlistfh, neuronlist, - nlapply, read.neurons

    - +

    Other neuronlist: +*.neuronlist(), +is.neuronlist(), +neuronlist-dataframe-methods, +neuronlistfh(), +neuronlist(), +nlapply(), +read.neurons()

    +

    Author

    + +

    jefferis

    Examples

    -
    # NOT RUN {
    +    
    if (FALSE) { # write some neurons in swc format -write.neurons(Cell07PNs, dir="testwn", format='swc') +write.neurons(Cell07PNs, dir="testwn", format='swc') # write some neurons in Amira hxlineset format -write.neurons(Cell07PNs, dir="testwn", format='hxlineset') +write.neurons(Cell07PNs, dir="testwn", format='hxlineset') # organise new files in directory hierarchy by glomerulus and Scored.By field -write.neurons(Cell07PNs,dir="testwn", - subdir=file.path(Glomerulus,Scored.By),format='hxlineset') +write.neurons(Cell07PNs,dir="testwn", + subdir=file.path(Glomerulus,Scored.By),format='hxlineset') # ensure that the neurons are named according to neuronlist names -write.neurons(Cell07PNs, dir="testwn", files=names(Cell07PNs), - subdir=file.path(Glomerulus,Scored.By),format='hxlineset') +write.neurons(Cell07PNs, dir="testwn", files=names(Cell07PNs), + subdir=file.path(Glomerulus,Scored.By),format='hxlineset') # only write a subset -write.neurons(subset(Cell07PNs, Scored.By="ACH"),dir="testwn2", - subdir=Glomerulus,format='hxlineset') +write.neurons(subset(Cell07PNs, Scored.By="ACH"),dir="testwn2", + subdir=Glomerulus,format='hxlineset') # The same, but likely faster for big neuronlists -write.neurons(Cell07PNs, dir="testwn3", - INDICES=subset(Cell07PNs,Scored.By="ACH",rval='names'), - subdir=Glomerulus,format='hxlineset') +write.neurons(Cell07PNs, dir="testwn3", + INDICES=subset(Cell07PNs,Scored.By="ACH",rval='names'), + subdir=Glomerulus,format='hxlineset') # set file name explicitly using a field in data.frame -write.neurons(subset(Cell07PNs, Scored.By="ACH"),dir="testwn4", - subdir=Glomerulus, files=paste0(ID,'.am'), format='hxlineset') -# }
    +write.neurons(subset(Cell07PNs, Scored.By="ACH"),dir="testwn4", + subdir=Glomerulus, files=paste0(ID,'.am'), format='hxlineset') +} +
    - +
    -

    Site built with pkgdown.

    +

    Site built with pkgdown 1.6.1.

    + + + + + diff --git a/docs/reference/write.nrrd.html b/docs/reference/write.nrrd.html index e66fb7fc..ce22daf8 100644 --- a/docs/reference/write.nrrd.html +++ b/docs/reference/write.nrrd.html @@ -1,6 +1,6 @@ - + @@ -8,25 +8,54 @@ Write data and metadata to NRRD file or create a detached NRRD (nhdr) file. — write.nrrd • nat + - + - - + + + + + + + - + + + + + + + + - - - + + + + + + + + + + - + + + - +
    +
    -
    +
    - +

    write.nrrd writes an array, vector or im3d object to a NRRD file. When x is an im3d object, appropriate spatial - calibration fields are added to the header. - - write.nrrd.header writes a nrrd header file. - - write.nrrd.header.for.file makes a detached NRRD + calibration fields are added to the header.

    +

    write.nrrd.header writes a nrrd header file.

    +

    write.nrrd.header.for.file makes a detached NRRD (nhdr) file that points at another image file on disk, making it NRRD compatible. This can be a convenient way to make NRRD inputs for other tools e.g. CMTK and also allows the same data block to pointed to by different nhdr files with different spatial calibration.

    - +
    + +
    write.nrrd(
    +  x,
    +  file,
    +  enc = c("gzip", "raw", "text"),
    +  dtype = c("float", "byte", "short", "ushort", "int", "double"),
    +  header = attr(x, "header"),
    +  endian = .Platform$endian,
    +  datafile = NULL
    +)
     
    -    
    write.nrrd(x, file, enc = c("gzip", "raw", "text"), dtype = c("float",
    -  "byte", "short", "ushort", "int", "double"), header = attr(x, "header"),
    -  endian = .Platform$endian, datafile = NULL)
    +write.nrrd.header(header, file)
     
    -write.nrrd.header(header, file)
    +write.nrrd.header.for.file(infile, outfile = NULL)
    -write.nrrd.header.for.file(infile, outfile = NULL)
    - -

    Arguments

    +

    Arguments

    @@ -163,7 +205,7 @@

    Ar default) then it will be set to <infilestem.nhdr>.

    - +

    Detached NRRDs

    NRRD files can be written in detached format @@ -185,7 +227,7 @@

    Data file paths

    When a detached NRRD is written, the @@ -198,7 +240,7 @@

    Header

    For write.nrrd, arguments enc, dtype, @@ -215,41 +256,35 @@

    See also

    -

    read.nrrd, .Platform

    - +
    - +
    -

    Site built with pkgdown.

    +

    Site built with pkgdown 1.6.1.

    + + + + + diff --git a/docs/reference/write.vtk.html b/docs/reference/write.vtk.html index bfdc4278..ca84a8ca 100644 --- a/docs/reference/write.vtk.html +++ b/docs/reference/write.vtk.html @@ -1,6 +1,6 @@ - + @@ -8,25 +8,46 @@ Write object to VTK file — write.vtk • nat + - + - - + + + + + + + - + + + + + + + + - - - + + + + + + + + + + - + + + - +
    +
    -
    +
    - +

    Write object to VTK file

    - +
    -
    write.vtk(x, file, ...)
    +    
    write.vtk(x, file, ...)
     
     # S3 method for neuron
    -write.vtk(x, file, datatype = c("float", "double"),
    -  title = file, WriteAllSubTrees = TRUE, ...)
    - -

    Arguments

    +write.vtk( + x, + file, + datatype = c("float", "double"), + title = file, + WriteAllSubTrees = TRUE, + ... +)
    + +

    Arguments

    @@ -137,37 +173,40 @@

    Ar the main tree.

    - +

    Examples

    -
    # NOT RUN {
    -n=Cell07PNs[[1]]
    -write.vtk(n, paste0(n$NeuronName, ".vtk"))
    -write.neuron(n, paste0(n$NeuronName, ".vtk"))
    -# }
    +
    if (FALSE) { +n=Cell07PNs[[1]] +write.vtk(n, paste0(n$NeuronName, ".vtk")) +write.neuron(n, paste0(n$NeuronName, ".vtk")) +} +
    - +
    -

    Site built with pkgdown.

    +

    Site built with pkgdown 1.6.1.

    + + + + + diff --git a/docs/reference/xform.html b/docs/reference/xform.html index 42b137be..824499ea 100644 --- a/docs/reference/xform.html +++ b/docs/reference/xform.html @@ -1,6 +1,6 @@ - + @@ -8,25 +8,54 @@ Transform the 3D location of objects such as neurons — xform • nat + - + - - + + + + + + + - + + + + + + + + - - - + + + + + + + + + + - + + + - +
    +
    -
    +
    - +

    xform is designed to operate on a variety of data types, especially objects encapsulating neurons. xform depends on two specialised downstream functions xformpoints and xformimage. These are user visible any contain some useful documentation, but should only be required for expert use; in almost all circumstances, you should use only -xform. - - xform.character is designed to work with files on disk. +xform.

    +

    xform.character is designed to work with files on disk. Presently it is restricted to images, although other datatypes may be supported in future.

    - +
    -
    xform(x, reg, ...)
    +    
    xform(x, reg, ...)
     
     # S3 method for default
    -xform(x, reg, na.action = c("warn", "none", "drop",
    -  "error"), ...)
    +xform(x, reg, na.action = c("warn", "none", "drop", "error"), ...)
     
     # S3 method for character
    -xform(x, reg, ...)
    +xform(x, reg, ...)
     
     # S3 method for list
    -xform(x, reg, FallBackToAffine = TRUE, na.action = "error",
    -  ...)
    +xform(x, reg, FallBackToAffine = TRUE, na.action = "error", ...)
     
     # S3 method for shape3d
    -xform(x, reg, FallBackToAffine = TRUE,
    -  na.action = "error", ...)
    +xform(x, reg, FallBackToAffine = TRUE, na.action = "error", ...)
     
     # S3 method for neuron
    -xform(x, reg, FallBackToAffine = TRUE, na.action = "error",
    -  ...)
    +xform(x, reg, FallBackToAffine = TRUE, na.action = "error", ...)
     
     # S3 method for data.frame
    -xform(x, reg, subset = NULL, ...)
    +xform(x, reg, subset = NULL, ...)
     
     # S3 method for dotprops
    -xform(x, reg, FallBackToAffine = TRUE, ...)
    +xform(x, reg, FallBackToAffine = TRUE, ...)
     
     # S3 method for neuronlist
    -xform(x, reg, subset = NULL, ..., OmitFailures = NA,
    -  VectoriseRegistrations = FALSE, TransformDFCoords = TRUE)
    - -

    Arguments

    +xform( + x, + reg, + subset = NULL, + ..., + OmitFailures = NA, + VectoriseRegistrations = FALSE, + TransformDFCoords = TRUE +)
    + +

    Arguments

    @@ -195,7 +235,7 @@

    Ar as well.

    - +

    Details

    Methods are provided for some specialised S3 classes. Further @@ -224,20 +264,22 @@

    Details dotprops objects (which do not otherwise store the soma position). Note that if transformation fails, a warning will be issued and the points will be replaced with NA values.

    -

    Registrations

    -

    When reg is a character vector, xform's specialised downstream + + +

    When reg is a character vector, xform's specialised downstream functions will check to see if it defines a path to one (or more) registrations on disk. These can be of two classes

    • CMTK registrations

    • reglist objects saved in R's RDS format (see - readRDS) which can contain any sequence of registrations + readRDS) which can contain any sequence of registrations supported by nat.

    -

    If the path does indeed point to a CMTK registration, this method will hand + +

    If the path does indeed point to a CMTK registration, this method will hand off to xformpoints.cmtkreg or xformimages.cmtkreg. In this case, the character vector may optionally have an attribute, 'swap', a logical vector of the same length indicating whether the transformation @@ -249,63 +291,59 @@

    myfun(x,), ... where the ... must be provided in order to swallow any arguments passed from higher level functions that are not relevant to this particular transformation function.

    -

    See also

    -

    xformpoints

    - +

    Examples

    -
    # NOT RUN {
    -kc1=kcs20[[1]]
    -kc1.default=xform(kc1,function(x,...) x)
    -stopifnot(isTRUE(all.equal(kc1,kc1.default)))
    -kc1.5=xform(kc1,function(x,...) x, k=5)
    -stopifnot(isTRUE(all.equal(kc1.5,kc1.default)))
    -kc1.20=xform(kc1,function(x,...) x, k=20)
    -stopifnot(!isTRUE(all.equal(kc1,kc1.20)))
    +    
    if (FALSE) { +kc1=kcs20[[1]] +kc1.default=xform(kc1,function(x,...) x) +stopifnot(isTRUE(all.equal(kc1,kc1.default))) +kc1.5=xform(kc1,function(x,...) x, k=5) +stopifnot(isTRUE(all.equal(kc1.5,kc1.default))) +kc1.20=xform(kc1,function(x,...) x, k=20) +stopifnot(!isTRUE(all.equal(kc1,kc1.20))) # apply two registrations converting sample->IS2->JFRC2 -reg_seq=c("IS2_sample.list", "JFRC2_IS2.list") -xform(kc1, reg_seq) +reg_seq=c("IS2_sample.list", "JFRC2_IS2.list") +xform(kc1, reg_seq) # apply two registrations, swapping the direction of the second one # i.e. sample -> IS2 -> FCWB -reg_seq=structure(c("IS2_sample.list", "IS2_FCWB.list"), swap=c(FALSE, TRUE)) -xform(kc1, reg_seq) -# }# NOT RUN { +reg_seq=structure(c("IS2_sample.list", "IS2_FCWB.list"), swap=c(FALSE, TRUE)) +xform(kc1, reg_seq) +} +if (FALSE) { # apply reg1 to Cell07PNs[[1]], reg2 to Cell07PNs[[2]] etc -regs=c(reg1, reg2, reg3) -nx=xform(Cell07PNs[1:3], reg=regs, VectoriseRegistrations=TRUE) -# }
    +regs=c(reg1, reg2, reg3) +nx=xform(Cell07PNs[1:3], reg=regs, VectoriseRegistrations=TRUE) +} +
    - +
    -

    Site built with pkgdown.

    +

    Site built with pkgdown 1.6.1.

    + + + + + diff --git a/docs/reference/xformimage.html b/docs/reference/xformimage.html index 8c978d7d..198b287f 100644 --- a/docs/reference/xformimage.html +++ b/docs/reference/xformimage.html @@ -1,6 +1,6 @@ - + @@ -8,25 +8,47 @@ Transform image files using a registration or affine matrix — xformimage • nat + - + - - + + + + + + + - + + + + + + + + - - - + + + + + + + + + + - + + + - +
    +
    -
    +
    - +

    You should almost always call xform rather calling thanxformimage directly.

    - +
    -
    xformimage(reg, image, ...)
    +    
    xformimage(reg, image, ...)
     
     # S3 method for character
    -xformimage(reg, image, ...)
    +xformimage(reg, image, ...)
     
     # S3 method for cmtkreg
    -xformimage(reg, image, transformtype = c("warp", "affine"),
    -  direction = NULL, ...)
    +xformimage(
    +  reg,
    +  image,
    +  transformtype = c("warp", "affine"),
    +  direction = NULL,
    +  ...
    +)
     
     # S3 method for reglist
    -xformimage(reg, image, ...)
    +xformimage(reg, image, ...)
     
     # S3 method for default
    -xformimage(reg, image, ...)
    - -

    Arguments

    +xformimage(reg, image, ...)
    + +

    Arguments

    @@ -150,11 +186,10 @@

    Ar (called inverse by CMTK). Default (when NULL is forward).

    - +

    Value

    Character vector with path to xformed image.

    -

    Details

    When passed a character vector, xformimage will check to see if it @@ -169,7 +204,8 @@

    Details
  • specifying a mask

  • passing additional arguments to reformatx

  • -

    Note that the direction of CMTK registrations can be the source of + +

    Note that the direction of CMTK registrations can be the source of much confusion. This is because CMTK defines the forward direction as the transform required to reformat an image in sample (floating) space to an image in template space. Since this operation involves @@ -190,40 +226,36 @@

    Details they are passed on to cmtk.reformatx.

    whereas CMTK's streamxform tool (wrapped by xformpoints) expects them in the opposite order.

    -

    See also

    -

    cmtk.reformatx, xformpoints, - xform

    - +
    - +
    -

    Site built with pkgdown.

    +

    Site built with pkgdown 1.6.1.

    + + + + + diff --git a/docs/reference/xformpoints.html b/docs/reference/xformpoints.html index fde8430a..14bce3c4 100644 --- a/docs/reference/xformpoints.html +++ b/docs/reference/xformpoints.html @@ -1,6 +1,6 @@ - + @@ -8,25 +8,47 @@ Transform 3D points using a registration, affine matrix or function — xformpoints • nat + - + - - + + + + + + + - + + + + + + + + - - - + + + + + + + + + + - + + + - +
    +
    -
    +
    - +

    You should almost always call xform rather calling thanxformpoints directly.

    - +
    -
    xformpoints(reg, points, ...)
    +    
    xformpoints(reg, points, ...)
     
     # S3 method for character
    -xformpoints(reg, points, ...)
    +xformpoints(reg, points, ...)
     
     # S3 method for cmtkreg
    -xformpoints(reg, points, transformtype = c("warp",
    -  "affine"), direction = NULL, FallBackToAffine = FALSE, ...)
    +xformpoints(
    +  reg,
    +  points,
    +  transformtype = c("warp", "affine"),
    +  direction = NULL,
    +  FallBackToAffine = FALSE,
    +  ...
    +)
     
     # S3 method for reglist
    -xformpoints(reg, points, ...)
    +xformpoints(reg, points, ...)
     
     # S3 method for default
    -xformpoints(reg, points, ...)
    - -

    Arguments

    +xformpoints(reg, points, ...)
    + +

    Arguments

    @@ -153,7 +190,7 @@

    Ar that fail to transform under a warping transformation.

    - +

    Details

    If a list of transformations is passed in, these transformations are @@ -169,31 +206,32 @@

    Details neuroanatomical work, one often has points in sample space that one would like to transform into template space. Here one needs the inverse transformation.

    -

    - +
    -

    Site built with pkgdown.

    +

    Site built with pkgdown 1.6.1.

    + + + + + diff --git a/docs/reference/xyzmatrix.html b/docs/reference/xyzmatrix.html index 5c60e6b9..3b0aca96 100644 --- a/docs/reference/xyzmatrix.html +++ b/docs/reference/xyzmatrix.html @@ -1,6 +1,6 @@ - + @@ -8,25 +8,49 @@ Get and assign coordinates for classes containing 3D vertex data — xyzmatrix • nat + - + - - + + + + + + + - + + + + + + + + - - - + + + + + + + + + + - + + + - +
    +
    -
    +
    - -

    xyzmatrix gets coordinates from objects containing 3D vertex data - - xyzmatrix<- assigns xyz elements of neuron or dotprops +

    +

    xyzmatrix gets coordinates from objects containing 3D vertex data

    +

    xyzmatrix<- assigns xyz elements of neuron or dotprops object and can also handle matrix like objects with columns named X, Y, Z or x, y, z.

    - +
    -
    xyzmatrix(x, ...)
    +    
    xyzmatrix(x, ...)
     
     # S3 method for default
    -xyzmatrix(x, y = NULL, z = NULL, ...)
    +xyzmatrix(x, y = NULL, z = NULL, ...)
     
     # S3 method for neuron
    -xyzmatrix(x, ...)
    +xyzmatrix(x, ...)
     
     # S3 method for neuronlist
    -xyzmatrix(x, ...)
    +xyzmatrix(x, ...)
     
     # S3 method for dotprops
    -xyzmatrix(x, ...)
    +xyzmatrix(x, ...)
     
     # S3 method for hxsurf
    -xyzmatrix(x, ...)
    +xyzmatrix(x, ...)
     
     # S3 method for igraph
    -xyzmatrix(x, ...)
    +xyzmatrix(x, ...)
     
     # S3 method for mesh3d
    -xyzmatrix(x, ...)
    +xyzmatrix(x, ...)
     
    -xyzmatrix(x) <- value
    +xyzmatrix(x) <- value
     
     # S3 method for neuron
    -xyzmatrix(x) <- value
    +xyzmatrix(x) <- value
     
     # S3 method for dotprops
    -xyzmatrix(x) <- value
    +xyzmatrix(x) <- value
     
     # S3 method for hxsurf
    -xyzmatrix(x) <- value
    +xyzmatrix(x) <- value
     
     # S3 method for igraph
    -xyzmatrix(x) <- value
    +xyzmatrix(x) <- value
     
     # S3 method for shape3d
    -xyzmatrix(x) <- value
    +xyzmatrix(x) <- value
     
     # S3 method for neuronlist
    -xyzmatrix(x) <- value
    - -

    Arguments

    +xyzmatrix(x) <- value
    + +

    Arguments

    @@ -169,66 +201,62 @@

    Ar

    Nx3 matrix specifying new xyz coords

    - +

    Value

    For xyzmatrix: Nx3 matrix containing 3D coordinates

    For xyzmatrix<-: Original object with modified coords

    -

    Details

    Note that xyzmatrix can extract or set 3D coordinates in a matrix or data.frame that either has exactly 3 columns or has 3 columns named X,Y,Z or x,y,z.

    -

    See also

    -

    xyzmatrix

    - +

    xyzmatrix

    Examples

    # see all available methods for different classes -methods('xyzmatrix')
    #> [1] xyzmatrix.default xyzmatrix.dotprops xyzmatrix.hxsurf -#> [4] xyzmatrix.igraph xyzmatrix.mesh3d xyzmatrix.neuron -#> [7] xyzmatrix.neuronlist +methods('xyzmatrix') +
    #> [1] xyzmatrix.default* xyzmatrix.dotprops* xyzmatrix.hxsurf* +#> [4] xyzmatrix.igraph* xyzmatrix.mesh3d* xyzmatrix.neuron* +#> [7] xyzmatrix.neuronlist* #> see '?methods' for accessing help and source code
    # ... and for the assignment method -methods('xyzmatrix<-')
    #> [1] xyzmatrix<-.default xyzmatrix<-.dotprops xyzmatrix<-.hxsurf -#> [4] xyzmatrix<-.igraph xyzmatrix<-.neuron xyzmatrix<-.neuronlist -#> [7] xyzmatrix<-.shape3d -#> see '?methods' for accessing help and source code
    n=Cell07PNs[[1]] -xyzmatrix(n)<-xyzmatrix(n) -stopifnot(isTRUE( - all.equal(xyzmatrix(n),xyzmatrix(Cell07PNs[[1]])) -))
    +methods('xyzmatrix<-') +
    #> [1] xyzmatrix<-.default* xyzmatrix<-.dotprops* xyzmatrix<-.hxsurf* +#> [4] xyzmatrix<-.igraph* xyzmatrix<-.neuron* xyzmatrix<-.neuronlist* +#> [7] xyzmatrix<-.shape3d* +#> see '?methods' for accessing help and source code
    n=Cell07PNs[[1]] +xyzmatrix(n)<-xyzmatrix(n) +stopifnot(isTRUE( + all.equal(xyzmatrix(n),xyzmatrix(Cell07PNs[[1]])) +)) +
    - +
    -

    Site built with pkgdown.

    +

    Site built with pkgdown 1.6.1.

    + + + + + diff --git a/inst/CITATION b/inst/CITATION index fa3139ac..7345e61e 100644 --- a/inst/CITATION +++ b/inst/CITATION @@ -1,11 +1,27 @@ -citHeader("To cite nat in publications, please use:") - -citEntry(entry = 'article', - Title = "{NeuroAnatomy Toolbox v1.5.2}", - Author = c(person("Jefferis, Gregory S X E"), person("Manton, James D")), - Doi = "10.5281/zenodo.10171", - Journal = "ZENODO", - Month = "May", - Year = "2014", - textVersion = "Gregory S X E Jefferis and James D Manton (2014). NeuroAnatomy Toolbox v1.5.2. ZENODO. 10.5281/zenodo.10171" -) +citHeader( + "If you use nat or other natverse packages, please always cite our natverse", + "paper (Bates, Manton et al, eLife 2020).", + "This justifies funding for continued development.", + "You may need to cite additional publications if you use specific packages", + "that implement specialised algorithms or provide datasets for reanalysis.", + "Use a command like:", + "citation(package=\"nat.nblast\")", + "to see if there is a specific citation to use for a given package", + "in addition to the general natverse paper.") +structure(list(structure(list(author = structure(list(list(given = c("Alexander", +"Shakeel"), family = "Bates", role = NULL, email = NULL, comment = NULL), + list(given = c("James", "D."), family = "Manton", role = NULL, + email = NULL, comment = NULL), list(given = c("Sridhar", + "R."), family = "Jagannathan", role = NULL, email = NULL, + comment = NULL), list(given = "Marta", family = "Costa", + role = NULL, email = NULL, comment = NULL), list(given = "Philipp", + family = "Schlegel", role = NULL, email = NULL, comment = NULL), + list(given = "Torsten", family = "Rohlfing", role = NULL, + email = NULL, comment = NULL), list(given = c("Gregory", + "S.", "X.", "E."), family = "Jefferis", role = NULL, email = NULL, + comment = NULL)), class = "person"), journal = "Elife", + month = "Apr", title = "The natverse, a versatile toolbox for combining and analysing neuroanatomical data", + volume = "9", year = "2020", doi = "10.7554/eLife.53350", + url = "https://doi.org/10.7554/eLife.53350"), bibtype = "Article", key = "Bates:2020aa", dateobj = structure(1585699200, class = c("POSIXct", +"POSIXt"), tzone = "UTC", day.mon = 1L))), class = c("BibEntry", +"bibentry")) diff --git a/man/Cell07PNs.Rd b/man/Cell07PNs.Rd index 27e48c5a..14698dc4 100644 --- a/man/Cell07PNs.Rd +++ b/man/Cell07PNs.Rd @@ -5,8 +5,8 @@ \alias{Cell07PNs} \title{Cell07PNs: 40 Sample Projection Neurons from Jefferis, Potter et al 2007} \description{ -These R lists (which have additional class neuronlist) contain 40 traced -olfactory projection neurons from Jefferis, Potter et al 2007 that have been +These R lists (which have additional class neuronlist) contain 40 traced +olfactory projection neurons from Jefferis, Potter et al 2007 that have been transformed onto the IS2 template brain (Cachero, Ostrovsky et al 2010). } \examples{ @@ -14,18 +14,20 @@ head(Cell07PNs) table(with(Cell07PNs,Glomerulus)) } \references{ -Jefferis G.S.X.E., Potter C.J., Chan A.M., Marin E.C., Rohlfing -T., Maurer C.R.J., and Luo L. (2007). Comprehensive maps of Drosophila higher -olfactory centers: spatially segregated fruit and pheromone representation. -Cell 128 (6), 1187--1203. -\href{http://dx.doi.org/10.1016/j.cell.2007.01.040}{doi:10.1016/j.cell.2007.01.040} +Jefferis G.S.X.E., Potter C.J., Chan A.M., Marin E.C., Rohlfing + T., Maurer C.R.J., and Luo L. (2007). Comprehensive maps of Drosophila + higher olfactory centers: spatially segregated fruit and pheromone + representation. Cell 128 (6), 1187--1203. \doi{10.1016/j.cell.2007.01.040} -Cachero S., Ostrovsky A.D., Yu J.Y., Dickson B.J., and Jefferis G.S.X.E. -(2010). Sexual dimorphism in the fly brain. Curr Biol 20 (18), 1589--601. -\href{http://dx.doi.org/10.1016/j.cub.2010.07.045}{doi:10.1016/j.cub.2010.07.045} + Cachero S., Ostrovsky A.D., Yu J.Y., Dickson B.J., and Jefferis G.S.X.E. + (2010). Sexual dimorphism in the fly brain. Curr Biol 20 (18), 1589--601. + \doi{10.1016/j.cub.2010.07.045} } \seealso{ \code{\link{head.neuronlist}}, \code{\link{with.neuronlist}} -Other nat-data: \code{\link{MBL.surf}}, \code{\link{kcs20}} +Other nat-data: +\code{\link{MBL.surf}}, +\code{\link{kcs20}} } +\concept{nat-data} diff --git a/man/MBL.surf.Rd b/man/MBL.surf.Rd index 9ad8cc09..20ad9d96 100644 --- a/man/MBL.surf.Rd +++ b/man/MBL.surf.Rd @@ -23,6 +23,8 @@ MBL.surf=subset(FCWBNP.surf, "MB.*_L", drop = T) \seealso{ \code{\link{hxsurf}} -Other nat-data: \code{\link{Cell07PNs}}, - \code{\link{kcs20}} +Other nat-data: +\code{\link{Cell07PNs}}, +\code{\link{kcs20}} } +\concept{nat-data} diff --git a/man/affmat2cmtkparams.Rd b/man/affmat2cmtkparams.Rd index 771a21b7..1968adb7 100644 --- a/man/affmat2cmtkparams.Rd +++ b/man/affmat2cmtkparams.Rd @@ -23,7 +23,9 @@ The version attribute of the resultant matrix marks this as (de)composition was fixed. } \seealso{ -Other cmtk-geometry: \code{\link{cmtk.dof2mat}}, - \code{\link{cmtk.mat2dof}}, - \code{\link{cmtkparams2affmat}} +Other cmtk-geometry: +\code{\link{cmtk.dof2mat}()}, +\code{\link{cmtk.mat2dof}()}, +\code{\link{cmtkparams2affmat}()} } +\concept{cmtk-geometry} diff --git a/man/all.equal.dotprops.Rd b/man/all.equal.dotprops.Rd index 2165f1fc..f974c579 100644 --- a/man/all.equal.dotprops.Rd +++ b/man/all.equal.dotprops.Rd @@ -4,8 +4,13 @@ \alias{all.equal.dotprops} \title{all.equal method tailored to dotprops objects} \usage{ -\method{all.equal}{dotprops}(target, current, check.attributes = FALSE, - absoluteVectors = TRUE, ...) +\method{all.equal}{dotprops}( + target, + current, + check.attributes = FALSE, + absoluteVectors = TRUE, + ... +) } \arguments{ \item{target, current}{dotprops objects to compare} diff --git a/man/all.equal.im3d.Rd b/man/all.equal.im3d.Rd index b587990a..01b62bcd 100644 --- a/man/all.equal.im3d.Rd +++ b/man/all.equal.im3d.Rd @@ -4,9 +4,15 @@ \alias{all.equal.im3d} \title{Check equality on data and key attributes of im3d objects} \usage{ -\method{all.equal}{im3d}(target, current, tolerance = 1e-06, - attrsToCheck = c("BoundingBox"), attrsToCheckIfPresent = c("dim", "names", - "dimnames", "x", "y", "z"), CheckSharedAttrsOnly = FALSE, ...) +\method{all.equal}{im3d}( + target, + current, + tolerance = 1e-06, + attrsToCheck = c("BoundingBox"), + attrsToCheckIfPresent = c("dim", "names", "dimnames", "x", "y", "z"), + CheckSharedAttrsOnly = FALSE, + ... +) } \arguments{ \item{target}{\R object.} diff --git a/man/all.equal.neuron.Rd b/man/all.equal.neuron.Rd index c01ae7f7..170a41fc 100644 --- a/man/all.equal.neuron.Rd +++ b/man/all.equal.neuron.Rd @@ -4,11 +4,18 @@ \alias{all.equal.neuron} \title{Check equality on key fields of neuron object} \usage{ -\method{all.equal}{neuron}(target, current, tolerance = 1e-06, - check.attributes = FALSE, fieldsToCheck = c("NumPoints", "StartPoint", - "BranchPoints", "EndPoints", "NumSegs", "SegList", "d"), +\method{all.equal}{neuron}( + target, + current, + tolerance = 1e-06, + check.attributes = FALSE, + fieldsToCheck = c("NumPoints", "StartPoint", "BranchPoints", "EndPoints", "NumSegs", + "SegList", "d"), fieldsToCheckIfPresent = c("NeuronName", "nTrees", "SubTrees"), - fieldsToExclude = character(), CheckSharedFieldsOnly = FALSE, ...) + fieldsToExclude = character(), + CheckSharedFieldsOnly = FALSE, + ... +) } \arguments{ \item{target}{\R object.} @@ -20,7 +27,7 @@ \code{1.5e-8}.} \item{check.attributes}{logical indicating if the - \code{\link{attributes}} of \code{target} and \code{current} + \code{\link[base]{attributes}} of \code{target} and \code{current} (other than the names) should be compared.} \item{fieldsToCheck}{Which fields in the neuron are always checked. The diff --git a/man/amiramesh-io.Rd b/man/amiramesh-io.Rd index 5cd3d0e3..55e39fbd 100644 --- a/man/amiramesh-io.Rd +++ b/man/amiramesh-io.Rd @@ -5,8 +5,15 @@ \alias{read.amiramesh.header} \title{Read AmiraMesh data in binary or ascii format} \usage{ -read.amiramesh(file, sections = NULL, header = FALSE, simplify = TRUE, - endian = NULL, ReadByteAsRaw = FALSE, Verbose = FALSE) +read.amiramesh( + file, + sections = NULL, + header = FALSE, + simplify = TRUE, + endian = NULL, + ReadByteAsRaw = FALSE, + Verbose = FALSE +) read.amiramesh.header(file, Parse = TRUE, Verbose = FALSE) } @@ -49,7 +56,10 @@ reading byte data as raw arrays requires 1/4 memory but complicates \seealso{ \code{\link{readBin}, \link{.Platform}} -Other amira: \code{\link{amiratype}}, - \code{\link{is.amiramesh}}, \code{\link{read.hxsurf}}, - \code{\link{write.hxsurf}} +Other amira: +\code{\link{amiratype}()}, +\code{\link{is.amiramesh}()}, +\code{\link{read.hxsurf}()}, +\code{\link{write.hxsurf}()} } +\concept{amira} diff --git a/man/amiratype.Rd b/man/amiratype.Rd index 6749e30d..099c159f 100644 --- a/man/amiratype.Rd +++ b/man/amiratype.Rd @@ -24,7 +24,10 @@ Note that when checking a file we first test if it is an amiramesh and determining content type (slow). } \seealso{ -Other amira: \code{\link{is.amiramesh}}, - \code{\link{read.amiramesh}}, \code{\link{read.hxsurf}}, - \code{\link{write.hxsurf}} +Other amira: +\code{\link{is.amiramesh}()}, +\code{\link{read.amiramesh}()}, +\code{\link{read.hxsurf}()}, +\code{\link{write.hxsurf}()} } +\concept{amira} diff --git a/man/as.hxsurf.Rd b/man/as.hxsurf.Rd index 3f04b54e..b77d6d78 100644 --- a/man/as.hxsurf.Rd +++ b/man/as.hxsurf.Rd @@ -43,8 +43,12 @@ plot3d(teth) \seealso{ \code{\link{as.mesh3d}} -Other hxsurf: \code{\link{as.mesh3d}}, - \code{\link{materials}}, \code{\link{plot3d.hxsurf}}, - \code{\link{read.hxsurf}}, \code{\link{subset.hxsurf}}, - \code{\link{write.hxsurf}} -} +Other hxsurf: +\code{\link{as.mesh3d}()}, +\code{\link{materials}()}, +\code{\link{plot3d.hxsurf}()}, +\code{\link{read.hxsurf}()}, +\code{\link{subset.hxsurf}()}, +\code{\link{write.hxsurf}()} +} +\concept{hxsurf} diff --git a/man/as.im3d.Rd b/man/as.im3d.Rd index abc3f2c6..d11d2649 100644 --- a/man/as.im3d.Rd +++ b/man/as.im3d.Rd @@ -22,8 +22,9 @@ object (see details) completely specifying the required space.} \item{origin}{the location (or centre) of the first voxel} -\item{BoundingBox}{Physical extent of image. See the details section -of \code{\link{boundingbox}}'s help for the distinction.} +\item{BoundingBox}{Physical extent of the image. See the details section of +\code{\link{boundingbox}}'s help for the distinction between +\code{BoundingBox} and \code{bounds}.} } \description{ Convert a suitable object to an im3d object. @@ -67,11 +68,19 @@ im=as.im3d(xyzmatrix(kcs20), JFRC2) \code{\link{im3d}}, \code{\link{as.im3d}} -Other im3d: \code{\link{boundingbox}}, - \code{\link{im3d-coords}}, \code{\link{im3d-io}}, - \code{\link{im3d}}, \code{\link{imexpand.grid}}, - \code{\link{imslice}}, \code{\link{is.im3d}}, - \code{\link{mask}}, \code{\link{origin}}, - \code{\link{projection}}, \code{\link{threshold}}, - \code{\link{unmask}}, \code{\link{voxdims}} +Other im3d: +\code{\link{boundingbox}()}, +\code{\link{im3d}()}, +\code{\link{im3d-coords}}, +\code{\link{im3d-io}}, +\code{\link{imexpand.grid}()}, +\code{\link{imslice}()}, +\code{\link{is.im3d}()}, +\code{\link{mask}()}, +\code{\link{origin}()}, +\code{\link{projection}()}, +\code{\link{threshold}()}, +\code{\link{unmask}()}, +\code{\link{voxdims}()} } +\concept{im3d} diff --git a/man/as.mesh3d.Rd b/man/as.mesh3d.Rd index 2e432aaa..adae8182 100644 --- a/man/as.mesh3d.Rd +++ b/man/as.mesh3d.Rd @@ -8,8 +8,7 @@ \usage{ \method{as.mesh3d}{ashape3d}(x, tri_to_keep = 2L, ...) -\method{as.mesh3d}{hxsurf}(x, Regions = NULL, material = NULL, - drop = TRUE, ...) +\method{as.mesh3d}{hxsurf}(x, Regions = NULL, material = NULL, drop = TRUE, ...) } \arguments{ \item{x}{Object to convert to mesh3d} @@ -29,7 +28,7 @@ object} } \value{ 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. } \description{ \code{as.mesh3d.ashape3d} converts an @@ -74,8 +73,12 @@ plot3d(kcs20, col=type, lwd=2) \code{\link[rgl]{as.mesh3d}}, \code{\link[rgl]{tmesh3d}}, \code{\link{as.hxsurf}}, \code{\link{read.hxsurf}} -Other hxsurf: \code{\link{as.hxsurf}}, - \code{\link{materials}}, \code{\link{plot3d.hxsurf}}, - \code{\link{read.hxsurf}}, \code{\link{subset.hxsurf}}, - \code{\link{write.hxsurf}} +Other hxsurf: +\code{\link{as.hxsurf}()}, +\code{\link{materials}()}, +\code{\link{plot3d.hxsurf}()}, +\code{\link{read.hxsurf}()}, +\code{\link{subset.hxsurf}()}, +\code{\link{write.hxsurf}()} } +\concept{hxsurf} diff --git a/man/boundingbox.Rd b/man/boundingbox.Rd index 6efb59f2..9cd8bbe3 100644 --- a/man/boundingbox.Rd +++ b/man/boundingbox.Rd @@ -23,8 +23,7 @@ boundingbox(x, ...) \method{boundingbox}{shape3d}(x, na.rm = FALSE, ...) -\method{boundingbox}{default}(x, dims, input = c("boundingbox", "bounds"), - ...) +\method{boundingbox}{default}(x, dims, input = c("boundingbox", "bounds"), ...) boundingbox(x) <- value } @@ -53,15 +52,13 @@ a \code{matrix} with 2 rows and 3 columns with \code{class='boundingbox'} or \emph{NULL} when missing. } \description{ -Get the bounding box of an im3d volume or other compatible object - \code{boundingbox.list} is designed to be used on objects that contain 3D point information and for which \code{xyzmatrix} is defined. \code{boundingbox.shape3d} is designed to be used on objects that contain 3D point information and inherit from \code{rgl}'s \code{shape3d} class and for which \code{xyzmatrix} is defined. Presently - this applies to \code{\link{mesh3d}} objects. + this applies to \code{\link[rgl]{mesh3d}} objects. Set the bounding box of an im3d object } @@ -76,7 +73,7 @@ The bounding box is defined as the position of the voxels at the two Note that there are two competing definitions for the physical extent of an image that are discussed e.g. - \url{http://teem.sourceforge.net/nrrd/format.html}. The definition that + \url{https://teem.sourceforge.net/nrrd/format.html}. The definition that makes most sense depends largely on whether you think of a pixel as a little square with some defined area (and therefore a voxel as a cube with some defined volume) \emph{or} you take the view that you can only define @@ -97,11 +94,19 @@ boundingbox(Cell07PNs[[1]]) \seealso{ \code{\link{plot3d.boundingbox}} -Other im3d: \code{\link{as.im3d}}, - \code{\link{im3d-coords}}, \code{\link{im3d-io}}, - \code{\link{im3d}}, \code{\link{imexpand.grid}}, - \code{\link{imslice}}, \code{\link{is.im3d}}, - \code{\link{mask}}, \code{\link{origin}}, - \code{\link{projection}}, \code{\link{threshold}}, - \code{\link{unmask}}, \code{\link{voxdims}} +Other im3d: +\code{\link{as.im3d}()}, +\code{\link{im3d}()}, +\code{\link{im3d-coords}}, +\code{\link{im3d-io}}, +\code{\link{imexpand.grid}()}, +\code{\link{imslice}()}, +\code{\link{is.im3d}()}, +\code{\link{mask}()}, +\code{\link{origin}()}, +\code{\link{projection}()}, +\code{\link{threshold}()}, +\code{\link{unmask}()}, +\code{\link{voxdims}()} } +\concept{im3d} diff --git a/man/clampmax.Rd b/man/clampmax.Rd index e68a240a..7f276c98 100644 --- a/man/clampmax.Rd +++ b/man/clampmax.Rd @@ -7,12 +7,12 @@ clampmax(xmin, xmax, replace.infinite = NA_real_) } \arguments{ -\item{xmin, xmax}{clamping range. If xmax is missing xmin should be a vector +\item{xmin, xmax}{clamping range. If xmax is missing xmin should be a vector of length 2.} -\item{replace.infinite}{The value with which to replace non-finite values -\emph{in the input vector}. When code{replace.infinite=FALSE} no action is -taken. The default value of \code{NA} will result in e.g. \code{Inf} being +\item{replace.infinite}{The value with which to replace non-finite values +\emph{in the input vector}. When \code{replace.infinite=FALSE} no action is +taken. The default value of \code{NA} will result in e.g. \code{Inf} being mapped to \code{NA}.} } \value{ @@ -22,7 +22,7 @@ A function with signature \code{f(x, ..., na.rm)} Return function that finds maximum of its inputs within a clamping range } \details{ -Note that by default infinite values in the input vector are +Note that by default infinite values in the input vector are converted to \code{NA}s before the being compared with the clampmax range. } \examples{ diff --git a/man/cmtk.bindir.Rd b/man/cmtk.bindir.Rd index 84bbee66..468cfdbf 100644 --- a/man/cmtk.bindir.Rd +++ b/man/cmtk.bindir.Rd @@ -5,62 +5,67 @@ \alias{cmtk} \title{Return path to directory containing CMTK binaries} \usage{ -cmtk.bindir(firstdir = getOption("nat.cmtk.bindir"), extradirs = c("~/bin", - "/usr/local/lib/cmtk/bin", "/usr/local/bin", "/opt/local/bin", - "/opt/local/lib/cmtk/bin/", "/Applications/IGSRegistrationTools/bin", - "C:\\\\cygwin64\\\\usr\\\\local\\\\lib\\\\cmtk\\\\bin", - "C:\\\\Program Files\\\\CMTK-3.3\\\\CMTK\\\\lib\\\\cmtk\\\\bin"), - set = FALSE, check = FALSE, cmtktool = "gregxform") +cmtk.bindir( + firstdir = getOption("nat.cmtk.bindir"), + extradirs = c("~/bin", "/usr/local/lib/cmtk/bin", "/usr/local/bin", "/opt/local/bin", + "/opt/local/lib/cmtk/bin/", "/Applications/IGSRegistrationTools/bin", + "C:\\\\cygwin64\\\\usr\\\\local\\\\lib\\\\cmtk\\\\bin", + "C:\\\\Program Files\\\\CMTK-3.3\\\\CMTK\\\\lib\\\\cmtk\\\\bin"), + set = FALSE, + check = FALSE, + cmtktool = "gregxform" +) } \arguments{ -\item{firstdir}{Character vector specifying path containing CMTK binaries or +\item{firstdir}{Character vector specifying path containing CMTK binaries or NA (see details). This defaults to options('nat.cmtk.bindir').} \item{extradirs}{Where to look if CMTK is not in \code{firstdir} or the PATH} -\item{set}{Whether to set options('nat.cmtk.bindir') with the found -directory. Also check/sets cygwin path on Windows (see Installation +\item{set}{Whether to set options('nat.cmtk.bindir') with the found +directory. Also check/sets cygwin path on Windows (see Installation section).} \item{check}{Whether to (re)check that a path that has been set appropriately -in options(nat.cmtk.bindir='/some/path') or now found in the PATH or +in options(nat.cmtk.bindir='/some/path') or now found in the PATH or alternative directories. Will throw an error on failure.} -\item{cmtktool}{Name of a specific cmtk tool which will be used to identify +\item{cmtktool}{Name of a specific cmtk tool which will be used to identify the location of all cmtk binaries.} } \value{ -Character vector giving path to CMTK binary directory or NULL when +Character vector giving path to CMTK binary directory or NULL when this cannot be found. } \description{ -The \href{www.nitrc.org/projects/cmtk}{Computational Morphometry - Toolkit} (CMTK) is the default image registration toolkit supported by nat. - An external CMTK installation is required in order to apply CMTK - registrations. This function attempts to locate the full path to the CMTK - executable files and can query and set an option. +The \href{https://www.nitrc.org/projects/cmtk}{Computational + Morphometry Toolkit} (CMTK) is the default image registration toolkit + supported by nat. An external CMTK installation is required in order to + apply CMTK registrations. This function attempts to locate the full path to + the CMTK executable files and can query and set an option. } \details{ -Queries options('nat.cmtk.bindir') if \code{firstdir} is not - specified. If that does not contain the appropriate binaries, it will look - in the system PATH for the \code{cmtk} wrapper script installed by most +Queries options('nat.cmtk.bindir') if \code{firstdir} is not + specified. If that does not contain the appropriate binaries, it will look + in the system PATH for the \code{cmtk} wrapper script installed by most recent cmtk installations. - - Failing that, it will look for the cmtk tool specified by \code{cmtktool}, - first in the path and then a succession of plausible places until it finds - something. Setting \code{options(nat.cmtk.bindir=NA)} or passing - \code{firstdir=NA} will stop the function from trying to locate CMTK, + + Failing that, it will look for the cmtk tool specified by \code{cmtktool}, + first in the path and then a succession of plausible places until it finds + something. Setting \code{options(nat.cmtk.bindir=NA)} or passing + \code{firstdir=NA} will stop the function from trying to locate CMTK, always returning NULL unless \code{check=TRUE}, in which case it will error out. } \section{Installation}{ - It is recommended to install released CMTK versions - available from the \href{www.nitrc.org/projects/cmtk/}{NITRC website}. A - bug in composition of affine transformations from CMTK parameters in the - CMTK versions <2.4 series means that CMTK>=3.0 is strongly recommended. - CMTK v3 registrations are not backwards compatible with CMTK v2, but CMTKv3 - can correctly interpret and convert registrations from earlier versions. - + It is recommended to install released CMTK versions + available from the \href{https://www.nitrc.org/projects/cmtk/}{NITRC + website}. A bug in composition of affine transformations from CMTK + parameters in the CMTK versions <2.4 series means that CMTK>=3.0 is + strongly recommended. CMTK v3 registrations are not backwards compatible + with CMTK v2, but CMTKv3 can correctly interpret and convert registrations + from earlier versions. + On Windows, when \code{set=TRUE}, cmtk.bindir will also check that the cygwin bin directory is in the PATH. If it is not, then it is added for the current R session. This should solve issues with missing cygwin dlls. diff --git a/man/cmtk.call.Rd b/man/cmtk.call.Rd index 1cde8772..9df9731d 100644 --- a/man/cmtk.call.Rd +++ b/man/cmtk.call.Rd @@ -5,8 +5,13 @@ \alias{cmtk.system2} \title{Utility function to create and run calls to CMTK commandline tools} \usage{ -cmtk.call(tool, PROCESSED.ARGS = NULL, ..., FINAL.ARGS = NULL, - RETURN.TYPE = c("string", "list")) +cmtk.call( + tool, + PROCESSED.ARGS = NULL, + ..., + FINAL.ARGS = NULL, + RETURN.TYPE = c("string", "list") +) cmtk.system2(cmtkcall, moreargs = NULL, ...) } @@ -54,7 +59,7 @@ See the help of \code{\link{system2}} for details. \details{ \code{cmtk.call} processes arguments in ... as follows: - \itemize{ + \describe{ \item{argument names}{ will be converted from \code{arg.name} to \code{--arg-name}} diff --git a/man/cmtk.dof2mat.Rd b/man/cmtk.dof2mat.Rd index 320fa604..342effdb 100644 --- a/man/cmtk.dof2mat.Rd +++ b/man/cmtk.dof2mat.Rd @@ -25,9 +25,13 @@ Transpose is true by default since this results in the orientation unless you're sure you know what you're doing! } \seealso{ -Other cmtk-commandline: \code{\link{cmtk.mat2dof}} +Other cmtk-commandline: +\code{\link{cmtk.mat2dof}()} -Other cmtk-geometry: \code{\link{affmat2cmtkparams}}, - \code{\link{cmtk.mat2dof}}, - \code{\link{cmtkparams2affmat}} +Other cmtk-geometry: +\code{\link{affmat2cmtkparams}()}, +\code{\link{cmtk.mat2dof}()}, +\code{\link{cmtkparams2affmat}()} } +\concept{cmtk-commandline} +\concept{cmtk-geometry} diff --git a/man/cmtk.extract_affine.Rd b/man/cmtk.extract_affine.Rd index ec92a0e2..3174da76 100644 --- a/man/cmtk.extract_affine.Rd +++ b/man/cmtk.extract_affine.Rd @@ -21,7 +21,10 @@ Extract affine registration from CMTK registration file or in-memory list \seealso{ \code{\link{cmtkreglist}} -Other cmtk-io: \code{\link{read.cmtkreg}}, - \code{\link{read.cmtk}}, \code{\link{write.cmtkreg}}, - \code{\link{write.cmtk}} +Other cmtk-io: +\code{\link{read.cmtk}()}, +\code{\link{read.cmtkreg}()}, +\code{\link{write.cmtk}()}, +\code{\link{write.cmtkreg}()} } +\concept{cmtk-io} diff --git a/man/cmtk.mat2dof.Rd b/man/cmtk.mat2dof.Rd index 4b8c2e2a..1f920337 100644 --- a/man/cmtk.mat2dof.Rd +++ b/man/cmtk.mat2dof.Rd @@ -4,8 +4,7 @@ \alias{cmtk.mat2dof} \title{Use CMTK mat2dof to convert homogeneous affine matrix into CMTK registration} \usage{ -cmtk.mat2dof(m, f = NULL, centre = NULL, Transpose = TRUE, - version = FALSE) +cmtk.mat2dof(m, f = NULL, centre = NULL, Transpose = TRUE, version = FALSE) } \arguments{ \item{m}{Homogenous affine matrix (4x4) last row 0 0 0 1 etc} @@ -34,9 +33,13 @@ Transpose is true by default since this results in an R matrix with the transpose in the fourth column being correctly interpreted by cmtk. } \seealso{ -Other cmtk-commandline: \code{\link{cmtk.dof2mat}} +Other cmtk-commandline: +\code{\link{cmtk.dof2mat}()} -Other cmtk-geometry: \code{\link{affmat2cmtkparams}}, - \code{\link{cmtk.dof2mat}}, - \code{\link{cmtkparams2affmat}} +Other cmtk-geometry: +\code{\link{affmat2cmtkparams}()}, +\code{\link{cmtk.dof2mat}()}, +\code{\link{cmtkparams2affmat}()} } +\concept{cmtk-commandline} +\concept{cmtk-geometry} diff --git a/man/cmtk.reformatx.Rd b/man/cmtk.reformatx.Rd index a241f00b..bb881842 100644 --- a/man/cmtk.reformatx.Rd +++ b/man/cmtk.reformatx.Rd @@ -4,11 +4,21 @@ \alias{cmtk.reformatx} \title{Reformat an image with a CMTK registration using the reformatx tool} \usage{ -cmtk.reformatx(floating, registrations, output, target, mask = FALSE, - direction = NULL, interpolation = c("linear", "nn", "cubic", "pv", - "sinc-cosine", "sinc-hamming"), dryrun = FALSE, Verbose = TRUE, - MakeLock = TRUE, OverWrite = c("no", "update", "yes"), - filesToIgnoreModTimes = NULL, ...) +cmtk.reformatx( + floating, + registrations, + output, + target, + mask = FALSE, + direction = NULL, + interpolation = c("linear", "nn", "cubic", "pv", "sinc-cosine", "sinc-hamming"), + dryrun = FALSE, + Verbose = TRUE, + MakeLock = TRUE, + OverWrite = c("no", "update", "yes"), + filesToIgnoreModTimes = NULL, + ... +) } \arguments{ \item{floating}{The floating image to be reformatted} @@ -22,14 +32,14 @@ cmtk.reformatx(floating, registrations, output, target, mask = FALSE, \code{im3d} object (or an object that can be coerced to im3d) or a 6-or 9-vector defining a grid in the form Nx,Ny,Nz,dX,dY,dZ,[Ox,Oy,Oz].} -\item{mask}{Whether to treat target as a binary mask (only reformatting +\item{mask}{Whether to treat target as a binary mask (only reformatting positive voxels)} \item{direction}{Whether to transform image from sample space to reference space (called \strong{forward} by CMTK) or from reference to sample space (called \strong{inverse} by CMTK). Default (when \code{NULL} is forward).} -\item{interpolation}{What interpolation scheme to use for output image +\item{interpolation}{What interpolation scheme to use for output image (defaults to linear - see details)} \item{dryrun}{Just print command} @@ -37,32 +47,32 @@ space (called \strong{forward} by CMTK) or from reference to sample space \item{Verbose}{Whether to show cmtk status messages and be verbose about file update checks. Sets command line \code{--verbose} option.} -\item{MakeLock}{Whether to use a lock file to allow simple parallelisation -(see \code{makelock})} +\item{MakeLock}{Whether to use a lock file to allow simple parallelisation +(see \code{\link[nat.utils]{makelock}})} -\item{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.} +\item{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.} -\item{filesToIgnoreModTimes}{Input files whose modification time should not +\item{filesToIgnoreModTimes}{Input files whose modification time should not be checked when determining if new output is required.} -\item{...}{additional arguments passed to CMTK \code{reformatx} after +\item{...}{additional arguments passed to CMTK \code{reformatx} after processing by \code{\link{cmtk.call}}.} } \value{ -the path to the ouput image (whether or not it was re-created afresh) - or \code{NA_character_} if no output was possible. +the path to the output image (whether or not it was re-created + afresh) or \code{NA_character_} if no output was possible. } \description{ 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 unintened consequences. Presently we have - no way of knowing whether an image should be treated as a mask, so the +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 + have no way of knowing whether an image should be treated as a mask, so the \code{interpolation} must be handled manually. } \examples{ @@ -70,11 +80,12 @@ Note that if you are reformatting a mask then you will need to 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)) } } \seealso{ -\code{\link{cmtk.bindir}, \link{cmtk.call}, \link{makelock}, - \link{RunCmdForNewerInput}} +\code{\link{cmtk.bindir}}, \code{\link{cmtk.call}}, + \code{\link[nat.utils]{makelock}}, + \code{\link[nat.utils]{RunCmdForNewerInput}} } diff --git a/man/cmtk.statistics.Rd b/man/cmtk.statistics.Rd index 8bbda055..c7fa9e32 100644 --- a/man/cmtk.statistics.Rd +++ b/man/cmtk.statistics.Rd @@ -4,8 +4,14 @@ \alias{cmtk.statistics} \title{Calculate image statistics for a nrrd or other CMTK compatible file} \usage{ -cmtk.statistics(f, mask, imagetype = c("greyscale", "label"), - masktype = c("label", "binary"), ..., Verbose = FALSE) +cmtk.statistics( + f, + mask, + imagetype = c("greyscale", "label"), + masktype = c("label", "binary"), + ..., + Verbose = FALSE +) } \arguments{ \item{f}{Path to image file (any CMTK compatible format)} diff --git a/man/cmtk.targetvolume.Rd b/man/cmtk.targetvolume.Rd index ded157e3..dacd58f5 100644 --- a/man/cmtk.targetvolume.Rd +++ b/man/cmtk.targetvolume.Rd @@ -27,8 +27,6 @@ a character vector specifying the full cmtk reformatx '--target' or '--target-grid' argument } \description{ -Defines a target volume for a CMTK reformatx operation - \code{cmtk.targetvolume.list} is designed to cope with any user-defined class for which an as.im3d method exists. Presently the only example in the nat.* ecosystem is diff --git a/man/cmtkparams2affmat.Rd b/man/cmtkparams2affmat.Rd index 9213fca9..02733473 100644 --- a/man/cmtkparams2affmat.Rd +++ b/man/cmtkparams2affmat.Rd @@ -4,9 +4,25 @@ \alias{cmtkparams2affmat} \title{Compose homogeneous affine matrix from CMTK registration parameters} \usage{ -cmtkparams2affmat(params = NULL, tx = 0, ty = 0, tz = 0, rx = 0, - ry = 0, rz = 0, sx = 1, sy = 1, sz = 1, shx = 0, shy = 0, - shz = 0, cx = 0, cy = 0, cz = 0, legacy = NA) +cmtkparams2affmat( + params = NULL, + tx = 0, + ty = 0, + tz = 0, + rx = 0, + ry = 0, + rz = 0, + sx = 1, + sy = 1, + sz = 1, + shx = 0, + shy = 0, + shz = 0, + cx = 0, + cy = 0, + cz = 0, + legacy = NA +) } \arguments{ \item{params}{5x3 matrix of CMTK registration parameters or list of length 5.} @@ -39,6 +55,9 @@ translation and centre components are assumed to be in physical coordinates. } \seealso{ -Other cmtk-geometry: \code{\link{affmat2cmtkparams}}, - \code{\link{cmtk.dof2mat}}, \code{\link{cmtk.mat2dof}} +Other cmtk-geometry: +\code{\link{affmat2cmtkparams}()}, +\code{\link{cmtk.dof2mat}()}, +\code{\link{cmtk.mat2dof}()} } +\concept{cmtk-geometry} diff --git a/man/cmtkreg.Rd b/man/cmtkreg.Rd index f954a6f7..67f53f5d 100644 --- a/man/cmtkreg.Rd +++ b/man/cmtkreg.Rd @@ -36,7 +36,7 @@ value in first line of file.} } \description{ \code{cmtkreg} creates an object of class \code{cmtkreg} that - describes one (or more) \href{www.nitrc.org/projects/cmtk/}{CMTK} + describes one (or more) \href{https://www.nitrc.org/projects/cmtk/}{CMTK} registrations. This is simply a character vector that also has class cmtkreg. diff --git a/man/cmtkreglist.Rd b/man/cmtkreglist.Rd index ab880980..f270ef3d 100644 --- a/man/cmtkreglist.Rd +++ b/man/cmtkreglist.Rd @@ -4,8 +4,7 @@ \alias{cmtkreglist} \title{Make in-memory CMTK registration list from affine matrix or CMTK parameters} \usage{ -cmtkreglist(x, centre = c(0, 0, 0), reference = "dummy", - floating = "dummy") +cmtkreglist(x, centre = c(0, 0, 0), reference = "dummy", floating = "dummy") } \arguments{ \item{x}{5x3 matrix of CMTK registration parameters OR 4x4 homogeneous affine diff --git a/man/coord2ind.Rd b/man/coord2ind.Rd index 4ff88e2f..b5a64427 100644 --- a/man/coord2ind.Rd +++ b/man/coord2ind.Rd @@ -7,8 +7,16 @@ \usage{ coord2ind(coords, ...) -\method{coord2ind}{default}(coords, imdims, voxdims = NULL, origin = NULL, - aperm, Clamp = FALSE, CheckRanges = !Clamp, ...) +\method{coord2ind}{default}( + coords, + imdims, + voxdims = NULL, + origin = NULL, + aperm, + Clamp = FALSE, + CheckRanges = !Clamp, + ... +) } \arguments{ \item{coords}{spatial coordinates of image voxels.} diff --git a/man/dotprops.Rd b/man/dotprops.Rd index 9cf57e79..7fef70b5 100644 --- a/man/dotprops.Rd +++ b/man/dotprops.Rd @@ -4,7 +4,6 @@ \alias{dotprops} \alias{is.dotprops} \alias{as.dotprops} -\alias{dotprops} \alias{dotprops.character} \alias{dotprops.dotprops} \alias{dotprops.im3d} @@ -36,7 +35,7 @@ dotprops(x, ...) \item{...}{Additional arguments passed to methods} -\item{k}{Number of nearest neighbours to use for tangent vector calculation +\item{k}{Number of nearest neighbours to use for tangent vector calculation (set to k=20 when passed NULL)} \item{OmitFailures}{Whether to omit neurons for which \code{FUN} gives an @@ -44,9 +43,9 @@ error. The default value (\code{NA}) will result in nlapply stopping with an error message the moment there is an eror. For other values, see details.} -\item{Labels}{Vector of labels for each point e.g. identifying axon vs +\item{Labels}{Vector of labels for each point e.g. identifying axon vs dendrite. The default value \code{NULL} will produce class-specific default -behaviour for different classes of input object, \code{TRUE} always uses +behaviour for different classes of input object, \code{TRUE} always uses labels when an incoming object has them and \code{FALSE} never uses labels.} \item{resample}{When finite, a new length to which all segmented edges will @@ -55,8 +54,6 @@ be resampled. See \code{\link{resample.neuron}}.} \item{na.rm}{Whether to remove \code{NA} points (default FALSE)} } \description{ -dotprops: Neurons as point clouds with tangent vectors (but no connectivity) - \code{dotprops} makes dotprops representation from raw 3D points (extracting vertices from S3 objects that have them) @@ -74,13 +71,13 @@ dotprops: Neurons as point clouds with tangent vectors (but no connectivity) original value of \code{k} is reused). } \references{ -The dotprops format is essentially identical to that developed +The dotprops format is essentially identical to that developed in: - - Masse N.Y., Cachero S., Ostrovsky A., and Jefferis G.S.X.E. (2012). A + + Masse N.Y., Cachero S., Ostrovsky A., and Jefferis G.S.X.E. (2012). A mutual information approach to automate identification of neuronal clusters in \emph{Drosophila} brain images. Frontiers in Neuroinformatics 6 (00021). - \href{http://dx.doi.org/10.3389/fninf.2012.00021}{doi: 10.3389/fninf.2012.00021} + \doi{10.3389/fninf.2012.00021} } \seealso{ \code{\link{nlapply}} diff --git a/man/figures/hex-natverse_logo.png b/man/figures/hex-natverse_logo.png new file mode 100644 index 00000000..3e5b5268 Binary files /dev/null and b/man/figures/hex-natverse_logo.png differ diff --git a/man/figures/logo.svg b/man/figures/logo.svg new file mode 100644 index 00000000..fd0c5886 --- /dev/null +++ b/man/figures/logo.svg @@ -0,0 +1 @@ +Asset 6 \ No newline at end of file diff --git a/man/figures/natverse_logo.svg b/man/figures/natverse_logo.svg new file mode 100644 index 00000000..f7878aac --- /dev/null +++ b/man/figures/natverse_logo.svg @@ -0,0 +1,3 @@ + + + diff --git a/man/fileformats.Rd b/man/fileformats.Rd index b6e48a5a..395ddd3d 100644 --- a/man/fileformats.Rd +++ b/man/fileformats.Rd @@ -7,11 +7,24 @@ \alias{getformatwriter} \title{Set or return list of registered file formats that we can read} \usage{ -fileformats(format = NULL, ext = NULL, read = NULL, write = NULL, - class = NULL, rval = c("names", "info", "all")) +fileformats( + format = NULL, + ext = NULL, + read = NULL, + write = NULL, + class = NULL, + rval = c("names", "info", "all") +) -registerformat(format = NULL, ext = format, read = NULL, write = NULL, - magic = NULL, magiclen = NA_integer_, class = NULL) +registerformat( + format = NULL, + ext = format, + read = NULL, + write = NULL, + magic = NULL, + magiclen = NA_integer_, + class = NULL +) getformatreader(file, class = NULL) @@ -43,7 +56,7 @@ from file header to determine file's type.} according to the value of rval. \item \code{getformatreader} returns a list. The reader can be accessed - with \code{$read} and the format can be acessed by \code{$format}. + with \code{$read} and the format can be accessed by \code{$format}. \item \code{getformatwriter} returns a list. The writer can be accessed with \code{$write}.} @@ -61,7 +74,7 @@ from file header to determine file's type.} } \details{ if a \code{format} argument is passed to \code{fileformats} it will - be matched wigth partial string matching and iif a unique match exists that + be matched with partial string matching and if a unique match exists that will be returned. \code{getformatreader} starts by reading a set number of bytes from diff --git a/man/find.neuron.Rd b/man/find.neuron.Rd index 1d345a75..72517cbb 100644 --- a/man/find.neuron.Rd +++ b/man/find.neuron.Rd @@ -4,35 +4,40 @@ \alias{find.neuron} \title{Find neurons within a 3D selection box (usually drawn in rgl window)} \usage{ -find.neuron(sel3dfun = select3d(), indices = names(db), - db = getOption("nat.default.neuronlist"), threshold = 0, invert = FALSE, - rval = c("names", "data.frame", "neuronlist")) +find.neuron( + sel3dfun = select3d(), + indices = names(db), + db = getOption("nat.default.neuronlist"), + threshold = 0, + invert = FALSE, + rval = c("names", "data.frame", "neuronlist") +) } \arguments{ -\item{sel3dfun}{A \code{\link{select3d}} style function to indicate if points -are within region} +\item{sel3dfun}{A \code{\link[rgl]{select3d}} style function to indicate if +points are within region} \item{indices}{Names of neurons to search (defaults to all neurons in list)} -\item{db}{\code{neuronlist} to search. Can also be a character vector naming +\item{db}{\code{neuronlist} to search. Can also be a character vector naming the neuronlist. Defaults to \code{options('nat.default.neuronlist')}.} \item{threshold}{More than this many points must be present in region} -\item{invert}{Whether to return neurons outside the selection box (default +\item{invert}{Whether to return neurons outside the selection box (default \code{FALSE})} \item{rval}{What to return (character vector, default='names')} } \value{ -Character vector of names of selected neurons, neuronlist, or +Character vector of names of selected neurons, neuronlist, or data.frame of attached metadata according to the value of \code{rval}. } \description{ Find neurons within a 3D selection box (usually drawn in rgl window) } \details{ -Uses \code{\link{subset.neuronlist}}, so can work on dotprops or +Uses \code{\link{subset.neuronlist}}, so can work on dotprops or neuron lists. } \examples{ @@ -44,11 +49,12 @@ find.neuron(db=kcs20) # make a standalone selection function vertical_lobe=select3d() find.neuron(vertical_lobe, db=kcs20) -# use base::Negate function to invert the selection function +# use base::Negate function to invert the selection function # i.e. choose neurons that do not overlap the selection region find.neuron(Negate(vertical_lobe), db=kcs20) } } \seealso{ -\code{\link{select3d}, \link{find.soma}, \link{subset.neuronlist}} +\code{\link[rgl]{select3d}, \link{find.soma}, + \link{subset.neuronlist}} } diff --git a/man/find.soma.Rd b/man/find.soma.Rd index bc8379b3..8480b821 100644 --- a/man/find.soma.Rd +++ b/man/find.soma.Rd @@ -4,20 +4,24 @@ \alias{find.soma} \title{Find neurons with soma inside 3D selection box (usually drawn in rgl window)} \usage{ -find.soma(sel3dfun = select3d(), indices = names(db), - db = getOption("nat.default.neuronlist"), invert = FALSE, - rval = c("names", "neuronlist", "data.frame")) +find.soma( + sel3dfun = select3d(), + indices = names(db), + db = getOption("nat.default.neuronlist"), + invert = FALSE, + rval = c("names", "neuronlist", "data.frame") +) } \arguments{ -\item{sel3dfun}{A \code{\link{select3d}} style function to indicate if points -are within region} +\item{sel3dfun}{A \code{\link[rgl]{select3d}} style function to indicate if +points are within region} \item{indices}{Names of neurons to search (defaults to all neurons in list)} -\item{db}{\code{neuronlist} to search. Can also be a character vector naming +\item{db}{\code{neuronlist} to search. Can also be a character vector naming the neuronlist. Defaults to \code{options('nat.default.neuronlist')}.} -\item{invert}{Whether to return neurons outside the selection box (default +\item{invert}{Whether to return neurons outside the selection box (default \code{FALSE})} \item{rval}{What to return (character vector, default='names')} @@ -29,10 +33,11 @@ Character vector of names of selected neurons Find neurons with soma inside 3D selection box (usually drawn in rgl window) } \details{ -Can work on \code{neuronlist}s containing \code{neuron} objects - \emph{or} \code{neuronlist}s whose attached data.frame contains soma +Can work on \code{neuronlist}s containing \code{neuron} objects + \emph{or} \code{neuronlist}s whose attached data.frame contains soma positions specified in columns called X,Y,Z . } \seealso{ -\code{\link{select3d}, \link{subset.neuronlist}, \link{find.neuron}} +\code{\link[rgl]{select3d}, \link{subset.neuronlist}, + \link{find.neuron}} } diff --git a/man/get-set-neuronlist-data.frame.Rd b/man/get-set-neuronlist-data.frame.Rd index 10bcdf00..608e94ef 100644 --- a/man/get-set-neuronlist-data.frame.Rd +++ b/man/get-set-neuronlist-data.frame.Rd @@ -6,8 +6,7 @@ \alias{data.frame<-.neuronlist} \title{Get or set the attached data.frame of a neuronlist} \usage{ -\method{as.data.frame}{neuronlist}(x, row.names = names(x), - optional = FALSE, ...) +\method{as.data.frame}{neuronlist}(x, row.names = names(x), optional = FALSE, ...) data.frame(x) <- value diff --git a/man/graph.nodes.Rd b/man/graph.nodes.Rd index 0d0aa622..710dd0ec 100644 --- a/man/graph.nodes.Rd +++ b/man/graph.nodes.Rd @@ -4,11 +4,15 @@ \alias{graph.nodes} \title{Return root, end, or branchpoints of an igraph object} \usage{ -graph.nodes(x, type = c("root", "end", "branch"), original.ids = "label", - exclude.isolated = TRUE) +graph.nodes( + x, + type = c("root", "end", "branch"), + original.ids = "label", + exclude.isolated = TRUE +) } \arguments{ -\item{x}{An igraph object} +\item{x}{An \code{\link{ngraph}} or raw \code{\link[igraph]{igraph}} object} \item{type}{one of root, end (which includes root) or branch} @@ -22,5 +26,11 @@ available). Set to FALSE when this is not desired.} Return root, end, or branchpoints of an igraph object } \details{ -Note that the graph must be directed in order to return a root point +This function underlies \code{\link{rootpoints.igraph}} methods and + 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]{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 } diff --git a/man/im3d-coords.Rd b/man/im3d-coords.Rd index 9401ea74..019430c3 100644 --- a/man/im3d-coords.Rd +++ b/man/im3d-coords.Rd @@ -37,11 +37,19 @@ stopifnot(all.equal(ijkpos(d,xyzpos(d,c(1,1,1))), c(1,1,1))) \seealso{ \code{\link{ind2coord}} -Other im3d: \code{\link{as.im3d}}, - \code{\link{boundingbox}}, \code{\link{im3d-io}}, - \code{\link{im3d}}, \code{\link{imexpand.grid}}, - \code{\link{imslice}}, \code{\link{is.im3d}}, - \code{\link{mask}}, \code{\link{origin}}, - \code{\link{projection}}, \code{\link{threshold}}, - \code{\link{unmask}}, \code{\link{voxdims}} +Other im3d: +\code{\link{as.im3d}()}, +\code{\link{boundingbox}()}, +\code{\link{im3d}()}, +\code{\link{im3d-io}}, +\code{\link{imexpand.grid}()}, +\code{\link{imslice}()}, +\code{\link{is.im3d}()}, +\code{\link{mask}()}, +\code{\link{origin}()}, +\code{\link{projection}()}, +\code{\link{threshold}()}, +\code{\link{unmask}()}, +\code{\link{voxdims}()} } +\concept{im3d} diff --git a/man/im3d-io.Rd b/man/im3d-io.Rd index 1408146c..e27f72bf 100644 --- a/man/im3d-io.Rd +++ b/man/im3d-io.Rd @@ -6,8 +6,13 @@ \alias{write.im3d} \title{Read/Write calibrated 3D blocks of image data} \usage{ -read.im3d(file, ReadData = TRUE, SimplifyAttributes = FALSE, - ReadByteAsRaw = FALSE, ...) +read.im3d( + file, + ReadData = TRUE, + SimplifyAttributes = FALSE, + ReadByteAsRaw = FALSE, + ... +) write.im3d(x, file, format = NULL, ...) } @@ -59,11 +64,19 @@ read.im3d("L1DS1_crop_straight.raw", ReadData = F, chan=2) \code{\link{write.nrrd}}, \code{\link{getformatwriter}} -Other im3d: \code{\link{as.im3d}}, - \code{\link{boundingbox}}, \code{\link{im3d-coords}}, - \code{\link{im3d}}, \code{\link{imexpand.grid}}, - \code{\link{imslice}}, \code{\link{is.im3d}}, - \code{\link{mask}}, \code{\link{origin}}, - \code{\link{projection}}, \code{\link{threshold}}, - \code{\link{unmask}}, \code{\link{voxdims}} +Other im3d: +\code{\link{as.im3d}()}, +\code{\link{boundingbox}()}, +\code{\link{im3d}()}, +\code{\link{im3d-coords}}, +\code{\link{imexpand.grid}()}, +\code{\link{imslice}()}, +\code{\link{is.im3d}()}, +\code{\link{mask}()}, +\code{\link{origin}()}, +\code{\link{projection}()}, +\code{\link{threshold}()}, +\code{\link{unmask}()}, +\code{\link{voxdims}()} } +\concept{im3d} diff --git a/man/im3d.Rd b/man/im3d.Rd index 6e6ea4b5..94af605e 100644 --- a/man/im3d.Rd +++ b/man/im3d.Rd @@ -4,24 +4,34 @@ \alias{im3d} \title{Construct an im3d object representing 3D image data, densities etc} \usage{ -im3d(x = numeric(0), dims = NULL, voxdims = NULL, origin = NULL, - BoundingBox = NULL, bounds = NULL, ...) +im3d( + x = numeric(0), + dims = NULL, + voxdims = NULL, + origin = NULL, + BoundingBox = NULL, + bounds = NULL, + ... +) } \arguments{ \item{x}{The object to turn into an im3d} -\item{dims}{The dimensions of the image array either as an integer vector -\emph{or} as an im3d object, whose attributes will provide defaults for -\code{dims, origin, BoundingBox, bounds} arguments. The default -(\code{dims=NULL}) will result in \code{dims} being set to \code{x} if +\item{dims}{The dimensions of the image array either as an integer vector +\emph{or} as an im3d object, whose attributes will provide defaults for +\code{dims, origin, BoundingBox, bounds} arguments. The default +(\code{dims=NULL}) will result in \code{dims} being set to \code{x} if \code{x} is an \code{im3d} object or \code{dim(x)} otherwise.} \item{voxdims}{The voxel dimensions} \item{origin}{the location (or centre) of the first voxel} -\item{BoundingBox, bounds}{Physical extent of image. See the details section -of \code{\link{boundingbox}}'s help for the distinction.} +\item{BoundingBox}{Physical extent of the image. See the details section of +\code{\link{boundingbox}}'s help for the distinction between +\code{BoundingBox} and \code{bounds}.} + +\item{bounds}{Physical extent of image} \item{...}{Additional attributes such as units or materials} } @@ -29,23 +39,31 @@ of \code{\link{boundingbox}}'s help for the distinction.} An array with additional class \code{im3d} } \description{ -\code{im3d} objects consist of a data array with attributes defining the -spatial positions at which the voxels are located. There should always be a -\code{BoundingBox} attribute which defines the physical extent of the volume -in the same manner as the Amira 3D visualisation and analysis software. This -corresponds to the \strong{node} centers option in the -\href{http://teem.sourceforge.net/nrrd/format.html}{NRRD format}. +\code{im3d} objects consist of a data array with attributes defining the +spatial positions at which the voxels are located. There should always be a +\code{BoundingBox} attribute which defines the physical extent of the volume +in the same manner as the Amira 3D visualisation and analysis software. This +corresponds to the \strong{node} centers option in the +\href{https://teem.sourceforge.net/nrrd/format.html}{NRRD format}. } \details{ -We follow Amira's convention of setting the bounding box equal to +We follow Amira's convention of setting the bounding box equal to voxel dimension (rather than 0) for any dimension with only 1 voxel. } \seealso{ -Other im3d: \code{\link{as.im3d}}, - \code{\link{boundingbox}}, \code{\link{im3d-coords}}, - \code{\link{im3d-io}}, \code{\link{imexpand.grid}}, - \code{\link{imslice}}, \code{\link{is.im3d}}, - \code{\link{mask}}, \code{\link{origin}}, - \code{\link{projection}}, \code{\link{threshold}}, - \code{\link{unmask}}, \code{\link{voxdims}} +Other im3d: +\code{\link{as.im3d}()}, +\code{\link{boundingbox}()}, +\code{\link{im3d-coords}}, +\code{\link{im3d-io}}, +\code{\link{imexpand.grid}()}, +\code{\link{imslice}()}, +\code{\link{is.im3d}()}, +\code{\link{mask}()}, +\code{\link{origin}()}, +\code{\link{projection}()}, +\code{\link{threshold}()}, +\code{\link{unmask}()}, +\code{\link{voxdims}()} } +\concept{im3d} diff --git a/man/image.im3d.Rd b/man/image.im3d.Rd index f8b85121..a146171b 100644 --- a/man/image.im3d.Rd +++ b/man/image.im3d.Rd @@ -4,12 +4,25 @@ \alias{image.im3d} \title{Method to plot spatially calibrated image arrays} \usage{ -\method{image}{im3d}(x, xlim = NULL, ylim = NULL, zlim = NULL, - plotdims = NULL, flipdims = "y", filled.contour = FALSE, asp = 1, - axes = FALSE, xlab = NULL, ylab = NULL, nlevels = 20, +\method{image}{im3d}( + x, + xlim = NULL, + ylim = NULL, + zlim = NULL, + plotdims = NULL, + flipdims = "y", + filled.contour = FALSE, + asp = 1, + axes = FALSE, + xlab = NULL, + ylab = NULL, + nlevels = 20, levels = pretty(zlim, nlevels + 1), color.palette = colorRampPalette(c("navy", "cyan", "yellow", "red")), - col = color.palette(length(levels) - 1), useRaster = NULL, ...) + col = color.palette(length(levels) - 1), + useRaster = NULL, + ... +) } \arguments{ \item{x}{The im3d object containing the data to be plotted (\code{NA}s are @@ -64,7 +77,7 @@ function.} \value{ A \code{list} with elements: - \itemize{ + \describe{ \item{zlim}{ The z (intensity limits)} diff --git a/man/imexpand.grid.Rd b/man/imexpand.grid.Rd index f0d01691..0d420e5a 100644 --- a/man/imexpand.grid.Rd +++ b/man/imexpand.grid.Rd @@ -22,11 +22,19 @@ imexpand.grid(d) \seealso{ expand.grid -Other im3d: \code{\link{as.im3d}}, - \code{\link{boundingbox}}, \code{\link{im3d-coords}}, - \code{\link{im3d-io}}, \code{\link{im3d}}, - \code{\link{imslice}}, \code{\link{is.im3d}}, - \code{\link{mask}}, \code{\link{origin}}, - \code{\link{projection}}, \code{\link{threshold}}, - \code{\link{unmask}}, \code{\link{voxdims}} +Other im3d: +\code{\link{as.im3d}()}, +\code{\link{boundingbox}()}, +\code{\link{im3d}()}, +\code{\link{im3d-coords}}, +\code{\link{im3d-io}}, +\code{\link{imslice}()}, +\code{\link{is.im3d}()}, +\code{\link{mask}()}, +\code{\link{origin}()}, +\code{\link{projection}()}, +\code{\link{threshold}()}, +\code{\link{unmask}()}, +\code{\link{voxdims}()} } +\concept{im3d} diff --git a/man/imscalebar.Rd b/man/imscalebar.Rd index 38890824..c0d5b1d2 100644 --- a/man/imscalebar.Rd +++ b/man/imscalebar.Rd @@ -4,8 +4,17 @@ \alias{imscalebar} \title{Make a scalebar to accompany an image.im3d plot} \usage{ -imscalebar(levels, col, nlevels = NULL, zlim = NULL, horizontal = TRUE, - lab = "Density", mar = c(4, 2, 2, 2) + 0.1, border = NULL, ...) +imscalebar( + levels, + col, + nlevels = NULL, + zlim = NULL, + horizontal = TRUE, + lab = "Density", + mar = c(4, 2, 2, 2) + 0.1, + border = NULL, + ... +) } \arguments{ \item{levels}{The levels at which z values were cut \strong{or} a list diff --git a/man/imslice.Rd b/man/imslice.Rd index 5560aed5..76f1aa7e 100644 --- a/man/imslice.Rd +++ b/man/imslice.Rd @@ -25,11 +25,19 @@ Note the sample locations stored in the x,y,z attributes will be updated appropriately. FIXME: Should we also update bounding box? } \seealso{ -Other im3d: \code{\link{as.im3d}}, - \code{\link{boundingbox}}, \code{\link{im3d-coords}}, - \code{\link{im3d-io}}, \code{\link{im3d}}, - \code{\link{imexpand.grid}}, \code{\link{is.im3d}}, - \code{\link{mask}}, \code{\link{origin}}, - \code{\link{projection}}, \code{\link{threshold}}, - \code{\link{unmask}}, \code{\link{voxdims}} +Other im3d: +\code{\link{as.im3d}()}, +\code{\link{boundingbox}()}, +\code{\link{im3d}()}, +\code{\link{im3d-coords}}, +\code{\link{im3d-io}}, +\code{\link{imexpand.grid}()}, +\code{\link{is.im3d}()}, +\code{\link{mask}()}, +\code{\link{origin}()}, +\code{\link{projection}()}, +\code{\link{threshold}()}, +\code{\link{unmask}()}, +\code{\link{voxdims}()} } +\concept{im3d} diff --git a/man/is.amiramesh.Rd b/man/is.amiramesh.Rd index 7735d350..b6ba3da8 100644 --- a/man/is.amiramesh.Rd +++ b/man/is.amiramesh.Rd @@ -24,7 +24,10 @@ Tries to be as fast as possible by reading only first 11 bytes and checking if they equal to "# AmiraMesh" or (deprecated) "# HyperMesh". } \seealso{ -Other amira: \code{\link{amiratype}}, - \code{\link{read.amiramesh}}, \code{\link{read.hxsurf}}, - \code{\link{write.hxsurf}} +Other amira: +\code{\link{amiratype}()}, +\code{\link{read.amiramesh}()}, +\code{\link{read.hxsurf}()}, +\code{\link{write.hxsurf}()} } +\concept{amira} diff --git a/man/is.im3d.Rd b/man/is.im3d.Rd index b3a503ab..b02c4caf 100644 --- a/man/is.im3d.Rd +++ b/man/is.im3d.Rd @@ -16,11 +16,19 @@ logical Test if an object is of class im3d } \seealso{ -Other im3d: \code{\link{as.im3d}}, - \code{\link{boundingbox}}, \code{\link{im3d-coords}}, - \code{\link{im3d-io}}, \code{\link{im3d}}, - \code{\link{imexpand.grid}}, \code{\link{imslice}}, - \code{\link{mask}}, \code{\link{origin}}, - \code{\link{projection}}, \code{\link{threshold}}, - \code{\link{unmask}}, \code{\link{voxdims}} +Other im3d: +\code{\link{as.im3d}()}, +\code{\link{boundingbox}()}, +\code{\link{im3d}()}, +\code{\link{im3d-coords}}, +\code{\link{im3d-io}}, +\code{\link{imexpand.grid}()}, +\code{\link{imslice}()}, +\code{\link{mask}()}, +\code{\link{origin}()}, +\code{\link{projection}()}, +\code{\link{threshold}()}, +\code{\link{unmask}()}, +\code{\link{voxdims}()} } +\concept{im3d} diff --git a/man/is.neuronlist.Rd b/man/is.neuronlist.Rd index 80ab13f4..e8833ca5 100644 --- a/man/is.neuronlist.Rd +++ b/man/is.neuronlist.Rd @@ -20,9 +20,13 @@ Tests if object is a neuronlist. lists of neurons that do not have a class attribute of neuronlist. } \seealso{ -Other neuronlist: \code{\link{*.neuronlist}}, - \code{\link{neuronlist-dataframe-methods}}, - \code{\link{neuronlistfh}}, \code{\link{neuronlist}}, - \code{\link{nlapply}}, \code{\link{read.neurons}}, - \code{\link{write.neurons}} +Other neuronlist: +\code{\link{*.neuronlist}()}, +\code{\link{neuronlist}()}, +\code{\link{neuronlist-dataframe-methods}}, +\code{\link{neuronlistfh}()}, +\code{\link{nlapply}()}, +\code{\link{read.neurons}()}, +\code{\link{write.neurons}()} } +\concept{neuronlist} diff --git a/man/is.nrrd.Rd b/man/is.nrrd.Rd index 6a4b9e98..cc9e576d 100644 --- a/man/is.nrrd.Rd +++ b/man/is.nrrd.Rd @@ -4,8 +4,7 @@ \alias{is.nrrd} \title{Check if a file is a NRRD file} \usage{ -is.nrrd(f = NULL, bytes = NULL, ReturnVersion = FALSE, - TrustSuffix = FALSE) +is.nrrd(f = NULL, bytes = NULL, ReturnVersion = FALSE, TrustSuffix = FALSE) } \arguments{ \item{f}{A character vector specifying the path or a raw vector with at least diff --git a/man/is.vaa3draw.Rd b/man/is.vaa3draw.Rd index 25dbf146..420ecded 100644 --- a/man/is.vaa3draw.Rd +++ b/man/is.vaa3draw.Rd @@ -15,7 +15,7 @@ single file (used in preference to reading file \code{f}).} } \description{ See http://www.vaa3d.org/ - https://svn.janelia.org/penglab/projects/vaa3d/trunk/imagej_io/v3draw_io_imagej/raw_reader.java + https://github.com/Vaa3D/v3d_external/blob/master/imagej_io/v3draw_io_imagej/raw_reader.java } \details{ Note that multiple files can be checked when a character vector of diff --git a/man/kcs20.Rd b/man/kcs20.Rd index a2454c6f..3904f220 100644 --- a/man/kcs20.Rd +++ b/man/kcs20.Rd @@ -5,11 +5,12 @@ \alias{kcs20} \title{List of 20 Kenyon Cells from Chiang et al 2011 converted to dotprops objects} \description{ -This R list (which has additional class \code{neuronlist}) contains 20 -skeletonized \emph{Drosophila} Kenyon cells as \code{dotprops} objects. -Original data is due to Chiang et al. 2011, who have generously shared their -raw data at \url{http://flycircuit.tw}. Image registration and further -processing was carried out by Greg Jefferis. +This R list (which has additional class \code{neuronlist}) contains 20 +skeletonized \emph{Drosophila} Kenyon cells as \code{dotprops} objects. +Original data is due to Chiang et al. 2011, who have generously shared their +raw data \doi{10.1016/j.cub.2010.11.056}. Image registration and further +processing was carried out by Greg Jefferis (see +\doi{10.1016/j.neuron.2016.06.012}). } \examples{ head(kcs20) @@ -21,18 +22,20 @@ plot3d(kcs20, col=type) } } \references{ -[1] Chiang A.S., Lin C.Y., Chuang C.C., Chang H.M., Hsieh C.H., - Yeh C.W., Shih C.T., Wu J.J., Wang G.T., Chen Y.C., Wu C.C., Chen G.Y., - Ching Y.T., Lee P.C., Lin C.Y., Lin H.H., Wu C.C., Hsu H.W., Huang Y.A., - Chen J.Y., et al. (2011). Three-dimensional reconstruction of brain-wide - wiring networks in Drosophila at single-cell resolution. Curr Biol 21 (1), +[1] Chiang A.S., Lin C.Y., Chuang C.C., Chang H.M., Hsieh C.H., + Yeh C.W., Shih C.T., Wu J.J., Wang G.T., Chen Y.C., Wu C.C., Chen G.Y., + Ching Y.T., Lee P.C., Lin C.Y., Lin H.H., Wu C.C., Hsu H.W., Huang Y.A., + Chen J.Y., et al. (2011). Three-dimensional reconstruction of brain-wide + wiring networks in Drosophila at single-cell resolution. Curr Biol 21 (1), 1--11. } \seealso{ -\code{\link{head.neuronlist}}, \code{\link{with.neuronlist}}, +\code{\link{head.neuronlist}}, \code{\link{with.neuronlist}}, \code{\link{plot3d.neuronlist}}, \code{\link{plot3d.dotprops}}, \code{\link{dotprops}} -Other nat-data: \code{\link{Cell07PNs}}, - \code{\link{MBL.surf}} +Other nat-data: +\code{\link{Cell07PNs}}, +\code{\link{MBL.surf}} } +\concept{nat-data} diff --git a/man/mask.Rd b/man/mask.Rd index a5c2fbd1..4afc24c5 100644 --- a/man/mask.Rd +++ b/man/mask.Rd @@ -7,8 +7,7 @@ \usage{ mask(x, ...) -\method{mask}{im3d}(x, mask, levels = NULL, rval = c("im3d", "values"), - invert = FALSE, ...) +\method{mask}{im3d}(x, mask, levels = NULL, rval = c("im3d", "values"), invert = FALSE, ...) } \arguments{ \item{x}{Object to be masked} @@ -48,11 +47,19 @@ image(mask(x, mask=m, levels=1)[,,1]) image(mask(x, mask=m, levels=1:2)[,,1]) } \seealso{ -Other im3d: \code{\link{as.im3d}}, - \code{\link{boundingbox}}, \code{\link{im3d-coords}}, - \code{\link{im3d-io}}, \code{\link{im3d}}, - \code{\link{imexpand.grid}}, \code{\link{imslice}}, - \code{\link{is.im3d}}, \code{\link{origin}}, - \code{\link{projection}}, \code{\link{threshold}}, - \code{\link{unmask}}, \code{\link{voxdims}} +Other im3d: +\code{\link{as.im3d}()}, +\code{\link{boundingbox}()}, +\code{\link{im3d}()}, +\code{\link{im3d-coords}}, +\code{\link{im3d-io}}, +\code{\link{imexpand.grid}()}, +\code{\link{imslice}()}, +\code{\link{is.im3d}()}, +\code{\link{origin}()}, +\code{\link{projection}()}, +\code{\link{threshold}()}, +\code{\link{unmask}()}, +\code{\link{voxdims}()} } +\concept{im3d} diff --git a/man/materials.Rd b/man/materials.Rd index a7968a8e..cc0b9915 100644 --- a/man/materials.Rd +++ b/man/materials.Rd @@ -25,8 +25,6 @@ disk.} A \code{data.frame} with columns \code{name, id, col} } \description{ -Extract or set the materials for an object - \code{materials.character} will read the materials from an im3d compatible image file on disk. @@ -43,8 +41,12 @@ Presently only amiramesh images are supported since they have a key-value pairs according to some ad hoc convention. } \seealso{ -Other hxsurf: \code{\link{as.hxsurf}}, - \code{\link{as.mesh3d}}, \code{\link{plot3d.hxsurf}}, - \code{\link{read.hxsurf}}, \code{\link{subset.hxsurf}}, - \code{\link{write.hxsurf}} +Other hxsurf: +\code{\link{as.hxsurf}()}, +\code{\link{as.mesh3d}()}, +\code{\link{plot3d.hxsurf}()}, +\code{\link{read.hxsurf}()}, +\code{\link{subset.hxsurf}()}, +\code{\link{write.hxsurf}()} } +\concept{hxsurf} diff --git a/man/mirror.Rd b/man/mirror.Rd index db6a2e10..8df2da6f 100644 --- a/man/mirror.Rd +++ b/man/mirror.Rd @@ -9,11 +9,16 @@ \usage{ mirror(x, ...) -\method{mirror}{character}(x, output, mirrorAxisSize = NULL, target = x, - ...) - -\method{mirror}{default}(x, mirrorAxisSize, mirrorAxis = c("X", "Y", "Z"), - warpfile = NULL, transform = c("warp", "affine", "flip"), ...) +\method{mirror}{character}(x, output, mirrorAxisSize = NULL, target = x, ...) + +\method{mirror}{default}( + x, + mirrorAxisSize, + mirrorAxis = c("X", "Y", "Z"), + warpfile = NULL, + transform = c("warp", "affine", "flip"), + ... +) \method{mirror}{neuronlist}(x, subset = NULL, OmitFailures = NA, ...) } diff --git a/man/nat-package.Rd b/man/nat-package.Rd index cff824d9..c6542422 100644 --- a/man/nat-package.Rd +++ b/man/nat-package.Rd @@ -6,174 +6,189 @@ \alias{nat} \title{Analyse 3D biological image data especially neurons} \description{ -\bold{nat} provides tools to read, analyse, plot, transform and convert +\bold{nat} provides tools to read, analyse, plot, transform and convert neuroanatomical data, especially representations of neurons. } \section{Neuron Objects}{ - At present there are 2 main representations of + At present there are 2 main representations of neuronal data: - - \itemize{ - - \item{\code{\link{neuron}}}{ objects contain one or more connected trees + + \describe{ + + \item{\code{\link{neuron}}}{ objects contain one or more connected trees that make up a neuron} - - \item{\code{\link{dotprops}}}{ objects can contain one (or more) neurons - represented as points and tangent vectors in which the connectivity + + \item{\code{\link{dotprops}}}{ objects can contain one (or more) neurons + represented as points and tangent vectors in which the connectivity information has been discarded} - + } - - The \code{subset} function has both \code{\link{subset.neuron}} and - \code{\link{subset.dotprops}} methods, which can be used to keep (or - reject) specified vertices within a neuron e.g. by spatial constraints. - \code{\link{subset.neuron}} will look after the tree structure of neurons + + The \code{subset} function has both \code{\link{subset.neuron}} and + \code{\link{subset.dotprops}} methods, which can be used to keep (or + reject) specified vertices within a neuron e.g. by spatial constraints. + \code{\link{subset.neuron}} will look after the tree structure of neurons in these circumstances. - - \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 - 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}} - function can convert \code{ngraph} objects back to \code{neuron}s or - selected vertex indices can be used to subset a neuron with + + \code{neuron} objects containing connected trees can be converted to + \code{\link{ngraph}} objects, a lightweight wrapper around the + \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}} + function can convert \code{ngraph} objects back to \code{neuron}s or + selected vertex indices can be used to subset a neuron with \code{\link{subset.neuron}}. } \section{Collections of Neurons}{ - Neurons can be collected as - \code{\link{neuronlist}} objects, which contain multiple - \code{\link{neuron}} or \code{dotprops} objects along with an attached - dataframe of metadata. The metadata can be accessed and manipulated using - the \code{myneuronlist[i,j]} notation (see + Neurons can be collected as + \code{\link{neuronlist}} objects, which contain multiple + \code{\link{neuron}} or \code{dotprops} objects along with an attached + dataframe of metadata. The metadata can be accessed and manipulated using + the \code{myneuronlist[i,j]} notation (see \code{\link{neuronlist-dataframe-methods}}). - - Neurons can be read in to a neuronlist using \code{\link{read.neurons}} or - written out using \code{\link{write.neurons}} with support for many of the + + Neurons can be read in to a neuronlist using \code{\link{read.neurons}} or + written out using \code{\link{write.neurons}} with support for many of the most common formats including swc. - - Metadata can be used to colour or subset the neurons during plotting (see - \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 rgl's \code{\link{select3d}} - function. - - \code{neuronlist} objects also provide additional functionality to - streamline arithmetic (e.g. scaling all the points in all neurons see + + Metadata can be used to colour or subset the neurons during plotting (see + \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[rgl]{select3d}} function. + + \code{neuronlist} objects also provide additional functionality to + streamline arithmetic (e.g. scaling all the points in all neurons see \code{\link{*.neuronlist}}) and transformations (see \bold{Transformations} - section below and \code{\link{xform}}). Arbitrary functions can be applied - to each individual neuron can be applied using the \code{\link{nlapply}} - function, which also provides options for progress bars and simple + section below and \code{\link{xform}}). Arbitrary functions can be applied + to each individual neuron can be applied using the \code{\link{nlapply}} + function, which also provides options for progress bars and simple parallelisation. } \section{Transformations}{ - \code{\link{neuron}} or \code{\link{dotprops}} - objects can be transformed from e.g. sample to template brain space using - affine or non-rigid registrations, typically calculated with the open - source CMTK package available at \url{www.nitrc.org/projects/cmtk/}, see - ?\link{cmtk} for installation details. The function \code{\link{xform}} has - methods to deal with a variety of types of interest. + \code{\link{neuron}} or \code{\link{dotprops}} + objects can be transformed from e.g. sample to template brain space using + affine or non-rigid registrations, typically calculated with the open + source CMTK package available at + \url{https://www.nitrc.org/projects/cmtk/}, see ?\link{cmtk} for + installation details. The function \code{\link{xform}} has methods to deal + with a variety of types of interest. } \section{3D Image Data}{ - In addition to data types defined by unstructured - collections of 3D vertices such as \code{\link{neuron}}, - \code{\link{dotprops}} and \code{\link{hxsurf}} objects nat provides the - \code{\link{im3d}} class to handle image/density data on a regular grid. - I/O is handled by \code{\link{read.im3d}} and \code{\link{write.im3d}}, - which are currently implemented for the amiramesh and nrrd file formats; - there is also read only access to the \href{www.vaa3d.org/}{vaa3d} raw - format. - - Spatial information can be queried with \code{\link{voxdims}}, + In addition to data types defined by unstructured + collections of 3D vertices such as \code{\link{neuron}}, + \code{\link{dotprops}} and \code{\link{hxsurf}} objects nat provides the + \code{\link{im3d}} class to handle image/density data on a regular grid. + I/O is handled by \code{\link{read.im3d}} and \code{\link{write.im3d}}, + which are currently implemented for the amiramesh and nrrd file formats; + there is also read only access to the \href{http://www.vaa3d.org/}{vaa3d} + raw format. + + Spatial information can be queried with \code{\link{voxdims}}, \code{\link{boundingbox}} and \code{\link{ijkpos}}, \code{\link{xyzpos}} - methods. You can convert between voxel data and coordinate (vertex) -based + methods. You can convert between voxel data and coordinate (vertex) -based representations using the following functions: - + \itemize{ - - \item \code{\link{as.im3d}} The \code{as.im3d.matrix} method converts XYZ + + \item \code{\link{as.im3d}} The \code{as.im3d.matrix} method converts XYZ coordinates to an \code{im3d} image volume - - \item \code{\link{ind2coord}} Find XYZ coordinates of specified voxels of + + \item \code{\link{ind2coord}} Find XYZ coordinates of specified voxels of an \code{im3d} image volume - - \item \code{\link{dotprops}} The \code{dotprops.im3d} method converts an - \code{im3d} object to a \code{dotprops} format neuron, i.e. a cloud of + + \item \code{\link{dotprops}} The \code{dotprops.im3d} method converts an + \code{im3d} object to a \code{dotprops} format neuron, i.e. a cloud of unconnected segments. - + } } \section{Surface Data}{ - \bold{nat} can read, write, transform and subset - surface (mesh) objects defined by Amira's HxSurface class. See + \bold{nat} can read, write, transform and subset + surface (mesh) objects defined by Amira's HxSurface class. See \code{\link{read.hxsurf}} and links therein. In addition hxsurf objects can be converted to the \code{\link[rgl]{mesh3d}} format, which provides a link - to the \code{\link[rgl]{rgl}} package and also to packages for - morphometrics and sophisticated mesh manipulation such as - \href{https://cran.r-project.org/package=Morpho}{Morpho} and + to the \code{\link[rgl]{rgl}} package and also to packages for + morphometrics and sophisticated mesh manipulation such as + \href{https://cran.r-project.org/package=Morpho}{Morpho} and \href{https://cran.r-project.org/package=Rvcg}{Rvcg}. } \section{rgl Package}{ - \bold{nat} uses the \bold{\code{\link[rgl]{rgl}}} + \bold{nat} uses the \bold{\code{\link[rgl]{rgl}}} package extensively for 3D visualisation. rgl's core function is to provide - interactive visualisation (usually in an X11 window depending on OpenGL - - and therefore on a graphics card or OpenGL software emulator) but recently - significant functionality for static snapshots and embedding results in + interactive visualisation (usually in an X11 window depending on OpenGL - + and therefore on a graphics card or OpenGL software emulator) but recently + significant functionality for static snapshots and embedding results in reports such as web pages has been added. With this in mind, Duncan Murdoch - has added the \code{\link[rgl]{rgl.useNULL}} option. As of nat 1.8.0, - \code{options(rgl.useNULL=TRUE)} will be set before nat is loaded in - non-interactive R sessions. If you want to use nat in interactive - environments where X11 is not available, you may want to set + has added the \code{\link[rgl]{rgl.useNULL}} option. As of nat 1.8.0, + \code{options(rgl.useNULL=TRUE)} will be set before nat is loaded in + non-interactive R sessions. If you want to use nat in interactive + environments where X11 is not available, you may want to set \code{options(rgl.useNULL=TRUE)} manually before loading nat. } \section{File Formats}{ - \bold{nat} supports multiple input and output data - formats for the object classes. There is a registry-based mechanism which - allows support for reading or writing specific file formats (see + \bold{nat} supports multiple input and output data + formats for the object classes. There is a registry-based mechanism which + allows support for reading or writing specific file formats (see \code{\link{fileformats}}) to be plugged in to reasonably generic functions - such as \code{\link{read.neurons}}. It is perfectly possible for other R - packages or end users to extend the supported list of file types by + such as \code{\link{read.neurons}}. It is perfectly possible for other R + packages or end users to extend the supported list of file types by registering new read/write or identification functions. } \section{Package Options}{ The following options can be set to specify default behaviour. - - \itemize{ - - \item{\code{nat.cmtk.bindir}}{ Location of CMTK binaries. See + + \describe{ + + \item{\code{nat.cmtk.bindir}}{ Location of CMTK binaries. See \code{\link{cmtk.bindir}}} - + \item{\code{nat.default.neuronlist}}{ A character string naming a neuronlist to use with the \code{\link{plot3d.character}} method} - - \item{\code{nat.progress}}{ The default progress reporter to use with - \code{\link{nlapply}}. See \code{\link[plyr]{create_progress_bar}} for - possible values. When unset is equivalent to special value \code{'auto'}. + + \item{\code{nat.progress}}{ The default progress reporter to use with + \code{\link{nlapply}}. See \code{\link[plyr]{create_progress_bar}} for + possible values. When unset is equivalent to special value \code{'auto'}. To suppress altogether, use \code{nat.progress="none"}.} - + } - + In addition there is one read-only option: \itemize{ - - \item \code{nat.cmtk.version} which is used to store the current cmtk + + \item \code{nat.cmtk.version} which is used to store the current cmtk version when there are repeated calls to \code{\link{cmtk.version}}. - + } } \seealso{ -\code{\link{neuron}}, \code{\link{dotprops}}, +\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}}. +} +\author{ +\strong{Maintainer}: Gregory Jefferis \email{jefferis@gmail.com} (\href{https://orcid.org/0000-0002-0587-9355}{ORCID}) + +Authors: +\itemize{ + \item James Manton (\href{https://orcid.org/0000-0001-9260-3156}{ORCID}) +} + +Other contributors: +\itemize{ + \item Dominik Krzeminski (\href{https://orcid.org/0000-0003-4568-0583}{ORCID}) [contributor] +} + } \keyword{package} diff --git a/man/ndigest.Rd b/man/ndigest.Rd index 7e8e14e2..3a5817bb 100644 --- a/man/ndigest.Rd +++ b/man/ndigest.Rd @@ -13,14 +13,18 @@ ndigest(x, ...) \method{ndigest}{dotprops}(x, absoluteVectors = TRUE, ...) -\method{ndigest}{neuron}(x, fieldsToExclude = c("InputFileName", "CreatedAt", - "NodeName", "InputFileStat", "InputFileMD5"), ...) +\method{ndigest}{neuron}( + x, + fieldsToExclude = c("InputFileName", "CreatedAt", "NodeName", "InputFileStat", + "InputFileMD5"), + ... +) } \arguments{ \item{x}{Object for which a normalised digest will be computed.} \item{...}{Additional arguments passed to methods and then on to -\code{\link{digest}}} +\code{\link[digest]{digest}}} \item{absoluteVectors}{Whether to check only the absolute value of eigenvectors for equality (default TRUE, see details)} @@ -29,7 +33,7 @@ eigenvectors for equality (default TRUE, see details)} } \value{ A character string containing the digest of the supplied object - computed by \code{\link{digest}}. + computed by \code{\link[digest]{digest}}. } \description{ The \emph{normalised} digest should exclude any fields or @@ -70,7 +74,7 @@ The \emph{normalised} digest should exclude any fields or stopifnot(all.equal(ndigest(kcs20[[1]]), "4c045b0343938259cd9986494fc1c2b0")) } \seealso{ -\code{\link{digest}} +\code{\link[digest]{digest}} \code{\link{all.equal.dotprops}} diff --git a/man/neuron.Rd b/man/neuron.Rd index c63f2634..d639fccf 100644 --- a/man/neuron.Rd +++ b/man/neuron.Rd @@ -10,9 +10,19 @@ \alias{as.neuron.default} \title{neuron: class to represent traced neurons} \usage{ -neuron(d, NumPoints = nrow(d), StartPoint, BranchPoints = integer(), - EndPoints, SegList, SubTrees = NULL, InputFileName = NULL, - NeuronName = NULL, ..., MD5 = TRUE) +neuron( + d, + NumPoints = nrow(d), + StartPoint, + BranchPoints = integer(), + EndPoints, + SegList, + SubTrees = NULL, + InputFileName = NULL, + NeuronName = NULL, + ..., + MD5 = TRUE +) is.neuron(x, Strict = FALSE) @@ -20,8 +30,7 @@ as.neuron(x, ...) \method{as.neuron}{data.frame}(x, ...) -\method{as.neuron}{ngraph}(x, vertexData = NULL, origin = NULL, - Verbose = FALSE, ...) +\method{as.neuron}{ngraph}(x, vertexData = NULL, origin = NULL, Verbose = FALSE, ...) \method{as.neuron}{igraph}(x, ...) @@ -147,13 +156,14 @@ hist(igraph::distances(ngw)) # converting back and forth between neurons and graphs g=as.ngraph(Cell07PNs[[1]]) -gstem=igraph::induced.subgraph(g, 1:10) +gstem=igraph::induced_subgraph(g, 1:10) # this is fine plot(gstem) 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) @@ -162,14 +172,20 @@ gstem2=as.ngraph(ug, root = 10) plot(gstem2) plot(as.neuron(gstem2)) } +} \seealso{ \code{\link{neuronlist}} -\code{\link{graph.dfs}, \link{as.seglist}} - -Other neuron: \code{\link{ngraph}}, - \code{\link{plot.neuron}}, - \code{\link{potential_synapses}}, \code{\link{prune}}, - \code{\link{resample}}, \code{\link{rootpoints}}, - \code{\link{spine}}, \code{\link{subset.neuron}} +\code{\link[igraph]{dfs}, \link{as.seglist}} + +Other neuron: +\code{\link{ngraph}()}, +\code{\link{plot.neuron}()}, +\code{\link{potential_synapses}()}, +\code{\link{prune}()}, +\code{\link{resample}()}, +\code{\link{rootpoints}()}, +\code{\link{spine}()}, +\code{\link{subset.neuron}()} } +\concept{neuron} diff --git a/man/neuronlist-arithmetic.Rd b/man/neuronlist-arithmetic.Rd index 09cbe804..98e5993b 100644 --- a/man/neuronlist-arithmetic.Rd +++ b/man/neuronlist-arithmetic.Rd @@ -32,9 +32,13 @@ TODO Figure out how to document arithemtic functions in one go mn2<-Cell07PNs[1:10]*2 } \seealso{ -Other neuronlist: \code{\link{is.neuronlist}}, - \code{\link{neuronlist-dataframe-methods}}, - \code{\link{neuronlistfh}}, \code{\link{neuronlist}}, - \code{\link{nlapply}}, \code{\link{read.neurons}}, - \code{\link{write.neurons}} +Other neuronlist: +\code{\link{is.neuronlist}()}, +\code{\link{neuronlist}()}, +\code{\link{neuronlist-dataframe-methods}}, +\code{\link{neuronlistfh}()}, +\code{\link{nlapply}()}, +\code{\link{read.neurons}()}, +\code{\link{write.neurons}()} } +\concept{neuronlist} diff --git a/man/neuronlist-dataframe-methods.Rd b/man/neuronlist-dataframe-methods.Rd index 7293dbec..3343b176 100644 --- a/man/neuronlist-dataframe-methods.Rd +++ b/man/neuronlist-dataframe-methods.Rd @@ -4,7 +4,6 @@ \alias{neuronlist-dataframe-methods} \alias{[.neuronlist} \alias{[<-.neuronlist} -\alias{neuronlist-dataframe-methods} \alias{droplevels.neuronlist} \alias{droplevels} \alias{with.neuronlist} @@ -38,12 +37,12 @@ only, empty. Numeric values are coerced to integer as if by lowest possible dimension. The default is to drop if only one column is left, but \bold{not} to drop if only one row is left.} -\item{value}{A suitable replacement value: it will be repeated a whole +\item{value}{a suitable replacement value: it will be repeated a whole number of times if necessary and it may be coerced: see the Coercion section. If \code{NULL}, deletes the column if a single column is selected.} -\item{except}{indices of columns from which \emph{not} to drop levels} +\item{except}{indices of columns from which \emph{not} to drop levels.} \item{...}{Further arguments passed to default methods (and usually ignored)} @@ -113,8 +112,13 @@ colnames(kcs20) \code{\link{tail}} -Other neuronlist: \code{\link{*.neuronlist}}, - \code{\link{is.neuronlist}}, \code{\link{neuronlistfh}}, - \code{\link{neuronlist}}, \code{\link{nlapply}}, - \code{\link{read.neurons}}, \code{\link{write.neurons}} +Other neuronlist: +\code{\link{*.neuronlist}()}, +\code{\link{is.neuronlist}()}, +\code{\link{neuronlist}()}, +\code{\link{neuronlistfh}()}, +\code{\link{nlapply}()}, +\code{\link{read.neurons}()}, +\code{\link{write.neurons}()} } +\concept{neuronlist} diff --git a/man/neuronlist.Rd b/man/neuronlist.Rd index c85fb25e..7798764e 100644 --- a/man/neuronlist.Rd +++ b/man/neuronlist.Rd @@ -45,9 +45,13 @@ methods(class='neuronlist') \code{\link{neuronlist-dataframe-methods}}, \code{\link{neuron}}, \code{\link{dotprops}} -Other neuronlist: \code{\link{*.neuronlist}}, - \code{\link{is.neuronlist}}, - \code{\link{neuronlist-dataframe-methods}}, - \code{\link{neuronlistfh}}, \code{\link{nlapply}}, - \code{\link{read.neurons}}, \code{\link{write.neurons}} +Other neuronlist: +\code{\link{*.neuronlist}()}, +\code{\link{is.neuronlist}()}, +\code{\link{neuronlist-dataframe-methods}}, +\code{\link{neuronlistfh}()}, +\code{\link{nlapply}()}, +\code{\link{read.neurons}()}, +\code{\link{write.neurons}()} } +\concept{neuronlist} diff --git a/man/neuronlistfh.Rd b/man/neuronlistfh.Rd index 1d975674..fad8384f 100644 --- a/man/neuronlistfh.Rd +++ b/man/neuronlistfh.Rd @@ -2,7 +2,6 @@ % Please edit documentation in R/neuronlistfh.R \name{neuronlistfh} \alias{neuronlistfh} -\alias{neuronlistfh} \alias{is.neuronlistfh} \alias{as.neuronlistfh} \alias{as.neuronlistfh.neuronlist} @@ -14,9 +13,15 @@ is.neuronlistfh(nl) as.neuronlistfh(x, df, ...) -\method{as.neuronlistfh}{neuronlist}(x, df = attr(x, "df"), dbdir = NULL, - dbClass = c("RDS", "RDS2"), remote = NULL, WriteObjects = c("yes", "no", - "missing"), ...) +\method{as.neuronlistfh}{neuronlist}( + x, + df = attr(x, "df"), + dbdir = NULL, + dbClass = c("RDS", "RDS2"), + remote = NULL, + WriteObjects = c("yes", "no", "missing"), + ... +) } \arguments{ \item{db}{a \code{filehash} object that manages an on disk database of neuron @@ -94,7 +99,7 @@ a \code{neuronlistfh} object which is a character \code{vector} with neurons e.g. for dynamic report generation using knitr or for users with <8Gb RAM or running 32 bit R. - neuronlistfh objects include: \itemize{ + neuronlistfh objects include: \describe{ \item{attr("keyfilemap")}{ A named character vector that determines the ordering of objects in the neuronlist and translates keys in R to filenames @@ -175,14 +180,20 @@ plot3d(subset(kcs20fh, type=='gamma')) \seealso{ \code{\link[filehash]{filehash-class}} -Other neuronlistfh: \code{\link{[.neuronlistfh}}, - \code{\link{read.neuronlistfh}}, - \code{\link{remotesync}}, - \code{\link{write.neuronlistfh}} - -Other neuronlist: \code{\link{*.neuronlist}}, - \code{\link{is.neuronlist}}, - \code{\link{neuronlist-dataframe-methods}}, - \code{\link{neuronlist}}, \code{\link{nlapply}}, - \code{\link{read.neurons}}, \code{\link{write.neurons}} +Other neuronlistfh: +\code{\link{[.neuronlistfh}()}, +\code{\link{read.neuronlistfh}()}, +\code{\link{remotesync}()}, +\code{\link{write.neuronlistfh}()} + +Other neuronlist: +\code{\link{*.neuronlist}()}, +\code{\link{is.neuronlist}()}, +\code{\link{neuronlist}()}, +\code{\link{neuronlist-dataframe-methods}}, +\code{\link{nlapply}()}, +\code{\link{read.neurons}()}, +\code{\link{write.neurons}()} } +\concept{neuronlist} +\concept{neuronlistfh} diff --git a/man/ngraph.Rd b/man/ngraph.Rd index c191c5eb..ab6d1ad3 100644 --- a/man/ngraph.Rd +++ b/man/ngraph.Rd @@ -7,15 +7,22 @@ \alias{as.ngraph.neuron} \title{ngraph: a graph to encode a neuron's connectivity} \usage{ -ngraph(el, vertexlabels, xyz = NULL, diam = NULL, directed = TRUE, - weights = FALSE, vertex.attributes = NULL, graph.attributes = NULL) +ngraph( + el, + vertexlabels, + xyz = NULL, + diam = NULL, + directed = TRUE, + weights = FALSE, + vertex.attributes = NULL, + graph.attributes = NULL +) as.ngraph(x, ...) \method{as.ngraph}{data.frame}(x, directed = TRUE, ...) -\method{as.ngraph}{neuron}(x, directed = TRUE, method = c("swc", "seglist"), - ...) +\method{as.ngraph}{neuron}(x, directed = TRUE, method = c("swc", "seglist"), ...) } \arguments{ \item{el}{A two columm matrix (start, end) defining edges. \code{start} means @@ -35,10 +42,10 @@ when 4th column is assumed to be diameter)} 3D distance between points should be added to graph (default \code{FALSE}) \emph{or} a numeric vector of weights.} -\item{vertex.attributes, graph.attributes}{List of named attributes to be -added to the graph. The elements of \code{vertex.attributes} must be -vectors whose length is compatible with the number of elements in the -graph. See \code{\link[igraph]{set.vertex.attribute}} for details.} +\item{vertex.attributes, graph.attributes}{List of named attributes to be +added to the graph. The elements of \code{vertex.attributes} must be +vectors whose length is compatible with the number of elements in the +graph. See \code{\link[igraph]{set_vertex_attr}} for details.} \item{x}{Object to convert (see method descriptions)} @@ -108,13 +115,18 @@ library(igraph) all.equal(V(g)$X, Cell07PNs[[1]]$d$X) } \seealso{ -\code{\link{igraph}}, \code{\link[igraph]{set.vertex.attribute}}, +\code{\link[igraph]{igraph}}, \code{\link[igraph]{set_vertex_attr}}, \code{\link{subset.neuron}} for example of graph-based manipulation of a neuron. -Other neuron: \code{\link{neuron}}, - \code{\link{plot.neuron}}, - \code{\link{potential_synapses}}, \code{\link{prune}}, - \code{\link{resample}}, \code{\link{rootpoints}}, - \code{\link{spine}}, \code{\link{subset.neuron}} +Other neuron: +\code{\link{neuron}()}, +\code{\link{plot.neuron}()}, +\code{\link{potential_synapses}()}, +\code{\link{prune}()}, +\code{\link{resample}()}, +\code{\link{rootpoints}()}, +\code{\link{spine}()}, +\code{\link{subset.neuron}()} } +\concept{neuron} diff --git a/man/nlapply.Rd b/man/nlapply.Rd index e022b0f2..620ac389 100644 --- a/man/nlapply.Rd +++ b/man/nlapply.Rd @@ -5,11 +5,25 @@ \alias{nmapply} \title{lapply and mapply for neuronlists (with optional parallelisation)} \usage{ -nlapply(X, FUN, ..., subset = NULL, OmitFailures = NA, - .progress = getOption("nat.progress", default = "auto")) - -nmapply(FUN, X, ..., MoreArgs = NULL, SIMPLIFY = FALSE, USE.NAMES = TRUE, - subset = NULL, OmitFailures = NA) +nlapply( + X, + FUN, + ..., + subset = NULL, + OmitFailures = NA, + .progress = getOption("nat.progress", default = "auto") +) + +nmapply( + FUN, + X, + ..., + MoreArgs = NULL, + SIMPLIFY = FALSE, + USE.NAMES = TRUE, + subset = NULL, + OmitFailures = NA +) } \arguments{ \item{X}{A neuronlist} @@ -38,11 +52,10 @@ examples).} \item{SIMPLIFY}{logical or character string; attempt to reduce the result to a vector, matrix or higher dimensional array; see - the \code{simplify} argument of \code{\link{sapply}}.} + the \code{simplify} argument of \code{\link[base]{sapply}}.} -\item{USE.NAMES}{logical; use names if the first \dots argument has - names, or if it is a character vector, use that character vector as - the names.} +\item{USE.NAMES}{logical; use the names of the first \dots argument, or + if that is an unnamed character vector, use that vector as the names.} } \value{ A neuronlist @@ -100,7 +113,7 @@ kcs.reduced=nlapply(kcs20,function(x) subset(x,sample(nrow(x$points),50))) open3d() plot3d(kcs.reduced,col='red', lwd=2) plot3d(kcs20,col='grey') -rgl.close() +close3d() \dontrun{ # example of using plyr's .inform argument for debugging error conditions @@ -131,7 +144,7 @@ xyzflip=nmapply(mirror, kcs20[1:3], mirrorAxis = c("X","Y","Z"), open3d() plot3d(kcs20[1:3]) plot3d(xyzflip) -rgl.close() +close3d() } \dontrun{ @@ -148,9 +161,13 @@ sl=nlapply(Cell07PNs, FUN = seglengths) \code{\link{mapply}} -Other neuronlist: \code{\link{*.neuronlist}}, - \code{\link{is.neuronlist}}, - \code{\link{neuronlist-dataframe-methods}}, - \code{\link{neuronlistfh}}, \code{\link{neuronlist}}, - \code{\link{read.neurons}}, \code{\link{write.neurons}} +Other neuronlist: +\code{\link{*.neuronlist}()}, +\code{\link{is.neuronlist}()}, +\code{\link{neuronlist}()}, +\code{\link{neuronlist-dataframe-methods}}, +\code{\link{neuronlistfh}()}, +\code{\link{read.neurons}()}, +\code{\link{write.neurons}()} } +\concept{neuronlist} diff --git a/man/nlscan.Rd b/man/nlscan.Rd index 4476af30..a7fdaa0e 100644 --- a/man/nlscan.Rd +++ b/man/nlscan.Rd @@ -4,9 +4,19 @@ \alias{nlscan} \title{Scan through a set of neurons, individually plotting each one in 3D} \usage{ -nlscan(neurons, db = NULL, col = "red", Verbose = T, Wait = T, - sleep = 0.1, extrafun = NULL, selected_file = NULL, - selected_col = "green", yaml = TRUE, ...) +nlscan( + neurons, + db = NULL, + col = "red", + Verbose = T, + Wait = T, + sleep = 0.1, + extrafun = NULL, + selected_file = NULL, + selected_col = "green", + yaml = TRUE, + ... +) } \arguments{ \item{neurons}{a \code{neuronlist} object or a character vector of names of diff --git a/man/nopen3d.Rd b/man/nopen3d.Rd index 877c1303..881eda4a 100644 --- a/man/nopen3d.Rd +++ b/man/nopen3d.Rd @@ -25,5 +25,5 @@ Note that sometimes (parts of) objects seem to disappear after panning and zooming. See help for \code{\link{pan3d}}. } \seealso{ -\code{\link{open3d},\link{pan3d}} +\code{\link[rgl]{open3d},\link{pan3d}} } diff --git a/man/normalise_swc.Rd b/man/normalise_swc.Rd index 7645ec6a..3e408924 100644 --- a/man/normalise_swc.Rd +++ b/man/normalise_swc.Rd @@ -4,11 +4,14 @@ \alias{normalise_swc} \title{Normalise an SWC format block of neuron morphology data} \usage{ -normalise_swc(x, requiredColumns = c("PointNo", "Label", "X", "Y", "Z", "W", - "Parent"), ifMissing = c("usedefaults", "warning", "stop"), - includeExtraCols = TRUE, defaultValue = list(PointNo = seq.int(nrow(x)), - Label = 2L, X = NA_real_, Y = NA_real_, Z = NA_real_, W = NA_real_, Parent = - NA_integer_)) +normalise_swc( + x, + requiredColumns = c("PointNo", "Label", "X", "Y", "Z", "W", "Parent"), + ifMissing = c("usedefaults", "warning", "stop"), + includeExtraCols = TRUE, + defaultValue = list(PointNo = seq.int(nrow(x)), Label = 2L, X = NA_real_, Y = NA_real_, + Z = NA_real_, W = NA_real_, Parent = NA_integer_) +) } \arguments{ \item{x}{A data.frame containing neuron morphology data} @@ -17,14 +20,14 @@ normalise_swc(x, requiredColumns = c("PointNo", "Label", "X", "Y", "Z", "W", \item{ifMissing}{What to do if \code{x} is missing a required column} -\item{includeExtraCols}{Whether to include any extra columns include in -code{x}} +\item{includeExtraCols}{Whether to include any extra columns included in +\code{x}} -\item{defaultValue}{A list containing default values to use for any missing +\item{defaultValue}{A list containing default values to use for any missing columns} } \value{ -A data.frame containing the normalised block of SWC data with +A data.frame containing the normalised block of SWC data with standard columns in standard order. } \description{ diff --git a/man/nvertices.Rd b/man/nvertices.Rd index 0ee92d7b..b367967c 100644 --- a/man/nvertices.Rd +++ b/man/nvertices.Rd @@ -4,6 +4,7 @@ \alias{nvertices} \alias{nvertices.default} \alias{nvertices.neuronlist} +\alias{nvertices.igraph} \title{Find the number of vertices in an object (or each element of a neuronlist)} \usage{ nvertices(x, ...) @@ -11,6 +12,8 @@ nvertices(x, ...) \method{nvertices}{default}(x, ...) \method{nvertices}{neuronlist}(x, ...) + +\method{nvertices}{igraph}(x, ...) } \arguments{ \item{x}{An object with 3d vertices (e.g. neuron, surface etc)} diff --git a/man/nview3d.Rd b/man/nview3d.Rd index 9664feeb..4b3a78ca 100644 --- a/man/nview3d.Rd +++ b/man/nview3d.Rd @@ -4,9 +4,13 @@ \alias{nview3d} \title{Set the 3D viewpoint of an RGL window using anatomical terms} \usage{ -nview3d(viewpoint = c("frontal", "anterior", "dorsal", "ventral", "posterior", - "left", "right", "oblique_right", "oblique_left"), FOV = 0, - extramat = NULL, ...) +nview3d( + viewpoint = c("frontal", "anterior", "dorsal", "ventral", "posterior", "left", "right", + "oblique_right", "oblique_left"), + FOV = 0, + extramat = NULL, + ... +) } \arguments{ \item{viewpoint}{Character vector specifying viewpoint} @@ -35,5 +39,5 @@ nview3d('frontal', extramat=rotationMatrix(pi/10, 1, 1, 0)) } } \seealso{ -\code{\link{nopen3d}}, \code{\link{view3d}} +\code{\link{nopen3d}}, \code{\link[rgl]{view3d}} } diff --git a/man/origin.Rd b/man/origin.Rd index 6ed76b37..69e7b521 100644 --- a/man/origin.Rd +++ b/man/origin.Rd @@ -18,11 +18,19 @@ Defined as the first coordinates (x,y,z) of the bounding box, of the first voxel. } \seealso{ -Other im3d: \code{\link{as.im3d}}, - \code{\link{boundingbox}}, \code{\link{im3d-coords}}, - \code{\link{im3d-io}}, \code{\link{im3d}}, - \code{\link{imexpand.grid}}, \code{\link{imslice}}, - \code{\link{is.im3d}}, \code{\link{mask}}, - \code{\link{projection}}, \code{\link{threshold}}, - \code{\link{unmask}}, \code{\link{voxdims}} +Other im3d: +\code{\link{as.im3d}()}, +\code{\link{boundingbox}()}, +\code{\link{im3d}()}, +\code{\link{im3d-coords}}, +\code{\link{im3d-io}}, +\code{\link{imexpand.grid}()}, +\code{\link{imslice}()}, +\code{\link{is.im3d}()}, +\code{\link{mask}()}, +\code{\link{projection}()}, +\code{\link{threshold}()}, +\code{\link{unmask}()}, +\code{\link{voxdims}()} } +\concept{im3d} diff --git a/man/pan3d.Rd b/man/pan3d.Rd index 9baad130..8efaab5e 100644 --- a/man/pan3d.Rd +++ b/man/pan3d.Rd @@ -17,7 +17,7 @@ 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 +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" } \examples{ @@ -27,7 +27,7 @@ is copied includes a note that "this doesn't play well with rescaling" } } \seealso{ -\code{\link{rgl.setMouseCallbacks}} +\code{\link[rgl]{rgl.setMouseCallbacks}} } \author{ Duncan Murdoch diff --git a/man/plot.neuron.Rd b/man/plot.neuron.Rd index d0c14a6a..559cf250 100644 --- a/man/plot.neuron.Rd +++ b/man/plot.neuron.Rd @@ -4,12 +4,30 @@ \alias{plot.neuron} \title{Plot a 2D projection of a neuron} \usage{ -\method{plot}{neuron}(x, WithLine = TRUE, WithNodes = TRUE, - WithAllPoints = FALSE, WithText = FALSE, PlotSubTrees = TRUE, - soma = FALSE, PlotAxes = c("XY", "YZ", "XZ", "ZY"), axes = TRUE, - asp = 1, main = x$NeuronName, sub = NULL, xlim = NULL, ylim = NULL, - AxisDirections = c(1, -1, 1), add = FALSE, col = NULL, PointAlpha = 1, - tck = NA, lwd = par("lwd"), boundingbox = NULL, ...) +\method{plot}{neuron}( + x, + WithLine = TRUE, + WithNodes = TRUE, + WithAllPoints = FALSE, + WithText = FALSE, + PlotSubTrees = TRUE, + soma = FALSE, + PlotAxes = c("XY", "YZ", "XZ", "ZY"), + axes = TRUE, + asp = 1, + main = x$NeuronName, + sub = NULL, + xlim = NULL, + ylim = NULL, + AxisDirections = c(1, -1, 1), + add = FALSE, + col = NULL, + PointAlpha = 1, + tck = NA, + lwd = par("lwd"), + boundingbox = NULL, + ... +) } \arguments{ \item{x}{a neuron to plot.} @@ -103,8 +121,14 @@ plot(Cell07PNs[[4]], WithNodes=FALSE, soma=1.25) \seealso{ \code{\link{plot3d.neuron}} -Other neuron: \code{\link{neuron}}, \code{\link{ngraph}}, - \code{\link{potential_synapses}}, \code{\link{prune}}, - \code{\link{resample}}, \code{\link{rootpoints}}, - \code{\link{spine}}, \code{\link{subset.neuron}} +Other neuron: +\code{\link{neuron}()}, +\code{\link{ngraph}()}, +\code{\link{potential_synapses}()}, +\code{\link{prune}()}, +\code{\link{resample}()}, +\code{\link{rootpoints}()}, +\code{\link{spine}()}, +\code{\link{subset.neuron}()} } +\concept{neuron} diff --git a/man/plot.neuronlist.Rd b/man/plot.neuronlist.Rd index 2b9f9115..1572f5b5 100644 --- a/man/plot.neuronlist.Rd +++ b/man/plot.neuronlist.Rd @@ -5,8 +5,16 @@ \title{2D plots of the elements in a neuronlist, optionally using a subset expression} \usage{ -\method{plot}{neuronlist}(x, subset = NULL, col = NULL, colpal = rainbow, - add = NULL, boundingbox = NULL, ..., SUBSTITUTE = TRUE) +\method{plot}{neuronlist}( + x, + subset = NULL, + col = NULL, + colpal = rainbow, + add = NULL, + boundingbox = NULL, + ..., + SUBSTITUTE = TRUE +) } \arguments{ \item{x}{a neuron list or, for \code{plot3d.character}, a character vector of diff --git a/man/plot3d.dotprops.Rd b/man/plot3d.dotprops.Rd index c21b33ce..4ca2f86d 100644 --- a/man/plot3d.dotprops.Rd +++ b/man/plot3d.dotprops.Rd @@ -4,9 +4,16 @@ \alias{plot3d.dotprops} \title{3D plots of dotprops objects using rgl package} \usage{ -\method{plot3d}{dotprops}(x, scalevecs = 1, alpharange = NULL, - color = "black", PlotPoints = FALSE, PlotVectors = TRUE, - UseAlpha = FALSE, ...) +\method{plot3d}{dotprops}( + x, + scalevecs = 1, + alpharange = NULL, + color = "black", + PlotPoints = FALSE, + PlotVectors = TRUE, + UseAlpha = FALSE, + ... +) } \arguments{ \item{x}{A dotprops object} diff --git a/man/plot3d.hxsurf.Rd b/man/plot3d.hxsurf.Rd index 6aa1a49a..9db672fc 100644 --- a/man/plot3d.hxsurf.Rd +++ b/man/plot3d.hxsurf.Rd @@ -40,8 +40,12 @@ plot3d(MBL.surf, alpha=0.3, \seealso{ \code{\link{read.hxsurf}} -Other hxsurf: \code{\link{as.hxsurf}}, - \code{\link{as.mesh3d}}, \code{\link{materials}}, - \code{\link{read.hxsurf}}, \code{\link{subset.hxsurf}}, - \code{\link{write.hxsurf}} +Other hxsurf: +\code{\link{as.hxsurf}()}, +\code{\link{as.mesh3d}()}, +\code{\link{materials}()}, +\code{\link{read.hxsurf}()}, +\code{\link{subset.hxsurf}()}, +\code{\link{write.hxsurf}()} } +\concept{hxsurf} diff --git a/man/plot3d.neuron.Rd b/man/plot3d.neuron.Rd index a372acfe..f8291894 100644 --- a/man/plot3d.neuron.Rd +++ b/man/plot3d.neuron.Rd @@ -4,9 +4,19 @@ \alias{plot3d.neuron} \title{Plot neurons in 3D using rgl library} \usage{ -\method{plot3d}{neuron}(x, WithLine = TRUE, NeuronNames = FALSE, - WithNodes = TRUE, WithAllPoints = FALSE, WithText = FALSE, - PlotSubTrees = TRUE, add = TRUE, col = NULL, soma = FALSE, ...) +\method{plot3d}{neuron}( + x, + WithLine = TRUE, + NeuronNames = FALSE, + WithNodes = TRUE, + WithAllPoints = FALSE, + WithText = FALSE, + PlotSubTrees = TRUE, + add = TRUE, + col = NULL, + soma = FALSE, + ... +) } \arguments{ \item{x}{A neuron to plot} @@ -65,7 +75,7 @@ plot3d(Cell07PNs[[2]],col='red',WithText=TRUE,add=FALSE) # include cell bodies plot3d(Cell07PNs[3:4], col='red', soma=TRUE) plot3d(Cell07PNs[5], col='red', soma=3) -rgl.close() +close3d() } } \seealso{ diff --git a/man/plot3d.neuronlist.Rd b/man/plot3d.neuronlist.Rd index b2f309d7..50475695 100644 --- a/man/plot3d.neuronlist.Rd +++ b/man/plot3d.neuronlist.Rd @@ -6,9 +6,17 @@ \title{3D plots of the elements in a neuronlist, optionally using a subset expression} \usage{ -\method{plot3d}{neuronlist}(x, subset = NULL, col = NULL, - colpal = rainbow, skipRedraw = ifelse(interactive(), 200L, TRUE), - WithNodes = FALSE, soma = FALSE, ..., SUBSTITUTE = TRUE) +\method{plot3d}{neuronlist}( + x, + subset = NULL, + col = NULL, + colpal = rainbow, + skipRedraw = ifelse(interactive(), 200L, TRUE), + WithNodes = FALSE, + soma = FALSE, + ..., + SUBSTITUTE = TRUE +) \method{plot3d}{character}(x, db = NULL, ...) } @@ -52,9 +60,6 @@ list of values of \code{plot3d} with subsetted dataframe as attribute \code{'df'} } \description{ -3D plots of the elements in a neuronlist, optionally using a subset -expression - \code{plot3d.character} is a convenience method intended for exploratory work on the command line. } diff --git a/man/pointsinside.Rd b/man/pointsinside.Rd index 354bf3b4..627a7a0f 100644 --- a/man/pointsinside.Rd +++ b/man/pointsinside.Rd @@ -7,8 +7,7 @@ \usage{ pointsinside(x, surf, ...) -\method{pointsinside}{default}(x, surf, ..., rval = c("logical", "distance", - "mesh3d")) +\method{pointsinside}{default}(x, surf, ..., rval = c("logical", "distance", "mesh3d")) } \arguments{ \item{x}{an object with 3D points.} @@ -52,6 +51,7 @@ Note that \code{hxsurf} surface objects will be converted to \code{alphashape3d::\link[alphashape3d]{ashape3d}} (see examples). } \examples{ +\donttest{ # check if the vertices in these neurons are inside the mushroom body calyx # surface object inout=pointsinside(kcs20, surf=subset(MBL.surf, "MB_CA_L")) @@ -61,7 +61,7 @@ table(inout) MBCAL=subset(MBL.surf, "MB_CA_L") inout5=pointsinside(kcs20, surf=MBCAL, rval='distance') > -5 table(inout5) -\donttest{ + # show which points are in or out # Hmm seems like there are a few red points in the vertical lobe # that are well outside the calyx diff --git a/man/potential_synapses.Rd b/man/potential_synapses.Rd index bad2f31f..1b5b9512 100644 --- a/man/potential_synapses.Rd +++ b/man/potential_synapses.Rd @@ -11,11 +11,26 @@ potential_synapses(a, b, s, ...) \method{potential_synapses}{neuronlist}(a, b, s, ...) -\method{potential_synapses}{neuron}(a, b, s, sigma = s, bounds, - method = c("direct", "approx"), ...) +\method{potential_synapses}{neuron}( + a, + b, + s, + sigma = s, + bounds, + method = c("direct", "approx"), + ... +) -\method{potential_synapses}{dotprops}(a, b, s, sigma = s, seglength = 1, - bounds = NULL, method = c("direct", "approx"), ...) +\method{potential_synapses}{dotprops}( + a, + b, + s, + sigma = s, + seglength = 1, + bounds = NULL, + method = c("direct", "approx"), + ... +) } \arguments{ \item{a, b}{neurons or neuronlists} @@ -36,19 +51,19 @@ potential_synapses(a, b, s, ...) This implements the method of Stepanyants and Chklovskii } \details{ -Note that \code{potential_synapses.neuronlist} uses - \code{\link{nlapply}} to process its first argument (\code{a}). This - enables progress bars, robustness to errors and simple parallel execution. - See the \code{\link{nlapply}} examples for further details of these +Note that \code{potential_synapses.neuronlist} uses + \code{\link{nlapply}} to process its first argument (\code{a}). This + enables progress bars, robustness to errors and simple parallel execution. + See the \code{\link{nlapply}} examples for further details of these arguments in action. - - For this reason if you have two neuronlists of unequal sizes, it is + + For this reason if you have two neuronlists of unequal sizes, it is recommended to put the larger one in argument \code{a}. } \examples{ potential_synapses(Cell07PNs[1], Cell07PNs[1:3], s=2) \dontrun{ -# if you have many neurons to calculate you should get a progress bar +# if you have many neurons to calculate you should get a progress bar potential_synapses(Cell07PNs[1:10], Cell07PNs[11:20], s=2) # you can also use parallel execution, here over 7 cores @@ -58,12 +73,18 @@ potential_synapses(Cell07PNs[1:10], Cell07PNs[11:20], s=2, .parallel=TRUE) } \references{ Neurogeometry and potential synaptic connectivity. Stepanyants A, - Chklovskii DB. Trends Neurosci. 2005 Jul;28(7):387-94. - \url{http://dx.doi.org/10.1016/j.tins.2005.05.006} + Chklovskii DB. Trends Neurosci. 2005 Jul;28(7):387-94. + \doi{10.1016/j.tins.2005.05.006} } \seealso{ -Other neuron: \code{\link{neuron}}, \code{\link{ngraph}}, - \code{\link{plot.neuron}}, \code{\link{prune}}, - \code{\link{resample}}, \code{\link{rootpoints}}, - \code{\link{spine}}, \code{\link{subset.neuron}} +Other neuron: +\code{\link{neuron}()}, +\code{\link{ngraph}()}, +\code{\link{plot.neuron}()}, +\code{\link{prune}()}, +\code{\link{resample}()}, +\code{\link{rootpoints}()}, +\code{\link{spine}()}, +\code{\link{subset.neuron}()} } +\concept{neuron} diff --git a/man/projection.Rd b/man/projection.Rd index 2aafb210..6be25f35 100644 --- a/man/projection.Rd +++ b/man/projection.Rd @@ -4,8 +4,14 @@ \alias{projection} \title{Make 2D (orthogonal) projection of 3D image data} \usage{ -projection(a, projdim = "z", projfun = c("integrate", "mean", "sum"), - na.rm = T, mask = NULL, ...) +projection( + a, + projdim = "z", + projfun = c("integrate", "mean", "sum"), + na.rm = T, + mask = NULL, + ... +) } \arguments{ \item{a}{Array of image data (im3d format)} @@ -54,11 +60,19 @@ image(projection(LHMask),asp=TRUE) \seealso{ \code{\link{groupGeneric}}, \code{\link{clampmax}} -Other im3d: \code{\link{as.im3d}}, - \code{\link{boundingbox}}, \code{\link{im3d-coords}}, - \code{\link{im3d-io}}, \code{\link{im3d}}, - \code{\link{imexpand.grid}}, \code{\link{imslice}}, - \code{\link{is.im3d}}, \code{\link{mask}}, - \code{\link{origin}}, \code{\link{threshold}}, - \code{\link{unmask}}, \code{\link{voxdims}} +Other im3d: +\code{\link{as.im3d}()}, +\code{\link{boundingbox}()}, +\code{\link{im3d}()}, +\code{\link{im3d-coords}}, +\code{\link{im3d-io}}, +\code{\link{imexpand.grid}()}, +\code{\link{imslice}()}, +\code{\link{is.im3d}()}, +\code{\link{mask}()}, +\code{\link{origin}()}, +\code{\link{threshold}()}, +\code{\link{unmask}()}, +\code{\link{voxdims}()} } +\concept{im3d} diff --git a/man/prune.Rd b/man/prune.Rd index 7f535cfc..504f4916 100644 --- a/man/prune.Rd +++ b/man/prune.Rd @@ -16,8 +16,7 @@ prune(x, target, ...) \method{prune}{neuronlist}(x, target, ...) -\method{prune}{default}(x, target, maxdist, keep = c("near", "far"), - return.indices = FALSE, ...) +\method{prune}{default}(x, target, maxdist, keep = c("near", "far"), return.indices = FALSE, ...) } \arguments{ \item{x}{The object to prune. (e.g. \code{dotprops} object, see details)} @@ -75,9 +74,14 @@ plot3d(kcs20,col='grey') \code{\link{subset.dotprops}} -Other neuron: \code{\link{neuron}}, \code{\link{ngraph}}, - \code{\link{plot.neuron}}, - \code{\link{potential_synapses}}, \code{\link{resample}}, - \code{\link{rootpoints}}, \code{\link{spine}}, - \code{\link{subset.neuron}} +Other neuron: +\code{\link{neuron}()}, +\code{\link{ngraph}()}, +\code{\link{plot.neuron}()}, +\code{\link{potential_synapses}()}, +\code{\link{resample}()}, +\code{\link{rootpoints}()}, +\code{\link{spine}()}, +\code{\link{subset.neuron}()} } +\concept{neuron} diff --git a/man/read.cmtk.Rd b/man/read.cmtk.Rd index e92eaabf..4b783dec 100644 --- a/man/read.cmtk.Rd +++ b/man/read.cmtk.Rd @@ -27,7 +27,10 @@ Note that if an open connection is passed to read.cmtk the version number of the CMTK TypedStream will not be checked or recorded. } \seealso{ -Other cmtk-io: \code{\link{cmtk.extract_affine}}, - \code{\link{read.cmtkreg}}, \code{\link{write.cmtkreg}}, - \code{\link{write.cmtk}} +Other cmtk-io: +\code{\link{cmtk.extract_affine}()}, +\code{\link{read.cmtkreg}()}, +\code{\link{write.cmtk}()}, +\code{\link{write.cmtkreg}()} } +\concept{cmtk-io} diff --git a/man/read.cmtkreg.Rd b/man/read.cmtkreg.Rd index 595be1db..6cf4e143 100644 --- a/man/read.cmtkreg.Rd +++ b/man/read.cmtkreg.Rd @@ -18,7 +18,10 @@ extract the registration element from the registration file.} Read a CMTK format registration } \seealso{ -Other cmtk-io: \code{\link{cmtk.extract_affine}}, - \code{\link{read.cmtk}}, \code{\link{write.cmtkreg}}, - \code{\link{write.cmtk}} +Other cmtk-io: +\code{\link{cmtk.extract_affine}()}, +\code{\link{read.cmtk}()}, +\code{\link{write.cmtk}()}, +\code{\link{write.cmtkreg}()} } +\concept{cmtk-io} diff --git a/man/read.hxsurf.Rd b/man/read.hxsurf.Rd index 16286364..7327a8bf 100644 --- a/man/read.hxsurf.Rd +++ b/man/read.hxsurf.Rd @@ -5,8 +5,13 @@ \alias{hxsurf} \title{Read Amira surface (aka HxSurface or HyperSurface) files into hxsurf object} \usage{ -read.hxsurf(filename, RegionNames = NULL, RegionChoice = "both", - FallbackRegionCol = "grey", Verbose = FALSE) +read.hxsurf( + filename, + RegionNames = NULL, + RegionChoice = "both", + FallbackRegionCol = "grey", + Verbose = FALSE +) } \arguments{ \item{filename}{Character vector defining path to file} @@ -23,7 +28,7 @@ details.} \item{Verbose}{Print status messages during parsing when \code{TRUE}} } \value{ -A list with S3 class hxsurf with elements \itemize{ +A list with S3 class hxsurf with elements \describe{ \item{Vertices}{ A data.frame with columns \code{X, Y, Z, PointNo}} @@ -68,12 +73,19 @@ read.hxsurf("my.surf", RegionChoice="both") \seealso{ \code{\link{plot3d.hxsurf}, \link{rgb}} -Other amira: \code{\link{amiratype}}, - \code{\link{is.amiramesh}}, \code{\link{read.amiramesh}}, - \code{\link{write.hxsurf}} +Other amira: +\code{\link{amiratype}()}, +\code{\link{is.amiramesh}()}, +\code{\link{read.amiramesh}()}, +\code{\link{write.hxsurf}()} -Other hxsurf: \code{\link{as.hxsurf}}, - \code{\link{as.mesh3d}}, \code{\link{materials}}, - \code{\link{plot3d.hxsurf}}, \code{\link{subset.hxsurf}}, - \code{\link{write.hxsurf}} +Other hxsurf: +\code{\link{as.hxsurf}()}, +\code{\link{as.mesh3d}()}, +\code{\link{materials}()}, +\code{\link{plot3d.hxsurf}()}, +\code{\link{subset.hxsurf}()}, +\code{\link{write.hxsurf}()} } +\concept{amira} +\concept{hxsurf} diff --git a/man/read.landmarks.Rd b/man/read.landmarks.Rd index 9a16d18c..acd7c140 100644 --- a/man/read.landmarks.Rd +++ b/man/read.landmarks.Rd @@ -7,8 +7,15 @@ \usage{ read.landmarks(f, ...) -write.landmarks(x, file, format = "amiralandmarks", ext = NULL, - Force = FALSE, MakeDir = TRUE, ...) +write.landmarks( + x, + file, + format = "amiralandmarks", + ext = NULL, + Force = FALSE, + MakeDir = TRUE, + ... +) } \arguments{ \item{f}{Path to a file (can also be a URL)} @@ -54,7 +61,7 @@ Presently the supported formats are \itemize{ \item CMTK - \item Fiji (see \url{http://fiji.sc/Name_Landmarks_and_Register}) } + \item Fiji (see \url{https://imagej.net/plugins/name-landmarks-and-register}) } See examples section for how to produce a listing of all currently available formats with \code{fileformats}. diff --git a/man/read.morphml.Rd b/man/read.morphml.Rd index 4ed5ba8d..68d308bc 100644 --- a/man/read.morphml.Rd +++ b/man/read.morphml.Rd @@ -42,7 +42,7 @@ NeuroML files consist of an XML tree containing one more or more information, but will probably be more convenient for most purposes. } \references{ -\url{http://www.neuroml.org/specifications} +\url{https://neuroml.org/} } \seealso{ \code{link[XML]{xmlParse}}, \code{\link{read.neuron.neuroml}} diff --git a/man/read.neuron.Rd b/man/read.neuron.Rd index edb1005b..243a0d0d 100644 --- a/man/read.neuron.Rd +++ b/man/read.neuron.Rd @@ -7,14 +7,14 @@ read.neuron(f, format = NULL, class = c("neuron", "ngraph"), ...) } \arguments{ -\item{f}{Path to file. This can be a URL, in which case the file is +\item{f}{Path to file. This can be a URL, in which case the file is downloaded to a temporary location before reading.} -\item{format}{The file format of the neuron. When \code{format=NULL}, the -default, \code{read.neuron} will infer the file format from the extension +\item{format}{The file format of the neuron. When \code{format=NULL}, the +default, \code{read.neuron} will infer the file format from the extension or file header (aka magic) using the \code{fileformats} registry.} -\item{class}{The class of the returned object - presently either +\item{class}{The class of the returned object - presently either \code{"neuron"} or \code{"ngraph"}} \item{...}{additional arguments passed to format-specific readers} @@ -23,32 +23,32 @@ or file header (aka magic) using the \code{fileformats} registry.} Read a single neuron from a file } \details{ -This function will handle \code{neuron} and \code{dotprops} objects - saved in R .rds or .rda format by default. Additional file formats can be +This function will handle \code{neuron} and \code{dotprops} objects + saved in R .rds or .rda format by default. Additional file formats can be registered using \code{fileformats}. - - At the moment the following formats are supported using file readers + + At the moment the following formats are supported using file readers already included with the nat package: \itemize{ - - \item \bold{swc} See \code{\link{read.neuron.swc}}. SWC files can also - return an \code{\link{ngraph}} object containing the neuron structure in a - (permissive) general graph format that also contains the 3D positions for + + \item \bold{swc} See \code{\link{read.neuron.swc}}. SWC files can also + return an \code{\link{ngraph}} object containing the neuron structure in a + (permissive) general graph format that also contains the 3D positions for each vertex. - + \item \bold{neuroml} See \code{\link{read.neuron.neuroml}} - + \item \bold{fijitraces} See \code{\link{read.neuron.fiji}}. The file format - used by the \href{http://fiji.sc/Simple_Neurite_Tracer}{Simple Neurite - Tracer} plugin of Fiji/ImageJ. - - \item \bold{hxlineset,hxskel} Two distinct fileformats used by Amira. - \code{hxlineset} is the generic one, \code{hxskel} is used by the + used by the \href{https://imagej.net/plugins/snt/}{SNT} plugin of + Fiji/ImageJ. + + \item \bold{hxlineset,hxskel} Two distinct fileformats used by Amira. + \code{hxlineset} is the generic one, \code{hxskel} is used by the hxskeletonize extension of Schmitt and Evers (see refs). - - \item \bold{rda,rds} Native R cross-platform binary formats (see - \code{\link{load}, \link{readRDS}}). Note that RDS only contains a single + + \item \bold{rda,rds} Native R cross-platform binary formats (see + \code{\link{load}, \link{readRDS}}). Note that RDS only contains a single unnamed neuron, whereas rda contains one or more named neurons. - + } } \examples{ @@ -64,11 +64,10 @@ fileformats(class='neuron', read=TRUE) } } \references{ -Schmitt, S. and Evers, J. F. and Duch, C. and Scholz, M. and - Obermayer, K. (2004). New methods for the computer-assisted 3-D - reconstruction of neurons from confocal image stacks. Neuroimage 4, - 1283--98. - \href{http://dx.doi.org/10.1016/j.neuroimage.2004.06.047}{doi:10.1016/j.neuroimage.2004.06.047} +Schmitt, S. and Evers, J. F. and Duch, C. and Scholz, M. and + Obermayer, K. (2004). New methods for the computer-assisted 3-D + reconstruction of neurons from confocal image stacks. Neuroimage 4, + 1283--98. \doi{10.1016/j.neuroimage.2004.06.047} } \seealso{ \code{\link{write.neuron}}, \code{\link{read.neurons}}, diff --git a/man/read.neuron.fiji.Rd b/man/read.neuron.fiji.Rd index 8762b3a7..96b49e29 100644 --- a/man/read.neuron.fiji.Rd +++ b/man/read.neuron.fiji.Rd @@ -24,6 +24,6 @@ This is an XML based format so parsing it depends on installation of the suggested XML package. } \references{ -\url{http://fiji.sc/Simple_Neurite_Tracer} - \url{http://fiji.sc/Simple_Neurite_Tracer:_.traces_File_Format} +\url{https://imagej.net/plugins/snt/} + \url{https://imagej.net/plugins/snt/extending} } diff --git a/man/read.neuron.neuroml.Rd b/man/read.neuron.neuroml.Rd index f73b8627..fc9e6b89 100644 --- a/man/read.neuron.neuroml.Rd +++ b/man/read.neuron.neuroml.Rd @@ -23,7 +23,7 @@ When the XML file contains only 1 cell \emph{and} Read one or more neurons from a NeuroML v1 file } \references{ -\url{http://www.neuroml.org/specifications} +\url{https://neuroml.org/} } \seealso{ \code{\link{read.morphml}} diff --git a/man/read.neuron.swc.Rd b/man/read.neuron.swc.Rd index 06b4f979..3414e59e 100644 --- a/man/read.neuron.swc.Rd +++ b/man/read.neuron.swc.Rd @@ -40,7 +40,7 @@ These functions will accept SWC neurons with multiple trees and } \section{SWC Format}{ According to - \url{http://research.mssm.edu/cnic/swc.html} SWC file format has a + \url{http://www.neuronland.org/NLMorphologyConverter/MorphologyFormats/SWC/Spec.html} SWC file format has a radius not a diameter specification } diff --git a/man/read.neuronlistfh.Rd b/man/read.neuronlistfh.Rd index 777ebd2f..f9e229ab 100644 --- a/man/read.neuronlistfh.Rd +++ b/man/read.neuronlistfh.Rd @@ -63,7 +63,10 @@ When reading a remote \code{neuronlistfh} object, it is downloaded neuronlistfh object, an error will result. } \seealso{ -Other neuronlistfh: \code{\link{[.neuronlistfh}}, - \code{\link{neuronlistfh}}, \code{\link{remotesync}}, - \code{\link{write.neuronlistfh}} +Other neuronlistfh: +\code{\link{[.neuronlistfh}()}, +\code{\link{neuronlistfh}()}, +\code{\link{remotesync}()}, +\code{\link{write.neuronlistfh}()} } +\concept{neuronlistfh} diff --git a/man/read.neurons.Rd b/man/read.neurons.Rd index c04254b4..a5e3fdd0 100644 --- a/man/read.neurons.Rd +++ b/man/read.neurons.Rd @@ -4,8 +4,17 @@ \alias{read.neurons} \title{Read one or more neurons from file to a neuronlist in memory} \usage{ -read.neurons(paths, pattern = NULL, neuronnames = basename, format = NULL, - nl = NULL, df = NULL, OmitFailures = TRUE, SortOnUpdate = FALSE, ...) +read.neurons( + paths, + pattern = NULL, + neuronnames = basename, + format = NULL, + nl = NULL, + df = NULL, + OmitFailures = TRUE, + SortOnUpdate = FALSE, + ... +) } \arguments{ \item{paths}{Paths to neuron input files \emph{or} a directory containing @@ -91,9 +100,13 @@ plot3d(vdnl, grepl("P[1-6].app", Lineage)) \code{\link{read.neuron}}, \code{\link{write.neurons}}, \code{\link{fileformats}} -Other neuronlist: \code{\link{*.neuronlist}}, - \code{\link{is.neuronlist}}, - \code{\link{neuronlist-dataframe-methods}}, - \code{\link{neuronlistfh}}, \code{\link{neuronlist}}, - \code{\link{nlapply}}, \code{\link{write.neurons}} +Other neuronlist: +\code{\link{*.neuronlist}()}, +\code{\link{is.neuronlist}()}, +\code{\link{neuronlist}()}, +\code{\link{neuronlist-dataframe-methods}}, +\code{\link{neuronlistfh}()}, +\code{\link{nlapply}()}, +\code{\link{write.neurons}()} } +\concept{neuronlist} diff --git a/man/read.nrrd.Rd b/man/read.nrrd.Rd index da9baa60..bcb61f3b 100644 --- a/man/read.nrrd.Rd +++ b/man/read.nrrd.Rd @@ -5,8 +5,14 @@ \alias{read.nrrd.header} \title{Read nrrd file into an array in memory} \usage{ -read.nrrd(file, origin = NULL, ReadData = TRUE, AttachFullHeader = TRUE, - Verbose = FALSE, ReadByteAsRaw = c("unsigned", "all", "none")) +read.nrrd( + file, + origin = NULL, + ReadData = TRUE, + AttachFullHeader = TRUE, + Verbose = FALSE, + ReadByteAsRaw = c("unsigned", "all", "none") +) read.nrrd.header(file, Verbose = FALSE) } diff --git a/man/remotesync.Rd b/man/remotesync.Rd index b32dda12..479fd927 100644 --- a/man/remotesync.Rd +++ b/man/remotesync.Rd @@ -5,12 +5,23 @@ \alias{remotesync.neuronlistfh} \title{Synchronise a remote object} \usage{ -remotesync(x, remote = attr(x, "remote"), download.missing = TRUE, - delete.extra = FALSE, ...) +remotesync( + x, + remote = attr(x, "remote"), + download.missing = TRUE, + delete.extra = FALSE, + ... +) -\method{remotesync}{neuronlistfh}(x, remote = attr(x, "remote"), - download.missing = FALSE, delete.extra = FALSE, indices = NULL, - update.object = TRUE, ...) +\method{remotesync}{neuronlistfh}( + x, + remote = attr(x, "remote"), + download.missing = FALSE, + delete.extra = FALSE, + indices = NULL, + update.object = TRUE, + ... +) } \arguments{ \item{x}{Object to synchronise with a remote URL} @@ -47,8 +58,10 @@ kcs20=remotesync(kcs20, indices=mbvl_neurons, download.missing=TRUE) } } \seealso{ -Other neuronlistfh: \code{\link{[.neuronlistfh}}, - \code{\link{neuronlistfh}}, - \code{\link{read.neuronlistfh}}, - \code{\link{write.neuronlistfh}} +Other neuronlistfh: +\code{\link{[.neuronlistfh}()}, +\code{\link{neuronlistfh}()}, +\code{\link{read.neuronlistfh}()}, +\code{\link{write.neuronlistfh}()} } +\concept{neuronlistfh} diff --git a/man/resample.Rd b/man/resample.Rd index 2537fb1a..ecadd860 100644 --- a/man/resample.Rd +++ b/man/resample.Rd @@ -30,9 +30,14 @@ resample a neuron with a new spacing \seealso{ \code{\link{approx}}, \code{\link{seglengths}} -Other neuron: \code{\link{neuron}}, \code{\link{ngraph}}, - \code{\link{plot.neuron}}, - \code{\link{potential_synapses}}, \code{\link{prune}}, - \code{\link{rootpoints}}, \code{\link{spine}}, - \code{\link{subset.neuron}} +Other neuron: +\code{\link{neuron}()}, +\code{\link{ngraph}()}, +\code{\link{plot.neuron}()}, +\code{\link{potential_synapses}()}, +\code{\link{prune}()}, +\code{\link{rootpoints}()}, +\code{\link{spine}()}, +\code{\link{subset.neuron}()} } +\concept{neuron} diff --git a/man/rootpoints.Rd b/man/rootpoints.Rd index a66f7688..60e31b8c 100644 --- a/man/rootpoints.Rd +++ b/man/rootpoints.Rd @@ -53,17 +53,20 @@ Integer point number of root/branch point } \description{ A neuron may have multiple subtrees and therefore multiple roots - -Return the branchpoints of a neuron or graph } \details{ \code{branchpoints.neuron} returns a list if more than one subtree is specified } \seealso{ -Other neuron: \code{\link{neuron}}, \code{\link{ngraph}}, - \code{\link{plot.neuron}}, - \code{\link{potential_synapses}}, \code{\link{prune}}, - \code{\link{resample}}, \code{\link{spine}}, - \code{\link{subset.neuron}} +Other neuron: +\code{\link{neuron}()}, +\code{\link{ngraph}()}, +\code{\link{plot.neuron}()}, +\code{\link{potential_synapses}()}, +\code{\link{prune}()}, +\code{\link{resample}()}, +\code{\link{spine}()}, +\code{\link{subset.neuron}()} } +\concept{neuron} diff --git a/man/scale.neuron.Rd b/man/scale.neuron.Rd index 054bc618..2ed205c6 100644 --- a/man/scale.neuron.Rd +++ b/man/scale.neuron.Rd @@ -21,8 +21,6 @@ neuron with scaled coordinates } \description{ -Scale and centre neuron 3D coordinates - note that \code{scale.dotprops} recalculates the tangent vectors after scaling the 3D coords. See \code{\link{dotprops}} for details. } diff --git a/man/seglengths.Rd b/man/seglengths.Rd index 78fd4a4d..8d725e88 100644 --- a/man/seglengths.Rd +++ b/man/seglengths.Rd @@ -16,7 +16,7 @@ multiple subtrees (default: \code{FALSE})} \code{all=TRUE}} \item{sumsegment}{Whether to return the length of each segment (when -{sumsegment=TRUE}, the default) or a list of vectors of lengths of each +\code{sumsegment=TRUE}, the default) or a list of vectors of lengths of each individual edge in the segment.} } \value{ diff --git a/man/seglist.Rd b/man/seglist.Rd index c0600d74..dce33dd1 100644 --- a/man/seglist.Rd +++ b/man/seglist.Rd @@ -66,5 +66,5 @@ sl=seglist(c(1:2),c(2:6)) \seealso{ \code{\link{neuron}} -\code{\link{ngraph},\link{igraph}} +\code{\link{ngraph},\link[igraph]{igraph}} } diff --git a/man/segmentgraph.Rd b/man/segmentgraph.Rd index 0bb6467f..f5115a4b 100644 --- a/man/segmentgraph.Rd +++ b/man/segmentgraph.Rd @@ -4,8 +4,14 @@ \alias{segmentgraph} \title{Return a simplified segment graph for a neuron} \usage{ -segmentgraph(x, weights = TRUE, segids = FALSE, exclude.isolated = FALSE, - include.xyz = FALSE, reverse.edges = FALSE) +segmentgraph( + x, + weights = TRUE, + segids = FALSE, + exclude.isolated = FALSE, + include.xyz = FALSE, + reverse.edges = FALSE +) } \arguments{ \item{x}{neuron} diff --git a/man/spine.Rd b/man/spine.Rd index 73f016f1..55e7f3a8 100644 --- a/man/spine.Rd +++ b/man/spine.Rd @@ -4,8 +4,13 @@ \alias{spine} \title{Compute the longest path (aka spine or backbone) of a neuron} \usage{ -spine(n, UseStartPoint = FALSE, SpatialWeights = TRUE, invert = FALSE, - rval = c("neuron", "length", "ids")) +spine( + n, + UseStartPoint = FALSE, + SpatialWeights = TRUE, + invert = FALSE, + rval = c("neuron", "length", "ids") +) } \arguments{ \item{n}{the neuron to consider.} @@ -57,14 +62,19 @@ plot3d(antispine, lwd=4, col='red') } \seealso{ -\code{\link[igraph]{diameter}}, - \code{\link[igraph]{shortest.paths}}, \code{\link{prune_strahler}} for - removing lower order branches from a neuron, \code{\link{prune}} for +\code{\link[igraph]{diameter}}, + \code{\link[igraph]{distances}}, \code{\link{prune_strahler}} for + removing lower order branches from a neuron, \code{\link{prune}} for removing parts of a neuron by spatial criteria. -Other neuron: \code{\link{neuron}}, \code{\link{ngraph}}, - \code{\link{plot.neuron}}, - \code{\link{potential_synapses}}, \code{\link{prune}}, - \code{\link{resample}}, \code{\link{rootpoints}}, - \code{\link{subset.neuron}} +Other neuron: +\code{\link{neuron}()}, +\code{\link{ngraph}()}, +\code{\link{plot.neuron}()}, +\code{\link{potential_synapses}()}, +\code{\link{prune}()}, +\code{\link{resample}()}, +\code{\link{rootpoints}()}, +\code{\link{subset.neuron}()} } +\concept{neuron} diff --git a/man/sub-.neuronlistfh.Rd b/man/sub-.neuronlistfh.Rd index 7ee2c021..3dbab2fa 100644 --- a/man/sub-.neuronlistfh.Rd +++ b/man/sub-.neuronlistfh.Rd @@ -55,8 +55,10 @@ unlink(tf, recursive=TRUE) \code{\link{neuronlistfh}}, \code{\link{[.neuronlist}}, \code{\link{[.data.frame}}, \code{\link{[<-.data.frame}}, -Other neuronlistfh: \code{\link{neuronlistfh}}, - \code{\link{read.neuronlistfh}}, - \code{\link{remotesync}}, - \code{\link{write.neuronlistfh}} +Other neuronlistfh: +\code{\link{neuronlistfh}()}, +\code{\link{read.neuronlistfh}()}, +\code{\link{remotesync}()}, +\code{\link{write.neuronlistfh}()} } +\concept{neuronlistfh} diff --git a/man/subset.hxsurf.Rd b/man/subset.hxsurf.Rd index 6691fe78..f02b8f7a 100644 --- a/man/subset.hxsurf.Rd +++ b/man/subset.hxsurf.Rd @@ -4,8 +4,7 @@ \alias{subset.hxsurf} \title{Subset hxsurf object to specified regions} \usage{ -\method{subset}{hxsurf}(x, subset = NULL, drop = TRUE, rval = c("hxsurf", - "names"), ...) +\method{subset}{hxsurf}(x, subset = NULL, drop = TRUE, rval = c("hxsurf", "names"), ...) } \arguments{ \item{x}{A dotprops object} @@ -40,8 +39,12 @@ plot3d(MBL.surf, "VL", alpha=0.3) } } \seealso{ -Other hxsurf: \code{\link{as.hxsurf}}, - \code{\link{as.mesh3d}}, \code{\link{materials}}, - \code{\link{plot3d.hxsurf}}, \code{\link{read.hxsurf}}, - \code{\link{write.hxsurf}} +Other hxsurf: +\code{\link{as.hxsurf}()}, +\code{\link{as.mesh3d}()}, +\code{\link{materials}()}, +\code{\link{plot3d.hxsurf}()}, +\code{\link{read.hxsurf}()}, +\code{\link{write.hxsurf}()} } +\concept{hxsurf} diff --git a/man/subset.neuron.Rd b/man/subset.neuron.Rd index 2e9eefb5..d5b832d2 100644 --- a/man/subset.neuron.Rd +++ b/man/subset.neuron.Rd @@ -62,9 +62,9 @@ points(t(xyzmatrix(n)[n$AxonLHEP, 1:2]), pch=19, cex=2.5) # now find the points downstream (distal) of that with respect to the root ng=as.ngraph(n) -# use a depth first search -distal_points=igraph::graph.dfs(ng, root=n$AxonLHEP, unreachable=FALSE, - neimode='out')$order +# use a depth first search +distal_points=igraph::dfs(ng, root=n$AxonLHEP, unreachable=FALSE, + mode='out')$order distal_tree=subset(n, distal_points) plot(distal_tree, add=TRUE, col='red', lwd=2) @@ -112,9 +112,14 @@ plot3d(y, col='red', lwd=2) \code{\link{prune.neuron}}, \code{\link{prune_vertices}}, \code{\link{subset.dotprops}} -Other neuron: \code{\link{neuron}}, \code{\link{ngraph}}, - \code{\link{plot.neuron}}, - \code{\link{potential_synapses}}, \code{\link{prune}}, - \code{\link{resample}}, \code{\link{rootpoints}}, - \code{\link{spine}} +Other neuron: +\code{\link{neuron}()}, +\code{\link{ngraph}()}, +\code{\link{plot.neuron}()}, +\code{\link{potential_synapses}()}, +\code{\link{prune}()}, +\code{\link{resample}()}, +\code{\link{rootpoints}()}, +\code{\link{spine}()} } +\concept{neuron} diff --git a/man/subset.neuronlist.Rd b/man/subset.neuronlist.Rd index de142a88..b8eb41b3 100644 --- a/man/subset.neuronlist.Rd +++ b/man/subset.neuronlist.Rd @@ -4,8 +4,13 @@ \alias{subset.neuronlist} \title{Subset neuronlist returning either new neuronlist or names of chosen neurons} \usage{ -\method{subset}{neuronlist}(x, subset, filterfun, rval = c("neuronlist", - "names", "data.frame"), ...) +\method{subset}{neuronlist}( + x, + subset, + filterfun, + rval = c("neuronlist", "names", "data.frame"), + ... +) } \arguments{ \item{x}{a neuronlist} diff --git a/man/summary.neuron.Rd b/man/summary.neuron.Rd index eeb27bdd..45475f7f 100644 --- a/man/summary.neuron.Rd +++ b/man/summary.neuron.Rd @@ -29,17 +29,17 @@ length estimate can be made.} A \code{data.frame} summarising the tree properties of the neuron with columns \itemize{ - \item{root} + \item root - \item{nodes} + \item nodes - \item{segments} + \item segments - \item{branchpoints} + \item branchpoints - \item{endpoints} + \item endpoints - \item{cable.length} + \item cable.length } } diff --git a/man/threshold.Rd b/man/threshold.Rd index a1942cac..25200d35 100644 --- a/man/threshold.Rd +++ b/man/threshold.Rd @@ -7,8 +7,12 @@ \usage{ threshold(x, ...) -\method{threshold}{im3d}(x, threshold = 0, mode = c("logical", "integer", - "raw", "numeric"), ...) +\method{threshold}{im3d}( + x, + threshold = 0, + mode = c("logical", "integer", "raw", "numeric"), + ... +) } \arguments{ \item{x}{Object to be thresholded} @@ -39,11 +43,19 @@ x=im3d(rnorm(1000),dims=c(10,10,10), BoundingBox=c(20,200,100,200,200,300)) stopifnot(all.equal(threshold(x, 0), threshold(x, x>0))) } \seealso{ -Other im3d: \code{\link{as.im3d}}, - \code{\link{boundingbox}}, \code{\link{im3d-coords}}, - \code{\link{im3d-io}}, \code{\link{im3d}}, - \code{\link{imexpand.grid}}, \code{\link{imslice}}, - \code{\link{is.im3d}}, \code{\link{mask}}, - \code{\link{origin}}, \code{\link{projection}}, - \code{\link{unmask}}, \code{\link{voxdims}} +Other im3d: +\code{\link{as.im3d}()}, +\code{\link{boundingbox}()}, +\code{\link{im3d}()}, +\code{\link{im3d-coords}}, +\code{\link{im3d-io}}, +\code{\link{imexpand.grid}()}, +\code{\link{imslice}()}, +\code{\link{is.im3d}()}, +\code{\link{mask}()}, +\code{\link{origin}()}, +\code{\link{projection}()}, +\code{\link{unmask}()}, +\code{\link{voxdims}()} } +\concept{im3d} diff --git a/man/unmask.Rd b/man/unmask.Rd index 8953995a..a8d131ab 100644 --- a/man/unmask.Rd +++ b/man/unmask.Rd @@ -4,8 +4,13 @@ \alias{unmask} \title{Make im3d image array containing values at locations defined by a mask} \usage{ -unmask(x, mask, default = NA, attributes. = attributes(mask), - copyAttributes = TRUE) +unmask( + x, + mask, + default = NA, + attributes. = attributes(mask), + copyAttributes = TRUE +) } \arguments{ \item{x}{the data to place on a regular grid} @@ -49,11 +54,19 @@ image(imslice(stripes,11), asp=TRUE) } } \seealso{ -Other im3d: \code{\link{as.im3d}}, - \code{\link{boundingbox}}, \code{\link{im3d-coords}}, - \code{\link{im3d-io}}, \code{\link{im3d}}, - \code{\link{imexpand.grid}}, \code{\link{imslice}}, - \code{\link{is.im3d}}, \code{\link{mask}}, - \code{\link{origin}}, \code{\link{projection}}, - \code{\link{threshold}}, \code{\link{voxdims}} +Other im3d: +\code{\link{as.im3d}()}, +\code{\link{boundingbox}()}, +\code{\link{im3d}()}, +\code{\link{im3d-coords}}, +\code{\link{im3d-io}}, +\code{\link{imexpand.grid}()}, +\code{\link{imslice}()}, +\code{\link{is.im3d}()}, +\code{\link{mask}()}, +\code{\link{origin}()}, +\code{\link{projection}()}, +\code{\link{threshold}()}, +\code{\link{voxdims}()} } +\concept{im3d} diff --git a/man/voxdims.Rd b/man/voxdims.Rd index cf71199f..06f28f2b 100644 --- a/man/voxdims.Rd +++ b/man/voxdims.Rd @@ -38,11 +38,19 @@ We follow Amira's convention of returning a voxel dimension equal to \seealso{ \code{\link{boundingbox}} -Other im3d: \code{\link{as.im3d}}, - \code{\link{boundingbox}}, \code{\link{im3d-coords}}, - \code{\link{im3d-io}}, \code{\link{im3d}}, - \code{\link{imexpand.grid}}, \code{\link{imslice}}, - \code{\link{is.im3d}}, \code{\link{mask}}, - \code{\link{origin}}, \code{\link{projection}}, - \code{\link{threshold}}, \code{\link{unmask}} +Other im3d: +\code{\link{as.im3d}()}, +\code{\link{boundingbox}()}, +\code{\link{im3d}()}, +\code{\link{im3d-coords}}, +\code{\link{im3d-io}}, +\code{\link{imexpand.grid}()}, +\code{\link{imslice}()}, +\code{\link{is.im3d}()}, +\code{\link{mask}()}, +\code{\link{origin}()}, +\code{\link{projection}()}, +\code{\link{threshold}()}, +\code{\link{unmask}()} } +\concept{im3d} diff --git a/man/write.amiramesh.Rd b/man/write.amiramesh.Rd index 2d6660bd..521bf6f7 100644 --- a/man/write.amiramesh.Rd +++ b/man/write.amiramesh.Rd @@ -4,9 +4,14 @@ \alias{write.amiramesh} \title{Write a 3D data object to an amiramesh format file} \usage{ -write.amiramesh(x, file, enc = c("binary", "raw", "text", "hxzip"), +write.amiramesh( + x, + file, + enc = c("binary", "raw", "text", "hxzip"), dtype = c("float", "byte", "short", "ushort", "int", "double"), - endian = .Platform$endian, WriteNrrdHeader = FALSE) + endian = .Platform$endian, + WriteNrrdHeader = FALSE +) } \arguments{ \item{x}{The image data to write (an im3d, or capable of being interpreted as diff --git a/man/write.cmtk.Rd b/man/write.cmtk.Rd index add0b9bf..a882291b 100644 --- a/man/write.cmtk.Rd +++ b/man/write.cmtk.Rd @@ -26,7 +26,10 @@ NB a version specified on the command line overrides one encoded as an attribute in the input list. } \seealso{ -Other cmtk-io: \code{\link{cmtk.extract_affine}}, - \code{\link{read.cmtkreg}}, \code{\link{read.cmtk}}, - \code{\link{write.cmtkreg}} +Other cmtk-io: +\code{\link{cmtk.extract_affine}()}, +\code{\link{read.cmtk}()}, +\code{\link{read.cmtkreg}()}, +\code{\link{write.cmtkreg}()} } +\concept{cmtk-io} diff --git a/man/write.cmtkreg.Rd b/man/write.cmtkreg.Rd index 957c6a70..c642d9a9 100644 --- a/man/write.cmtkreg.Rd +++ b/man/write.cmtkreg.Rd @@ -11,14 +11,15 @@ write.cmtkreg(reglist, foldername, version = "2.4") \item{foldername}{Path to registration folder (usually ending in .list)} -\item{version}{CMTK version for registration (default 2.4)} +\item{version}{CMTK version for registration (default 2.4). Will be converted +to character vector if not already.} } \description{ Write out CMTK registration list to folder } \details{ Note that transformation in the forward direction (i.e. sample->ref) - e.g. as calculated from a set of landmarks where set 1 is the sample is + e.g. as calculated from a set of landmarks where set 1 is the sample is considered an inverse transformation by the IGS software. So in order to use such a transformation as an initial affine with the registration command the switch --initial-inverse must be used specifying the folder @@ -31,7 +32,10 @@ CMTK v2.4 fixed a long-standing bug in affine (de)composition to by default. } \seealso{ -Other cmtk-io: \code{\link{cmtk.extract_affine}}, - \code{\link{read.cmtkreg}}, \code{\link{read.cmtk}}, - \code{\link{write.cmtk}} +Other cmtk-io: +\code{\link{cmtk.extract_affine}()}, +\code{\link{read.cmtk}()}, +\code{\link{read.cmtkreg}()}, +\code{\link{write.cmtk}()} } +\concept{cmtk-io} diff --git a/man/write.hxsurf.Rd b/man/write.hxsurf.Rd index 0aafd154..23bf8784 100644 --- a/man/write.hxsurf.Rd +++ b/man/write.hxsurf.Rd @@ -20,12 +20,19 @@ Write Amira surface (aka HxSurface or HyperSurface) into .surf file. \seealso{ \code{\link{plot3d.hxsurf}},\code{\link{read.hxsurf}}, \code{\link{rgb}} -Other amira: \code{\link{amiratype}}, - \code{\link{is.amiramesh}}, \code{\link{read.amiramesh}}, - \code{\link{read.hxsurf}} +Other amira: +\code{\link{amiratype}()}, +\code{\link{is.amiramesh}()}, +\code{\link{read.amiramesh}()}, +\code{\link{read.hxsurf}()} -Other hxsurf: \code{\link{as.hxsurf}}, - \code{\link{as.mesh3d}}, \code{\link{materials}}, - \code{\link{plot3d.hxsurf}}, \code{\link{read.hxsurf}}, - \code{\link{subset.hxsurf}} +Other hxsurf: +\code{\link{as.hxsurf}()}, +\code{\link{as.mesh3d}()}, +\code{\link{materials}()}, +\code{\link{plot3d.hxsurf}()}, +\code{\link{read.hxsurf}()}, +\code{\link{subset.hxsurf}()} } +\concept{amira} +\concept{hxsurf} diff --git a/man/write.neuron.Rd b/man/write.neuron.Rd index 0575d41a..8a722855 100644 --- a/man/write.neuron.Rd +++ b/man/write.neuron.Rd @@ -4,8 +4,16 @@ \alias{write.neuron} \title{Write out a neuron in any of the file formats we know about} \usage{ -write.neuron(n, file = NULL, dir = NULL, format = NULL, ext = NULL, - Force = FALSE, MakeDir = TRUE, ...) +write.neuron( + n, + file = NULL, + dir = NULL, + format = NULL, + ext = NULL, + Force = FALSE, + MakeDir = TRUE, + ... +) } \arguments{ \item{n}{A neuron} diff --git a/man/write.neuronlistfh.Rd b/man/write.neuronlistfh.Rd index 5d789c4b..eb1d1606 100644 --- a/man/write.neuronlistfh.Rd +++ b/man/write.neuronlistfh.Rd @@ -39,7 +39,10 @@ This function writes the main neuronlistfh object to disk, but makes \seealso{ \code{\link{saveRDS}} -Other neuronlistfh: \code{\link{[.neuronlistfh}}, - \code{\link{neuronlistfh}}, - \code{\link{read.neuronlistfh}}, \code{\link{remotesync}} +Other neuronlistfh: +\code{\link{[.neuronlistfh}()}, +\code{\link{neuronlistfh}()}, +\code{\link{read.neuronlistfh}()}, +\code{\link{remotesync}()} } +\concept{neuronlistfh} diff --git a/man/write.neurons.Rd b/man/write.neurons.Rd index 1c929e6c..412e17e1 100644 --- a/man/write.neurons.Rd +++ b/man/write.neurons.Rd @@ -4,8 +4,16 @@ \alias{write.neurons} \title{Write neurons from a neuronlist object to individual files, or a zip archive} \usage{ -write.neurons(nl, dir, format = NULL, subdir = NULL, INDICES = names(nl), - files = NULL, Force = FALSE, ...) +write.neurons( + nl, + dir, + format = NULL, + subdir = NULL, + INDICES = names(nl), + files = NULL, + Force = FALSE, + ... +) } \arguments{ \item{nl}{neuronlist object} @@ -69,12 +77,16 @@ write.neurons(subset(Cell07PNs, Scored.By="ACH"),dir="testwn4", \code{\link{write.neuron}}, \code{\link{read.neurons}}, \code{\link{fileformats}} -Other neuronlist: \code{\link{*.neuronlist}}, - \code{\link{is.neuronlist}}, - \code{\link{neuronlist-dataframe-methods}}, - \code{\link{neuronlistfh}}, \code{\link{neuronlist}}, - \code{\link{nlapply}}, \code{\link{read.neurons}} +Other neuronlist: +\code{\link{*.neuronlist}()}, +\code{\link{is.neuronlist}()}, +\code{\link{neuronlist}()}, +\code{\link{neuronlist-dataframe-methods}}, +\code{\link{neuronlistfh}()}, +\code{\link{nlapply}()}, +\code{\link{read.neurons}()} } \author{ jefferis } +\concept{neuronlist} diff --git a/man/write.nrrd.Rd b/man/write.nrrd.Rd index f24a87a2..2d012183 100644 --- a/man/write.nrrd.Rd +++ b/man/write.nrrd.Rd @@ -6,9 +6,15 @@ \alias{write.nrrd.header.for.file} \title{Write data and metadata to NRRD file or create a detached NRRD (nhdr) file.} \usage{ -write.nrrd(x, file, enc = c("gzip", "raw", "text"), dtype = c("float", - "byte", "short", "ushort", "int", "double"), header = attr(x, "header"), - endian = .Platform$endian, datafile = NULL) +write.nrrd( + x, + file, + enc = c("gzip", "raw", "text"), + dtype = c("float", "byte", "short", "ushort", "int", "double"), + header = attr(x, "header"), + endian = .Platform$endian, + datafile = NULL +) write.nrrd.header(header, file) @@ -53,7 +59,7 @@ default) then it will be set to \code{}.} } \section{Detached NRRDs}{ NRRD files can be written in \emph{detached} format - (see \url{http://teem.sourceforge.net/nrrd/format.html#detached}) in which + (see \url{https://teem.sourceforge.net/nrrd/format.html#detached}) in which a text \bold{nhdr} file is used to described the contents of a separate (usually binary) data file. This means that the nhdr file can be inspected and edited with a text editor, while the datablock can be in a completely @@ -107,7 +113,7 @@ default) then it will be set to \code{}.} and \code{endian} along with the dimensions of the input (\code{x}) will override the corresponding NRRD header fields from any supplied \code{header} argument. See - \url{http://teem.sourceforge.net/nrrd/format.html} for details of the NRRD + \url{https://teem.sourceforge.net/nrrd/format.html} for details of the NRRD fields. } diff --git a/man/write.vtk.Rd b/man/write.vtk.Rd index cce676d6..ab488a76 100644 --- a/man/write.vtk.Rd +++ b/man/write.vtk.Rd @@ -7,8 +7,14 @@ \usage{ write.vtk(x, file, ...) -\method{write.vtk}{neuron}(x, file, datatype = c("float", "double"), - title = file, WriteAllSubTrees = TRUE, ...) +\method{write.vtk}{neuron}( + x, + file, + datatype = c("float", "double"), + title = file, + WriteAllSubTrees = TRUE, + ... +) } \arguments{ \item{x}{Object to write} diff --git a/man/xform.Rd b/man/xform.Rd index da0368fd..c1f70dc6 100644 --- a/man/xform.Rd +++ b/man/xform.Rd @@ -14,26 +14,29 @@ \usage{ xform(x, reg, ...) -\method{xform}{default}(x, reg, na.action = c("warn", "none", "drop", - "error"), ...) +\method{xform}{default}(x, reg, na.action = c("warn", "none", "drop", "error"), ...) \method{xform}{character}(x, reg, ...) -\method{xform}{list}(x, reg, FallBackToAffine = TRUE, na.action = "error", - ...) +\method{xform}{list}(x, reg, FallBackToAffine = TRUE, na.action = "error", ...) -\method{xform}{shape3d}(x, reg, FallBackToAffine = TRUE, - na.action = "error", ...) +\method{xform}{shape3d}(x, reg, FallBackToAffine = TRUE, na.action = "error", ...) -\method{xform}{neuron}(x, reg, FallBackToAffine = TRUE, na.action = "error", - ...) +\method{xform}{neuron}(x, reg, FallBackToAffine = TRUE, na.action = "error", ...) \method{xform}{data.frame}(x, reg, subset = NULL, ...) \method{xform}{dotprops}(x, reg, FallBackToAffine = TRUE, ...) -\method{xform}{neuronlist}(x, reg, subset = NULL, ..., OmitFailures = NA, - VectoriseRegistrations = FALSE, TransformDFCoords = TRUE) +\method{xform}{neuronlist}( + x, + reg, + subset = NULL, + ..., + OmitFailures = NA, + VectoriseRegistrations = FALSE, + TransformDFCoords = TRUE +) } \arguments{ \item{x}{an object to transform} diff --git a/man/xformimage.Rd b/man/xformimage.Rd index 6711b359..90d88fe2 100644 --- a/man/xformimage.Rd +++ b/man/xformimage.Rd @@ -12,8 +12,13 @@ xformimage(reg, image, ...) \method{xformimage}{character}(reg, image, ...) -\method{xformimage}{cmtkreg}(reg, image, transformtype = c("warp", "affine"), - direction = NULL, ...) +\method{xformimage}{cmtkreg}( + reg, + image, + transformtype = c("warp", "affine"), + direction = NULL, + ... +) \method{xformimage}{reglist}(reg, image, ...) diff --git a/man/xformpoints.Rd b/man/xformpoints.Rd index 277281e6..0979b5fd 100644 --- a/man/xformpoints.Rd +++ b/man/xformpoints.Rd @@ -12,8 +12,14 @@ xformpoints(reg, points, ...) \method{xformpoints}{character}(reg, points, ...) -\method{xformpoints}{cmtkreg}(reg, points, transformtype = c("warp", - "affine"), direction = NULL, FallBackToAffine = FALSE, ...) +\method{xformpoints}{cmtkreg}( + reg, + points, + transformtype = c("warp", "affine"), + direction = NULL, + FallBackToAffine = FALSE, + ... +) \method{xformpoints}{reglist}(reg, points, ...) diff --git a/tests/testthat/setup.R b/tests/testthat/setup.R new file mode 100644 index 00000000..f6643203 --- /dev/null +++ b/tests/testthat/setup.R @@ -0,0 +1,6 @@ +setup({ + ff=dir(test_path('testdata'), pattern = '\\.swc\\.txt$', + recursive = T, full.names = T) + ffnew=sub("\\.txt$","",ff) + file.copy(ff, ffnew) +}) diff --git a/tests/testthat/teardown.R b/tests/testthat/teardown.R new file mode 100644 index 00000000..28155c28 --- /dev/null +++ b/tests/testthat/teardown.R @@ -0,0 +1,11 @@ +pdf_path = test_path('Rplots.pdf') + +# check for write permission +if(isTRUE(file.access(pdf_path, mode = 2)==0)) + file.remove(pdf_path) + +ffnew=dir(test_path('testdata'), pattern = '\\.swc$', recursive = T, + full.names = T) +if(isTRUE(all(file.access(ffnew, mode = 2)==0))) { + file.remove(ffnew) +} diff --git a/tests/testthat/test-cmtk.R b/tests/testthat/test-cmtk.R index 20c9fce5..2a8afc35 100644 --- a/tests/testthat/test-cmtk.R +++ b/tests/testthat/test-cmtk.R @@ -1,8 +1,28 @@ +test_that("cmtk.arg.names works",{ + expect_equal(cmtk.arg.name('mask'),'--mask') + expect_equal(cmtk.arg.name('target.grid'),'--target-grid') + expect_equal(cmtk.arg.name('target.offset.pixels'),'--target-offset-pixels') +}) + +test_that("cmtk.version works",{ + op=options(nat.cmtk.bindir="",nat.cmtk.version=NULL) + on.exit(options(op)) + expect_true(is.na(cmtk.version())) + expect_true(is.na(cmtk.version('1.1'))) + + # now let's set a meaningful version and test + options(nat.cmtk.version='3.2.1') + expect_equal(cmtk.version(), numeric_version('3.2.1')) + expect_true(cmtk.version('3.2.1')) + expect_false(cmtk.version('3.2.2')) +}) + + # tests for cmtk command line tools +# CMTK will never be installed on CRAN +skip_on_cran() -if(is.null(cmtk.bindir())){ - message("skipping cmtk command line tool tests since CMTK is not installed") -} else { +skip_if(is.null(cmtk.bindir()), message = "skipping cmtk command line tool tests since CMTK is not installed") context("cmtk command line tools") @@ -134,24 +154,3 @@ test_that("cmtk.statistics",{ Z = c(35.102241, 31.604381)) expect_equal(cmtk.statistics(lhmaskfile, imagetype = 'label'), baseline_label) }) - -} - -test_that("cmtk.arg.names works",{ - expect_equal(cmtk.arg.name('mask'),'--mask') - expect_equal(cmtk.arg.name('target.grid'),'--target-grid') - expect_equal(cmtk.arg.name('target.offset.pixels'),'--target-offset-pixels') -}) - -test_that("cmtk.version works",{ - op=options(nat.cmtk.bindir="",nat.cmtk.version=NULL) - on.exit(options(op)) - expect_true(is.na(cmtk.version())) - expect_true(is.na(cmtk.version('1.1'))) - - # now let's set a meaningful version and test - options(nat.cmtk.version='3.2.1') - expect_equal(cmtk.version(), numeric_version('3.2.1')) - expect_true(cmtk.version('3.2.1')) - expect_false(cmtk.version('3.2.2')) -}) diff --git a/tests/testthat/test-cmtk_io.R b/tests/testthat/test-cmtk_io.R index 64250b70..a88a2196 100644 --- a/tests/testthat/test-cmtk_io.R +++ b/tests/testthat/test-cmtk_io.R @@ -19,7 +19,7 @@ test_that("read.cmtk and write.cmtk can round-trip a registration file", { reglist=read.cmtkreg(reg) tf=tempfile('dofv1.1wshears_copy',fileext='.list') on.exit(unlink(tf,recursive=TRUE)) - write.cmtkreg(reglist,foldername=tf,version=1.1) + write.cmtkreg(reglist, foldername=tf, version=1.1) ctf=cmtkreg(tf,returnDir=TRUE) # equivalent because we are not interested in the file.info attributes # though this also removes version attribute which might be worth a thought diff --git a/tests/testthat/test-hxsurf.R b/tests/testthat/test-hxsurf.R index 71220e21..e2a9ff10 100644 --- a/tests/testthat/test-hxsurf.R +++ b/tests/testthat/test-hxsurf.R @@ -24,7 +24,7 @@ test_that("we can read hxsurf object", { plot3d(surf,alpha=0.2) clear3d() plot3d(surf,col=rainbow,alpha=0.2) - rgl.close() + close3d() }) test_that("we fail for bad surface files", { diff --git a/tests/testthat/test-landmarks-io.R b/tests/testthat/test-landmarks-io.R index 2c36bdec..b932bf45 100644 --- a/tests/testthat/test-landmarks-io.R +++ b/tests/testthat/test-landmarks-io.R @@ -64,7 +64,7 @@ test_that("generic landmarks I/O", { f="testdata/landmarks/JFRC2.points" expect_is(l<-read.landmarks(f), "landmarks") if(nzchar(Sys.getenv("NAT_INTERNET_TESTS"))){ - u=paste0('https://raw.githubusercontent.com/jefferis/nat/master/tests/testthat/', f) + u=paste0('https://raw.githubusercontent.com/natverse/nat/master/tests/testthat/', f) expect_equal(read.landmarks(u), l) } diff --git a/tests/testthat/test-ndigest.R b/tests/testthat/test-ndigest.R index 10da1290..b69f7f8e 100644 --- a/tests/testthat/test-ndigest.R +++ b/tests/testthat/test-ndigest.R @@ -4,13 +4,14 @@ library(digest) test_that("ndigest works for overloaded and regular classes",{ expect_false(isTRUE(all.equal(ndigest(kcs20[[1]]),digest(kcs20[[1]])))) - expect_equal(ndigest(kcs20[[1]]),"4c045b0343938259cd9986494fc1c2b0") - expect_equal(ndigest(''),digest('')) + skip_on_cran() + + expect_equal(ndigest(kcs20[[1]]),"4c045b0343938259cd9986494fc1c2b0") expect_equal(ndigest(read.neuron('testdata/neuron/EBT7R.am')), - "f24c1252d17b6bd9898c7842f1ad9f5d") + "a84b2255bb21e35d7906c756e7d14e47") # three neuronlists with different names but same contents tf=tempfile('kcs20fh') @@ -29,4 +30,4 @@ test_that("ndigest works for overloaded and regular classes",{ kcs20fh4=read.neuronlistfh(file.path(tf2,'kcs20fh2.rds')) expect_equal(ndigest(kcs20fh3), ndigest(kcs20fh)) expect_equal(ndigest(kcs20fh3), ndigest(kcs20fh4)) -}) \ No newline at end of file +}) diff --git a/tests/testthat/test-neuroml-io.R b/tests/testthat/test-neuroml-io.R index b2b33b59..a9f7f3a0 100644 --- a/tests/testthat/test-neuroml-io.R +++ b/tests/testthat/test-neuroml-io.R @@ -45,7 +45,9 @@ test_that("parse neuroml files", { }) test_that("is.neuroml", { - ff=dir(c("testdata/neuroml","testdata/neuroml2"), full.names = T, recursive = T) + ff=dir(c("testdata/neuroml","testdata/neuroml2"), + full.names = T, recursive = T, pattern = '\\.(swc|xml)$') + notswc=tools::file_ext(ff)!="swc" expect_equivalent(is.neuroml(ff), notswc) }) diff --git a/tests/testthat/test-neuron.R b/tests/testthat/test-neuron.R index 0a1813bb..46857d32 100644 --- a/tests/testthat/test-neuron.R +++ b/tests/testthat/test-neuron.R @@ -234,7 +234,7 @@ test_that("we can subset a neuron", { test_that("we can subset a neuron with a vertex sequence", { n = Cell07PNs[[1]] - n_graph_dfs = igraph::graph.dfs(as.ngraph(n), root = 48, neimode = "out", unreachable = FALSE) + n_graph_dfs = igraph::dfs(as.ngraph(n), root = 48, mode = "out", unreachable = FALSE) expect_is(n_subset <- subset(n, n_graph_dfs$order, invert = F), 'neuron') expect_is(n_subset <- subset(n, n_graph_dfs$order, invert = T), 'neuron') }) diff --git a/tests/testthat/test-neuronlist.R b/tests/testthat/test-neuronlist.R index 9e3ed82d..501ada55 100644 --- a/tests/testthat/test-neuronlist.R +++ b/tests/testthat/test-neuronlist.R @@ -23,7 +23,7 @@ test_that("c.neuronlist behaves", { expect_equivalent(c(Cell07PNs[1:5], c610.nodf), Cell07PNs[1:10]) expect_equivalent(kcs20[1:6], c(kcs20[1:2], kcs20[3:4], kcs20[5:6])) - expect_error(c(Cell07PNs[1:5], NULL)) + expect_error(c(Cell07PNs[1:5], list())) expect_error(c(Cell07PNs[1:5], Cell07PNs[1:5]), "neurons with the same name") }) @@ -210,7 +210,7 @@ test_that("basic interactive 3d functionality",{ expect_equal(find.soma(selfun, db=Cell07PNs, rval='neuronlist'), Cell07PNs[sel_soma]) - rgl.close() + close3d() }) context("neuronlist: set operations") diff --git a/tests/testthat/test-ngraph.R b/tests/testthat/test-ngraph.R index 9ba089b0..4d78905d 100644 --- a/tests/testthat/test-ngraph.R +++ b/tests/testthat/test-ngraph.R @@ -1,5 +1,5 @@ context("ngraph class") -library(igraph, warn.conflicts = FALSE) +suppressPackageStartupMessages(library(igraph, warn.conflicts = FALSE)) # make a very simple neuron # 1 2 3b 4 5 @@ -13,7 +13,7 @@ test_that("as.ngraph can convert swc data into an ngraph object",{ expect_is(g1,'ngraph') # check we keep ngraph class when modifying ngraph - expect_is(set.graph.attribute(g1,'origin',1),'ngraph') + expect_is(set_graph_attr(g1,'origin',1),'ngraph') # same neuron with PointNo 2 greater testd2=data.frame(PointNo=3:8,Label=2, @@ -127,7 +127,7 @@ test_that("we can find the inverse of the spine", { }) test_that("prune_edges (and therefore spine) can cope with paths with reversed edges", { - # see https://github.com/jefferis/nat/issues/320 + # see https://github.com/natverse/nat/issues/320 baseline=prune_edges(Cell07PNs[[1]], cbind(1:3, 2:4), invert=TRUE) expect_equal(prune_edges(Cell07PNs[[1]], cbind(c(2,3,3), c(1,2,4)), invert=TRUE), baseline) @@ -137,16 +137,19 @@ test_that("setting of graph attributes",{ gatts=list(name='testneuron',nclass="PN") expect_is(testg <- as.ngraph(testd, graph.attributes = gatts, vertex.attributes=list(X=testd$X)), 'ngraph') - expect_equal(get.graph.attribute(testg, name = 'nclass'), gatts$nclass) - expect_equal(get.graph.attribute(testg, name = 'name'), gatts$name) + expect_equal(graph_attr(testg, name = 'nclass'), gatts$nclass) + expect_equal(graph_attr(testg, name = 'name'), gatts$name) # null attributes - expect_equal(get.graph.attribute(testg, name = 'rhubarb'), gatts$rhubarb) + expect_equal(graph_attr(testg, name = 'rhubarb'), gatts$rhubarb) # vertex attributes - expect_equal(get.vertex.attribute(testg, name = 'X'), testd$X) - expect_warning(testg <- as.ngraph(testd, graph.attributes = gatts, - vertex.attributes=list(X=testd$X[-1]))) -}) + expect_equal(vertex_attr(testg, name = 'X'), testd$X) + if(igraph::igraph_version()>=numeric_version("1.3.5.9098")) + expect_error(testg <- as.ngraph(testd, graph.attributes = gatts, + vertex.attributes=list(X=testd$X[-1]))) + else + expect_warning(testg <- as.ngraph(testd, graph.attributes = gatts, + vertex.attributes=list(X=testd$X[-1])))}) test_that("graph weights can be calculated and set",{ # weights for a neuron with unit length segments @@ -165,7 +168,7 @@ test_that("we can find the segmentgraph of a neuron",{ testn=as.neuron(testd) expect_is(sg<-segmentgraph(testn), 'igraph') - baseline=graph(c(1,2,2,3,2,4), directed=TRUE) + baseline=make_graph_nat(c(1,2,2,3,2,4), directed=TRUE) expect_true(graph.isomorphic(sg, baseline)) expect_equal(E(sg)$weight, c(2, 2, 1)) @@ -184,7 +187,7 @@ test_that("we can find the segmentgraph of a neuron",{ test_that("as.ngraph can convert undirected graph into an ngraph object",{ g1=as.ngraph(testd) - expect_is(g2<-as.ngraph(as.undirected(g1), root = rootpoints(g1)), 'ngraph') + expect_is(g2<-as.ngraph(as_undirected_nat(g1), root = rootpoints(g1)), 'ngraph') expect_true(graph.isomorphic(g1,g2)) }) diff --git a/tests/testthat/test-pop3d.R b/tests/testthat/test-pop3d.R index 8fa211e4..3d30ca89 100644 --- a/tests/testthat/test-pop3d.R +++ b/tests/testthat/test-pop3d.R @@ -2,11 +2,11 @@ context("npop3d") test_that("pop last plotted neurons",{ nopen3d() - original.rgl.ids=rgl.ids() + original.rgl.ids=ids3d() plot3d(c("EBH11R", "EBH20L"), db=Cell07PNs) npop3d() - expect_equal(rgl.ids(), original.rgl.ids) - rgl.close() + expect_equal(ids3d(), original.rgl.ids) + close3d() }) context("nview3d") diff --git a/tests/testthat/test-seglist.R b/tests/testthat/test-seglist.R index 078c8875..260d3805 100644 --- a/tests/testthat/test-seglist.R +++ b/tests/testthat/test-seglist.R @@ -7,7 +7,7 @@ test_that("make a seglist directly",{ test_that("convert graph to seglist",{ # simple linear graph - g=graph(c(1, 2, 2, 3)) + g=make_graph_nat(c(1, 2, 2, 3)) sl=seglist(c(1, 2, 3)) expect_is(sl,'seglist') expect_equal(as.seglist(g), sl) @@ -16,38 +16,38 @@ test_that("convert graph to seglist",{ expect_error(as.seglist(1:10)) # empty graph - expect_null(as.seglist(igraph::graph.empty())) - expect_warning(sl<-as.seglist(igraph::graph.empty(), Verbose = T)) + expect_null(as.seglist(igraph::make_empty_graph())) + expect_warning(sl<-as.seglist(igraph::make_empty_graph(), Verbose = T)) # simple linear graph with different vids - g=graph(c(1, 2, 2, 3)) + g=make_graph_nat(c(1, 2, 2, 3)) igraph::V(g)$vid=3:5 sl=seglist(3:5) expect_equal(as.seglist(g), sl) # simple linear graph with different vids and different origin - g=graph(c(1, 2, 2, 3)) + g=make_graph_nat(c(1, 2, 2, 3)) igraph::V(g)$vid=3:5 sl=seglist(5:3) expect_equal(as.seglist(g, origin=5), sl) # simple linear graph with different vids and origin at centre, resulting # in a branched seglist - g=graph(c(1, 2, 2, 3)) + g=make_graph_nat(c(1, 2, 2, 3)) igraph::V(g)$vid=3:5 sl=seglist(4:3,4:5) expect_equal(as.seglist(g, origin=4), sl) # multiple subtrees -> exception since seglist only defined for 1 subtree - g=graph(c(1,2,2,3,3,4,5,6)) + g=make_graph_nat(c(1,2,2,3,3,4,5,6)) expect_error(as.seglist(g)) # cyclic graph -> exception since seglist is undefined - g=graph(c(1, 2, 2, 3, 3, 1)) + g=make_graph_nat(c(1, 2, 2, 3, 3, 1)) expect_error(as.seglist(g)) # single floating point - g=graph(NULL,n=1) + g=make_graph_nat(NULL,n=1) expect_equal(as.seglist(g),seglist(1)) # single floating point with different vid @@ -55,24 +55,24 @@ test_that("convert graph to seglist",{ expect_equal(as.seglist(g),seglist(4)) # trifurcation - g=graph(c(1,2, 2,3, 2,4, 2,5, 5,6, 6,7)) + g=make_graph_nat(c(1,2, 2,3, 2,4, 2,5, 5,6, 6,7)) sl=seglist(c(1,2),c(2,3),c(2,4),c(2,5,6,7)) expect_equal(as.seglist(g),sl) # undirected equivalent - nb origin must be specified - expect_equal(as.seglist(as.undirected(g),origin=1),sl) + expect_equal(as.seglist(as_undirected_nat(g),origin=1),sl) # rapid branching - g=graph(c(1,2, 2,3, 2,4, 4,5, 4,6)) + g=make_graph_nat(c(1,2, 2,3, 2,4, 4,5, 4,6)) sl=seglist( c(1,2),c(2,3),c(2,4),c(4,5),c(4,6) ) expect_equal(as.seglist(g),sl) # different root - g=graph(c(1,2, 2,3, 2,4, 4,5, 4,6)) + g=make_graph_nat(c(1,2, 2,3, 2,4, 4,5, 4,6)) sl=seglist( c(6,4),c(4,2),c(2,1),c(2,3),c(4,5) ) expect_equal(as.seglist(g,origin=6),sl) # non-sequential numbering - g=graph(c(1,2, 2,6, 2,4, 4,5, 4,3)) + g=make_graph_nat(c(1,2, 2,6, 2,4, 4,5, 4,3)) sl<-seglist( c(1,2),c(2,4),c(4,3),c(4,5),c(2,6) ) expect_equal(as.seglist(g,origin=1),sl) diff --git a/tests/testthat/test-summary.R b/tests/testthat/test-summary.R index a664f739..442a9407 100644 --- a/tests/testthat/test-summary.R +++ b/tests/testthat/test-summary.R @@ -2,6 +2,6 @@ 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_known_value(s, file = test_path('testdata/summary_cell07pns.rds'), tolerance=1e-3) expect_is(summary(kcs20, veclength=1.2), 'data.frame') }) diff --git a/tests/testthat/testdata/neuroml/level1/CablesIncluded.swc b/tests/testthat/testdata/neuroml/level1/CablesIncluded.swc.txt similarity index 100% rename from tests/testthat/testdata/neuroml/level1/CablesIncluded.swc rename to tests/testthat/testdata/neuroml/level1/CablesIncluded.swc.txt diff --git a/tests/testthat/testdata/neuroml/level1/Simple.morph.swc b/tests/testthat/testdata/neuroml/level1/Simple.morph.swc.txt similarity index 100% rename from tests/testthat/testdata/neuroml/level1/Simple.morph.swc rename to tests/testthat/testdata/neuroml/level1/Simple.morph.swc.txt diff --git a/tests/testthat/testdata/neuron/EBT7R.CNG.swc b/tests/testthat/testdata/neuron/EBT7R.CNG.swc.txt old mode 100755 new mode 100644 similarity index 100% rename from tests/testthat/testdata/neuron/EBT7R.CNG.swc rename to tests/testthat/testdata/neuron/EBT7R.CNG.swc.txt diff --git a/tests/testthat/testdata/neuron/EBT7R.am b/tests/testthat/testdata/neuron/EBT7R.am old mode 100755 new mode 100644 diff --git a/tests/testthat/testdata/neuron/XT6L2.CNG.swc b/tests/testthat/testdata/neuron/XT6L2.CNG.swc.txt old mode 100755 new mode 100644 similarity index 100% rename from tests/testthat/testdata/neuron/XT6L2.CNG.swc rename to tests/testthat/testdata/neuron/XT6L2.CNG.swc.txt diff --git a/tests/testthat/testdata/neuron/unfitted.swc b/tests/testthat/testdata/neuron/unfitted.swc.txt similarity index 100% rename from tests/testthat/testdata/neuron/unfitted.swc rename to tests/testthat/testdata/neuron/unfitted.swc.txt diff --git a/tests/testthat/testdata/summary_cell07pns.rda b/tests/testthat/testdata/summary_cell07pns.rda deleted file mode 100644 index f01e467e..00000000 Binary files a/tests/testthat/testdata/summary_cell07pns.rda and /dev/null differ diff --git a/tests/testthat/testdata/summary_cell07pns.rds b/tests/testthat/testdata/summary_cell07pns.rds new file mode 100644 index 00000000..b9b2d19f Binary files /dev/null and b/tests/testthat/testdata/summary_cell07pns.rds differ diff --git a/vignettes/Installation.Rmd b/vignettes/Installation.Rmd index 28663c76..599a37b6 100644 --- a/vignettes/Installation.Rmd +++ b/vignettes/Installation.Rmd @@ -13,10 +13,10 @@ This document provides additional details about installation that may help you solve certain difficulties, especially on Windows or Mac platforms. The source code for this vignette is available at -https://github.com/jefferis/nat/blob/master/vignettes/Installation.Rmd. +https://github.com/natverse/nat/blob/master/vignettes/Installation.Rmd. If you find something unclear or notice a typo, I would be very happy if you would click on the Pencil Icon on that page or follow -[this link to edit](https://github.com/jefferis/nat/edit/master/vignettes/Installation.Rmd) +[this link to edit](https://github.com/natverse/nat/edit/master/vignettes/Installation.Rmd) and suggest an alternative wording. Don't be shy about doing this; I have to review any change and even if your suggestion is not perfect it will still be a prompt for me to improve this document. Thank you! @@ -31,7 +31,7 @@ pre-requisite for most functionality is a recent version of R (>=3.1.0 recommend you use RStudio or R from the terminal, you must have a copy of XQuartz, the X11 window manager, installed. This is no longer a default install since Mac OS X 10.8. You need to install XQuartz, before installing the nat package. Logout and login for the installation to take effect. You can get it from -https://xquartz.macosforge.org/landing/. This page is also linked from the +https://www.xquartz.org/. This page is also linked from the [Download R for (Mac) OS X](https://cran.r-project.org/bin/macosx/) page. If you want to apply non-rigid registrations calculated by the @@ -61,19 +61,19 @@ package (if you have not already done so) and then use that to install nat. # install devtools if required if (!require("devtools")) install.packages("devtools") # then install nat -devtools::install_github("jefferis/nat") +devtools::install_github("natverse/nat") ``` The **nat** package includes extensive unit tests which are run along with R's -(extremely fastidious) package check routines by the [Travis](http://travis-ci.org/jefferis/nat) +(extremely fastidious) package check routines by the [GitHub Actions(https://github.com/natverse/nat/actions) continuous integration server. The master branch is therefore considered very stable and may well contain fixes or enhancements over released versions. -However, you can install any [release version](https://github.com/jefferis/nat/tags) -including the [latest release](https://github.com/jefferis/nat/releases/latest) +However, you can install any [release version](https://github.com/natverse/nat/tags) +including the [latest release](https://github.com/natverse/nat/releases/latest) as follows: ```r -devtools::install_github("jefferis/nat@v1.8.6") +devtools::install_github("natverse/nat@v1.8.6") ``` The same syntax can be used to install any arbitrary version that you want @@ -87,13 +87,14 @@ do not already have it. **nat** is self sufficient for core functionality, but the transformation of 3D data using Computational Morphometry Toolkit (CMTK) registrations depends on an external installation of that toolkit. CMTK binaries can be downloaded for -Windows, Linux and Mac at . Source code is +Windows, Linux and Mac at . Source code is available from the same site or an unofficial mirror repository at . We have extensive experience of using CMTK under Linux (where we compile from source) and Mac (where we compile or use the MacOSX-10.6-x86_64.dmg binary installers). We have also used -[neurodebian](http://neuro.debian.net/pkgs/cmtk.html) to install as part of the -Travis continuous integration setup (see the project's [.travis.yml](https://github.com/jefferis/nat/blob/master/.travis.yml) file). +[neurodebian](http://neuro.debian.net/pkgs/cmtk.html) to install as part of +our (now retired) Travis continuous integration setup (see the project's +[.travis.yml](https://github.com/natverse/nat/blob/d2ecca2d533abbd0dc2047b8919008af67b56789/.travis.yml) file). ## CMTK+nat on Windows @@ -102,7 +103,7 @@ Experiments in May 2016 suggest that the best option is to use the cygwin CMTK distribution (cygwin provides a linux like environment). Here are the steps we took: -* You must ensure that you have at least version [nat v1.8.5](https://github.com/jefferis/nat/releases/tag/v1.8.5). +* You must ensure that you have at least version [nat v1.8.5](https://github.com/natverse/nat/releases/tag/v1.8.5). It is recommended that follow the steps for installing the development version of nat straight from github as described in section **Development version** * Install [Cygwin](https://www.cygwin.com/) accepting the default path `C:\cygwin64` diff --git a/vignettes/neurons-intro.Rmd b/vignettes/neurons-intro.Rmd index 19f46224..14ab45e0 100644 --- a/vignettes/neurons-intro.Rmd +++ b/vignettes/neurons-intro.Rmd @@ -14,10 +14,10 @@ features of nat by teaching you about how it handles individual neurons and collections of neurons. The source code for this vignette is available at -https://github.com/jefferis/nat/blob/master/vignettes/neurons-intro.Rmd. +https://github.com/natverse/nat/blob/master/vignettes/neurons-intro.Rmd. If you find something unclear or notice a typo, I would be very happy if you would click on the Pencil Icon on that page or follow -[this link to edit](https://github.com/jefferis/nat/edit/master/vignettes/neurons-intro.Rmd) +[this link to edit](https://github.com/natverse/nat/edit/master/vignettes/neurons-intro.Rmd) and suggest an alternative wording. Don't be shy about doing this; I have to review any change and even if your suggestion is not perfect it will still be a prompt for me to improve this document. Thank you! @@ -38,6 +38,9 @@ library(nat) rgl::setupKnitr() library(knitr) opts_chunk$set(fig.width=5) +# to avoid issues on CRAN when webshot2/rmarkdown unavailable +use_rgl=requireNamespace('webshot2', quietly=TRUE) && requireNamespace('rmarkdown', quietly=TRUE) && + rmarkdown::pandoc_available() ``` ## Neurons and Neuronlists @@ -65,7 +68,7 @@ A subset of the original data are distributed as a sample data object with the data("Cell07PNs") ``` -For more information about these data see [Cell07PNs](http://jefferis.github.io/nat/reference/Cell07PNs.html). +For more information about these data see [Cell07PNs](http://natverse.org/nat/reference/Cell07PNs.html). This `Cell07PNs` object has two classes `neuronlist` and the base class `list` @@ -172,7 +175,7 @@ Note that if you write `?plot` you will get the documentation for the basic `plot` function supplied with R. It is also good idea to look at -[nat's function reference page](http://jefferis.github.io/nat/reference/index.html) +[nat's function reference page](http://natverse.org/nat/reference/index.html) which groups available functions into categories that often reflect the class of object they can work on. @@ -212,7 +215,7 @@ summary(n1) summary(n1.lh) ``` -See [nat's function reference page](http://jefferis.github.io/nat/reference/index.html) +See [nat's function reference page](http://natverse.org/nat/reference/index.html) for additional functions for working with neurons. ## Neuronlists @@ -404,12 +407,12 @@ plot(Cell07PNs, subset=Glomerulus=="DA1", add=TRUE) So far we have only used 2D plots in this document, but especially for interactive analysis and exploration, it is much more helpful to have 3D plots that can be rotated, zoomed etc. **nat** provides numerous functions -for [3D plots](http://jefferis.github.io/nat/reference/index.html#section--d-plotting-of-objects) +for [3D plots](http://natverse.org/nat/reference/index.html#section--d-plotting-of-objects) based on the [rgl package](https://cran.r-project.org/package=rgl). It is -actually possible to embed fully interactive 3d figures in [rmarkdown](http://rmarkdown.rstudio.com/) reports +actually possible to embed fully interactive 3d figures in [rmarkdown](https://rmarkdown.rstudio.com/) reports like this one by setting the [webgl chunk option](https://CRAN.R-project.org/package=rgl/vignettes/WebGL.html). -```{r, webgl=TRUE} +```{r, webgl=TRUE, eval=use_rgl} clear3d() plot3d(Cell07PNs[[1]], col='red') # set a grey background so it's easier to see extent of the webgl canvas @@ -423,14 +426,14 @@ we will not use it further here. For now let's show a plot in which we both select a subset of neurons and colour them according to their glomerulus of origin. -```{r, rgl=TRUE, fig.width=6} +```{r, rgl=TRUE, fig.width=6, eval=use_rgl} # 3d plot of neurons from olfactory glomeruli beginning with a D # coloured by glomerulus rval=plot3d(Cell07PNs, subset=grepl("^D", Glomerulus), col=Glomerulus, lwd=2, WithNodes=FALSE) ``` -```{r plot3d-legend, fig.width=3, fig.height=3} +```{r plot3d-legend, fig.width=3, fig.height=3, eval=use_rgl} # make a legend so that you know which colours match which glomerulus plot.new() with(attr(rval,'df'), legend('center', legend = unique(Glomerulus), fill=unique(col))) @@ -503,7 +506,7 @@ with a chance level of about 25% for these 4 classes. We hope this tutorial will provide you with a good foundation for further use of the **nat** and related packages. Please visit the main -[nat README](http://jefferis.github.io/nat/index.html) for +[nat README](http://natverse.org/nat/index.html) for suggestions of resources to learn more and solve problems. You may also find that some time spent reading Hadley Wickham's [Advanced R](http://adv-r.had.co.nz/) is a worthwhile investment. I recommend the first 7 chapters