コード例 #1
0
 public static SpotGazeFileData CloneFileData(SpotGazeFileData originalData)
 {
     return(new SpotGazeFileData
     {
         Eye = originalData.Eye,
         Spot = originalData.Spot,
         Time = originalData.Time,
         TimeDeltas = originalData.TimeDeltas,
         FileType = originalData.FileType
     });
 }
コード例 #2
0
 public static SpotGazeFileData CutData(SpotGazeFileData resultData, int skipCount, int takeCount)
 {
     return(new SpotGazeFileData
     {
         Eye = resultData.Eye.Skip(skipCount).Take(takeCount).ToArray(),
         Spot = resultData.Spot.Skip(skipCount).Take(takeCount).ToArray(),
         Time = resultData.Time.Skip(skipCount).Take(takeCount).ToArray(),
         TimeDeltas = resultData.TimeDeltas.Skip(skipCount).Take(takeCount).ToArray(),
         FileType = resultData.FileType
     });
 }
コード例 #3
0
 public static double?GetScaledTimeFromIndex(SpotGazeFileData resultData, int index)
 {
     if (index < resultData.TimeDeltas.Count())
     {
         var delta       = resultData.TimeDeltas[index];
         var scaledDelta = ScaleByTimeFactor(delta, 2, true, resultData.FileType);
         return(scaledDelta);
     }
     else
     {
         return(null);
     }
 }
コード例 #4
0
        public static int?GetIndexFromScaledTime(SpotGazeFileData resultData, double delta)
        {
            var scaledDelta = ScaleByTimeFactor(delta, 2, false, resultData.FileType);

            try
            {
                var indexItem = resultData.TimeDeltas.Where(x => x >= scaledDelta).OrderBy(x => x).FirstOrDefault();
                var index     = Array.IndexOf(resultData.TimeDeltas, indexItem);
                return(index);
            }
            catch
            {
                return(null);
            }
        }
コード例 #5
0
 public static void GetPOMSummary(SpotGazeFileData fileData, FiltersConfig pursuitWindowsFilterConfig)
 {
     var pursuitCalculations = DataAnalyzer.CountSingleTypeSignalPursuitParameters(fileData, pursuitWindowsFilterConfig);
     var sinGain             = pursuitCalculations.Gains.FirstOrDefault().Value;
     var sinAccuracy         = pursuitCalculations.Accuracies.FirstOrDefault().Value;
 }
コード例 #6
0
        public static SpotGazeFileData LoadDataForSpotAndGaze(string filePath, int timeColumnIndex, int eyeColumnIndex,
                                                              int spotColumnIndex)
        {
            var fileInfo       = new FileInfo(filePath);
            var fileStream     = fileInfo.OpenRead();
            var fileDataStream = new StreamReader(fileStream);
            var fileText       = fileDataStream.ReadToEnd();
            var lines          = fileText.Split('\n');

            var outputData = new SpotGazeFileData();

            outputData.FileType = GetFileType(filePath);

            // fix for JazzNovo
            DateTime testOut;
            var      isDate = DateTime.TryParse(lines[0].Split(' ')[0], out testOut);

            if (isDate)
            {
                lines = FixJazzNovoFormat(lines);
                outputData.FileType = FileType.JazzNovo;
            }

            outputData.Time = new int[lines.Length];
            outputData.Eye  = new double[lines.Length];
            outputData.Spot = new double[lines.Length];

            var isFileRead = true;



            for (int i = 0; i < lines.Length; i++)
            {
                var lineColumns = lines[i].Split(' '); //;

                if (lineColumns.Length >= 4)           //4
                {
                    var isTimeConverted = int.TryParse(lineColumns[timeColumnIndex], out outputData.Time[i]);

                    double rEye;
                    double spot;
                    var    isREyeConverted  = double.TryParse(lineColumns[eyeColumnIndex], NumberStyles.Any, CultureInfo.InvariantCulture, out rEye);                               //3
                    var    isSopotConverted = double.TryParse(lineColumns[spotColumnIndex].Replace(@"\r", string.Empty), NumberStyles.Any, CultureInfo.InvariantCulture, out spot); //5

                    if (!isTimeConverted || !isREyeConverted || !isSopotConverted)
                    {
                        MessageBox.Show("Invalid format in input file at line " + i);
                        isFileRead = false;
                        break;
                    }
                    else
                    {
                        outputData.Eye[i]  = Math.Round(rEye, 3);
                        outputData.Spot[i] = Math.Round(spot, 3);
                    }
                }
                else
                {
                    if (i != (lines.Length - 1))
                    {
                        MessageBox.Show("Missing columns in input file at line " + i);
                        break;
                    }
                }
            }


            if (isFileRead)
            {
                outputData.TimeDeltas = GetUnifiedTimeDeltas(outputData.Time, outputData.FileType);
                return(outputData);
            }
            else
            {
                return(null);
            }
        }