Frame loop slowdown on Ubuntu 18.04.5

XCERKC2T-2021215121530:f8d55c82df11a956a60411580df64d4710b9a11762c8f3d72f566d48ebd0b276

Dear Mario,

Running Dell customise version Ubuntu 18.04.5 LTS
Matlab version R2020b for Linux

Memory 3.7 GiB
Processor: Intel Pentium R CPU 5405U @2.30GHx4
Graphics: Intel UHD Graphics 610 (WHL GT1)
GNOME: 3.28.2
OS type 64-bit
120.2 GB
Psychtoolbox version 3.0.17 flavor beta

The trial timing is delayed in that the key presses do not immediately move the picture presented to the next stimulus presented.

As it is the same problem when tried on Mac we presume it is coding or hardware (projector via USB cable for stimulus presentation and HDMI cable to scanner) . I ran the first three trials and crashed out and will copy the error message below. We believe there is a problem with storing too many frames in memory but we are unable to work out where to put in the close frame function within the loops.

Is this likely to be what is affecting the memory and therefore appearing to delay stimulus presentation?
Where/is is possible to put a close previous frame function in here or perhaps to limit to 5 or so frames open at any one time to improve performance?

A second issue is that in the initial check key inputs at the start it registers the TTLs, and registers the first button press, but the command to input the second button press does not come on the screen as it should. I have tried pressing the second button regardless on the button box and it will proceed. I have checked it is not simply the fact it is not registering the second button press as to why it doesn’t proceed.

I have inserted the relevant start of code here, as it calls on subfunctions/other codes I have tried to make it clear and indicated their names:

ldir = fullfile('_DATA_SUPRA',['S' num2str(sID)]);
lfn  = fullfile(ldir,['MRI_FACE_PRIME_' num2str(sID) '_CFGinit']);
load(lfn);
 
% create a file name for current save data
cfg.datestr = datestr(clock,'yyyy-mm-dd-HHMM');
 
sfn         = sprintf('S%d_MRI_FP_SUPRADATA_%s',cfg.sID,cfg.datestr);
cfg.sfn     = fullfile(cfg.sdir,sfn);
 
 
%% run specific alterations
cfg.monitorMode     = 2;
cfg.viewingDistance = 350; % mm
cfg.startBlock      = 1;
cfg.startTrial      = 1;
 
cfg.askForTwoKeys   = 1;
 
cfg.checkTTL        = 1;
cfg.triggerOut      = 0;
cfg.environment     = 'ubuntu';
clearvars -except cfg
 
cfg = CISC_Keyboard_check(cfg);
clc;commandwindow;
fprintf('Starting...\n');
FacePrime_MRI_Main_SUPRA;

---------------------------------SCRIPT CISC_Keyboard_check

function cfg    = CISC_Keyboard_check(cfg);
clc;commandwindow;
switch cfg.environment
    case 'ubuntu'
%% ************* UBUNTU
%% CHECK THE DEVICE IDs of the input devices
ListenChar(2);
devindx     = GetKeyboardIndices;
 
nd          = numel(devindx);
 
fprintf('Found %d keyboards \n',nd);
 
%% define them! 
% devices     = PsychHID('devices');
% devices     = devices(devindx);
for i = 1:nd
    fprintf('Starting keyboard %d\n',devindx(i));
    KbQueueCreate(devindx(i));KbQueueStart(devindx(i));
end
 
%% check each one
fprintf('\n\n\n');
check_devices = 1;
 
cfg.k_dev_ctrl  = nan;
cfg.k_dev_TTL   = nan;
cfg.k_dev_bbox  = nan;
cfg.k_devices   = [nan nan nan];
chk_ind         = 1;
chk_txt         = {'Press control room keyboard','Press button box button 1','Start TTL simulation'};
for chk_ind = 1:3
    ck  = 1;
    fprintf('%s\n',chk_txt{chk_ind});
    while ck
        for i = 1:nd
            [p firstpress] = KbQueueCheck(devindx(i));
            if p
                k = find(firstpress);
                switch chk_ind
                    case 1
                        cfg.k_dev_ctrl  = devindx(i);
                        fprintf('Ctrl room is device %d\n\n',devindx(i));
                        cfg.k_devices(1) = devindx(i);
                    case 2
                        cfg.k_bang      = k;
                        cfg.k_dev_bbox  = devindx(i);
                        fprintf('Button box button 1 is device %d value %d\n\n',devindx(i),cfg.k_bang);
                        cfg.k_devices(2) = devindx(i);
                        if cfg.askForTwoKeys == 1
                        goon = 0;
                        fprintf('Press button box 2\n',devindx(i),cfg.k_bang);
                        while ~goon 
                            [p firstpress] = KbQueueCheck(cfg.k_dev_bbox);
                            if p
                                cfg.k_bang_2 = find(firstpress);
                                if cfg.k_bang_2 == cfg.k_bang
                                fprintf('Button box button 2 is same as button box button 1! Try again.\n');
                                WaitSecs(.001);
                                else
                                fprintf('Button box button 2 is device %d value %d\n\n',devindx(i),cfg.k_bang_2);
                                goon = 1;
                                end
                            end
                        end
                        else
                            cfg.k_bang_2 = cfg.k_bang;
                        end
                        
                        cfg.userButtonValues    = [cfg.k_bang, cfg.k_bang_2];
 
                    case 3
                        cfg.k_TTL           = k;
                        cfg.k_dev_TTL       = devindx(i);
                        fprintf('TTL is device %d value %d\n\n',devindx(i),cfg.k_TTL);
                        cfg.k_devices(3)    = devindx(i);
                end
                ck = 0;
            end
            WaitSecs(.001);
        end
    end
    check_devices = 0;
    
    cfg.k_devices       = unique(cfg.k_devices);
end


ERROR MESSAGE AFTER THREE TRIALS

PTB-INFO: OpenGL-Renderer is Intel Open Source Technology Center :: Mesa DRI Intel® UHD Graphics 610 (WHL GT1) :: 3.0 Mesa 20.0.8

PTB-INFO: VBL startline = 1080 , VBL Endline = -1

PTB-INFO: Will try to use OS-Builtin OpenML sync control support for accurate Flip timestamping.

PTB-INFO: Measured monitor refresh interval from VBLsync = 16.661687 ms [60.017933 Hz]. (50 valid samples taken, stddev=0.005810 ms.)

PTB-INFO: Reported monitor refresh interval from operating system = 16.663056 ms [60.013000 Hz].

PTB-INFO: Small deviations between reported values are normal and no reason to worry.

Screen running at 60 Hz

Gender 1 emo 1 emoN FACE_SELECT/male/neutral/1.jpg

id 1 scr 1

,Gender 1 emo 1 emoN FACE_SELECT/male/neutral/1.jpg

id 1 scr 2

,Gender 1 emo 1 emoN FACE_SELECT/male/neutral/1.jpg

id 1 scr 3

,Gender 1 emo 1 emoN FACE_SELECT/male/neutral/1.jpg

id 1 scr 4

,Gender 1 emo 1 emoN FACE_SELECT/male/neutral/1.jpg

id 1 scr 5

,Gender 1 emo 1 emoN FACE_SELECT/male/neutral/1.jpg

id 1 scr 6

,Gender 1 emo 1 emoN FACE_SELECT/male/neutral/1.jpg

id 1 scr 7

,Gender 1 emo 1 emoN FACE_SELECT/male/neutral/1.jpg

id 1 scr 8

,Gender 1 emo 1 emoN FACE_SELECT/male/neutral/1.jpg

id 1 scr 9

,Gender 1 emo 1 emoN FACE_SELECT/male/neutral/1.jpg

id 1 scr 10

,Gender 1 emo 1 emoN FACE_SELECT/male/neutral/1.jpg

id 1 scr 11

,Gender 1 emo 1 emoN FACE_SELECT/male/neutral/1.jpg

id 1 scr 12

,Gender 1 emo 1 emoN FACE_SELECT/male/neutral/1.jpg

id 1 scr 13

,Gender 1 emo 1 emoN FACE_SELECT/male/neutral/1.jpg

id 1 scr 14

,Gender 1 emo 1 emoN FACE_SELECT/male/neutral/1.jpg

id 1 scr 15

,Gender 1 emo 1 emoN FACE_SELECT/male/neutral/1.jpg

id 1 scr 16

,Gender 1 emo 1 emoN FACE_SELECT/male/neutral/1.jpg

id 1 scr 17

,Gender 1 emo 1 emoN FACE_SELECT/male/neutral/1.jpg

id 1 scr 18

,Gender 1 emo 1 emoN FACE_SELECT/male/neutral/1.jpg

id 1 scr 19

,Gender 1 emo 1 emoN FACE_SELECT/male/neutral/1.jpg

id 1 scr 20

,Gender 1 emo 1 emoN FACE_SELECT/male/neutral/2.jpg

id 2 scr 1

,Gender 1 emo 1 emoN FACE_SELECT/male/neutral/2.jpg

id 2 scr 2

,Gender 1 emo 1 emoN FACE_SELECT/male/neutral/2.jpg

id 2 scr 3

,Gender 1 emo 1 emoN FACE_SELECT/male/neutral/2.jpg

id 2 scr 4

,Gender 1 emo 1 emoN FACE_SELECT/male/neutral/2.jpg

id 2 scr 5

,Gender 1 emo 1 emoN FACE_SELECT/male/neutral/2.jpg

id 2 scr 6

,Gender 1 emo 1 emoN FACE_SELECT/male/neutral/2.jpg

id 2 scr 7

,Gender 1 emo 1 emoN FACE_SELECT/male/neutral/2.jpg

id 2 scr 8

,Gender 1 emo 1 emoN FACE_SELECT/male/neutral/2.jpg

id 2 scr 9

,Gender 1 emo 1 emoN FACE_SELECT/male/neutral/2.jpg

id 2 scr 10

,Gender 1 emo 1 emoN FACE_SELECT/male/neutral/2.jpg

id 2 scr 11

,Gender 1 emo 1 emoN FACE_SELECT/male/neutral/2.jpg

id 2 scr 12

,Gender 1 emo 1 emoN FACE_SELECT/male/neutral/2.jpg

id 2 scr 13

,Gender 1 emo 1 emoN FACE_SELECT/male/neutral/2.jpg

id 2 scr 14

,Gender 1 emo 1 emoN FACE_SELECT/male/neutral/2.jpg

id 2 scr 15

,Gender 1 emo 1 emoN FACE_SELECT/male/neutral/2.jpg

id 2 scr 16

,Gender 1 emo 1 emoN FACE_SELECT/male/neutral/2.jpg

id 2 scr 17

,Gender 1 emo 1 emoN FACE_SELECT/male/neutral/2.jpg

id 2 scr 18

,Gender 1 emo 1 emoN FACE_SELECT/male/neutral/2.jpg

id 2 scr 19

,Gender 1 emo 1 emoN FACE_SELECT/male/neutral/2.jpg

id 2 scr 20

,Gender 1 emo 1 emoN FACE_SELECT/male/neutral/3.jpg

id 3 scr 1

,Gender 1 emo 1 emoN FACE_SELECT/male/neutral/3.jpg

id 3 scr 2

,Gender 1 emo 1 emoN FACE_SELECT/male/neutral/3.jpg

id 3 scr 3

,Gender 1 emo 1 emoN FACE_SELECT/male/neutral/3.jpg

id 3 scr 4

,Gender 1 emo 1 emoN FACE_SELECT/male/neutral/3.jpg

id 3 scr 5

,Gender 1 emo 1 emoN FACE_SELECT/male/neutral/3.jpg

id 3 scr 6

,Gender 1 emo 1 emoN FACE_SELECT/male/neutral/3.jpg

id 3 scr 7

,Gender 1 emo 1 emoN FACE_SELECT/male/neutral/3.jpg

id 3 scr 8

,Gender 1 emo 1 emoN FACE_SELECT/male/neutral/3.jpg

id 3 scr 9

,Gender 1 emo 1 emoN FACE_SELECT/male/neutral/3.jpg

id 3 scr 10

,Gender 1 emo 1 emoN FACE_SELECT/male/neutral/3.jpg

id 3 scr 11

,Gender 1 emo 1 emoN FACE_SELECT/male/neutral/3.jpg

id 3 scr 12

,Gender 1 emo 1 emoN FACE_SELECT/male/neutral/3.jpg

id 3 scr 13

,Gender 1 emo 1 emoN FACE_SELECT/male/neutral/3.jpg

id 3 scr 14

,Gender 1 emo 1 emoN FACE_SELECT/male/neutral/3.jpg

id 3 scr 15

,Gender 1 emo 1 emoN FACE_SELECT/male/neutral/3.jpg

id 3 scr 16

,Gender 1 emo 1 emoN FACE_SELECT/male/neutral/3.jpg

id 3 scr 17

,Gender 1 emo 1 emoN FACE_SELECT/male/neutral/3.jpg

id 3 scr 18

,Gender 1 emo 1 emoN FACE_SELECT/male/neutral/3.jpg

id 3 scr 19

,Gender 1 emo 1 emoN FACE_SELECT/male/neutral/3.jpg

id 3 scr 20

,Gender 1 emo 2 emoN FACE_SELECT/male/angry/1.jpg

id 1 scr 1

,Gender 1 emo 2 emoN FACE_SELECT/male/angry/1.jpg

id 1 scr 2

,Gender 1 emo 2 emoN FACE_SELECT/male/angry/1.jpg

id 1 scr 3

,Gender 1 emo 2 emoN FACE_SELECT/male/angry/1.jpg

id 1 scr 4

,Gender 1 emo 2 emoN FACE_SELECT/male/angry/1.jpg

id 1 scr 5

,Gender 1 emo 2 emoN FACE_SELECT/male/angry/1.jpg

id 1 scr 6

,Gender 1 emo 2 emoN FACE_SELECT/male/angry/1.jpg

id 1 scr 7

,Gender 1 emo 2 emoN FACE_SELECT/male/angry/1.jpg

id 1 scr 8

,Gender 1 emo 2 emoN FACE_SELECT/male/angry/1.jpg

id 1 scr 9

,Gender 1 emo 2 emoN FACE_SELECT/male/angry/1.jpg

id 1 scr 10

,Gender 1 emo 2 emoN FACE_SELECT/male/angry/1.jpg

id 1 scr 11

,Gender 1 emo 2 emoN FACE_SELECT/male/angry/1.jpg

id 1 scr 12

,Gender 1 emo 2 emoN FACE_SELECT/male/angry/1.jpg

id 1 scr 13

,Gender 1 emo 2 emoN FACE_SELECT/male/angry/1.jpg

id 1 scr 14

,Gender 1 emo 2 emoN FACE_SELECT/male/angry/1.jpg

id 1 scr 15

,Gender 1 emo 2 emoN FACE_SELECT/male/angry/1.jpg

id 1 scr 16

,Gender 1 emo 2 emoN FACE_SELECT/male/angry/1.jpg

id 1 scr 17

,Gender 1 emo 2 emoN FACE_SELECT/male/angry/1.jpg

id 1 scr 18

,Gender 1 emo 2 emoN FACE_SELECT/male/angry/1.jpg

id 1 scr 19

,Gender 1 emo 2 emoN FACE_SELECT/male/angry/1.jpg

id 1 scr 20

,Gender 1 emo 2 emoN FACE_SELECT/male/angry/2.jpg

id 2 scr 1

,Gender 1 emo 2 emoN FACE_SELECT/male/angry/2.jpg

id 2 scr 2

,Gender 1 emo 2 emoN FACE_SELECT/male/angry/2.jpg

id 2 scr 3

,Gender 1 emo 2 emoN FACE_SELECT/male/angry/2.jpg

id 2 scr 4

,Gender 1 emo 2 emoN FACE_SELECT/male/angry/2.jpg

id 2 scr 5

,Gender 1 emo 2 emoN FACE_SELECT/male/angry/2.jpg

id 2 scr 6

,Gender 1 emo 2 emoN FACE_SELECT/male/angry/2.jpg

id 2 scr 7

,Gender 1 emo 2 emoN FACE_SELECT/male/angry/2.jpg

id 2 scr 8

,Gender 1 emo 2 emoN FACE_SELECT/male/angry/2.jpg

id 2 scr 9

,Gender 1 emo 2 emoN FACE_SELECT/male/angry/2.jpg

id 2 scr 10

,Gender 1 emo 2 emoN FACE_SELECT/male/angry/2.jpg

id 2 scr 11

,Gender 1 emo 2 emoN FACE_SELECT/male/angry/2.jpg

id 2 scr 12

,Gender 1 emo 2 emoN FACE_SELECT/male/angry/2.jpg

id 2 scr 13

,Gender 1 emo 2 emoN FACE_SELECT/male/angry/2.jpg

id 2 scr 14

,Gender 1 emo 2 emoN FACE_SELECT/male/angry/2.jpg

id 2 scr 15

,Gender 1 emo 2 emoN FACE_SELECT/male/angry/2.jpg

id 2 scr 16

,Gender 1 emo 2 emoN FACE_SELECT/male/angry/2.jpg

id 2 scr 17

,Gender 1 emo 2 emoN FACE_SELECT/male/angry/2.jpg

id 2 scr 18

,Gender 1 emo 2 emoN FACE_SELECT/male/angry/2.jpg

id 2 scr 19

,Gender 1 emo 2 emoN FACE_SELECT/male/angry/2.jpg

id 2 scr 20

,Gender 1 emo 2 emoN FACE_SELECT/male/angry/3.jpg

id 3 scr 1

,Gender 1 emo 2 emoN FACE_SELECT/male/angry/3.jpg

id 3 scr 2

,Gender 1 emo 2 emoN FACE_SELECT/male/angry/3.jpg

id 3 scr 3

,Gender 1 emo 2 emoN FACE_SELECT/male/angry/3.jpg

id 3 scr 4

,Gender 1 emo 2 emoN FACE_SELECT/male/angry/3.jpg

id 3 scr 5

,Gender 1 emo 2 emoN FACE_SELECT/male/angry/3.jpg

id 3 scr 6

,Gender 1 emo 2 emoN FACE_SELECT/male/angry/3.jpg

id 3 scr 7

,Gender 1 emo 2 emoN FACE_SELECT/male/angry/3.jpg

id 3 scr 8

,Gender 1 emo 2 emoN FACE_SELECT/male/angry/3.jpg

id 3 scr 9

,Gender 1 emo 2 emoN FACE_SELECT/male/angry/3.jpg

id 3 scr 10

,Gender 1 emo 2 emoN FACE_SELECT/male/angry/3.jpg

id 3 scr 11

,Gender 1 emo 2 emoN FACE_SELECT/male/angry/3.jpg

id 3 scr 12

,Gender 1 emo 2 emoN FACE_SELECT/male/angry/3.jpg

id 3 scr 13

,Gender 1 emo 2 emoN FACE_SELECT/male/angry/3.jpg

id 3 scr 14

,Gender 1 emo 2 emoN FACE_SELECT/male/angry/3.jpg

id 3 scr 15

,Gender 1 emo 2 emoN FACE_SELECT/male/angry/3.jpg

id 3 scr 16

,Gender 1 emo 2 emoN FACE_SELECT/male/angry/3.jpg

id 3 scr 17

,Gender 1 emo 2 emoN FACE_SELECT/male/angry/3.jpg

id 3 scr 18

,Gender 1 emo 2 emoN FACE_SELECT/male/angry/3.jpg

id 3 scr 19

,Gender 1 emo 2 emoN FACE_SELECT/male/angry/3.jpg

id 3 scr 20

,Gender 2 emo 1 emoN FACE_SELECT/female/neutral/1.jpg

id 1 scr 1

,Gender 2 emo 1 emoN FACE_SELECT/female/neutral/1.jpg

id 1 scr 2

,Gender 2 emo 1 emoN FACE_SELECT/female/neutral/1.jpg

id 1 scr 3

,Gender 2 emo 1 emoN FACE_SELECT/female/neutral/1.jpg

id 1 scr 4

,Gender 2 emo 1 emoN FACE_SELECT/female/neutral/1.jpg

id 1 scr 5

,Gender 2 emo 1 emoN FACE_SELECT/female/neutral/1.jpg

id 1 scr 6

,Gender 2 emo 1 emoN FACE_SELECT/female/neutral/1.jpg

id 1 scr 7

,Gender 2 emo 1 emoN FACE_SELECT/female/neutral/1.jpg

id 1 scr 8

,Gender 2 emo 1 emoN FACE_SELECT/female/neutral/1.jpg

id 1 scr 9

,Gender 2 emo 1 emoN FACE_SELECT/female/neutral/1.jpg

id 1 scr 10

,Gender 2 emo 1 emoN FACE_SELECT/female/neutral/1.jpg

id 1 scr 11

,Gender 2 emo 1 emoN FACE_SELECT/female/neutral/1.jpg

id 1 scr 12

,Gender 2 emo 1 emoN FACE_SELECT/female/neutral/1.jpg

id 1 scr 13

,Gender 2 emo 1 emoN FACE_SELECT/female/neutral/1.jpg

id 1 scr 14

,Gender 2 emo 1 emoN FACE_SELECT/female/neutral/1.jpg

id 1 scr 15

,Gender 2 emo 1 emoN FACE_SELECT/female/neutral/1.jpg

id 1 scr 16

,Gender 2 emo 1 emoN FACE_SELECT/female/neutral/1.jpg

id 1 scr 17

,Gender 2 emo 1 emoN FACE_SELECT/female/neutral/1.jpg

id 1 scr 18

,Gender 2 emo 1 emoN FACE_SELECT/female/neutral/1.jpg

id 1 scr 19

,Gender 2 emo 1 emoN FACE_SELECT/female/neutral/1.jpg

id 1 scr 20

,Gender 2 emo 1 emoN FACE_SELECT/female/neutral/2.jpg

id 2 scr 1

,Gender 2 emo 1 emoN FACE_SELECT/female/neutral/2.jpg

id 2 scr 2

,Gender 2 emo 1 emoN FACE_SELECT/female/neutral/2.jpg

id 2 scr 3

,Gender 2 emo 1 emoN FACE_SELECT/female/neutral/2.jpg

id 2 scr 4

,Gender 2 emo 1 emoN FACE_SELECT/female/neutral/2.jpg

id 2 scr 5

,Gender 2 emo 1 emoN FACE_SELECT/female/neutral/2.jpg

id 2 scr 6

,Gender 2 emo 1 emoN FACE_SELECT/female/neutral/2.jpg

id 2 scr 7

,Gender 2 emo 1 emoN FACE_SELECT/female/neutral/2.jpg

id 2 scr 8

,Gender 2 emo 1 emoN FACE_SELECT/female/neutral/2.jpg

id 2 scr 9

,Gender 2 emo 1 emoN FACE_SELECT/female/neutral/2.jpg

id 2 scr 10

,Gender 2 emo 1 emoN FACE_SELECT/female/neutral/2.jpg

id 2 scr 11

,Gender 2 emo 1 emoN FACE_SELECT/female/neutral/2.jpg

id 2 scr 12

,Gender 2 emo 1 emoN FACE_SELECT/female/neutral/2.jpg

id 2 scr 13

,Gender 2 emo 1 emoN FACE_SELECT/female/neutral/2.jpg

id 2 scr 14

,Gender 2 emo 1 emoN FACE_SELECT/female/neutral/2.jpg

id 2 scr 15

,Gender 2 emo 1 emoN FACE_SELECT/female/neutral/2.jpg

id 2 scr 16

,Gender 2 emo 1 emoN FACE_SELECT/female/neutral/2.jpg

id 2 scr 17

,Gender 2 emo 1 emoN FACE_SELECT/female/neutral/2.jpg

id 2 scr 18

,Gender 2 emo 1 emoN FACE_SELECT/female/neutral/2.jpg

id 2 scr 19

,Gender 2 emo 1 emoN FACE_SELECT/female/neutral/2.jpg

id 2 scr 20

,Gender 2 emo 1 emoN FACE_SELECT/female/neutral/3.jpg

id 3 scr 1

,Gender 2 emo 1 emoN FACE_SELECT/female/neutral/3.jpg

id 3 scr 2

,Gender 2 emo 1 emoN FACE_SELECT/female/neutral/3.jpg

id 3 scr 3

,Gender 2 emo 1 emoN FACE_SELECT/female/neutral/3.jpg

id 3 scr 4

,Gender 2 emo 1 emoN FACE_SELECT/female/neutral/3.jpg

id 3 scr 5

,Gender 2 emo 1 emoN FACE_SELECT/female/neutral/3.jpg

id 3 scr 6

,Gender 2 emo 1 emoN FACE_SELECT/female/neutral/3.jpg

id 3 scr 7

,Gender 2 emo 1 emoN FACE_SELECT/female/neutral/3.jpg

id 3 scr 8

,Gender 2 emo 1 emoN FACE_SELECT/female/neutral/3.jpg

id 3 scr 9

,Gender 2 emo 1 emoN FACE_SELECT/female/neutral/3.jpg

id 3 scr 10

,Gender 2 emo 1 emoN FACE_SELECT/female/neutral/3.jpg

id 3 scr 11

,Gender 2 emo 1 emoN FACE_SELECT/female/neutral/3.jpg

id 3 scr 12

,Gender 2 emo 1 emoN FACE_SELECT/female/neutral/3.jpg

id 3 scr 13

,Gender 2 emo 1 emoN FACE_SELECT/female/neutral/3.jpg

id 3 scr 14

,Gender 2 emo 1 emoN FACE_SELECT/female/neutral/3.jpg

id 3 scr 15

,Gender 2 emo 1 emoN FACE_SELECT/female/neutral/3.jpg

id 3 scr 16

,Gender 2 emo 1 emoN FACE_SELECT/female/neutral/3.jpg

id 3 scr 17

,Gender 2 emo 1 emoN FACE_SELECT/female/neutral/3.jpg

id 3 scr 18

,Gender 2 emo 1 emoN FACE_SELECT/female/neutral/3.jpg

id 3 scr 19

,Gender 2 emo 1 emoN FACE_SELECT/female/neutral/3.jpg

id 3 scr 20

,Gender 2 emo 2 emoN FACE_SELECT/female/angry/1.jpg

id 1 scr 1

,Gender 2 emo 2 emoN FACE_SELECT/female/angry/1.jpg

id 1 scr 2

,Gender 2 emo 2 emoN FACE_SELECT/female/angry/1.jpg

id 1 scr 3

,Gender 2 emo 2 emoN FACE_SELECT/female/angry/1.jpg

id 1 scr 4

,Gender 2 emo 2 emoN FACE_SELECT/female/angry/1.jpg

id 1 scr 5

,Gender 2 emo 2 emoN FACE_SELECT/female/angry/1.jpg

id 1 scr 6

,Gender 2 emo 2 emoN FACE_SELECT/female/angry/1.jpg

id 1 scr 7

,Gender 2 emo 2 emoN FACE_SELECT/female/angry/1.jpg

id 1 scr 8

,Gender 2 emo 2 emoN FACE_SELECT/female/angry/1.jpg

id 1 scr 9

,Gender 2 emo 2 emoN FACE_SELECT/female/angry/1.jpg

id 1 scr 10

,Gender 2 emo 2 emoN FACE_SELECT/female/angry/1.jpg

id 1 scr 11

,Gender 2 emo 2 emoN FACE_SELECT/female/angry/1.jpg

id 1 scr 12

,Gender 2 emo 2 emoN FACE_SELECT/female/angry/1.jpg

id 1 scr 13

,Gender 2 emo 2 emoN FACE_SELECT/female/angry/1.jpg

id 1 scr 14

,Gender 2 emo 2 emoN FACE_SELECT/female/angry/1.jpg

id 1 scr 15

,Gender 2 emo 2 emoN FACE_SELECT/female/angry/1.jpg

id 1 scr 16

,Gender 2 emo 2 emoN FACE_SELECT/female/angry/1.jpg

id 1 scr 17

,Gender 2 emo 2 emoN FACE_SELECT/female/angry/1.jpg

id 1 scr 18

,Gender 2 emo 2 emoN FACE_SELECT/female/angry/1.jpg

id 1 scr 19

,Gender 2 emo 2 emoN FACE_SELECT/female/angry/1.jpg

id 1 scr 20

,Gender 2 emo 2 emoN FACE_SELECT/female/angry/2.jpg

id 2 scr 1

,Gender 2 emo 2 emoN FACE_SELECT/female/angry/2.jpg

id 2 scr 2

,Gender 2 emo 2 emoN FACE_SELECT/female/angry/2.jpg

id 2 scr 3

,Gender 2 emo 2 emoN FACE_SELECT/female/angry/2.jpg

id 2 scr 4

,Gender 2 emo 2 emoN FACE_SELECT/female/angry/2.jpg

id 2 scr 5

,Gender 2 emo 2 emoN FACE_SELECT/female/angry/2.jpg

id 2 scr 6

,Gender 2 emo 2 emoN FACE_SELECT/female/angry/2.jpg

id 2 scr 7

,Gender 2 emo 2 emoN FACE_SELECT/female/angry/2.jpg

id 2 scr 8

,Gender 2 emo 2 emoN FACE_SELECT/female/angry/2.jpg

id 2 scr 9

,Gender 2 emo 2 emoN FACE_SELECT/female/angry/2.jpg

id 2 scr 10

,Gender 2 emo 2 emoN FACE_SELECT/female/angry/2.jpg

id 2 scr 11

,Gender 2 emo 2 emoN FACE_SELECT/female/angry/2.jpg

id 2 scr 12

,Gender 2 emo 2 emoN FACE_SELECT/female/angry/2.jpg

id 2 scr 13

,Gender 2 emo 2 emoN FACE_SELECT/female/angry/2.jpg

id 2 scr 14

,Gender 2 emo 2 emoN FACE_SELECT/female/angry/2.jpg

id 2 scr 15

,Gender 2 emo 2 emoN FACE_SELECT/female/angry/2.jpg

id 2 scr 16

,Gender 2 emo 2 emoN FACE_SELECT/female/angry/2.jpg

id 2 scr 17

,Gender 2 emo 2 emoN FACE_SELECT/female/angry/2.jpg

id 2 scr 18

,Gender 2 emo 2 emoN FACE_SELECT/female/angry/2.jpg

id 2 scr 19

,Gender 2 emo 2 emoN FACE_SELECT/female/angry/2.jpg

id 2 scr 20

,Gender 2 emo 2 emoN FACE_SELECT/female/angry/3.jpg

id 3 scr 1

,Gender 2 emo 2 emoN FACE_SELECT/female/angry/3.jpg

id 3 scr 2

,Gender 2 emo 2 emoN FACE_SELECT/female/angry/3.jpg

id 3 scr 3

,Gender 2 emo 2 emoN FACE_SELECT/female/angry/3.jpg

id 3 scr 4

,Gender 2 emo 2 emoN FACE_SELECT/female/angry/3.jpg

id 3 scr 5

,Gender 2 emo 2 emoN FACE_SELECT/female/angry/3.jpg

id 3 scr 6

,Gender 2 emo 2 emoN FACE_SELECT/female/angry/3.jpg

id 3 scr 7

,Gender 2 emo 2 emoN FACE_SELECT/female/angry/3.jpg

id 3 scr 8

,Gender 2 emo 2 emoN FACE_SELECT/female/angry/3.jpg

id 3 scr 9

,Gender 2 emo 2 emoN FACE_SELECT/female/angry/3.jpg

id 3 scr 10

,Gender 2 emo 2 emoN FACE_SELECT/female/angry/3.jpg

id 3 scr 11

,Gender 2 emo 2 emoN FACE_SELECT/female/angry/3.jpg

id 3 scr 12

,Gender 2 emo 2 emoN FACE_SELECT/female/angry/3.jpg

id 3 scr 13

,Gender 2 emo 2 emoN FACE_SELECT/female/angry/3.jpg

id 3 scr 14

,Gender 2 emo 2 emoN FACE_SELECT/female/angry/3.jpg

id 3 scr 15

,Gender 2 emo 2 emoN FACE_SELECT/female/angry/3.jpg

id 3 scr 16

,Gender 2 emo 2 emoN FACE_SELECT/female/angry/3.jpg

id 3 scr 17

,Gender 2 emo 2 emoN FACE_SELECT/female/angry/3.jpg

id 3 scr 18

,Gender 2 emo 2 emoN FACE_SELECT/female/angry/3.jpg

id 3 scr 19

,Gender 2 emo 2 emoN FACE_SELECT/female/angry/3.jpg

id 3 scr 20

,Elapsed time is 1.985815 seconds.

Control room quit.

PTB-INFO: There are still 252 textures, offscreen windows or proxy windows open. Screen(‘CloseAll’) will auto-close them.

PTB-INFO: This may be fine for studies where you only use a few textures or windows, but a large number of open

PTB-INFO: textures or offscreen windows can be an indication that you forgot to dispose no longer needed items

PTB-INFO: via a proper call to Screen(‘Close’, [windowOrTextureIndex]); , e.g., at the end of each trial. These

PTB-INFO: stale objects linger around and can consume significant memory ressources, causing degraded performance,

PTB-INFO: timing trouble (if the system has to resort to disk paging) and ultimately out of memory conditions or

PTB-INFO: crashes. Please check your code. (Screen(‘Close’) is a quick way to release all textures and offscreen windows)

INFO: PTB’s Screen(‘Flip’, 10) command seems to have missed the requested stimulus presentation deadline

INFO: a total of 32 times out of a total of 1390 flips during this session.

INFO: This number is fairly accurate (and indicative of real timing problems in your own code or your system)

INFO: if you provided requested stimulus onset times with the ‘when’ argument of Screen(‘Flip’, window [, when]);

INFO: If you called Screen(‘Flip’, window); without the ‘when’ argument, this count is more of a ‘‘mild’’ indicator

INFO: of timing behaviour than a hard reliable measurement. Large numbers may indicate problems and should at least

INFO: deserve your closer attention. Cfe. ‘help SyncTrouble’, the FAQ section at www.psychtoolbox.org and the

INFO: examples in the PDF presentation in PsychDocumentation/Psychtoolbox3-Slides.pdf for more info and timing tips.


THERE WAS AN ERROR!
<<

I believe the relevant bit of code is copied below which contains the loops with frames opening. If you need more of the other code for context I can provide it.


%% Rest of trial frames
    trials(t).targeton  = 0;
    trials(t).keypress  = 0; % only check for keypresses if this is 0.
    framesFromTarget    = 0;
    for f = 1:length(fr_list)
        %% DRAW PREMASK
        if fr_list(f,1) == 1
            Screen('DrawTexture',cfg.win,premask_tex,[],t_central_rect);
        end
        
        %% DRAW PRIME
        if fr_list(f,2) == 1 
            Screen('DrawTexture',cfg.win,prime_tex,[],t_central_rect);
        end
        
        %% DRAW MASK                
        if fr_list(f,3) == 1  
            Screen('DrawTexture',cfg.win,mask_tex,[],t_central_rect);
        end
 
        %% Draw Target Circle
        if fr_list(f,4) == 1 
            Screen('FillOval',cfg.win,targetColour,target_rect);
            % if this is 1st target frame
            if trials(t).targeton == 0
                trials(t).targeton = 1;
            end
        end
 
        %% RUNSLOW for debugging
            if cfg.runslow; WaitSecs(.3);end       
 
        %% NOW WE FLIP THE FRAME!
        Screen('DrawingFinished',cfg.win);
        Screen('Flip',cfg.win);
        fr_list(f,5) = GetSecs;
        
        %% log frame onset events
        % if target just came on
        if trials(t).targeton == 1
            trials(t).targeton = 2;
            txt = sprintf('Target b%d t%d %s %s',block,t,trialtype,emotion);
            cfg.event_log = LogEvent(cfg.event_log,txt,0);
            trials(t).targetonset   = fr_list(f,5);
        end
        
        %% Send trigger if necessary
        if cfg.triggerOut && trials(t).targetOn == 1
            % first onset of target frame
            ParportTTL('Set', 255);            
            trials(t).targetOn  = trials(t).targetOn + 1;% increase that count
        elseif cfg.triggerOut && trials(t).targetOn == cfg.triggerOutFrames + 1;
            % if we've gone x frames from target onset
            % reset the trigger output to zero
            ParportTTL('Set', 0);            
            trials(t).targetOn  = trials(t).targetOn + 1;% increase that count
        elseif cfg.triggerOut && trials(t).targetOn < cfg.triggerOutFrames + 1;
            trials(t).targetOn  = trials(t).targetOn + 1;% increase that count
        end
        
        %% CHECK FOR TTL
        [cfg,pulse,key,k_time] = CheckKeys(cfg);
%         % log a key press, only if key hasn't been pressed so far!!
%         if key == cfg.k_bang && ~trials(t).keypress
%             txt = sprintf('Keypress b%d t%d %s %s',block,t,trialtype,emotion);
%             cfg.event_log = LogEvent(cfg.event_log,txt,k_time);
%             trials(t).keypress = k_time;
%         elseif key == cfg.k_escape
%             disp('Control room quit.');
%             err;
%         end       
        
    end % Loop round for another frame!
    
    %% CHECK KEYS NOW
    checkKey = 1;
    DrawFormattedText(cfg.win,'Was the face male or female?','center','center');
    DrawFormattedText(cfg.win,'Male               Female','center',center_y+100);
    Screen('Flip',cfg.win);
    while checkKey == 1
        [cfg,pulse,key,k_time] = CheckKeys(cfg);
        % log a key press, only if key hasn't been pressed so far!!
        if key == cfg.k_bang && ~trials(t).keypress
            txt = sprintf('Keypress b%d t%d %s %s',block,t,trialtype,emotion);
            cfg.event_log = LogEvent(cfg.event_log,txt,k_time);
            trials(t).keypress  = k_time;
            trials(t).answer    = 1; % male
            checkKey = 0;
        elseif key == cfg.k_bang_2 && ~trials(t).keypress
            txt = sprintf('Keypress b%d t%d %s %s',block,t,trialtype,emotion);
            cfg.event_log = LogEvent(cfg.event_log,txt,k_time);
            trials(t).keypress  = k_time;
            trials(t).answer    = 2; % female
            checkKey = 0;
        elseif key == cfg.k_escape
            disp('Control room quit.');
            err;
        end      
    end

Thank you for any assistance that you can provide.

Best wishes,

Camilla

@cclark

Ok, so first wrt. CISC_Keyboard_check not telling you “Press button box 2”:

Your fprintf() statement is faulty:

You specify two variables devindx(i) and cfg.k_bang to print, but the statment does not contain the %d specifiers. This confuses Matlab and apparently it doesn’t want to print that:
fprintf('Press button box 2\n'); otoh. will work just fine. Mystery solved.

A few more tips for that section:

  • Use ListenChar(-1); instead of ListenChar(2); if you just want to suppress spilling of characters into the Matlab window but do not use GetChar() or CharAvail() in the rest of your scripts. That will only suppress the character printing, but not record key strokes pointlessly.

  • The [devidx, productnames] = GetKeyboardIndices() function also returns the product names of the keyboards connected. If those names are unique - as i assume, given that each of your keyboards is a quite unique device - one is an actual keyboard, one a button box, and one a trigger device - you could directly select the input device via, e.g., cfg.k_dev_ctrl = GetKeyboardIndices(‘myControlRoomKeyboard’) if ‘myControlRoomKeyboard’ would be the name (see productnames array) of that keyboard. This way you won’t have to probe all keyboard devices, but only check the actual three devices you use. But your way of doing it is also ok, but it has some chance of attaching to weirdly behaving devices, e.g., the power button of the machine, or some sensors or other things that show up as weird keyboards. However, don’t forget to KbQueueRelease the keyboard queues you don’t actually use, ie. all that re not in cfg.k_devices() at the end, e.g., devicesToClose = setdiff(devindx, cfg.k_devices); might get the right list.

Wrt. slowdowns, yes, having so many textures open at once will probably get you into memory trouble. But as the warning messages at the end say, you can close all open textures via Screen('Close'), or a subset of textures by passing in a vector with all to-be-closed texture handles Screen('Close', texturevector); Or Screen('Close', tex); will just close texture tex.
Obviously if you only have n jpg images, you only need to create n textures in total. If n is big, you could at the start of each trial or block of trials only imread() and Screen(‘MakeTexture’) the textures you need in that trial or block of trials, and then use one of the mentioned close functions to clean up after each trial or block of trials. In your 3 example trials i count 12 different jpg image files, so there should be only 12 textures open for those 12 images, so 252 open textures at the end sound excessive. The question here would be where premask_tex, prime_tex, mask_tex come from? Are all textures for the whole session created once at the beginning of the session? How many distinct images do you have? How big? Or do you do img=imread(...); prime_tex = Screen('MakeTexture', ..., img) at the beginning of each individual trial, but then don’t dispose of prime_tex once it isn’t needed anymore via Screen('Close', prime_tex)? That would leak a lot of texture memory.

The command winfo = Screen('GetWindowInfo', cfg.win); would give you an (under-)estimate in the subfield winfo.GuesstimatedMemoryUsageMB of how many MB’s of RAM are used for image textures at the moment. It doesn’t account for all used memory, but it should at least give an idea of how much those conventional textures use up. If that is a large fraction of the 4GB of memory that your machine has, then that will certainly cause slowdowns as the experiment progresses.

Other than that, don’t do this:

for higher accuracy wrt. stimulus onset. The Screen('DrawingFinished') is redundant btw. if a Screen('Flip') follows immediately without any other Matlab code inbetween.

instead do

fr_list(f,5) = Screen('Flip', cfg.win);

Work time used so far: 128 Minutes.
-mario

=======================================================================

KCPJ9RXC-2021222151342:d42829138406919239f72f6d8b9b08fa267b2d27b71612a10e8ac9e42606f41d

=======================================================================

This code precedes that extract above. I’ve tried inserting Screen(‘Close’) and Screen(‘Close All’) at various points but I can’t work out where it needs to go to have the effect of closing down the textures to save memory. I think all the stimuli are loading at onset as whenever I abort the paradigm the number of open textures is fairly constant.

Each cropped face image (angry/neutral, male/female) is circa 240-270 kB. There are 12 images in total (3 in each of the four categories of angry (male and female), neutral (male and female)) There are 120 trials.

Thanks again Mario,

Best wishes

@cclark


%% BRING IN THE FACES!
cfg.n_scrambles     = 20;
DrawFormattedText(cfg.win,'Task loading','center','center',[255 255 255]);
Screen('Flip',cfg.win);
cfg.faces                           = fn_scramble_faces(cfg);
DrawFormattedText(cfg.win,'Done','center','center',[255 255 255]);
Screen('Flip',cfg.win);


%% GET READY TO START.
run_expt                        = 1;
cfg.currentBlock                = 1;


for block = cfg.startBlock:cfg.numberBlocks % loop blocks
    
    %% extract current block trials
    trials  = cfg.blockTrials(block).trials;
    
    cfg.currentBlock        = block;
    txt                     = sprintf('Block Point %d',cfg.currentBlock);
    cfg.event_log = LogEvent(cfg.event_log,txt,0);
      
    %% Wait for controller space
        waitForButton = 1;
        while waitForButton
            txt = sprintf('Wait for researcher.');
            DrawFormattedText(cfg.win,txt,'center','center');
            Screen('Flip',cfg.win);
                % check keyboard for a controller space
                [cfg,pulse,key,k_time] = CheckKeys(cfg);
                if key == cfg.k_space;
                    waitForButton = 0;
                end

max_shift_deg                   = .5;%.2;
max_shift                       = max_shift_deg * ppd;
image_deg                       = 5;
target_deg                      = 3;
response_deg                    = 4.3;
border_deg                      = 9;
image_side                      = round(ppd * image_deg); % in pixels
target_side                     = round(ppd * target_deg); % in pixels
response_side                   = round(ppd * response_deg); % in pixels
border_side                     = round(ppd * border_deg);
central_rect                    = CenterRectOnPoint([0 0 image_side image_side],center_x,center_y);
border_rect                     = CenterRectOnPoint([0 0 border_side border_side],center_x,center_y);
target_rect                     = CenterRectOnPoint([0 0 target_side target_side],center_x,center_y);
response_rect                   = CenterRectOnPoint([0 0 response_side response_side],center_x,center_y);

%% BRING IN THE FACES!
cfg.n_scrambles     = 20;
DrawFormattedText(cfg.win,'Task loading','center','center',[255 255 255]);
Screen('Flip',cfg.win);
cfg.faces                           = fn_scramble_faces(cfg);
DrawFormattedText(cfg.win,'Done','center','center',[255 255 255]);
Screen('Flip',cfg.win);


%% GET READY TO START.
run_expt                        = 1;
cfg.currentBlock                = 1;


for block = cfg.startBlock:cfg.numberBlocks % loop blocks
    
    %% extract current block trials
    trials  = cfg.blockTrials(block).trials;
    
    cfg.currentBlock        = block;
    txt                     = sprintf('Block Point %d',cfg.currentBlock);
    cfg.event_log = LogEvent(cfg.event_log,txt,0);
      
    %% Wait for controller space
        waitForButton = 1;
        while waitForButton
            txt = sprintf('Wait for researcher.');
            DrawFormattedText(cfg.win,txt,'center','center');
            Screen('Flip',cfg.win);
                % check keyboard for a controller space
                [cfg,pulse,key,k_time] = CheckKeys(cfg);
                if key == cfg.k_space;
                    waitForButton = 0;
                end
            WaitSecs(.001);
        end
        
    %% Wait for controller G
        waitForButton = 1;
        while waitForButton
            txt = sprintf('Wait for researcher...');
            DrawFormattedText(cfg.win,txt,'center','center');
            Screen('Flip',cfg.win);
                % check keyboard for a controller space
                [cfg,pulse,key,k_time] = CheckKeys(cfg);
                if key == cfg.k_g;
                    waitForButton = 0;
                end
            WaitSecs(.001);
        end
    
    
    %% ********* THIS IS GENERAL BIT FOR WAITING for 5 TTL then going on 6
        % wait for 5 TTL
        txt = sprintf('Wait');
        DrawFormattedText(cfg.win,txt,'center','center');
        Screen('Flip',cfg.win);
        cfg.thisIsTheStart = 0;
        % now we wait for x TTL pulses, we will start on x+1;
        for TTL = 1:cfg.TTLwait
            waitForKey = 1;
            while waitForKey == 1
                [cfg,pulse] = CheckTTL(cfg);
                if pulse
                    waitForKey = 0;
                else
                    WaitSecs(.001);
                end
            end
        end
        txt = sprintf('READY!');
        DrawFormattedText(cfg.win,txt,'center','center');
        Screen('Flip',cfg.win);
        cfg.thisIsTheStart = 0;
        % wait one more TTL then immediate start!
        for TTL = 1
            waitForKey = 1;
            while waitForKey == 1
                [cfg,pulse] = CheckTTL(cfg);
                if pulse
                    waitForKey = 0;
                else
                    WaitSecs(.001);
                end
            end
        end
        %% ******* end of TTL bit
        
        
    for t = cfg.startTrial:numel(trials)
        %% check TTL at trial start
        [cfg,pulse] = CheckTTL(cfg);
        
        
        %% define current trial parameters
        gender          = trials(t).gender;
        id              = trials(t).id;
        emotion         = trials(t).emotion;
        trialtype       = trials(t).trialtype;
        
        % make a random number to pull scrambles from
        rn = randperm(cfg.n_scrambles);
        
        % define pre-mask texture number
        premask_tex     = cfg.faces.neutral.(gender).id(id).scrambled(rn(1));
        
        % define prime texture
        switch emotion
            case 'nonsocial'
                prime_tex       = cfg.faces.neutral.(gender).id(id).scrambled(rn(2));
            otherwise
                prime_tex       = cfg.faces.(emotion).(gender).id(id).clean;                
        end
        
        % define mask texture
        mask_tex        = cfg.faces.neutral.(gender).id(id).scrambled(rn(3));
        
        % what are the frame numbers?
        [fixation_frames]           = trials(t).fixframes;
        [premask_frames]            = cfg.premaskframes;
        [prime_frames]              = cfg.primeframes;
        [mask_frames]               = cfg.maskframes;
        mask_to_target_frames       = cfg.masktotarget;
    
        target_colours =           [0 255 0; 255 0 0; 255 255 0];
        switch trials(t).trialtype
            case 'go'
                targetColour        = target_colours(1,:);
            case 'nogo'
                targetColour        = target_colours(2,:);
            case 'choose'
                targetColour        = target_colours(3,:);
        end
        
        %% what's the shift amount for the faces?
        trials(t).thisXShift         = round(max_shift * ((rand-.5)*2));
        trials(t).thisYShift         = round(max_shift * ((rand-.5)*2));
        t_central_rect = central_rect;
        t_central_rect([1 3]) = t_central_rect([1 3])+trials(t).thisXShift; 
        t_central_rect([2 4]) = t_central_rect([2 4])+trials(t).thisYShift; 
        
        %% FRAMES
        % set up the frames!
        fr_list                                 = zeros(sum([premask_frames prime_frames mask_frames]),5);
        % columns: 1 % premaks on, 2 prime on, 3 mask on, 4 target on
        fr_list(1:premask_frames,1)                     = 1;
        fr_list(sum(premask_frames)+ (1:prime_frames),2) = 1;
        fr_list(sum([premask_frames prime_frames])+ (1:mask_frames),3) = 1;
        fr_list(sum([premask_frames prime_frames mask_to_target_frames]+1):end,4) = 1;

        %% check TTL
        [cfg,pulse] = CheckTTL(cfg);    
        %% play the fixation frames 
        Screen('Flip',cfg.win);
        for f = 1:fixation_frames
            txt = sprintf('Fixation b%d t%d',block,t);
            Screen('Drawlines',cfg.win,fix_matrix,fix_width,fix_col);
            Screen('DrawingFinished',cfg.win);
            Screen('Flip',cfg.win);
            % if this is 1st fixation frame write event
            if f == 1
                cfg.event_log = LogEvent(cfg.event_log,txt,0);
            end
            % check TTL
            [cfg,pulse] = CheckTTL(cfg);
        end

If you only have 12 pictures in total then there should be only exactly 12 executions of imread() and Screen(‘MakeTexture’) in your script, somewhere executed during startup, leading to a total of 12 textures instead 240 textures. That would just comfortably fit into memory.

I think the images will get loaded and textures created somewhere within fn_scramble_faces? The code with the ``Screen(‘MakeTexture’) and imread() commands in it.

-mario

Dear Mario,

We are now running the fMRI successfully and I wanted to say a huge thank you for your patience with my questions and your excellent service with your quick and comprehensive replies.

Best wishes

Camilla

1 Like