AR-Eye-Tracking-Toolkit / ARETT-R-Package

R Package for the Augmented Reality Eye Tracking Toolkit for Head Mounted Displays (ARETT)
MIT License
1 stars 4 forks source link

Problems executing gap_fill() and calculate_velocity() #2

Closed NLeins closed 9 months ago

NLeins commented 10 months ago

Hi,

I'm having issues executing the functions gap_fill() and calculate_velocity() on datasets which are created with your HoloLens 2 Unity package.

The code I'm executing looks like:

# data import
data <- read.csv2("/file/...", sep=',', dec = '.')

# set types
data$gazeHasValue <- as.logical(data$gazeHasValue)
data$eyeDataRelativeTimestamp <- as.numeric(data$eyeDataRelativeTimestamp)

data <- gap_fill(data, max_gap_length = 75)
data <- calculate_velocity(data, window_length = 20)

With the gap_fill() function I get: Error in if (gapDuration < max_gap_length) { : argument is of length zero

With the calculate_velocity() function I get: Error in $<-.data.frame(tmp*, "velocity", value = c(NA_real_, NA_real_ :replacement has 2 rows, data has 17965

The strange thing is that it works for some data sets but not for all. When it occurs seems quite random. Is this a known issues and have you any ideas how I could solve this?

Best regards, Nicolas

sekapp commented 10 months ago

Hi Nicolas,

sadly I'm unable to resolve this issue as I no longer work in research and don't have access to a HL2 or other equipment anymore.

Without further knowledge I would guess your raw data is somehow incomplete or contains errors which lead to these issues with the R scripts. Maybe you can look at the gapDuration and max_gap_length values in the gap_fill function to identify which argument is of length zero. As you specify the max_gap_length in the function call the gapDuration calculation probably had issues so you might be able to work backwards through the code to identify at which point the issue first occurs. The calculate_velocity function also seems to have issues due to incomplete or invalid raw data. Maybe you can compare a working and a broken file in a text editor/spreadsheet if a difference is immediately obvious.

Best regards, Sebastian

NLeins commented 9 months ago

Hi Sebastian,

thanks for the reply! I had a deeper look into the problem and found a solution which is working for me.

Regarding gap_fill(), the problem occured with datasets in which the first row had a FALSE in the gazeHasValue column. I edited the gap_fill() with the following code: # Find the index of the first valid row firstValidRow <- which(data$gazeHasValue)[1] for (row in firstValidRow:nrow(data)) {

The problem with the calculate_velocity() was an issue with a not existing column for the velocity variable. I fixed that with manually creating the velocity column before the calculation: data$velocity <- NA

Maybe this helps someone avoiding the porblems I had.

Best regards, Nicolas