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:
- timestamps#
Timestamps of the stream in nanoseconds.
- Type:
np.ndarray
- ts#
Alias for timestamps.
- Type:
np.ndarray
- times#
Timestamps converted to seconds relative to stream start.
- Type:
np.ndarray
- sampling_freq_effective#
Effective sampling frequency of the stream (number of time points divided by duration).
- Type:
- sampling_freq_nominal#
Nominal sampling frequency of the stream as specified by Pupil Labs (https://pupil-labs.com/products/neon/specs).
- Type:
- 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 toNone
.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 toNone
.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:
- 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).
- class pyneon.video.NeonVideo(video_file: Path, timestamps_file: Path, info_file: Path)#
Bases:
VideoCapture
Loaded video file with timestamps.
- Parameters:
video_file (
pathlib.Path
) – Path to the video file.timestamps_file (
pathlib.Path
) – Path to the timestamps file.
- timestamps#
Timestamps of the video frames in nanoseconds.
- Type:
np.ndarray
- ts#
Alias for timestamps.
- Type:
np.ndarray
- 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. 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.