navis.mirror_brain¶
- navis.mirror_brain(x, template, mirror_axis='x', warp='auto', via=None, verbose=False)[source]¶
Mirror 3D object (neuron, coordinates) about given axis.
- The way this works is:
Look up the length of the template space along the given axis. For this, the template space has to be registered (see docs for details).
Flip object along midpoint of axis using a affine transformation.
(Optional) Apply a warp transform that corrects asymmetries.
- Parameters:
x (Neuron/List | Volume/trimesh | numpy.ndarray | pandas.DataFrame) – Data to transform. Dataframe must contain
['x', 'y', 'z']
columns. Numpy array must be shape(N, 3)
.template (str | TemplateBrain) – Source template brain space that the data is in. If string will be searched against registered template brains. Alternatively check out
navis.transforms.mirror()
for a lower level interface.mirror_axis ('x' | 'y' | 'z', optional) – Axis to mirror. Defaults to x.
warp (bool | "auto" | Transform, optional) – If ‘auto’, will check if a non-rigi mirror transformation exists for the given
template
and apply it after the flipping. Alternatively, you can also pass a Transform or TransformSequence directly.via (str | None) – If provided, (e.g. “FCWB”) will first transform coordinates into that space, then mirror and transform back. Use this if there is no mirror registration for the original template, or to transform to a symmetrical template in which flipping is sufficient.
verbose (bool) – If True, will print some useful info on the transform(s).
- Returns:
Same object type as input (array, neurons, etc) but with transformed coordinates.
- Return type:
xf
Examples
This example requires the flybrains library to be installed:
pip3 install flybrains
Also, if you haven’t already, you will need to have the optional Saalfeld lab (Janelia Research Campus) transforms installed (this is a one-off):
>>> import flybrains >>> flybrains.download_jrc_transforms()
Once
flybrains
is installed and you have downloaded the registrations, you can run this:>>> import navis >>> import flybrains >>> # navis example neurons are in raw hemibrain (JRCFIB2018Fraw) space >>> n = navis.example_neurons(1) >>> # Mirror about x axis (this is a simple flip in this case) >>> mirrored = navis.mirror_brain(n * 8 / 1000, tem plate='JRCFIB2018F', via='JRC2018F') >>> # We also need to get back to raw coordinates >>> mirrored = mirrored / 8 * 1000
See also
navis.mirror()
Lower level function for mirroring. You can use this if you want to mirror data without having a registered template for it.