Scene video class#

class pyneon.video.NeonVideo(video_file: Path, timestamps_file: Path, info_file: Path)#

Bases: VideoCapture

Loaded video file with timestamps.

Parameters:
timestamps#

Timestamps of the video frames in nanoseconds.

Type:

np.ndarray

ts#

Alias for timestamps.

Type:

np.ndarray

n_frames#

Number of frames in the video.

Type:

int

fps#

Frames per second of the video.

Type:

float

width#

Width of the video frames in pixels.

Type:

int

height#

Height of the video frames in pixels.

Type:

int

plot_frame(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:
  • index (int) – Index of the frame to plot.

  • ax (matplotlib.pyplot.Axes or None) – Axis to plot the frame on. If None, a new figure is created. Defaults to None.

  • 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.video.sync_gaze_to_video(rec: NeonRecording, window_size: int | None = None) DataFrame#

Synchronize gaze data to video frames by applying windowed averaging around each video frame timestamp. See window_average() for details on the averaging process.

Parameters:#

recNeonRecording

Recording object containing gaze and video data.

window_sizeint, optional

The size of the time window (in nanoseconds) over which to compute the average around each new timestamp. If None (default), the window size is set to the median interval between the new timestamps, i.e., np.median(np.diff(new_ts)). The window size must be larger than the median interval between the original data timestamps, i.e., window_size > np.median(np.diff(data.index)).

Returns:#

pd.DataFrame

DataFrame containing gaze data mapped to video timestamps.

pyneon.video.estimate_scanpath(video: NeonVideo, sync_gaze: NeonGaze, lk_params: dict | None = None) DataFrame#

Map fixations to video frames using optical flow.

Parameters:
  • video (NeonVideo) – Video object containing the frames.

  • sync_gaze (NeonGaze) – Gaze data synchronized with the video frames.

  • lk_params (dict, optional) – Parameters for the Lucas-Kanade optical flow algorithm.

Returns:

DataFrame containing the scanpath with updated fixation points.

Return type:

pd.DataFrame