Learn R Programming

nat.templatebrains (version 0.6.1)

xform_brain: Transform 3D object between template brains

Description

Transform 3D object between template brains

Usage

xform_brain(x, sample, reference, via = NULL, imagedata = is.character(x),
  checkboth = NULL, ...)

Arguments

x
the 3D object to be transformed
sample
Source template brain (e.g. IS2) that data is currently in.
reference
Target template brain (e.g. IS2) that data should be transformed into.
via
optional intermediate brain to use when there is no direct bridging registration.
imagedata
Whether x should be treated as image data (presently only supported as a file on disk or 3D object vertices - see details).
checkboth
When TRUE will look for registrations in both directions. See details.
...
extra arguments to pass to xform.

Details

NB the sample, reference and via brains can either be templatebrain objects or a character string containing the short name of the template e.g. "IS2".

The significance of the imagedata and checkboth arguments is that CMTK registrations are not directly invertible although they can be numerically inverted in most cases (unless there are regions where folding occurred). For image data, numerical inversion is much slower.

You can control whether you want to allow inverse registrations manually by setting checkboth explicitly. Otherwise when checkboth=NULL the following default behaviour occurs:

  • whenvia=NULLcheckboth=Tbut a warning will be given if an inversion must be used.
  • whenviais specified thencheckboth=Tbut a warning will be given if an inversion must be used.

Examples

Run this code
## depends on nat.flybrains package and system CMTK installation
## reformat neurons
##
library(nat.flybrains)
# Plot Kenyon cells in their original FCWB template brain
nopen3d()
plot3d(kcs20)
plot3d(FCWB)
# Convert to JFCR2 template brain
kcs20.jfrc2=xform_brain(kcs20, sample = FCWB, reference=JFRC2, .progress='text')
# now plot in the new JFRC2 space
nopen3d()
plot3d(kcs20.jfrc2)
plot3d(JFRC2)
# compare with the untransformed neurons
plot3d(kcs20)
# plot with neuropil sub regions for the left mushroom body
clear3d()
plot3d(kcs20.jfrc2)
# nb "MB.*_L" is a regular expression
plot3d(JFRC2NP.surf, "MB.*_L", alpha=0.3)
# compare with originals - briging registration is no perfect in peduncle
nopen3d()
plot3d(kcs20)
plot3d(FCWBNP.surf, "MB.*_L", alpha=0.3)


## reformat image examples
# see ?cmtk.reformatx for details of all additional arguments
xform_brain('in.nrrd', sample=FCWB, ref=JFRC2, output='out.nrrd', Verbose=F)

# use nearest neighbour interpolation for label field
xform_brain('labels.nrrd', sample=FCWB, ref=JFRC2, output='out.nrrd', interpolation='nn')

# use binary mask to restrict (and speed up) reformatting
xform_brain('in.nrrd', sample=FCWB, ref=JFRC2, output='out.nrrd', mask='neuropil.nrrd')

Run the code above in your browser using DataLab