dmirman / gazer

Functions for reading and pre-processing eye tracking data.
43 stars 11 forks source link

problems using the function 'parse_edf' #3

Closed juthzi closed 3 years ago

juthzi commented 3 years ago

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

jgeller112 commented 3 years ago

I’m sorry to hear you are running into some issues with edfR. One quick check: did you install the SR SDK from their website? If you have, one possible solution would be downgrading the version of R Studio you have (see https://github.com/jashubbard/edfR/issues/9). If the SDK is installed and you have downgraded your version of R, it should work. I will point out that you do not need edfR if you are using Data Viewer from SR to extract your VWP data. In fact, I recommend doing that. Please check out an earlier version of the gazeR manuscript that doesn’t rely on edfR: https://psyarxiv.com/gvcxb/.

If those suggestions do not work, I have been working on a solution. I have packaged edfR into my gazeR container on Code Ocean: https://codeocean.com/capsule/4600160/tree/v1. This runs gazeR and edfR in a containerized form so that it always works. What is neat (and the primary reason I decided to use it) is that users can use the capsule to process their own data (Code Ocean has a R Studio Cloud environment that opens up in the container). There are some limitations (e.g., users only get 20 GB for free and they have to sign-up for an account). To get started, you will need to login and duplicate the capsule. Once you have done that, you can add your data and launch a cloud workstation from inside the capsule. I have a video showing how to do this on our GitHub page. If you have any more questions, please do not hesitate to reach out.

Jason

juthzi commented 3 years ago

Hello Jason, thank you for your advice.

It seems to be the case that I do not need the function if I follow the earlier version of the gazeR manuscript. However, the way I understood it, the parse_edf function does the wrangling of eyelink-produced data for you. That is, why it seems very advantageous to me. And edfR seems to be necessary for the parse_edf function.

I downgraded the RSTudio version to 1.1.463 (1.2.1335 was not available), but I still cannot install edfR (error message: '... installation of package ... had non-zero exit status'). I have now installed the SR SDK from the website, which I did not have installed before. However, do I somehow have to tell R, where it is installed, or does the code find it by itself? Since they are in different directories, I am not sure that the reference will be clear.

jgeller112 commented 3 years ago

You are correct, if you want to read edf files directly then you need to use the edfR package. If you want to export your data directly from Data Viewer then you don't need parse_edf. It is ready to be used in gazeR.

Have you tried installing edfR after downloading the SR SDK? I was able to re-install edfR on R 4.0 with newest version of R studio.

jgeller112 commented 3 years ago

You are correct, if you want to read edf files directly then you need to use the edfR package. If you want to export your data directly from Data Viewer then you don't need parse_edf. It is ready to be used in gazeR.

Have you tried installing edfR after downloading the SR SDK? I was able to re-install edfR on R 4.0 with newest version of R studio.

Should mention this was on a Mac.

juthzi commented 3 years ago

I have tried it again with the newest version of Rstudio and R, but I still get the same error when trying to install the edfR package. I am working on Windows 7.

jgeller112 commented 3 years ago

I recommend using the edfR package contained within my gazeR CodeOcean container. I have a video link posted on the homepage showing how you can do this.

Sadly, I can’t do much about the edfR package as it’s not mine.

Get Outlook for iOShttps://aka.ms/o0ukef


From: juthzi notifications@github.com Sent: Wednesday, July 15, 2020 7:42:32 AM To: dmirman/gazer gazer@noreply.github.com Cc: Geller, Jason jason-geller@uiowa.edu; Comment comment@noreply.github.com Subject: [External] Re: [dmirman/gazer] problems using the function 'parse_edf' (#3)

I have tried it again with the newest version of Rstudio and R, but I still get the same error when trying to install the edfR package. I am working on Windows 7.

— You are receiving this because you commented. Reply to this email directly, view it on GitHubhttps://github.com/dmirman/gazer/issues/3#issuecomment-658719436, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AEMTQECU6TWBHMBCGTTOWQ3R3WI2RANCNFSM4OUWPC4A.

juthzi commented 3 years ago

Thanks, I tried using the capsule. However, I get an error message when I load in one of my edfs: Error: Can't subset columns that don't exist. x The column blink doesn't exist.

Do you know what to do here? Do I have to change the edf file prior to loading it in, or could it be that I produced the wrong edf format in my experiment?

jgeller112 commented 3 years ago

That makes me think there is something wrong with your edf file. Can you please send me one of your edf files so I can have a look.

juthzi commented 3 years ago

Yes. Since I did not suceed pasting it here, you can download one of them here: https://uni-koeln.sciebo.de/s/8IIDyEHkXGOtsfP/download

jgeller112 commented 3 years ago

I was able to process the file.

Did you copy and paste this into the capsule before running?

devtools::load_all()
library(gazer)
juthzi commented 3 years ago

Yes, I did. I now tried a Mac. I still get an error message, however a different one. The code I ran is the following:


library(data.table)
library(tidyverse)
library(zoo)
library(here)

devtools::load_all()
library(gazer)

# get the whereabouts
here()

# define output path
directory_csv_from_edf_conversion = '/root/capsule/code'

# parse edf 
gazer::parse_edf(file.choose(), output_dir = directory_csv_from_edf_conversion) 

The output I get is the following:

Skipping install of 'saccades' from a github remote, the SHA1 (bb55d203) has not changed since last install.
  Use `force = TRUE` to force installation
Loading file /root/capsule/code/R/edf_data/j001_.EDF
Loading Events (12828 events across 96 trials)....
Loading Samples (854254 samples across 96 trials) ...
Success! (854254 samples)
Error in file(file, ifelse(append, "a", "w")) : 
  cannot open the connection
In addition: Warning message:
In file(file, ifelse(append, "a", "w")) :
jgeller112 commented 3 years ago

That is a new problem I am working with Code Ocean to solve.

If you open up the parse_edf function in the capsule please comment out the subOutData line and put this:

#subOutData <- file.path(output_dir, paste(file_list[sub], "_raw_pupil.csv", sep=""))
  subOutData=paste(file_list[sub], "_raw_pupil.csv", sep="")

and run the script again to save it.

juthzi commented 3 years ago

Great! That actually worked. Thanks for your help. However, now I run into a problem when processing more than one file.

When I run the following code in code ocean, the parse_edf function does not work.

# specify the directory holding the edfs
directory_edf = '/root/capsule/code/R/edf_data/'

# create a list of edf files
file_list_edf = list.files(path = directory_edf, pattern = '.edf')

# parse all edfs in the edf folder
parse_edf(file_list = file_list_edf, output_dir = directory_csv_from_edf_conversion,
          type = 'pupil')

error message:

Skipping install of 'saccades' from a github remote, the SHA1 (bb55d203) has not changed since last install.
  Use `force = TRUE` to force installation
Loading file j001_.EDF
The file j001_.EDF could not be opened
File Could not be opened!

 Error in UseMethod("rename_") : 
  no applicable method for 'rename_' applied to an object of class "NULL"
jgeller112 commented 3 years ago

What is the content of file_list_edf? I suspect that paths are missing for each file (this is a Code Ocean thing).

To get around that, change the working directory to where your data is held and run the function again. This should solve the problem.

juthzi commented 3 years ago

The content of file_list_edf was character(0), because I wrongly assigned the pattern '.edf' when it should have been '.EDF'.

Still, the code didn't work then. But changing the working directory did the trick. So, for my capsule it works now. Thank you for solving this!

There is still one thing I find strange. I switched to another account and duplicated the gazer capsule from the github site again. However in this new capsule it did not work (even though I checked that the subOutData line was correct). Again I got the error message:

Error: Can't subset columns that don't exist. x The column blink doesn't exist.

jgeller112 commented 3 years ago

I’m glad you got it working!

I can’t reproduce that error. I tried the capsule on Mac and Windows. I’m not sure why.

Jason Geller, Ph.D. University of Iowa Department of Psychological & Brain Sciences

On Jul 16, 2020, at 6:01 AM, juthzi notifications@github.com wrote:



The content of file_list_edf was character(0), because I wrongly assigned the pattern '.edf' when it should have been '.EDF'.

Still, the code didn't work then. But changing the working directory did the trick. So, for my capsule it works now. Thank you for solving this!

There is still one thing I find strange. I switched to another account and duplicated the gazer capsule from the github site again. However in this new capsule it did not work (even though I checked that the subOutData line was correct). Again I got the error message:

Error: Can't subset columns that don't exist. x The column blink doesn't exist.

— You are receiving this because you commented. Reply to this email directly, view it on GitHubhttps://github.com/dmirman/gazer/issues/3#issuecomment-659309764, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AEMTQEHPVQMAT4LVQYMECR3R33FYTANCNFSM4OUWPC4A.

juthzi commented 3 years ago

Weird things will keep happening. But I am happy that it is working for me now :-)

Thank you so much for your help!

jgeller112 commented 3 years ago

Please let me know if you encounter anymore errors with the rest of the pipeline within the capsule. I want to make sure everything is running smoothly for users :).