File size: 3,720 Bytes
227148b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
function trial = runFeedback(disp_struct, task_struct, trial, ioObject, LTP1address)
    % define the text font
    Screen('TextSize', disp_struct.wPtr, 60);
    Screen('TextFont', disp_struct.wPtr, 'Times');
    Screen('TextStyle', disp_struct.wPtr, 0);
    Screen('TextColor', disp_struct.wPtr, [255 255 255]);
    Screen('FillRect', disp_struct.wPtr,[0 0 0]);
    
    % get feedback for the selected stimulus
    if trial(task_struct.cTrialCond) == task_struct.NC && ~trial(task_struct.cMatch)
        fbText = 'You must match the framed symbol';
        respRew = NaN;
        SIMPLEFB=1;
    elseif trial(task_struct.cRespAct) == trial(task_struct.cS1)
        % they picked stim 1
        respRew = trial(task_struct.cS1Rew);
        fbText = num2str(respRew);
        SIMPLEFB=0;
    elseif trial(task_struct.cRespAct) == trial(task_struct.cS2)
        % they picked stim 2
        respRew = trial(task_struct.cS2Rew);
        fbText = num2str(respRew);
        SIMPLEFB=0;
    else 
        % they responded too slow
        fbText = ['Too Slow!\nYou must respond in under ' num2str(task_struct.maxRT) ' seconds'];
        respRew = NaN;
        SIMPLEFB=1;
    end
    
    
    % define the left and right stimuli
    center_x = round(disp_struct.wPtr_rect(3)/2);
    center_y = round(disp_struct.wPtr_rect(4)/2);
    sWidth = 300;
    sHeight = 300;
    sTop = center_y - sHeight/2;
    sL_left = center_x - 80 - sWidth;
    sR_left = center_x + 80;
    sL_rect = [sL_left, sTop, sL_left + sWidth, sTop + sHeight];
    sR_rect = [sR_left, sTop, sR_left + sWidth, sTop + sHeight];
    if trial(task_struct.cIsS1Left)
        respL = trial(task_struct.cS1);
        respR = trial(task_struct.cS2);
        s1Rect = sL_rect;
        s2Rect = sR_rect;
    else
        respL = trial(task_struct.cS2);
        respR = trial(task_struct.cS1);
        s1Rect = sR_rect;
        s2Rect = sL_rect;
    end
    if respRew==0
        Screen('TextSize', disp_struct.wPtr, 100);
        Screen('TextColor', disp_struct.wPtr, [255 0 0]);
    elseif  respRew==1
        Screen('TextSize', disp_struct.wPtr, 100);
        Screen('TextColor', disp_struct.wPtr, [0 255 0]);
    end
    
    
    % show the feedback
    if SIMPLEFB==1
        DrawFormattedText(disp_struct.wPtr, fbText, 'center', 'center');
        Screen(disp_struct.wPtr, 'Flip');
        WaitSecs(0.75);
        Screen(disp_struct.wPtr, 'Flip');
    else
        % FIRST show the selected stim
        Screen('DrawTexture', disp_struct.wPtr, disp_struct.cards(trial(task_struct.cS1)), [], s1Rect);
        Screen('DrawTexture', disp_struct.wPtr, disp_struct.cards(trial(task_struct.cS2)), [], s2Rect);
        % Blank out the alternative
        if trial(task_struct.cRespAct) == respL
            Screen('FillRect', disp_struct.wPtr, [0 0 0], sR_rect);
        elseif trial(task_struct.cRespAct) == respR
            Screen('FillRect', disp_struct.wPtr, [0 0 0], sL_rect);
        end
        % If forced, show the box
        if trial(task_struct.cTrialCond) == task_struct.NC
            if trial(task_struct.cRespAct) == trial(task_struct.cS1)
                ncFrameRect = s1Rect;
            else
                ncFrameRect = s2Rect;
            end
            Screen('FrameRect', disp_struct.wPtr, [0 0 255], ncFrameRect, 5);
        end
        % Next show the FB
        DrawFormattedText(disp_struct.wPtr, fbText, 'center', 'center');
        Screen(disp_struct.wPtr, 'Flip');
        WaitSecs(1.25);
        Screen(disp_struct.wPtr, 'Flip');
    end

    Screen('TextSize', disp_struct.wPtr, 60);
    Screen('TextColor', disp_struct.wPtr, [255 255 255]);
    
    % store the feedback
    trial(task_struct.cRespRew) = respRew; 
end % function