public List <EyeMoveCalculation> Calculate(List <EyeMove> eyeMovePositions, EyeMoveTypes eyeMoveType) { var saccCalculations = new List <EyeMoveCalculation>(); foreach (var saccadePosition in eyeMovePositions) { var saccParams = CalculateSaccadeParams(saccadePosition, eyeMoveType); saccCalculations.Add(saccParams); } return(saccCalculations); }
public EyeMoveCalculation CalculateSaccadeParams(EyeMove saccadePosition, EyeMoveTypes eyeMoveType) { var frameCount = Math.Abs(saccadePosition.EyeEndIndex - saccadePosition.EyeStartIndex); //+ 1; var duration = frameCount / this.trackerFrequency; var spotEyeIndexDiff = Math.Abs(saccadePosition.EyeStartIndex - saccadePosition.SpotMove.SpotStartIndex); var latency = (spotEyeIndexDiff / this.trackerFrequency); double[] saccadeCoords; if (eyeCoords.Length > 1) { saccadeCoords = eyeCoords.Skip(saccadePosition.EyeStartIndex).Take(Math.Abs(saccadePosition.EyeEndIndex - saccadePosition.EyeStartIndex) + 1).ToArray(); } else { saccadeCoords = eyeCoords; } var spotLenght = (saccadePosition.SpotMove.SpotEndIndex - saccadePosition.SpotMove.SpotStartIndex); var spotMove = spotCoords.Skip(saccadePosition.SpotMove.SpotStartIndex).Take(spotLenght).ToArray(); var eyeMoveDistancesOnScreen = CountOnScreenDistance(saccadeCoords); var multipiedDistanceOnScreen = eyeMoveDistancesOnScreen.Sum(); var spotMoveDistanceOnScreen = CountOnScreenDistance(spotMove).Sum(); var tangens = multipiedDistanceOnScreen / this.distanceFromScreen; var ampInRadians = Math.Atan(tangens); var amplitude = Math.Round(RadianToDegree(ampInRadians)); var maxEyeDistance = eyeMoveDistancesOnScreen.Max(); var movePrecentage = (maxEyeDistance / multipiedDistanceOnScreen) * 100; var maxAmpPercentage = (amplitude / 100) * movePrecentage; var maxVelocity = maxAmpPercentage / 0.016; /* 0.016 = one frame*/ var velocity = amplitude / duration; var gain = multipiedDistanceOnScreen / spotMoveDistanceOnScreen; return(new EyeMoveCalculation { EyeMove = saccadePosition, LatencyFrameCount = Convert.ToInt32(spotEyeIndexDiff), DurationFrameCount = Convert.ToInt32(frameCount), Latency = Math.Round(latency, 3), Duration = Math.Round(duration, 3), Distance = Math.Round(multipiedDistanceOnScreen, 3), Amplitude = amplitude, AvgVelocity = Math.Round(velocity, 0), MaxVelocity = Math.Round(maxVelocity, 0), Gain = Math.Round(gain, 2) }); }
public static List <int> GetSpotMoveDataBlock(ResultData resultData, EyeMoveTypes eyeMoveType, FileType fileType) { int initStartTime = -1; int initEndTime = -1; if (eyeMoveType == EyeMoveTypes.Saccade) { if (fileType == FileType.Brudno) { initStartTime = Consts.SaccadeStartTimeStandard; initEndTime = Consts.AntiSaccadeStartTimeStandard; } else if (fileType == FileType.Maruniec) { initStartTime = Consts.SaccadeStartTimeMaruniec; initEndTime = Consts.AntiSaccadeStartTimeMaruniec; } else if (fileType == FileType.JazzNovo) { initStartTime = 2006; initEndTime = 57001; } //initStartTime = 10676000; //9946000; //initEndTime = 15095000; } else if (eyeMoveType == EyeMoveTypes.AntiSaccade) { if (fileType == FileType.Brudno) { initStartTime = Consts.AntiSaccadeStartTimeStandard; } else if (fileType == FileType.Maruniec) { initStartTime = Consts.AntiSaccadeStartTimeMaruniec; } initEndTime = resultData.TimeStamps.Last(); //initStartTime = 15426000; //initEndTime = 19844000; } var blockStart = resultData.SpotMoves.FirstOrDefault(x => x.SpotStartTimeStamp >= initStartTime); var blockEnd = resultData.SpotMoves.LastOrDefault(x => x.SpotStartTimeStamp <= initEndTime); var spotBlock = resultData.SpotMoves.Where(x => x.SpotStartTimeStamp >= initStartTime && x.SpotStartTimeStamp <= initEndTime); return(spotBlock.Select(x => x.SpotStartIndex).ToList()); }
public static string GetSaccAntiSaccTextLog(List <EyeMoveCalculation> results, ResultData currentSpotEyePointsForSaccades, EyeMoveTypes eyeMoveType) { var sb = new StringBuilder(); var sep = " "; var rowSep = "========================================="; sb.Append(rowSep); sb.Append(Environment.NewLine); sb.Append($"Date/Time: {DateTime.Now.ToShortDateString()} {DateTime.Now.ToShortTimeString()}"); sb.Append(Environment.NewLine); sb.Append($"Results for: {eyeMoveType}s. Item Count: {results.Count}"); sb.Append(Environment.NewLine); sb.Append(rowSep); sb.Append(Environment.NewLine); sb.Append(Environment.NewLine); foreach (var result in results) { sb.Append($"{result.EyeMove.EyeMoveType} Id: {result.EyeMove.Id}"); sb.Append(Environment.NewLine); sb.Append($"First in Spot Sequence: {result.EyeMove.IsFirstMove}"); sb.Append(Environment.NewLine); sb.Append($"Spot Start Index: {result.EyeMove.SpotMove.SpotStartIndex}"); sb.Append(Environment.NewLine); sb.Append($"Spot Start X: {currentSpotEyePointsForSaccades.SpotCoords[result.EyeMove.SpotMove.SpotStartIndex]}"); sb.Append(Environment.NewLine); sb.Append($"Spot Start Time: {currentSpotEyePointsForSaccades.TimeStamps[result.EyeMove.SpotMove.SpotStartIndex]}"); sb.Append(Environment.NewLine); sb.Append($"Spot End Index: {result.EyeMove.SpotMove.SpotEndIndex}"); sb.Append(Environment.NewLine); sb.Append($"Spot End X: {currentSpotEyePointsForSaccades.SpotCoords[result.EyeMove.SpotMove.SpotEndIndex]}"); sb.Append(Environment.NewLine); sb.Append($"Spot End Time: {currentSpotEyePointsForSaccades.TimeStamps[result.EyeMove.SpotMove.SpotEndIndex]}"); sb.Append(Environment.NewLine); sb.Append($"Eye Start Index: {result.EyeMove.EyeStartIndex}"); sb.Append(Environment.NewLine); sb.Append($"Eye Start X: {currentSpotEyePointsForSaccades.EyeCoords[result.EyeMove.EyeStartIndex]}"); sb.Append(Environment.NewLine); sb.Append($"Eye Start Time: {currentSpotEyePointsForSaccades.TimeStamps[result.EyeMove.EyeStartIndex]}"); sb.Append(Environment.NewLine); sb.Append($"Eye End Index: {result.EyeMove.EyeEndIndex}"); sb.Append(Environment.NewLine); sb.Append($"Eye End X: {currentSpotEyePointsForSaccades.EyeCoords[result.EyeMove.EyeEndIndex]}"); sb.Append(Environment.NewLine); sb.Append($"Eye End Time: {currentSpotEyePointsForSaccades.TimeStamps[result.EyeMove.EyeEndIndex]}"); sb.Append(Environment.NewLine); sb.Append(Environment.NewLine); sb.Append($"Control Amp/ Test Value: {result.EyeMove.ControlAmpTestValue}"); sb.Append(Environment.NewLine); sb.Append($"Min.Length Test Value: {result.EyeMove.MinLengthTestValue}"); sb.Append(Environment.NewLine); sb.Append(Environment.NewLine); sb.Append($"Latency Frame Count: {result.LatencyFrameCount}"); sb.Append(Environment.NewLine); sb.Append($"Duration Frame Count: {result.DurationFrameCount}"); sb.Append(Environment.NewLine); sb.Append(Environment.NewLine); sb.Append($"Eye/Spot Gain: {result.Gain} "); sb.Append(Environment.NewLine); sb.Append($"Distance: {result.Distance}"); sb.Append(Environment.NewLine); sb.Append($"Latency: {result.Latency} sec"); sb.Append(Environment.NewLine); sb.Append($"Duration: {result.Duration} sec"); sb.Append(Environment.NewLine); sb.Append($"Visual Angle: {result.Amplitude} deg"); sb.Append(Environment.NewLine); sb.Append($"Average Velocity: {result.AvgVelocity} deg/sec");; sb.Append(Environment.NewLine); sb.Append($"Max Velocity: {result.MaxVelocity} deg/sec");; sb.Append(Environment.NewLine); sb.Append(Environment.NewLine); sb.Append("Y Values:"); sb.Append(Environment.NewLine); for (int i = result.EyeMove.EyeStartIndex; i < result.EyeMove.EyeStartIndex + result.DurationFrameCount; i++) { sb.Append($"Index:{i} - Value: {currentSpotEyePointsForSaccades.EyeCoords[i]}"); sb.Append(Environment.NewLine); } sb.Append(Environment.NewLine); sb.Append("X Values:"); sb.Append(Environment.NewLine); for (int i = result.EyeMove.EyeStartIndex; i < result.EyeMove.EyeStartIndex + result.DurationFrameCount; i++) { sb.Append($"Index:{i} - Time: {currentSpotEyePointsForSaccades.TimeDeltas[i]}"); sb.Append(Environment.NewLine); } sb.Append(Environment.NewLine); } return(sb.ToString()); }