Fetch a mesh volume from CATMAID

catmaid_get_volume(
  x,
  rval = c("mesh3d", "catmaidmesh", "raw"),
  invertFaces = FALSE,
  conn = NULL,
  pid = 1,
  ...
)

Arguments

x

The integer volume id or character volume name

rval

The class to return.

invertFaces

Whether to invert the faces (swapping inside and outside, see details).

conn

the catmaid_connection object

pid

project id (default 1)

...

Additional arguments passed to the catmaid_fetch function.

Value

When rval mesh3d, the standard format used by the rgl and nat packages is the default. catmaidmesh is a tidy version of the mesh format used by catmaid. raw will allow any return value.

Details

Note that if x is a volume name as a character vector then it must be unique (something that CATMAID servers do not insist on).

Note also that this function is targeted at mesh volumes, but CATMAID also support box volumes - these can still be returned and will have a valid set of vertices but an invalid set of indices.

I have noticed that some CATMAID meshes are returned with the normals facing into the mesh (the opposite of what one would expect). This causes pointsinside to do the opposite of what one would expect. Use invertFaces=TRUE to fix this.

Examples

## NB all these examples refer to the FAFB adult Drosophila brain
## CATMAID instance
# \donttest{
fafbconn=vfbcatmaid("fafb")
v14.neuropil=catmaid_get_volume('v14.neuropil', conn=fafbconn)
# specifying by name is easier / less fragile than numeric ids
# }

if (FALSE) {
AL_R=catmaid_get_volume("AL_R", conn=fafbconn)
shade3d(AL_R, col='red', alpha=.3)

if(require("Morpho")) {
  plotNormals(facenormals(AL_R), length=5e3)
}

## Fetch MB surfaces 
vl=catmaid_get_volumelist(conn=fafbconn)
mbids=vl$id[grepl("^MB_", vl$name)]
mbsurfs=lapply(mbids, catmaid_get_volume, conn=fafbconn)
# ... and plot
mapply(shade3d, mbsurfs, col=rainbow(length(mbsurfs)))

## find surfaces for olfactory glomeruli
# not currently present in the catmaid FAFB
glomids=vl$id[grepl("v14.[DV][MLAPC]{0,1}[0-9]{0,1}[dvaplm]{0,1}$", vl$name)]
# fetch them all
gg=lapply(glomids, catmaid_get_volume, conn=fafbconn)
# ... and plot
mapply(shade3d, gg, col=rainbow(length(gg)))

# alternatively wrap them all in an rgl shapelist3d, plotting each object
sl=shapelist3d(gg, col=rainbow(length(gg)), plot=TRUE)

}