NeuPrint Janelia hemibrain dataset to FlyWire coordinates

305 views
Skip to first unread message

Altyn Rymbek

unread,
May 21, 2020, 9:21:22 PM5/21/20
to nat-user
Hi all,

I am trying to get FlyWire coordinates of the oviDNa neuron (published in https://doi.org/10.1038/s41586-020-2055-9) from NeuPrint hemibrain dataset. I followed the worked example provided by Dr. Jefferis in another thread (https://groups.google.com/forum/?utm_medium=email&utm_source=footer#!msg/nat-user/zNaCyQnZeVg/0aruyJvrAQAJ):

library(nat.jrcbrains)
dl1.hemibrain=neuprint_read_neurons('oviDNa')
dl1.hemibrain.fafb=xform_brain(dl1.hemibrain/125, reference= "FAFB14", sample="JRCFIB2018F")

dl1.hemibrain.jrc2018f=xform_brain(dl1.hemibrain*8/1000, reference= "JRC2018F", sample="JRCFIB2018F")

fafbconn=catmaid::catmaid_login(server='https://fafb.catmaid.virtualflybrain.org/')
dl1.fafb=catmaid::read.neurons.catmaid('name:oviDN', conn=fafbconn)
dl1.fafb.jrc2018f=xform_brain(dl1.fafb, reference = "JRC2018F", sample="FAFB14")

plot3d(dl1.fafb.jrc2018f, col='red')
plot3d(dl1.hemibrain.jrc2018f, col='cyan')
plot3d(JRC2018F)

However, in dl1.fafb=catmaid::read.neurons.catmaid('name:oviDN', conn=fafbconn) I get errors:

Error in catmaid_fetch(path, body = post_data, include_headers = F, conn = conn,  : 
  Internal Server Error (HTTP 500).
In addition: Warning message:
In catmaid_skids(skids, conn = conn, pid = pid) :
  No matches for query "name:oviDNa"!

I guess the error and warning appear because there is no "oviDNa" neuron in the fafb.catmaid dataset. I am wondering how to fix this in order to obtain x,y,z coordinates of "oviDNa" neuron to find it in FlyWire EM stacks.

In case there is a way to find oviDNa neuron in fafb.catmaid dataset, I should probably do the following to convert the obtained neuron from JRC2018F to FAFB template and obtain the coordinates in FlyWire EM stacks.

my_neuron_FAFB_raw <- xform_brain(dl1.fafb.jrc2018f,sample=JRC2018F,reference=FAFB)
my_neuron_FAFB <- my_neuron_FAFB_raw/voxdims(FAFB14)
my_neuron_pixel_coordinates <- xyzmatrix(my_neuron_FAFB)
sample_pixel <- my_neuron_pixel_coordinates[100,]
sample_pixel

Any help in resolving this error or any other suggestions about getting the coordinates of neuPrint neurons in FlyWire would be highly appreciated!

Thank you!

Kind regards,

Altyn

Greg Jefferis

unread,
May 26, 2020, 9:21:21 PM5/26/20
to nat-user
Dear Altyn,

Thanks for your interst in nat and the natverse. The problem with what you are doing below is that you are trying to fetch the oviDN neuron from the FAFB dataset hosted by the Virtual Fly Brain. Although Barry Dickson's group traced these neurons in FAFB, they have not yet shared the traced neurons with VFB. You can write Barry and/or the first authors and request the tracings and this might also be a nudge for them to be deposited to VFB. This would be the most durect way to get to FlyWire coordinates since they are both based on the same underlying EM data (albeit with differences in the in the registration of the image data that result in order 1µm variations in position).

What you say you want to do is transform the hemibrain neurons into FAFB space, which is not quite your edited code is trying to do. You have already fetched the oviDN neurons from the hemibrain dataset via neuprint. See code below for how to go from hemibrain to FAFB14 (Zheng et al 2018) and then jump to the FlyWire location.

library(natverse)
ovidns
.hemibrain=neuprintr::neuprint_read_neurons('oviDN')
library
(nat.jrcbrains)
# if you haven't already ...
# download_saalfeldlab_registrations()

# convert hemibrain to *FAFB* space
ovidns
.fib.fafb=xform_brain(ovidns.fib*8/1000, reference= "FAFB14",
                            sample
="JRCFIB2018F", via=JRC2018F)

plot3d
(ovidns.fib.fafb, lwd=2)
plot3d
(FAFB)


# Next let's try to find the FlyWire neurons by jumping to a location

# chosen from the transformed hemibrain neurons
# (the fafbseg package comes with the natverse if not:
# remotes::install_github("jefferis/fafbseg")


# I then did this command drawing a rectangle on the rgl 3d window  picking what I suspected to be a low variability part of the neuron
# and hit one of the oviDNs exactly.
library
(fafbseg)
open_fafb_ngl
(ovidns.fib.fafb, coords.only=FALSE)

# the latest version of fabseg lets you do this
choose_segmentation('flywire')
# jump straight to flywire
open_fafb_ngl(ovidns.fib.fafb, sample="FAFB14", reference="FlyWire")

# you could then fetch meshes for those neurons 
# if you have the cloudvolume python package installed and configures
ovidn1
.flywire.meshes=fafbseg::read_cloudvolume_meshes(c("720575940617432523","720575940628757445"))
shade3d(ovidn1.flywire.meshes[[1]], col='green')
shade3d(ovidn1.flywire.meshes[[2]], col='magenta')






ovidns-hemibrain.png
ovidns-hemibrain-flywire.png

Altyn Rymbek

unread,
Jun 2, 2020, 9:03:27 PM6/2/20
to nat-user
Dear Dr. Greg Jefferis,

Thank you so much for the very detailed and clear response. This is really helpful!

I followed your explanation and eventually found the neuron. From my experience, it looks like because of the displacement, some time is required to search for the neuron of interest in the proximity of the FlyWire coordinates found after drawing the rectangle on the rgl 3d window.

Thank you very much for investing your time to provide such a clear explanation.

Kind regards,

Altyn

вторник, 26 мая 2020 г., 18:21:21 UTC-7 пользователь Greg Jefferis написал:

Le Anh Duc

unread,
Jun 15, 2020, 11:47:25 AM6/15/20
to nat-user
Dear Dr. Jefferis,

Thank you for developing this beautiful tool! I have a similar purpose as Altyn here, except the neurons that I am interested in are LPLC4 neurons, can be found on the neuprint explorer website by searching LPLC4. 

I am trying to explore the codes you wrote for Altyn above here regarding oviDN neurons, and will try to apply it to my LPLC4 neurons. I am a complete newbie to R so I would very much appreciate your explanations on these 2 questions that I have:

1. For the lines below, could you please explain where does the ovidns.fib come from? I tried to run the code but R tells me it cannot find ovidns.fib.
Also, what does the 8/1000 mean, and how should I know what factor to put for my LPLC4 neurons? 


# convert hemibrain to *FAFB* space
ovidns
.fib.fafb=xform_brain(ovidns.fib*8/1000, reference= "FAFB14",
                            sample
="JRCFIB2018F", via=JRC2018F)


2. There are 46 LPLC4 neurons in the results of neuprint explorer. Is there a way to only look at one of it, say the first one that pops up on the results?

Thank you so much once again!      

Mike

Greg Jefferis

unread,
Jun 15, 2020, 3:02:33 PM6/15/20
to Le Anh Duc, nat-user
Dear Mike,

Thanks for your message. 

1a) You are right, there was a typo in the example, change 

ovidns.hemibrain=neuprintr::neuprint_read_neurons('oviDN')

to 

ovidns.fib=neuprintr::neuprint_read_neurons('oviDN')

1b) The factor of 8/1000 converts raw voxels to microns and has been covered a couple of times previously on the user group. Please see


And let us know if you still have questions.

2. To look at individual neurons, here are some ideas

library(neuprintr)

# WIP package targeted at hemibrain 
remotes::install_github("flyconnectome/hemibrainr")
library(hemibrainr)

# this immediately converts to microns
LPLC4=hemibrain_read_neurons("LPLC4", microns=TRUE)

# clear 3D display
nclear3d()
# brain surface for context
plot3d(hemibrainr::hemibrain_microns.surf, alpha=.2)
# plot all
plot3d(LPLC4, soma=T)

# just one, chosen by position in the results list
nclear3d()
plot3d(hemibrainr::hemibrain_microns.surf, alpha=.2)
plot3d(LPLC4[1], soma=T)

# chosen by bodyid
nclear3d()
plot3d(hemibrainr::hemibrain_microns.surf, alpha=.2)
plot3d(LPLC4["5812990157"], soma=T)

# scan through neurons one by one
nclear3d()
plot3d(hemibrainr::hemibrain_microns.surf, alpha=.2)
nlscan(LPLC4, soma=T, lwd=2)


3. Please feel free to keep asking questions here, but as mentioned at http://natverse.org/learn/, we recommend working through


And scanning 


This will probably save you time in the long run.

All the best,

Greg.


--
You received this message because you are subscribed to the Google Groups "nat-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nat-user+u...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/nat-user/016204ea-7581-4fc8-a45b-f2df867f108eo%40googlegroups.com.

Le Anh Duc

unread,
Jun 16, 2020, 2:01:01 PM6/16/20
to nat-user
Dear Greg,

Thank you very much for the codes to plot LPLC4 neurons. They work beautifully for me.

I'm still running into trouble with the code that you wrote for Altyn earlier. Particularly, when I try to run the following codes (after successfully executing the preceeding ones:


# I then did this command drawing a rectangle on the rgl 3d window  picking what I suspected to be a low variability part of the neuron
# and hit one of the oviDNs exactly.
library
(fafbseg)
open_fafb_ngl
(ovidns.fib.fafb, coords.only=FALSE)

# the latest version of fabseg lets you do this
choose_segmentation('flywire')
# jump straight to flywire
open_fafb_ngl(ovidns.fib.fafb, sample="FAFB14", reference="FlyWire")

The yellow highlighted codes just open blank RGL devices and not really do anything else. I'd appreciate it if you have any inputs for this.

What's interesting is that I was able to successfully execute the example provided in the R Documentation for the open_fafb_ngl function (as pasted below). I'm thinking there maybe something about the ovidns.fib.fafb that the open_fafb_ngl function couldn't work with.

u=paste0("https://fafb.catmaid.virtualflybrain.org/?pid=2&zp=131280&",
"yp=170014.98879622458&xp=426584.81386896875&tool=navigator&sid0=2&s0=-1")

# translate URL but don't open browser
open_fafb_ngl(u, open=FALSE)

# produce an x,y,z string to paste into Neuroglancer
open_fafb_ngl(u, coords.only=TRUE)

# translate URL converting from FAFB14 to FlyWire coordinates
# (only a small shift)
open_fafb_ngl(u, sample="FAFB14", reference="FlyWire", open=FALSE)
## Not run: 
# copy CATMAID URL from clipboard and Neuroglancer coords to clipboard
clipr::write_clip(open_fafb_ngl(clipr::read_clip(), coords.only=TRUE))

# Open a location in MB peduncle with current preferred segmentation
open_fafb_ngl(c(433440, 168344, 131200))

# choose a particular segmentation (Google FAFB)
with_segmentation("20190805", open_fafb_ngl(c(433440, 168344, 131200),
zoomFactor=2))

# or FlyWire
with_segmentation("flywire", open_fafb_ngl(c(433440, 168344, 131200)))

# ... and translate FAFB14 to FlyWire coordinates
with_segmentation("flywire", open_fafb_ngl(c(433440, 168344, 131200),
sample="FAFB14", reference="FlyWire", zoomFactor=2))

# open a CATMAID URL in Neuroglancer
open_fafb_ngl(u)

# Set an existing scene URL (pointing to any old location) to act as
# the template for open_fafb_ngl
# nb the package sets one for you on startup if you haven't set yourself
options(fafbseg.sampleurl="https://<neuroglancerlurl>")
# Edit your R profile if you want to set a different default
usethis::edit_r_profile()

## End(Not run)   

Really, really appreciate your help with this matter!

Regards,
Mike

Gregory Jefferis

unread,
Jun 16, 2020, 2:18:18 PM6/16/20
to Le Anh Duc, nat-user
Dear Mike, those examples assume that you have previously plotted the object called ovidns.fib.fafb and that it is still visible in your rgl window. 

This could be as simple as:

plot3d(ovidns.fib.fafb)

I think there were examples of doing this in the code sample I sent previously. 

This then acts as a target for you to do an interactive selection of a small region. 

All the best,

Greg. 


Sent from my iPhone

On 16 Jun 2020, at 19:01, Le Anh Duc <anhd...@gmail.com> wrote:


--
You received this message because you are subscribed to the Google Groups "nat-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nat-user+u...@googlegroups.com.

Le Anh Duc

unread,
Jun 16, 2020, 2:24:21 PM6/16/20
to nat-user
Dear Greg,

Perfect, worked beautifully. 

Thank you very much!!! I greatly appreciate your help!!!

Regards,
Mike
To unsubscribe from this group and stop receiving emails from it, send an email to nat-...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages