samhforbes / PupillometryR

An R package for preparing and analysing pupillometry data
Other
42 stars 4 forks source link

Degree argument in filter_data #5

Closed bruceewmesmo closed 4 years ago

bruceewmesmo commented 4 years ago

Hi, Hope you're doing fine during quarantine,

I was hoping you could give me some clarification on what the "degree" argument represents and what escale it stands, so i could truly understand what i'm messing with.

Thank you for your attention, Bruce

samhforbes commented 4 years ago

Hi Bruce, This is an argument being passed to the filtering functions (see the signal package filter and stats::filter as 'n', but for clashing reasons I didn't want to use n here, although I think degree is too vague).

So for example for the median filter it represents k in runmed(x, k, ...) where x is the pupil data vector.

Hope that helps! Sam

bruceewmesmo commented 4 years ago

y <- signal::filter(filt, a, c(x, numeric(2 * max(length(a), length(filt)))), init = rep(mean(x, na.rm = T) + 1, degree))

Oh, i see. Now i get it. Yes, it helps a lot!

I have another question now. Why did you use 11 as standard? It was better for the Sirois' data or it was for another reason?

Bruce

samhforbes commented 4 years ago

Ah brilliant question. I played around with a few datasets and this seemed to be a reasonable compromise between smoothing too much and too little, and I had seen forums that suggested the same. I thought about not including a standard at all, but I wanted to make it possible for people without too much knowledge of signal analysis to at least have a bash at analysing pupil data, so this is the compromise! Best, Sam

bruceewmesmo commented 4 years ago

I did some play around too and noticed the changes too. I believe i found the best fit for my data.

Thank you so much for your help, Bruce