123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107 |
- OnsetResp=0;
- rt_catch = 0;
- resp_text = 0;
- resp_catch = 'No_Response'; %Just in case we don't have response
-
- % Screen priority
- Priority(MaxPriority(window1));
- Priority(2);
-
- % Show fixation cross
-
- drawCross(window1,W,H,barColor);
- tFixation = Screen('Flip', window1);
-
- Screen(window1, 'FillRect', backgroundColor);
- Screen('Flip', window1, tFixation + (fixationDuration)- slack,0)
- % Show Object 1
-
- Screen('DrawTexture', window1, objectodisplay, [], positiontodisplay,rottodisplay);
- startTime = Screen('Flip', window1); % Start of trial
- Onset_object_2 = startTime-ExpStart; %Onset
- press_trigger(trigger_object_2,triggers_on);
-
- while GetSecs - startTime < objectTimeout
- [keyIsDown,secs,keyCode] = KbCheck;
- % ESC key quits the experiment
- if keyCode(KbName('Q')) == 1
- close all
- sca
- return;
- end
-
- respTime = GetSecs;
- pressedKeys = find(keyCode);
- % Check for response keys
- if ~isempty(pressedKeys)
- for i = 1:length(responseKeys)
- if KbName(responseKeys{i}) == pressedKeys(1)
-
- break
- end
- end
- end
- end
- % Empty screen between object offset and next fix cross
- % Screen priority
-
- Priority(MaxPriority(window1));
- Priority(2);
- Screen(window1, 'FillRect', backgroundColor);
- Screen('Flip', window1 )
-
- while GetSecs - startTime < postobjectTimeout2
- % ESC key quits the experiment
- if keyCode(KbName('Q')) == 1
- close all
- sca
- return;
- end
- [keyIsDown,secs,keyCode] = KbCheck;
- respTime = GetSecs;
- pressedKeys = find(keyCode);
- % Check for response keys
- if ~isempty(pressedKeys)
- for i = 1:length(responseKeys)
- if KbName(responseKeys{i}) == pressedKeys(1)
- resp_catch = responseKeys{i};
- rt_catch = respTime - startTime;
- OnsetResp = GetSecs - ExpStart;
- break
- end
- end
- end
- end
- %%
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- %% Subfunctions
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- % Draw a fixation cross (overlapping horizontal and vertical bar)
- function drawCross(window,W,H,barColor)
- if nargin==3
- barColor = [0 0 0];
- end
- barLength = 16; % in pixels
- barWidth = 2; % in pixels
- %0.5; % number from 0 (black) to 1 (white)
- Screen('FillRect', window, barColor,[ (W-barLength)/2 (H-barWidth)/2 (W+barLength)/2 (H+barWidth)/2]);
- Screen('FillRect', window, barColor,[ (W-barWidth)/2 (H-barLength)/2 (W+barWidth)/2 (H+barLength)/2]);
- end
|