- navis.mirror_brain(x, template, mirror_axis='x', warp='auto', via=None, verbose=False)¶
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.
x (Neuron/List | Volume/trimesh | numpy.ndarray | pandas.DataFrame) – Data to transform. Dataframe must contain
['x', 'y', 'z']columns. Numpy array must be shape
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 mirror transformation exists for the given
templateand apply it after the flipping. You can also just pass a Transform or TransformSequence.
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.
Same object type as input (array, neurons, etc) but with transformed coordinates.
- Return type:
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()
flybrainsis 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
Lower level function for mirroring. You can use this if you want to mirror data without having a registered template for it.