Giter Club home page Giter Club logo

nat.flybrains's Introduction

nat.flybrains

natverse Build Status Release Version DOI Docs

nat.flybrains provides additional data and functions for use with the NeuroAnatomy Toolbox (nat). In particular nat.flybrains defines the physical properties of a number of commonly used template brains in Drosophila neuronatomy including:

along with bridging registrations between some of these template brains (see https://github.com/jefferislab/BridgingRegistrations) and functions to transform objects such as nat neurons from one space to another as simply as:

# convert neuron from IS2 space to JFRC2 space
myneuron.jfrc2=xform_brain(myneuron, sample=IS2, reference=JFRC2)

# flip neuron to opposite hemisphere of JFRC2 space
myneuron.jfrc2.flip=mirror_brain(myneuron.jfrc2, JFRC2)

# to install additional/updated registrations 
# (beyond those distributed as part of the R package)
# Strongly recommended!
download_jefferislab_registrations()

# for more information
JFRC2
IS2
?xform_brain
?mirror_brain

Installation

This package is fully functional but there are presently no plans to release a version to CRAN, since there is a significant amount of data included with the package (and CRAN discourages large packages).

You can, however, download the tar ball, and run R CMD INSTALL on it, or (highly recommended) use the devtools package to install straight from github:

# install devtools package if you don't already have it
if (!require("remotes")) install.packages("remotes")
remotes::install_github("natverse/nat.flybrains")

# to install additional/updated registrations 
# (beyond those distributed as part of the R package)
# Strongly recommended!
nat.flybrains::download_jefferislab_registrations()

Note: Windows users need Rtools and devtools to install this way.

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

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.

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"        

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.

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.

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?

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.

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)

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.

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.

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.

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)

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.

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.

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.