UNPKG

gazeplotter

Version:

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

47 lines (46 loc) 1.56 kB
import { AbstractEyeDeserializer } from './AbstractEyeDeserializer.ts'; export class BeGazeEyeDeserializer extends AbstractEyeDeserializer { cStart; cEnd; cStimulus; cParticipant; cCategory; cAoi; constructor(header) { super(); this.cStart = this.getIndex(header, 'Event Start Trial Time [ms]'); this.cEnd = this.getIndex(header, 'Event End Trial Time [ms]'); this.cStimulus = this.getIndex(header, 'Stimulus'); this.cParticipant = this.getIndex(header, 'Participant'); this.cCategory = this.getIndex(header, 'Category'); this.cAoi = this.getIndex(header, 'AOI Name'); } deserialize(row) { const start = row[this.cStart]; const end = row[this.cEnd]; const stimulus = row[this.cStimulus]; const participant = row[this.cParticipant]; const category = row[this.cCategory]; const aoi = row[this.cAoi]; if (this.isNan(start) || this.isNan(end)) return null; if (this.isInvalidCategory(category)) return null; const transformedAoi = this.transformAoi(aoi); return { aoi: transformedAoi, category, end, participant, start, stimulus }; } finalize() { return null; } isNan(value) { return isNaN(Number(value)); } isInvalidCategory(category) { return category === 'Separator'; } transformAoi(aoi) { if (aoi === '-' || aoi === 'White Space' || aoi === null) return null; return [aoi]; } }