add_angle_rgb_to_nap#

ethograph.io.pynapple.add_angle_rgb_to_nap(tsdframe, smoothing_params, position_key='position', xy_columns=['x', 'y'])[source]#

Compute heading-angle RGB colour coding from 2-D position data.

Calculates the heading angle from consecutive (x, y) positions in tsdframe and maps each angle to an RGB triplet via get_angle_rgb(). Gaussian smoothing is applied before angle computation.

Parameters:
  • tsdframe (nap.TsdFrame) – Position data with at least two columns (x and y). If more than two columns are present, xy_columns selects which two to use.

  • smoothing_params (dict) – Keyword arguments forwarded to scipy.ndimage.gaussian_filter1d() (e.g. {"sigma": 3}).

  • position_key (str, optional) – Input type passed to get_angle_rgb (default "position").

  • xy_columns (list[str], optional) – Column names to use as x and y when tsdframe has more than two columns (default ["x", "y"]).

Returns:

A new TsdFrame with three columns ["R", "G", "B"] on the same time support as tsdframe.

Return type:

nap.TsdFrame

Examples

>>> import ethograph as eto
>>> data = eto.load_nap_data("experiment.nwb")
>>> rgb = eto.add_angle_rgb_to_nap(
...     data["position"],
...     smoothing_params={"sigma": 3},
... )
>>> rgb.columns
['R', 'G', 'B']