navis 1.4.0
  • Install
  • Quickstart
  • Tutorials
  • API
  • Changelog
  • Github
  • Ecosystem
  • Site
    • Page
        • navis.xform
          • xform()

    navis.xform¶

    navis.xform(x, transform, affine_fallback=True, caching=True)[source]¶

    Apply transform(s) to data.

    Notes

    For Neurons only: whether there is a change in units during transformation (e.g. nm -> um) is inferred by comparing distances between x/y/z coordinates before and after transform. This guesstimate is then used to convert .units and node/soma radii. This works reasonably well with base 10 increments (e.g. nm -> um) but is off with odd changes in units.

    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).

    • transform (Transform/Sequence or list thereof) – Either a single transform or a transform sequence.

    • affine_fallback (bool) – In same cases the non-rigid transformation of points can fail - for example if points are outside the deformation field. If that happens, they will be returned as NaN. Unless affine_fallback is True, in which case we will apply only the rigid affine part of the transformation to at least get close to the correct coordinates.

    • caching (bool) –

      If True, will (pre-)cache data for transforms whenever possible. Depending on the data and the type of transforms this can tremendously speed things up at the cost of increased memory usage:

      • False = no upfront cost, lower memory footprint

      • True = higher upfront cost, most definitely faster

      Only applies if input is NeuronList and if transforms include H5 transform.

    Returns:

    Copy of input with transformed coordinates.

    Return type:

    same type as x

    Examples

    >>> import navis
    >>> # Example neurons are in 8nm voxel space
    >>> nl = navis.example_neurons()
    >>> # Make a simple Affine transform to go from voxel to nanometers
    >>> import numpy as np
    >>> M = np.diag([8, 8, 8, 8])
    >>> tr = navis.transforms.AffineTransform(M)
    >>> # Apply the transform
    >>> xf = navis.xform(nl, tr)
    

    See also

    navis.xform_brain()

    Higher level function that finds and applies a sequence of transforms to go from one template brain to another.

    Back to top

    Source

    © Copyright 2018, Philipp Schlegel.
    Created using Sphinx 5.3.0.