Mirror an object in FAFB space using FAFB-JRC2018F registration

mirror_fafb(x, sample = NULL, subset = NULL, via = NULL, ...)

Arguments

x

An object containing 3D vertices (e.g. a neuron, surface, points)

sample

The starting brain space in which x lives - FAFB14 by default if it is not otherwise other specified.

subset

Character, numeric or logical vector specifying on which subset of X the function FUN should be applied. Elements outside the subset are passed through unmodified.

via

(optional, for expert use only) Intermediate template brain that the registration sequence must pass through. See details and xform_brain for more information.

...

Additional arguments passed to xform_brain and mirror_brain

Value

A mirrored version of the neuron/surface or other 3D object.

Details

This function works by mapping the input data to JRC2018F, a high quality symmetric female brain template. The data are then flipped (since JRC2018F is symmetric no other action is required) and then returned to the starting space. In order to ensure that the Bogovic et al bridging registrations are preferred the via argument will be filled with the value "FAFB14um" i.e. FAFB14 calibrated in microns. This works because the Bogovic registrations were based on a mock synaptic staining using synapse locations that had been rescaled to microns before calculating a registration with ANTs to JRC2018F.

Examples

# \donttest{ # transform arbitrary location (in nm) mirror_fafb(cbind(388112, 162988, 132840))
#> [,1] [,2] [,3] #> [1,] 667366.9 174034.2 102780.7
# same but in units of microns mirror_fafb(cbind(388.112, 162.988, 132.84), sample='FAFB14um')
#> [,1] [,2] [,3] #> [1,] 667.3669 174.0342 102.7807
# no messages mirror_fafb(cbind(388112, 162988, 132840), Verbose=FALSE)
#> [,1] [,2] [,3] #> [1,] 667366.9 174034.2 102780.7
# transform arbitrary location (from and to raw pixel coordinates) voxel.size=c(4,4,40) mirror_fafb(cbind(97028, 40747, 3321)* voxel.size)/c(voxel.size)
#> [,1] [,2] [,3] #> [1,] 166841.7 43508.56 2569.518
library(nat.flybrains) if(require('elmr', quietly = TRUE)) { FAFB.surf.m <- mirror_fafb(FAFB14.surf) wire3d(as.mesh3d(FAFB.surf), col='blue') wire3d(as.mesh3d(FAFB.surf.m), col='red') } if (FALSE) { # you can also use with points in https://flywire.ai space # converts from raw (voxel) coords used by Neuroglancer to nm and back again voxel.size=c(4,4,40) mirror_fafb(cbind(120508, 46292, 1667)*voxel.size, sample='FlyWire')/voxel.size # compare with just using FAFB14 mirror_fafb(cbind(120508, 46292, 1667)*voxel.size)/voxel.size } # }