%% the most critical part of the code clear_Screen = Screen('MakeTexture', window, const.img{curr_img_type, curr_img_index}); Screen('DrawTexture', window, clear_Screen, [], [const.winWid/2-300, const.winHeig/2-300, const.winWid/2+300, const.winHeig/2+300]); Screen('Flip', window); % draw stimulus pic and onset tms_lock = 0; tic %start timing %% pic presentation time(160ms/310ms); TMS pulse start time(150ms/300ms) while toc