Closed catsquito-dl closed 10 months ago
Hi @catsquito-dl Do you have a small reproducible example you can post? It looks like perhaps the issue might be with the time bin size - but I can't tell until there's an example. What was your sample rate?
Hi @catsquito-dl Do you have a small reproducible example you can post? It looks like perhaps the issue might be with the time bin size - but I can't tell until there's an example. What was your sample rate?
Thanks for your reply. Sure I'd like to share an example, is it ok if I reach by email?
Yes of course, please feel free to send to the email on my GitHub profile!
Hi @catsquito-dl , I can't replicate this error. If I try the below it seems to run, although you should check a couple of things. Missing data seems to be -1000 in your data set, and also trial start time seems to be not the same across trials.
library(tidyverse)
library(PupillometryR)
data <- read_csv('F12_F06_T1T2_L1_pupil_deleteNA.csv')
hist(data$ET_PupilLeft_mm)
hist(data$ET_PupilRight_mm)
pupil_data <- data %>%
mutate(ET_PupilLeft_mm = ifelse(ET_PupilLeft_mm < 0, NA, ET_PupilLeft_mm),
ET_PupilRight_mm = ifelse(ET_PupilRight_mm < 0, NA, ET_PupilRight_mm))
Sdata <- make_pupillometryr_data(data = pupil_data,
subject = ID,
trial = Trial,
time = Timestamp,
condition = Types)
plot(Sdata, pupil = ET_PupilLeft_mm, group = 'condition')
regressed_data <- regress_data(data = Sdata,
pupil1 = ET_PupilLeft_mm,
pupil2 = ET_PupilRight_mm)
mean_data <- calculate_mean_pupil_size(data = regressed_data,
pupil1 = ET_PupilLeft_mm,
pupil2 = ET_PupilRight_mm)
mean_data <- downsample_time_data(data = mean_data,
pupil = mean_pupil,
timebin_size = 50,
option = 'median')
plot(mean_data, pupil = mean_pupil, group = 'condition')
Hi @catsquito-dl , I can't replicate this error. If I try the below it seems to run, although you should check a couple of things. Missing data seems to be -1000 in your data set, and also trial start time seems to be not the same across trials.
library(tidyverse) library(PupillometryR) data <- read_csv('F12_F06_T1T2_L1_pupil_deleteNA.csv') hist(data$ET_PupilLeft_mm) hist(data$ET_PupilRight_mm) pupil_data <- data %>% mutate(ET_PupilLeft_mm = ifelse(ET_PupilLeft_mm < 0, NA, ET_PupilLeft_mm), ET_PupilRight_mm = ifelse(ET_PupilRight_mm < 0, NA, ET_PupilRight_mm)) Sdata <- make_pupillometryr_data(data = pupil_data, subject = ID, trial = Trial, time = Timestamp, condition = Types) plot(Sdata, pupil = ET_PupilLeft_mm, group = 'condition') regressed_data <- regress_data(data = Sdata, pupil1 = ET_PupilLeft_mm, pupil2 = ET_PupilRight_mm) mean_data <- calculate_mean_pupil_size(data = regressed_data, pupil1 = ET_PupilLeft_mm, pupil2 = ET_PupilRight_mm) mean_data <- downsample_time_data(data = mean_data, pupil = mean_pupil, timebin_size = 50, option = 'median') plot(mean_data, pupil = mean_pupil, group = 'condition')
Dear Dr. Forbes,
Thanks for the update! Sorry, yesterday I was out of town and couldn't reply.
I tried the code you posted and it works. I guess mutate() helps although I am unfamiliar with this function or dplyr package which I will learn more about it.
I also tried the window analyses, however, some mean_pupil from window is NaN. I assume this is caused by the inconsistent trial start time. There are missing data which are -1000, that's correct. Previously, I manually deleted these data because I am afraid these -1000 would cause errors.
I will fix the trial start time first and see if I can make window analyses work.
Dear Dr. Forbes,
I am trying to display the values of mean and quartiles in the raincloud plot in the window analysis, but it sees not to work. Could you help with it?
base_data <- baseline_data(data = filtered_data, pupil = mean_pupil, start = 0, stop = 35000)
window <- create_window_data(data = base_data, pupil = mean_pupil) plot(window, pupil = mean_pupil, windows = FALSE, geom = 'raincloud', for (i in unique(window)) { mean_val <- round(mean(mean_pupil$pupil[window == i]), 2) text(x = i, y = 0.5, labels = mean_val, col = "red") })
Below is the results of window analysis:
and this is the plot:
I manually calculated the mean values of two conditions (baseline, challenging), but in the results mean of baseline > mean of challenging, which is different from the raincloud plot. I am confused. Any suggestions will be appreciated.
Hi @catsquito-dl I only have the data you sent previously which is just 2 participants, so I can't check this. If you'd like to send updated data I can take a look.
Are those baseline values the ones you want to use? And what do you want the plot to look like? I can't visualise that in my head. Note the boxplot already gives IQR by default.
Closing as inactive, but feel free to reopen if something comes up.
Dear Dr. Forbes,
I obtained pupil data from HTC Vive Pro Eye and removed all 0 and -1 from both eyes. I followed the PupillometryR procedures here. I was able to run smoothing function, but when I run downsample I got the below error: I had the same error when running the median filter ( I guess it is because I didn't successfully downsample using option 'median'.)
This is how the data look like:
There are two subjects and four trials in the current data, would it be a problem? I am new to eye data analysis. Any suggestions will be appreciated!