Code Monkey home page Code Monkey logo

nat.flybrains's Introduction

natverse

natverse GitHub Docs Travis build status Coveralls test coverage

The natverse package is a wrapper for all of the commonly used NeuroAnatomy Toolbox packages. This is convenient both for package installation and for loading/attaching these packages without many calls to library().

See http://natverse.org for more details.

Installation

The recommended approach to install the full natverse is to use a helper package natmanager, which is available on CRAN. You can therefore do:

install.packages("natmanager")
natmanager::install("natverse")

See http://natverse.org/install for more details.

Use

Once installed, you can load the natverse package:

library(natverse)
#> Loading required package: elmr
#> Loading required package: catmaid
#> Loading required package: httr
#> Warning: package 'httr' was built under R version 3.6.2
#> Loading required package: nat
#> Loading required package: rgl
#> Warning: package 'rgl' was built under R version 3.6.2
#> Registered S3 method overwritten by 'nat':
#>   method             from
#>   as.mesh3d.ashape3d rgl
#> 
#> Attaching package: 'nat'
#> The following object is masked from 'package:rgl':
#> 
#>     wire3d
#> The following objects are masked from 'package:base':
#> 
#>     intersect, setdiff, union
#> Loading required package: nat.flybrains
#> Loading required package: nat.templatebrains
#> Loading required package: nat.nblast
# example 3D plot of some neurons
plot(kcs20, col=type)

Installation Details

Conflicts and Dependencies

The natverse package contains many packages and it is possible that there could be conflicts where functions in the natverse have the same name as another package.

natverse_conflicts()
#> ── Conflicts ─────────────────────────────────────────────────────────────── natverse_conflicts() ──
#> x nat::intersect() masks base::intersect()
#> x nat::setdiff()   masks base::setdiff()
#> x nat::union()     masks base::union()
#> x nat::wire3d()    masks rgl::wire3d()

You can always choose the correct version by prepending the specific package name e.g. nat::flip() will select the nat version rather than any other.

Updates

Once installed, you check the status of all natverse packages and their dependencies like so:

natverse_update()
#> 
#> The following packages are either locally installed or information about them is missing!
#> 
#>   blob, formattable, import, mockr, nycflights13, pingr, fafbsegdata, reticulate, nat
#> 
#> Please install them manually from their appropriate source locations
#> 
#> The following natverse dependencies are out-of-date, see details below:
#> 
#> We recommend updating them by running:
#> natverse_update(update=TRUE)
#> 
#> package         remote         local          source   repo                        status 
#> --------------  -------------  -------------  -------  --------------------------  -------
#> bit64           0.9-7.1        0.9-7          CRAN     https://cran.rstudio.com/   x      
#> data.table      1.13.0         1.12.8         CRAN     https://cran.rstudio.com/   x      
#> elmr            deb0e27df...   7a2be4537...   GitHub   natverse                    x      
#> ff              2.2-14.2       2.2-14         CRAN     https://cran.rstudio.com/   x      
#> flycircuit      1b7b48e29...   cc4594f47...   GitHub   natverse                    x      
#> git2r           0.27.1         0.26.1         CRAN     https://cran.rstudio.com/   x      
#> insectbrainr    6331b4df6...   8fef94a05...   GitHub   natverse                    x      
#> mouselightr     9c2ce1c31...   8e26b7702...   GitHub   natverse                    x      
#> nat.flybrains   28ff33213...   36c622a15...   GitHub   natverse                    x      
#> nat.jrcbrains   85ed4a791...   44c95667e...   GitHub   natverse                    x      
#> neuprintr       7403d3ce2...   8ab03b744...   GitHub   natverse                    x      
#> RCurl           1.98-1.2       1.98-1.1       CRAN     https://cran.rstudio.com/   x      
#> tibble          b4eec19dd...   3f4e5dfae...   GitHub   tidyverse                   x      
#> tidyr           1.1.0          1.0.3          CRAN     https://cran.rstudio.com/   x      
#> xfun            0.16           0.15           CRAN     https://cran.rstudio.com/   x      
#> XML             NA             3.99-0.3       CRAN     https://cran.rstudio.com/   x

You can then update like so:

natverse_update(update = TRUE)

However, if you are in a hurry and want to save time from the questions use like below:

natverse_update(update=TRUE, upgrade = 'always')

If want to upgrade the natverse package itself:

remotes::update_packages('natverse')

nat.flybrains's People

Contributors

ajdm avatar istvantaisz avatar jdmanton avatar jefferis avatar lgoetz avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

nat.flybrains's Issues

Fail to install natverse

Hi, I am a newer in R. I ran it in Windows. When I follow the instructions to install natverse, I can't install some packages(elmr,flycircuit,nat.jrcbrains) because of nat.flybrains is not installed.
The error is as follows:

Error in as.templatebrain.character("data-raw/JRC2018_MALE_38um_iso_16bit.nrrd",  : 
  x does not specify a valid path!
Error: unable to load R code in package 'nat.flybrains'
Execution halted
ERROR: lazy loading failed for package 'nat.flybrains'

As a result, there is no 'natverse' package, I can't use 'library(natverse)'
Could anyone help me? I would appreciate it.

JFRC2013 template brain

This is now of particular interest as it is being used as the endpoint of a bridging registration to the FAFB whole adult brain EM volume. It is also widely used for light data at Janelia.

Use one function for bridging and mirroring

It would be nice to be able to use just one function for all transformations such that bridging and mirroring could be done with just one command, with the function working out what should be done based on the number of templates it is given.

Problem downloading jefferislab registrations on Windows

Noticed by Dana Galili on Windows 7 laptop

Error in git2r::clone(url, localdir, ...) : 
  Error in 'git2r_clone': Failed to make directory 'C:\Users\KADOWG~1\AppData\Local\rpkg-nat.templatebrains\rpkg-nat.templatebrains': The system cannot find the path specified.

Add JRC2018U temblate brain

It would be nice if the JRC2018U (unisex) template brain could be included. I added a bridging registration to the BridingRegistration package, but need a templatebrain object to use it with some nat functionality (e.g. writing NRRD files) in order to have meta-information like the voxdims available.

I tried to add this templatebrain object following the existing JRC2018F example, but couldn't get R to make this object available and use it when the bridging registration is used. Therefore I add this as an issue here including the information I collected so far.

This is the information I get when loading the reference brain NRRD file with as.tenplatebrain():

=== Template Brain ===                
Name: JRC2018_UNISEX_20x_HR           
Short Name: JRC2018_UNISEX_20x_HR     
Type:                                 
Sex:                                  
Dimensions:1210 x 566 x 174 voxels    
Voxel size:                           
  x = 0.518916129032258 microns       
  y = 0.51891610619469 microns        
  z = 1 microns                       
Bounding box (microns):               
  x = 0, y = 0, z = 0,                
  x = 627.3696, y = 293.1876, z = 173.
Description:                          

I also extraced the NRRD header of the original JRC2018U reference NRRD file (data-raw/RC2018_UNISEX_20x_HR.nrrd):

NRRD0004
# Created by Nrrd_Writer at Thu Nov 29 15:08:01 EST 2018
type: uint16
encoding: gzip
endian: big
dimension: 3
sizes: 1210 566 174
space dimension: 3
space directions: (0.5189161,0,0) (0,0.5189161,0) (0,0,1.0)
space units: "microns" "microns" "microns"

This is the templatebrain object I added to data-raw/jrc2018.R, based on JRC2018F:

JRC2018U <-
  as.templatebrain('data-raw/JRC2018_UNISEX_20x_HR.nrrd',
    regName = 'JRC2018U',
    type = 'Average template brain',
    sex = 'U',
    doi = 'https://doi.org/10.1101/376384',
    description="Average template brain constructed from JRC2018F and JRC2018M."
  )
use_data(JRC2018U, overwrite = T

This didn't work though, the JRC2018U templatebrain wasn't available after installing a new version of this package. I likely forgot to add something, but figured this might be easier solvable here. Also, I am not sure the meta information above is correct, I merely guessed what it could be.

Allow more than two template brains to be passed to xform_brain

It would be useful to be able to do, for example,

xform_brain(object, template1, template2, template3)

to bridge object from template1 to template3 via template2, rather than

xform_brain(xform_brain(object, template1, template2),  template2, template3)

IS2NP.surf has some malformed volumes

m=as.mesh3d(subset(IS2NP.surf,'MB_ML_R'))

has a small extra volume that causes a problem with pointsinside inappropriately reporting that points in the LH_L are inside that area.

maybe could check if any points that are a little bit outside this volume are inside other volumes as a quality control.

Add JRCVNC2018U (aka JRC2018_VNC_UNISEX_4iso) template

@istvantaisz would you be able to add this based on previous examples? You could add this amira surface JRC2018_VNC_UNISEX_4iso_8bit3-30k.surf.zip
to data-raw and use this

$ unu head /GD/projects/WeiLee/vnctemplates/JRC2018_VNC_UNISEX_4iso_8bit.nrrd 

to make a .nhdr file as I have done elsewhere

NRRD0004
# Created by Nrrd_Writer at Thu Nov 21 20:04:23 GMT 2019
type: uint8
encoding: gzip
endian: big
dimension: 3
sizes: 660 1290 382
space dimension: 3
space directions: (0.4,0,0) (0,0.4,0) (0,0,0.4)
space units: "microns" "microns" "microns"

Let me know if you have any trouble! This will help us get high quality support for VNC transforms properly integrated.

xform_brain should not require an explicit target specification for image data

Error:

xform_brain("/Volumes/teraraid/flybrain/Shahar/SplitRegistration/IS2/reformatted/IS2_JK733SF457-1_02_warp_m0g80c8e1e-1x26r4.nrrd", ref=JFRC2, sample=IS2, outfile=path.expand("~/projects/Shahar/Screen/AdditionalOutputs/JFRC2_IS2_JK733SF457-1_02_warp_m0g80c8e1e-1x26r4.nrrd"))

Error in basename(as.character(f)) :
argument "target" is missing, with no default

OK:

xform_brain("/Volumes/teraraid/flybrain/Shahar/SplitRegistration/IS2/reformatted/IS2_JK733SF457-1_02_warp_m0g80c8e1e-1x26r4.nrrd", ref=JFRC2, sample=IS2, target=JFRC2, outfile=path.expand("~/projects/Shahar/Screen/AdditionalOutputs/JFRC2_IS2_JK733SF457-1_02_warp_m0g80c8e1e-1x26r4.nrrd"))
Reading transformation from studylist /Library/Frameworks/R.framework/Versions/3.2/Resources/library/nat.flybrains/extdata/bridgingregistrations/JFRC2_IS2.list
WARNING: image does not have valid orientation meta information; cannot reorient.
cmd:
'/usr/local/lib/cmtk/bin/reformatx' --verbose --outfile '/Volumes/teraraid/flybrain/Shahar/SplitRegistration/IS2/reformatted/JFRC2_IS2_JK733SF457-1_02_warp_m0g80c8e1e-1x26r4.nrrd' --floating '/Volumes/teraraid/flybrain/Shahar/SplitRegistration/IS2/reformatted/IS2_JK733SF457-1_02_warp_m0g80c8e1e-1x26r4.nrrd' --interpolation linear --outfile '/Volumes/teraraid/flybrain/Shahar/SplitRegistration/IS2/reformatted/JFRC2_IS2_JK733SF457-1_02_warp_m0g80c8e1e-1x26r4.nrrd' --target-grid 1024,512,218:0.622088,0.622088,0.622088:0.000000,0.000000,0.000000 '/Library/Frameworks/R.framework/Versions/3.2/Resources/library/nat.flybrains/extdata/bridgingregistrations/JFRC2_IS2.list'

(moved from)

brain2reg implementation

For the time being brain2reg will isolate any path dependencies and so you can choose whatever approach you like and we will not need to change much. It might be a bit more modular if it relied on the object to have a function that returned appropriate paths. Bridging registrations are trickier though. Here we might eventually need another registry style approach (see nat::fileformats) i.e. an environment in nat that stores registrations it know about. Data packages would then use a nat function to tell it about the type location of registrations.

isuuses in download_registrations and loss of JRCFIB2018F and JRCFIB2018Fraw

  1. When I use "nat.flybrains::download_jefferislab_registrations()" function, there is an error. "Error in git2r::pull(repo):branch is NULL". I think maybe there is a loss of the file?
  2. Here I get one bodyID in the neuprint and find and plot this neuron in natverse. I want to show it in the templatebrain. However, I can't use the two files: JRCFIB2018F and JRCFIB2018Fraw. It return "Error in get(paste0(as.character(x), ".surf")) : can't find the object 'JRCFIB2018Fraw.surf'". And also I can't use the xform_brain form JRCFIB2018Fraw to JFRC2.
    Could anyone answer these questions and give me some instructions to show this known neuron in hemibrain dataset in another template brain? Thanks a lot!

Missing template brains

Although #25 tried to bring template brains up to date, we have no template object for the following:

> library(nat.flybrains)
> setdiff(igraph::V(bridging_graph())$name, ls(envir = as.environment('package:nat.flybrains')))
[1] "Dyak"       "Cell07"     "JFRC2014"   "JFRC2014DS" "V2"        

Add xform_brain, mirror_brain and brain2reg functions

So after our discussion, I think the simplest strategy looks like:

brain2reg(reference=, sample=, mirror=)
xform_brain(x, reference=, sample=, ...) xform(x, brain2reg(refererence,sample), ...)
mirror_brain(x, brain=, ...) xform_brain(x, brain2reg(brain=mirror,...)

I think there could be some reasonable discussion about whether a mirror_brain function was also necessary, but people might expect to find one given the existence of nat::mirror.

S3 generic/method consistency

Currently, we have the following signatures:

xform:
  function(x, reg, ...)
xform.BrainTemplate:
  function(x, x2, data, transform, ...)

We cannot change xform() as this is part of nat, but we don't want reg as the whole point is to let the user avoid having to deal with registration files directly. This suggests that we should use a different function instead.

function to calculate overlap with labelfield

Would like either a function or simple examples showing how to calculate overlap with a label field.

Should we be including the VFB label field in e.g. JFRC2, FCWB, T1 and IS2 space?

Change architecture of trans()

Rather than have an S4 method that works out whether a bridging or mirroring registration should be performed, with the associated documentation issues, have two methods, xform_brain() and mirror_brain() that are completely decoupled from xform() (for method signature purposes) and that are as clear as possible with regard to which brain is the template, which is the reference, etc.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.