dmirman / gazer Goto Github PK
View Code? Open in Web Editor NEWThis project forked from dmirman-zz/gazer
Functions for reading and pre-processing eye tracking data.
This project forked from dmirman-zz/gazer
Functions for reading and pre-processing eye tracking data.
I have done all the preprocessing steps, as specified in the paper
But when i try to perform baseline corrections,my output is :
Error: Problem with filter()
input ..1
. x comparison (1) is possible only for atomic and list types i Input ..1
is message == "target"
. i The error occurred in group 1: subject = 1, trial = "1". Run rlang::last_error()
to see where the error occurred.
This is the commend I use:
baseline_pupil <- baseline_correction_pupil_msg(smooth_interp,
pupil_colname = "pup_interp",
baseline_dur = 50,
event="target",
baseline_method = "sub")
I would like to use the function find_messages_edf(), which worked for some of my files. However, when I wanted to process all of them, I get the following error message:
Error: Can't recycle ..1
(size 95) to match ..2
(size 96).
Investigating the files, I found that the csv, which I created earlier in the script from the edf file, contains the expected 96 trials, whereas there are only 95 instances of "TRIALID" in the asc file I created from my edf file (because I cannot read the edf file with a text program). Investigating further, I found that apparently in some of my edf files, the first or last TRIALID-message was not logged. I do not know why this would happen, maybe because I did not hand over the actual number of the trial in my experiment script, so it only loggs "TRIALID", but not the actual number associated with it? The behaviour is odd also because the rest of the trial's messages were logged (e.g. the 96 objects pertaining to the 96 trials are always logged). I could alter the asc files manually (adding an extra line of message with "TRIALID"), to make the function work on my files. However, I do not know of a way to alter edf files. Does anyone have an idea?
Dear Dan, or other gazer-professionals,
I would like to use the gazer package, so I have installed the package. However when I run the function 'parse_edf' in R Studio, R (version 3.5.1, but I also tried 3.6.0) for some reason wants to access a package called edfR (by jashubbard).
my command:
parse_edf(file_list = file_list_edf, output_dir = directory_csv_from_edf_conversion, type = "pupil")
R output:
Fehler in library(edfR) : there is no package called ‘edfR’
When I enter 'gazer::parse_edf(...)', the same error message occurs.
I also tried installing the package edfR, but it cannot be compiled for some reason. Before I proceed investigating this compiling problem further, I thought you might have an idea, what is going on in the first place.
Thank you for any advice on how to proceed.
Juliane
Hi, I am a beginner in R and in eyetracking data analysis. My stimuli are shown in triangle formation on the screen. I was wondering how I exactly I can add the coordinates to the aoi_loc
argument in such cases. In your vignette, it says that "each AOI location should be a separate row in a data frame that has variables xmin, xmax, ymin, and ymax" but I am not sure how that information should be inputted in the code. Also, I am using a webcam-based eyetracker and the coordinates will be different for each participant.
Here are the coordinates for my stimuli:
top --> x = 653, y = 683, width = 230, height = 172
left --> x = 204, y = 9, width = 230, height = 172
right --> x = 1102, y = 9, width = 230, height = 172
Data yielded from one of my participants in a pilot study outputted the following:
top --> x_normalized = 0.400173611, y_normalized = 0.790509259, width_normalized = 0.199652778, height_normalized =
0.199074074
left --> x_normalized = 0.010416667, y_normalized = 0.010416667, width_normalized = 0.199652778, height_normalized =
0.199074074
right --> x_normalized =0.789930556, y_normalized = 0.010416667, width_normalized = 0.199652778, height_normalized =
0.199074074
Thnak you so much! I would appreciate if you could post an example.
Hi! I'm trying to us the downsample_gaze function to downsample pupil data. However, using the downsample_gaze function I stumble upon the following error:
Error in sym(timevar)/bin.length : non-numeric argument to binary operator
If you want to reproduce the error, this error is also present when trying to use the downsample_gaze function in the Pupil Preprocessing vignette. How to solve this?
To downsample XY coordinates you will have to modify the downsample_gaze
function
#' This function will combine gaze samples into time bins
#' @param dataframe dataframe
#' @param bin.length Length of time bins
#' @param timevar time column
#' @param aggvars vector of variable names to group by for aggregation
#' @param type pupil for pupil data gaze for gaze data
#' @export
downsample_gaze <- function(dataframe, bin.length = 50, timevar = "time", aggvars = c("subject", "condition", "target", "trial", "object", "timebins"), type="gaze"){
if(type=="gaze") {
downsample <- dataframe %>%
mutate(timebins = round(!!sym(timevar)/bin.length)*bin.length)
# if there are aggregation variables, then aggregate
if(length(aggvars > 0)){
downsample <- downsample %>%
dplyr::group_by_(.dots = aggvars) %>%
dplyr::summarize(acc = unique(acc), rt = unique(rt),
Fix = mean(Fix) > 0.5) %>%
dplyr::ungroup()
}
return(downsample)
}
if (type=="pupil") {
downsample <- dataframe %>%
mutate(timebins = round(!!sym(timevar)/bin.length)*bin.length)
# if there are aggregation variables, then aggregate
if(length(aggvars > 0)){
downsample <- downsample %>%
dplyr::group_by(.dots = aggvars) %>%
dplyr::summarize(aggbaseline=mean(pupilcol, na.rm=TRUE), mean_x=mean(x, na.rm=TRUE), mean_y=mean(y, na.rm=TRUE)) %>%
dplyr::ungroup()
}
}
return(downsample)
}
You will probably have to make sure you interpolate the missing gaze values or delete them altogether before aggregating.
Dear GazeR-Team,
I have trouble processing my pupil data with some of the GazeR functions. I run into working space limit problems.
Therefore, I wanted to downsample the files (they have been created with 1000 Hz) to 250 Hz for a start. In the GazeR manual you describe a way to downsample using "downsample_gaze", but for me, this step occurs too late in the script, so that I run into problems beforehand. Do you know, if there is a way to downsample the edf files when they are initially parsed(edf) or imported (csv) into R? Or can I simply use the "downsample_gaze" at an earlier point in the script without messing other things up?
For explanation:
The problem is not so much the reading in of the files, but running the functions following after that, so far: behave_pupil() and baseline_correction_pupil_msg().
I guess I could run these functions on individual files or on only a couple of files. However, I am reluctant to do this, because this means, that I have to run the whole pipeline for an individual file and afterwards concatenate the files, which always creates new sources of errors (I am not that firm with R yet, or the package).
Thank you for your advice,
Juliane
Hi! Happy to see this implemented! I am wondering if "hz=250" on line 34 should be set to "hz=hz"?
mutate(extendpupil=extend_blinks(blinks_pupil, fillback=fillback, fillforward=fillforward, hz=250)) %>%
mutate(extendpupil=extend_blinks(blinks_pupil, fillback=fillback, fillforward=fillforward, hz=hz)) %>%
If not. what is the rational for using a different sample rate for extending blinks?
Moreover, I am wondering if blink extension and interpolation need to be incorporated in this function at all... I find it odd not to give the choice of interpolation type (linear or cubic) or max gap which you have incorporated into the interpolation function.
Best,
Bonnie
I would like to extract variables from EDF files using the function find_messages_edf(). However, when using the following code (following the paper on GazeR), I get only NAs for the trial column. The other columns look fine, though. Am I doing something wrong here? Thank you for any advice.
find_messages_edf(file_list = file_list_edf,
varnames = c("TRIALID", "TRIAL_VAR condition", "TRIAL_VAR item", "TRIAL_VAR keypress"),
patterns = c("TRIALID", "!V TRIAL_VAR condition", "!V TRIAL_VAR item", "!V TRIAL_VAR keypress"),
output_dir_behave_data)
Hi,
I was wondering if it could directly read pupil size data in the excel file. I recorded the pupil size data using MATLAB, and exported the data as excel file. But when I used the merge_gazer_files function, it reported an error. I have tried several methods, but I still can't solve it. The column "RECORDING_SESSION_LABEL" exist in the excel file. When I tried to use another function (read_fixation_report), it reported the same error.
Hi,
I was wondering if it possible to adjust the code to monocular recording? so far, I exchanged the average_in_blink and average_in_pupil with right_in_blink and right_in_pupil but its causing trouble when I am trying to run the code for the baseline corrections (cause its still based on avg_pupil?).
Do you have any recommendation how to preceed?
Thanks and all the best,
Anna
Hi,
I am unable to install packages saccades and edfR. The message I receive is:
"Error: (converted from warning) package 'zoom' was built under R version 4.0.4
Execution halted
ERROR: lazy loading failed for package 'saccades'
Maybe you have seen this before? Any help is very appreciated.
Dear all,
I am trying to run the Gazer_walkthrough.R script, i am getting an error when running the following part
gaze_obj <-gaze_aoi %>% dplyr::gather(key ="object", value ="fix",Targ, Comp, Unrelated, factor_key =TRUE) %>% dplyr::mutate(Fix =replace_na(fix, FALSE)) # recode NA as not-
Error: 'gather' is not an exported object from 'namespace:dplyr'
Any help is much appreciated
Thanks in advance!
Best regards,
Nayla
Hi,
Thanks for the comprehensive overview of the package, much appreciated!
One quick question - when the functions specify hz input, is this referring to the original sampling rate, or to the downsampled rate if this has already been conducted in Eyelink dataviewer?
Hi,
I would like to use gazeR to analyse my pupil data. I tried to load in an edf on Code Ocean but I received the following error message:
Error: Can't subset columns that don't exist.
x The column `blink` doesn't exist.
I've also tried to load in a few different edfs but I receive the same error message each time.
Any advice on what the issue might be here would be greatly appreciated!
Many thanks,
Iman
We built a 3D scene in Unity and then used the HTC VIVE pro eye, a virtual reality headset device, to obtain eye movement data as follows.
The data includes pupil size, gaze direction, and gaze starting position for both eyes, but the coordinates include X-axis, Y-axis, and Z-axis. Can GazeR analyze such data? And we exported the CSV file directly.
Hi there!
I am updating some past scripts and noticed that merge_pupil
does not change sample_message to message but merge_gazer_files
does. This becomes an issues when you call baseline_correction_pupil_msg
. Is merge_pupil just an old hold over from the earlier versions of the package? Everything is working with the updated calls.
Thanks,
Bonnie
Hello everyone,
I use the parse_edf function, which outputs the csv file with the expected number of trials (96) for most of my participants. However, for one subject, it outputs 97 trials. The number of logs of 'TRIALID' in that participant seems to be 96, however, so I do not know why this happens.
Thank you for any help regarding the issue.
Dear GazeR team,
My experiment was programmed using MATLAB. After transferring edf to asc files and compare my datasets with EB examples, I find the format of my datasets is different from that programmed in Experiment Builder. As shown below, the messages of my dataset is plugged into the data point.
So I want to know whether GazeR can preprocess the datasets like this?
Dear Team,
I encountered your paper published in Behavior Research Methods Journal on GazeR.
I find the paper very informative and helpful for pupillometry data pre-processing and wanted to give it a try.
And direct download from Github is also giving the same error.
I wonder if you could help fix this technical issue.
Thank you,
Odko
Hi Jason,
Thanks for developing the great package :) I ran into two issues and I would be grateful if you could help me with that.
For my experiment, I want to get the peak pupil size in each trial and remove those greater or less than 3SD of the personal mean. I am just wondering if there is a function that exists in the package that could help me find the peak pupil size (and to winsorize, ideally) in a trial directly.
Also, I have another question about the package not excluding the participant that has the percentage of missing trials over the missing threshold I specified. For example, in the below screenshot, I set the missing threshold as 0.2. However, subject 4 has 23.6% of missing trials but was not taken out, which was a bit confusing.
Many thanks for your help in advance!
Best,
Rongru
Hello everyone,
I have just now realized that after using the parse_edf function, a lot of my messages got lost on the way, which means, they are not present in the csv file anymore. This seems to be case whenever there are multiple message logged for ONE timestamp in the EDF/ASC file, like in this example excerpt:
...
MSG 1072433 !V TRIAL_VAR condition high_short
MSG 1072433 !V TRIAL_VAR item blume
MSG 1072433 !V TRIAL_VAR keypress 1
MSG 1072433 !V IAREA RECTANGLE 1 854 385 1066 495 roi_eyes
MSG 1072433 !V IAREA RECTANGLE 2 820 213 1100 627 roi_head
MSG 1072433 !V IAREA RECTANGLE 3 820 770 1100 1051 roi_object
MSG 1072433 TRIAL_RESULT
1072433 497.7 522.0 697.0 127.0 ...
...
Here, all messages in theory are logged with sample 1072433, but only the first message ('!V TRIAL_VAR condition high_short') makes it through the parse_edf function. It makes sense, that the function would not know where to attribute these messages to if not to the following sample. However, I need these messages (at least the 'item' and 'keypress') for analysis. Do you have plans to include this functionality in the function? If not, do you have recommendations for me how to tackle this issue?
Thank you!
Hello!
I'm trying to use the edfR package for R 4.2.0 on a Macbook Pro (MacOS Monterey 12.4).
I already installed the Eyelink Developer's Kit (EDF API) and all the packages required. However, I keep receiving this error:
Error: package or namespace load failed for ‘edfR’ in dyn.load(file, DLLpath = DLLpath, ...):
unable to load shared object '/Library/Frameworks/R.framework/Versions/4.2/Resources/library/edfR/libs/edfR.so':
dlopen(/Library/Frameworks/R.framework/Versions/4.2/Resources/library/edfR/libs/edfR.so, 0x0006): Library not loaded: @rpath/edfapi.framework/Versions/A/edfapi
Referenced from: /Library/Frameworks/R.framework/Versions/4.2/Resources/library/edfR/libs/edfR.so
Reason: tried: '/System/Library/Frameworks/edfapi.framework/Versions/A/edfapi' (no such file)
So, I switched to Code Ocean (following your tutorial on YouTube), and I loaded in an edf file, but I got the following error message:
Success! (633988 samples)
Error: Can't subset columns that don't exist.
x The column blink
doesn't exist.
I took a look at the suggestions reported here, but still having issues.
I wonder is there anyone having a similar problem as me that edfR does not work (had reported an issue in edfR: jashubbard/edfR#12). Is there any other alternative approach to parse the edf file when package edfR doesn't work? thanks a lot!
Hello, thanks for the great algorithm!
every other function is working great for me exept for the downsample_gaze one. The error showed in the console is the following:
> timebins1 <- downsample_gaze(baseline_pupil_onset, bin.length = 100, timevar = "time_zero", aggvars= c("subject", "timebins"), type="pupilz")
Error in downsample_gaze(baseline_pupil_onset, bin.length = 100, timevar = "time_zero", :
object 'downsample' not found
Is there a reason why or am I just applying it wrong??
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.