UNPKG

gazeplotter

Version:

Gazeplotter is a Svelte application for visualizing eye-tracking data.

163 lines (162 loc) 8.14 kB
import type { SingleDeserializerOutput } from '../../../type/DeserializerOutput/SingleDeserializerOutput/SingleDeserializerOutput.js'; import { AbstractEyeDeserializer } from './AbstractEyeDeserializer.ts'; /** * Deserializer for Tobii eyetracking files. * @extends AbstractEyeDeserializer * @category Eye * @subcategory Deserializer * @member cAoiInfo - Array of objects containing information about AOI columns. It's being iterated over to find active AOIs, so Array > Map here. * @member cRecordingTimestamp - Index of the Recording timestamp column. * @member cStimulus - Index of the Presented Stimulus name column. * @member cParticipant - Index of the Participant name column. * @member cRecording - Index of the Recording name column. * @member cCategory - Index of the Eye movement type column. * @member cEvent - Index of the Event column. * @member cEyeMovementTypeIndex - Index of the Eye movement type index column. * @member mStimulus - Current stimulus name. * @member mParticipant - Current participant name. * @member mRecordingStart - Current recording start timestamp. * @member mEyeMovementTypeIndex - Current eye movement type index. * @member mRecordingLast - Current recording last timestamp. * @member mCategory - Current eye movement type. * @member mAoi - Current AOIs. * @member mBaseTime - Current base time. * @member stimuliRevisit - Object containing information about revisited stimuli. * @member stimulusGetter - Function that returns the stimulus name, either from the Presented Stimulus name column or from the Event column. */ export declare class TobiiEyeDeserializer extends AbstractEyeDeserializer { cAoiInfo: Array<{ columnPosition: number; aoiName: string; stimulusName: string; }>; cRecordingTimestamp: number; cStimulus: number; cParticipant: number; cRecording: number; cCategory: number; cEvent: number; cEyeMovementTypeIndex: number; mStimulus: string; mParticipant: string; mRecordingStart: string; mEyeMovementTypeIndex: string; mRecordingLast: string; mCategory: string; mAoi: string[] | null; mBaseTime: string; stimulusGetter: (row: string[]) => string; stimuliBaseTimes: Map<string, string>; static readonly TYPE = "tobii"; static readonly TIME_MODIFIER = 0.001; /** * @group Initialization * @description Initializes the deserializer with headers and user input. * @param {string[]} header - Array of header names. * @param {string} userInput - User-defined input for interval markers. */ constructor(header: string[], userInput: string); /** * @group Initialization * @description Creates a dictionary of stimuli from the header. Specifically, it looks for columns starting with 'AOI hit [STIMULUS_NAME' and extracts the stimulus name. * @param {string[]} header - Array of header names. * @returns {string[]} Array of unique stimuli names based on AOI hit columns. */ constructStimuliDictionary(header: string[]): string[]; /** * @group Initialization * @description Creates an array of objects containing information about AOI columns. * @param {string[]} header - Array of header names. * @param {string[]} stimuliDictionary - Array of unique stimuli names based on AOI hit columns. * @returns {Array<{ columnPosition: number; aoiName: string; stimulusName: string }>} Array of objects containing information about AOI columns. * @example [{ columnPosition: 5, aoiName: 'AOI_1', stimulusName: 'Stimulus_1' }] */ constructAoiMapping(header: string[], stimuliDictionary: string[]): Array<{ columnPosition: number; aoiName: string; stimulusName: string; }>; /** * @group StimulusGetterInitialization * @description Creates a function that returns the stimulus name from the Presented Stimulus name column. * @returns {(row: string[]) => string} Function that returns the stimulus name from the Presented Stimulus name column. * @example (row: string[]) => row[5] */ constructBaseStimulusGetter(): (row: string[]) => string; /** * @group StimulusGetterInitialization * @description Creates a function that returns the stimulus name based on interval information in the Event column. * @param {string} userInput - User-defined input for interval markers. * @returns {(row: string[]) => string} Function that returns the stimulus name based on the Event column. */ constructIntervalStimulusGetter(userInput: string): (row: string[]) => string; /** * @group StimulusGetterInitialization * @description Extracts interval markers from user input to be used in the Event column for stimulus name extraction. * @param {string} userInput - User-defined input for interval markers. * @returns {{ startMarker: string; endMarker: string }} Object containing start and end interval markers. * @example { startMarker: ' IntervalStart', endMarker: ' IntervalEnd' } * @throws {Error} Throws an error if the user input does not contain exactly two interval markers. */ constructIntervalMarkers(userInput: string): { startMarker: string; endMarker: string; }; /** * @group Deserialization * @description Deserializes a row of data. * @param {string[]} row - Row of data. * @returns {SingleDeserializerOutput | null} Deserialized data. * @example { stimulus: 'Stimulus_1', participant: 'Participant_1', start: '0', end: '1000', category: 'Fixation', aoi: ['AOI_1'] } */ deserialize(row: string[]): SingleDeserializerOutput | null; /** * @group Deserialization * @description Deserializes a row of data that belongs to the same segment as the previous row. Always returns null. Saves the last timestamp of the segment to be used in case of a new segment in the next row. * @param {string[]} row - Row of data. * @returns {null} Always returns null. */ deserializeSameSegment(row: string[]): null; /** * @group Deserialization * @description Deserializes a row of data that belongs to a new segment. Releases the previous segment and starts a new one. * @param {string[]} row - Row of data. * @returns {SingleDeserializerOutput | null} Deserialized data. * @example { stimulus: 'Stimulus_1', participant: 'Participant_1', start: '0', end: '1000', category: 'Fixation', aoi: ['AOI_1'] } */ deserializeNewSegment(row: string[]): SingleDeserializerOutput | null; /** * @group Deserialization * @description Checks if a row is empty based on the Category column. * @param {string[]} row - Row of data. * @returns {boolean} True if the row is empty, false otherwise. */ isEmptyRow: (row: string[]) => boolean; /** * @group Deserialization * @description Checks if a row is still part of the same segment as the previous row. * @param {string[]} row - Row of data. * @returns {boolean} True if the row is part of the same segment, false otherwise. */ isSameSegment(row: string[]): boolean; /** * @group Deserialization * @description Finalizes the deserialization process. Releases the last segment. Used when there is no more data to deserialize. * @returns {SingleDeserializerOutput | null} Deserialized data. */ finalize(): SingleDeserializerOutput | null; /** * @group Deserialization * @description Releases the last segment. Used either when there is no more data to deserialize or when a new segment is encountered. * @returns {SingleDeserializerOutput | null} Deserialized data. */ getPreviousSegment(): SingleDeserializerOutput | null; /** * @group Deserialization * @description Extracts AOIs from a row of data. Iterates over the array of AOI information objects to find active AOIs. * @param {string[]} row - Row of data. * @returns {string[]} Array of AOIs. * @example ['AOI_1', 'AOI_2'] */ getAoisFromRow(row: string[]): string[]; }