Visualization module#
- pyneon.vis.plot_frame(video: NeonVideo, index: int = 0, ax: Axes | None = None, auto_title: bool = True, show: bool = True)#
Plot a frame from the video on a matplotlib axis.
- Parameters:
video (
NeonVideo
) – Video object to plot the frame from.index (int) – Index of the frame to plot.
ax (
matplotlib.pyplot.Axes
or None) – Axis to plot the frame on. IfNone
, a new figure is created. Defaults toNone
.auto_title (bool) – Whether to automatically set the title of the axis. The automatic title includes the video file name and the frame index. Defaults to
True
.
- Returns:
fig (
matplotlib.pyplot.Figure
) – Figure object containing the plot.ax (
matplotlib.pyplot.Axes
) – Axis object containing the plot.
- pyneon.vis.plot_distribution(rec: NeonRecording, heatmap_source: Literal['gaze', 'fixations', None] = 'gaze', scatter_source: Literal['gaze', 'fixations', None] = 'fixations', step_size: int = 10, sigma: Number | None = 2, width_height: tuple[int, int] = (1600, 1200), cmap: str | None = 'inferno', ax: Axes | None = None, show: bool = True)#
Plot a heatmap of gaze or fixation data on a matplotlib axis. Users can flexibly choose to generate a smoothed heatmap and/or scatter plot and the source of the data (gaze or fixation).
- Parameters:
rec (
NeonRecording
) – Recording object containing the gaze and video data.heatmap_source ({'gaze', 'fixations', None}) – Source of the data to plot as a heatmap. If None, no heatmap is plotted. Defaults to ‘gaze’.
scatter_source ({'gaze', 'fixations', None}) – Source of the data to plot as a scatter plot. If None, no scatter plot is plotted. Defaults to ‘fixations’. Gaze data is typically more dense and thus less suitable for scatter plots.
step_size (int) – Size of the grid cells in pixels. Defaults to 10.
sigma (float or None) – Standard deviation of the Gaussian kernel used to smooth the heatmap. If None or 0, no smoothing is applied. Defaults to 2.
width_height (tuple[int, int]) – If video is not available, the width and height of the scene camera frames to specify the heatmap dimensions. Defaults to (1600, 1200).
cmap (str or None) – Colormap to use for the heatmap. Defaults to ‘inferno’.
ax (
matplotlib.pyplot.Axes
or None) – Axis to plot the frame on. IfNone
, a new figure is created. Defaults toNone
.show (bool) – Show the figure if
True
. Defaults to True.
- Returns:
fig (
matplotlib.pyplot.Figure
) – Figure object containing the plot.ax (
matplotlib.pyplot.Axes
) – Axis object containing the plot.