首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >显示所需帧数的静态图像序列时出现的问题MATLAB

显示所需帧数的静态图像序列时出现的问题MATLAB
EN

Stack Overflow用户
提问于 2021-02-05 14:09:51
回答 1查看 47关注 0票数 0

我必须向我的参与者展示一系列的视觉刺激,每个刺激持续一定数量的帧。每个刺激都编码为一个数字(在stimuli_matrix中报告),其应持续的帧数在stimframesVector中报告。stimuli_matrix行代表试验。

我的问题是,对于指定的帧数,刺激没有显示出来。作为另一种选择,我试图创建一个矩阵,其中包含:试验应该持续的帧数和要呈现的刺激序列,我只获得了一个闪烁的、不准确的和错误的(时间方向)刺激呈现。你能帮助我改进代码,使其显示指定数量的帧的刺激而不闪烁吗?

以下是代码

代码语言:javascript
复制
vbl = Screen('Flip', window);

ifi = Screen('GetFlipInterval', window);

Screen('Flip',window);


for righe=1:size(stimuli_matrix,1)

    for prov=1:size(stimuli_matrix,2)
        waitframes=1;
        stimduration = .5;
        begduration = 1;
        rndnumb=rand;
        jitter= (rndnumb-0.5)*0.1;
        Jittered_stim = stimduration + jitter;
        Jittered_beg = begduration + jitter;
        
        % How long should the image stay up in frames
        
        Stim_Frames = round(Jittered_stim / ifi);
        
        % Duration in frames of trial start
        
        Beg_Frames = round(Jittered_beg / ifi);
        
        stimframesVector=ones(1,Stim_Frames);
        indice=stimuli_matrix(righe,prov)
        
        %stimframesVector1=stimframesVector(1)*1
        [keyIsDown,secs, keyCode] = KbCheck;
        if keyCode(escapeKey)
            sca;
        end
         tic;
        for frames=1:length(stimframesVector)
            if indice==0
                Screen('DrawLines', window, allCoords,lineWidthPix, white, [xCenter yCenter], 2);
                Screen('Flip', window, [], 1);
            elseif indice == 1
                Screen('DrawTextures', window, D1, [], allRects,0);
                Screen('Flip', window, [], 1);
            elseif indice == 2
                Screen('DrawTextures', window, C1, [], allRects,0);
                Screen('Flip', window, [], 1);
            elseif indice == 3
                Screen('DrawTextures', window, B1, [], allRects,0);
                Screen('Flip', window, [], 1);
            elseif indice == 4
                Screen('DrawTextures', window, A1, [], allRects,0);
                Screen('Flip', window, [], 1);
            elseif indice == 5
                Screen('DrawTextures', window, H1, [], allRects,0);
                Screen('Flip', window, [], 1);
            elseif indice == 6
                Screen('DrawTextures', window, G1, [], allRects,0);
                Screen('Flip', window, [], 1);
            elseif indice == 7
                Screen('DrawTextures', window, F1, [], allRects,0);
                Screen('Flip', window, [], 1);
            elseif  indice == 8
                Screen('DrawTextures', window, E1, [], allRects,0);
                Screen('Flip', window, [], 1);
            end
        end
     Screen('Flip', window, vbl+(waitframes-0.5)*ifi);
     stimvec2=stimframesVector %checking time
      toc; 
    end
end
EN

回答 1

Stack Overflow用户

发布于 2021-02-06 07:07:59

我认为问题在于,您没有指定何时使用Screen Flip命令翻转刺激序列中的每个刺激。下面是一个简化的示例,它根据帧生成具有随机颜色和随机时间间隔的椭圆形序列。关键是每个屏幕Flip命令都包括第三个参数,该参数指示应呈现刺激的心理工具箱时间。

代码语言:javascript
复制
try
    screenNum= max(Screen('Screens'));
    [wPtr, wRect]=PsychImaging('OpenWindow', screenNum, 0);
    ifi = Screen('GetFlipInterval', wPtr);
    
    number_stim = 10;
    stimuli_colors = round(rand(number_stim, 3) * 255);
    frame_deltas = 15 + round(rand(number_stim, 1) * 15);
   
    % initial flip
    [~, lastOnset] = Screen('Flip', wPtr);
    for f = 1:number_stim
        Screen('FillOval', wPtr, stimuli_colors(f, :), CenterRect([0 0, 400, 400], wRect));
        [~, lastOnset] = Screen('Flip', wPtr, lastOnset + ((frame_deltas(f) - 0.5) * ifi));
    end
   
    sca;
    
catch e
    sca;
    rethrow(e)
end
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/66058401

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档