Random error on GetClicks

I have encountered an error that occurred only randomly when the program gets to the command GetClicks.

[~, xm, ym, ~] = GetClicks( self.window, 0);

The error message is as follows:

Error in function GlobalRect: Usage error
Argument was recognized as neither a window index nor a screen pointer

From my understanding of the error, it seems that the screen was closed and thus the window index was no longer indicative. However, what participants saw with this error was a dark grey screen with nothing on it, instead of the screen closing entirely. I have read in a past thread that the screen may be forced to close when it encounters some errors in the previous code. If that is the case, wouldn’t the error be systematic and shouldn’t I encounter this error for every trial? Instead, it only happened in 1/3 participants and only 1-2 trials if it does. Please feel free to tell me any possible reason behind this error. I will check accordingly.

I use a Lenovo E50 laptop, Matlab 2018a with Psychtoolbox version 3.0.14. Please do tell me if more information should be provided. I am totally baffled with the situation right now. Thank you very much!

Yes, if the window closed due to some auto-close-on-error that would be the case.

Depends on the error/bug in your script. PsychDebugWindowConfiguration or the diary on function may be of help to narrow it down.

PTB 3.0.14 is totally outdated and unsupported by now, might contain bugs long fixed or workarounds for operating system bugs if those would be at play. First step would be to upgrade to the latest PTB 3.0.18 release. Further advice from myself would require paid support, as described on our webpage.

-mario