bachlab / PsPM

A matlab suite for Psycho-Physiological Modelling
GNU General Public License v3.0
43 stars 11 forks source link

Bug in pspm_get_eyelink function expand_mask #14

Closed eozd closed 4 years ago

eozd commented 4 years ago

Post by Ulrike Horn:

"

Summary

I am using a very recent commit because the asc eyetracking file import functions are way faster now - thank you for implementing all these great tools! I guess, I noticed a small bug in the get_eyelink function, but maybe you can have a look into that. When the mask for blinks and saccades is expanded by a certain offset, the for loop runs over the indices_to_expand, creates beginning and ending and sets everything in between true. But as the loop is using the whole indices vector instead of single elements, only the first value from each vector is taken and then the loop is left. Furthermore, for the left indices the endidx elements are smaller than the begidx elements, so these should be switched. I hope this wasn't too confusingly explained, sorry!

Steps to Reproduce

using pspm_import with a pupil datafile that contains blinks

Expected Results

pspm_get_eyelink gets called and expands the blink by the given offset using the function expand_mask

Actual Results

only the first blink is expanded

(Optional) Possible Cause and Solutions

see summary above, I changed lines 428ff to:

for ii = 1:numel(indices_to_expand_towards_left) idx = indices_to_expand_towards_left(ii); begidx = max(1, idx - offset); endidx = max(1, idx - 1); mask(begidx : endidx) = true; end

for ii = 1: numel(indices_to_expand_towards_right) idx = indices_to_expand_towards_right(ii); begidx = min(ndata, idx + 1); endidx = min(ndata, idx + offset); mask(begidx : endidx) = true; end

(Optional) Screenshots if Graphical User Interface is Used

Technical Info

"

eozd commented 4 years ago

Hi Ulrike,

Thank you for your detailed bug report. You are definitely right in both of your observations. I will incorporate your suggested changes to PsPM in the next revision.

eozd commented 4 years ago

80fbbd9 fixes this bug.