// Need to return an array of List<Fixation>, and then calculate all features for each
        // element (slice) of the fixations.

        // We can either slice by: number of fixations or time period

        /*
         * private List<Slice> SliceFixations(List<Fixation> allFixations, int numberOfFixations) {
         *  // go through the array, keeping tracking of teh current count and adding each fixation to the current slide
         *  // when reach numberOfFixations, add current slice to array, then start a new slice
         *
         *  List<Slice> slices = new List<Slice>();
         *  List<Fixation> currentSliceFixations = new List<Fixation>();
         *  RawToFixationConverter converter = new RawToFixationConverter();
         *
         *  int count = 0;
         *
         *  foreach(Fixation fixation in allFixations) {
         *
         *      count++;
         *      currentSliceFixations.Add(fixation);
         *
         *      if(count >= numberOfFixations) {
         *          Slice slice = new Slice();
         *
         *          slice.fixations = currentSliceFixations;
         *          slice.saccades = converter.GenerateSaccades(currentSliceFixations);
         *
         *          slices.Add(slice);
         *          currentSliceFixations = new List<Fixation>();
         *      }
         *  }
         *
         *  return slices;
         * }
         */

        // number of slices = total time for fixations in ms / (timePeriod / 2)
        private List <Slice> SliceFixations(List <Fixation> allFixations, double timePeriod, double step)
        {
            List <Slice>           slices    = new List <Slice>();
            RawToFixationConverter converter = new RawToFixationConverter();

            double windowStep = step; // This is window step size.

            // increment some counter by halfTimePeriod until it is < length of all fixations - a single time period

            Fixation finalFixation = allFixations.Last();

            for (double start = 0; start < finalFixation.endTime - timePeriod; start += windowStep)
            {
                double windowStart = start;
                double windowEnd   = start + timePeriod;

                // Get the fixations within this window
                List <Fixation> fixationsInWindow = GetFixationsInTimePeriod(windowStart, windowEnd, allFixations);

                // As long as there was at least 3 fixation in that window
                if (fixationsInWindow.Count > 3)
                {
                    // Create a new slice with those fixations.
                    Slice slice = new Slice();
                    slice.fixations = fixationsInWindow;
                    slice.saccades  = converter.GenerateSaccades(fixationsInWindow);
                    slices.Add(slice);
                }
            }

            return(slices);
        }
示例#2
0
        // Fixations
        private void DrawFixations()
        {
            RawToFixationConverter converter = new RawToFixationConverter(gazePoints);

            List <Fixation> fixations = converter.CalculateFixations(currentWindowSize, (float)peakThreshold, (float)radius, 0); // don't clip any gazepoints when simply drawing
            List <Saccade>  saccades  = converter.GenerateSaccades(fixations);

            calculatedSaccades  = saccades;
            calculatedFixations = fixations;

            foreach (Fixation fixation in fixations)
            {
                double lengthOfFixation = fixation.endTime - fixation.startTime;
                double seconds          = lengthOfFixation / 1000;

                System.Windows.Media.SolidColorBrush brush = VSLocationBrushes[fixation.location];
                DrawCircle(fixation.x, fixation.y, brush, fixationCircleSize, CircleType.FixationCircle);
                DrawLabel(seconds.ToString(), fixation.x + fixationCircleSize, fixation.y, brush);
            }
        }