Classes for individual data types#

class pyneon.data.NeonData(file: Path)#

Bases: object

Base for Neon tabular data. It reads from a CSV file and stores the data as a pandas DataFrame (with section and recording IDs removed).

class pyneon.stream.NeonStream(file: Path)#

Bases: NeonData

Base for Neon continuous data (gaze, eye states, IMU). It must contain a timestamp [ns] column.

Parameters:

file (pathlib.Path) – Path to the CSV file containing the stream data.

data#

DataFrame containing the stream data.

Type:

pandas.DataFrame

timestamps#

Timestamps of the stream in nanoseconds.

Type:

np.ndarray

ts#

Alias for timestamps.

Type:

np.ndarray

first_ts#

First timestamp of the stream.

Type:

int

last_ts#

Last timestamp of the stream.

Type:

int

times#

Timestamps converted to seconds relative to stream start.

Type:

np.ndarray

duration#

Duration of the stream in seconds.

Type:

float

sampling_freq_effective#

Effective sampling frequency of the stream (number of time points divided by duration).

Type:

float

sampling_freq_nominal#

Nominal sampling frequency of the stream as specified by Pupil Labs (https://pupil-labs.com/products/neon/specs).

Type:

int

crop(tmin: Number | None = None, tmax: Number | None = None, by: Literal['timestamp', 'time'] = 'timestamp', inplace: bool = False) DataFrame#

Crop data to a specific time range.

Parameters:
  • tmin (number, optional) – Start time or timestamp to crop the data to. If None, the minimum timestamp or time in the data is used. Defaults to None.

  • tmax (number, optional) – End time or timestamp to crop the data to. If None, the maximum timestamp or time in the data is used. Defaults to None.

  • by ("timestamp" or "time", optional) – Whether tmin and tmax are UTC timestamps in nanoseconds or relative times in seconds. Defaults to “timestamp”.

  • inplace (bool, optional) – Whether to replace the data in the object with the cropped data. Defaults to False.

Returns:

Cropped data.

Return type:

pd.DataFrame

interpolate(new_ts: None | ndarray = None, float_kind: str = 'linear', other_kind: str = 'nearest', inplace: bool = False) DataFrame#

Interpolate the stream to a new set of timestamps.

Parameters:
  • new_ts (np.ndarray, optional) – New timestamps to evaluate the interpolant at. If None, new timestamps are generated according to the nominal sampling frequency of the stream as specified by Pupil Labs: https://pupil-labs.com/products/neon/specs.

  • data (pd.DataFrame) – Data to interpolate. Must contain a monotonically increasing timestamp [ns] column.

  • float_kind (str, optional) – Kind of interpolation applied on columns of float type, by default “linear”. For details see scipy.interpolate.interp1d.

  • other_kind (str, optional) – Kind of interpolation applied on columns of other types, by default “nearest”.

Returns:

Interpolated data.

Return type:

pandas.DataFrame

class pyneon.stream.NeonGaze(file: Path)#

Bases: NeonStream

Gaze data that inherits attributes and methods from NeonStream.

class pyneon.stream.NeonEyeStates(file: Path)#

Bases: NeonStream

3D eye states data that inherits attributes and methods from NeonStream.

class pyneon.stream.NeonIMU(file: Path)#

Bases: NeonStream

IMU data that inherits attributes and methods from NeonStream.

class pyneon.events.NeonEV(file)#

Bases: NeonData

Base for Neon event data (blinks, fixations, saccades, “events” messages).

Bases: NeonEV

Blink data.

class pyneon.events.NeonFixations(file)#

Bases: NeonEV

Fixation data.

class pyneon.events.NeonSaccades(file)#

Bases: NeonEV

Saccade data.

class pyneon.events.NeonEvents(file)#

Bases: NeonEV

Event data.

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.