Esempio n. 1
0
        public Observation(string[] observationEntry, GazeLogEntry[] gazeLogEntries)
        {
            this.stimulus = Single.Parse(observationEntry[0]);
            this.response = Int16.Parse(observationEntry[1]);

            this.gazeEntries = gazeLogEntries;
        }
Esempio n. 2
0
        public bool IsWithinDistance(GazeLogEntry other, float distance)
        {
            if( Math.Abs(this.distance - other.distance) < distance)
            {
                return true;
            }

            return false;
        }
Esempio n. 3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Experiment1Analysis.Trial"/> class.
        /// </summary>
        /// <param name="observationLogStream">Observation log, as a stream.</param>
        /// <param name="gazeLogStream">Gaze log, as a stream.</param>
        /// <param name="ID">1-based sequential ID number</param>
        public Trial(StreamReader observationLogStream, StreamReader gazeLogStream, int ID, double clipObservationDurationMillis)
        {
            this.ID = ID;

            // Skip forward to point where we're past headers
            string[] observationsStrings = GetLinesStartingWithDigits(observationLogStream);
            string[] gazeStrings = GetLinesStartingWithDigits(gazeLogStream);

            List<GazeLogEntry> gazeLogs = new List<GazeLogEntry>(gazeStrings.Length);
            List<int> observationsIndices = new List<int>(10);
            observationsIndices.Add (0);

            // Populate gazeLogs with data from gazeStrings, and find indices where a new observation begins
            for(int i = 0; i < gazeStrings.Length; i++)
            {
                gazeLogs.Add (new GazeLogEntry(gazeStrings[i]));
                if(i > 0)
                {
                    TimeSpan ts = gazeLogs[i].timestamp - gazeLogs[i - 1].timestamp;
                    if(ts.TotalSeconds >= MINIMUM_SECONDS_BETWEEN_OBSERVATIONS)
                    {
                        observationsIndices.Add (i);
                    }
                }
            }

            observationsIndices.Add (gazeStrings.Length);
            observations = new Observation[observationsStrings.Length];

            // Generate Observations from the combined observation and gaze data
            // but disregard the last observation, as it is added by us
            for(int i = 0; i < observationsStrings.Length - 1; i++)
            {
                int fromIndex = observationsIndices[i];
                int toIndex = observationsIndices[i + 1];
                int gazeLogCount = toIndex - fromIndex;

                GazeLogEntry[] gazeEntriesForThisObservation = new GazeLogEntry[gazeLogCount];
                gazeLogs.CopyTo(fromIndex, gazeEntriesForThisObservation, 0, gazeLogCount);

                observations[i] = new Observation(
                    observationsStrings[i],
                    gazeEntriesForThisObservation,
                    clipObservationDurationMillis);
            }

            observations[observations.Length - 1] = new Observation(
                observationsStrings[observations.Length - 1],
                new GazeLogEntry[]{},
                0);
        }
Esempio n. 4
0
        public void ClipToDurationFromBeginning(double durationMillis)
        {
            if(gazeEntries.Length < 1)
            {
                return;
            }

            DateTime start = gazeEntries[0].timestamp;

            int lastIndexWithinDuration = 1;
            for( ; lastIndexWithinDuration < gazeEntries.Length; lastIndexWithinDuration++)
            {
                DateTime current = gazeEntries[lastIndexWithinDuration].timestamp;

                if(durationMillis < (current - start).TotalMilliseconds)
                {
                    break;
                }
            }

            GazeLogEntry[] clipped = new GazeLogEntry[lastIndexWithinDuration + 1];
            Array.Copy(gazeEntries, clipped, lastIndexWithinDuration + 1);

            gazeEntries = clipped;
        }
Esempio n. 5
0
 public Observation(string observationEntry, GazeLogEntry[] gazeLogEntries)
     : this(observationEntry.Split (new char[]{','}), gazeLogEntries)
 {
 }
Esempio n. 6
0
 public Observation(string observationEntry, GazeLogEntry[] gazeLogEntries, double clipDurationMillis)
     : this(observationEntry.Split (new char[]{','}), gazeLogEntries)
 {
     ClipToDurationFromBeginning(clipDurationMillis);
 }