navis.interfaces.r.xform_brain¶
- navis.interfaces.r.xform_brain(x, source, target, fallback=None, bulk=False, verbose=False, **kwargs)[source]¶
Transform 3D data between template brains.
This is a simple wrapper for
nat.templatebrains:xform_brain
.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 radii (for TreeNeurons).- Parameters:
x (Neuron/List | numpy.ndarray | pandas.DataFrame) – Data to transform. Dataframe must contain
['x', 'y', 'z']
columns. Numpy array must be shape(N, 3)
.source (str) – Source template brain that the data currently is in.
target (str) – Target template brain that the data should be transformed into.
fallback (None | "AFFINE",) – If “AFFINE”, will fall back to affine transformation if CMTK transformation fails. Else coordinates of points for which the transformation failed (e.g. b/c they are out of bounds), will be returned as
None
.bulk (bool | int) – If True or number and input is NeuronList, will xform all coordinates in chunks (default=100k) instead of neuron-by-neuron. This can be ~2x faster (due to reduced overhead) is very memory intensive! If
bulk
is a number will process chunks of given size.**kwargs – Keyword arguments passed to
nat.templatebrains:xform_brain
- Returns:
Copy of input with transformed coordinates.
- Return type:
same type as
x