PupillometryR icon indicating copy to clipboard operation
PupillometryR copied to clipboard

Retaining multiple columns in the 'other' argument in make_pupillometryr_data

Open KarinvdB opened this issue 3 years ago • 5 comments

Hello,

First of all, thank you very much for creating this package and the extensive getting started tutorial on it's website! I'm currently working on my master's thesis and inexperienced in pupillometry and data analysis, so it's been incredibly helpful so far!

I have a question regarding how to retain multiple columns from my datafile in the final pre-processed dataframe to then run stats on. I have columns regarding general gaze coordinates on the screen and whether a participant is looking at a target or not, among others, which I would like to include in the final dataframe. At the moment, I could only add a different (yet important) variable in the 'other =' argument for the make_pupillometryr_data function, and I don't see how I can add multiple columns in this argument. It gives back an error:

Error in make_pupillometryr_data(data = subsetDataPostSwitch, subject = RECORDING_SESSION_LABEL, : unused arguments (LOOK_ON_TARGET, GazePointX, GazePointY)

The above happens if I use "other = Block, LOOK_ON_TARGET, GazePointX, GazePointY" in the argument. I've also tried to use c() as suggested by the topic starter of issue #17, namely "other = c(Block, LOOK_ON_TARGET, GazePointX, GazePointY)". This seems to work initially, but gives an error when using the downsample_time_data function:

Error in group_by(): ! Must group by variables found in .data. ✖ Column c(Block, LOOK_ON_TARGET, GazePointX, GazePointY) is not found. Run rlang::last_error() to see where the error occurred.

Is there a way to make 'other' accept multiple/all leftover columns in the original df that also works in the following pre-processing functions, such that the baseline_data generates a dataframe with multiple columns retained?

Best,

Karin

KarinvdB avatar Jun 21 '22 17:06 KarinvdB

Hi @KarinvdB , Great point. PupillometryR was designed initially for quite simple experiments, however expanding this is on my to do list. I will play with a couple of options here to make this more flexible - however at the same time I'd like to make sure that while I do that, it also works for your experiment. I will post updates here, but if you would like to send me an email with more particular details of what you are trying to do, I'll try to make this possible.

Sam

samhforbes avatar Jun 24 '22 12:06 samhforbes

@KarinvdB please try the dev version from github and see if that resolves some of the issues.

samhforbes avatar Jun 24 '22 15:06 samhforbes

@samhforbes thank you so much! The dev version indeed allows for multiple columns using c(), so that helps a lot. There are some other issues later in the pre-processing that emerge though, regarding the filter_data() and interpolate_data() functions. I've just send you an email with more details, the script and the datafile. It's a lot, so I understand if it's too much to look at. Regardless, it's already a step forward and this may already allow for more tinkering on my side again.

KarinvdB avatar Jun 26 '22 22:06 KarinvdB

@KarinvdB glad to hear we have some progress! I have looked at what you sent and it seems like the functions are (maybe unfortunately) doing what they're suppoed to do, but the issue is that the data you want to retain is continuous data within the trial. Because some of the functions change the shape of the data frame (reducing rows for example), the only way to be sure we can keep the data is to treat it as a grouping variable, and this causes problems for you later on. I'll leave this issue open for the time being while I think through the implications, but in the meantime I'll email you with thoughts about your specific case.

samhforbes avatar Jun 27 '22 09:06 samhforbes

@samhforbes your explanation makes a lot of sense, thank you once again for delving into it further! I've send you a reply.

KarinvdB avatar Jun 27 '22 10:06 KarinvdB