Reputation: 1
I am running my experiment using Psychtoolbox. Unfortunately, I cannot share the whole script here, but generally it's a centre-out reaching task where my participants use a joystick to reach targets. The joystick trajectory is being tracked with high temporal resolution and saved.
The tasks is presented using Psychtoolbox-3 (3.0.19) running on the MATLAB platform (2021b) in ubuntu (22.04).
The script works somewhat unstable. In 50 percent of cases it runs smoothly without any issues. In the other 50 percent it crushes with the following error message:
Identifier: MATLAB:badsubscript (line 643)
Error: Index in position 1 exceeds array bounds. Index must not exceed 552.
Error in function TextSize: Invalid Window (or Texture) Index provided: It doesn't correspond to an open window or texture.
Did you close it accidentally via Screen('Close') or Screen('CloseAll') ?
Error using Screen
Usage:
oldTextSize=Screen('TextSize', windowPtr [,textSize]);
Error in C_cued_cursor_rotation_joystick_noCentre (line 727)
Screen('TextSize',wPtr, 40);
Here's a few lines of my script with line 643 highlighted:
motion(:,9) = [NaN; ((velo/pix_per_mm)/1000)]; %convert velocity units to m/s
%store raw data
trialDat{trial} = motion;
%extract reach data
reachDat{trial} = motion(move_loc:endLoc,:); % LINE 643
%get velocity trend
reachDat{trial}(:,10) = trenddecomp(reachDat{trial}(:,9));
%identify max velocity from trend data
[maxVelo, maxLoc] = max(reachDat{trial}(:, 10));
I'm not a great expert in Matlab unfortunetely. What bugs me is that the script crushes at random time points. Sometimes after 50 trials, sometimes after 450+. And there seems to be nothing different im terms of participant's performance compared to other trials.
Do you have any ideas what can cause this issue? And why it doesn't crush from the very first trial?
Described above in details
Upvotes: 0
Views: 38
Reputation: 1473
From the error message, the problem is on line 727 of your script (not line 643, that is the line of error inside the function you called).
Specifically the problem is in your call to Screen('TextSize',wPtr, 40), that you are referencing a window pointer that doesn't exist. It's hard to tell without seeing more of the code, but you may be creating too many Windows without closing them, it's possible the error is seemingly random because it is related to how much memory you have available.
Upvotes: 0