Skip to content

Commit ab9847e

Browse files
committed
add exp block and event trial code
1 parent cc28a6c commit ab9847e

File tree

2 files changed

+64
-57
lines changed

2 files changed

+64
-57
lines changed

ALocalizer.m

Lines changed: 1 addition & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,65 +1,9 @@
1-
%% Experiment Parametes
2-
%% Experimental Design
3-
% function "experimental_design" while assign the blocks, conditions, and
4-
% the number of targets that will be used in the motion localizer
5-
%[names,targets,condition] = experimental_design(nrBlocks,range_targets);
6-
[names,targets,condition,directions,isTarget] = experimental_design(nrBlocks,numEventsPerBlock,range_targets) ;
7-
8-
numBlocks = length(names); % Create a variable with the number of blocks in the whole experiment
9-
10-
11-
%% FUNCTION
12-
if strcmp(device,'PC')
13-
DrawFormattedText(w,'Waiting For Trigger',...
14-
'center', 'center', black);
15-
Screen('Flip', w);
16-
17-
% press key
18-
KbWait();
19-
KeyIsDown=1;
20-
while KeyIsDown>0
21-
[KeyIsDown, ~, ~]=KbCheck;
22-
end
23-
24-
% open Serial Port "SerPor" - COM1 (BAUD RATE: 11520)
25-
elseif strcmp(device,'Scanner')
26-
DrawFormattedText(w,'Waiting For Trigger','center', 'center', black);
27-
Screen('Flip', w);
28-
SerPor = MT_portAndTrigger;
29-
Screen('Flip', w);
30-
end
31-
32-
%% Experiment Start (Main Loop)
33-
experimentStartTime = GetSecs;
34-
35-
%% To correct for the y-axis problem inside the scanner
36-
if strcmp(device,'Scanner')
37-
adjusted_yAxis = 2/3*th; % where the lower 1/3 of the screen is not appearing because of coil
38-
elseif strcmp(device,'PC')
39-
adjusted_yAxis = th; % y-axis is the same, no changes
40-
end
41-
42-
%% Pixels per degree
43-
[mirrorPixelPerDegree] = mirror2Pixels (winRect,v_dist,mirror_width) ; % Calculate pixel per degree on the mirror surface
44-
45-
%% fixation coordiates
46-
fix_cord = [[tw/2 adjusted_yAxis/2]-fix_r*mirrorPixelPerDegree [tw/2 adjusted_yAxis/2]+fix_r*mirrorPixelPerDegree];
47-
48-
%% Experiment start
49-
% The experment will wait (initial_wait) Secs before running the stimuli
50-
Screen('FillOval', w, uint8(white), fix_cord); % draw fixation dot (flip erases it)
51-
blank_onset=Screen('Flip', w);
52-
WaitSecs('UntilTime', blank_onset + initial_wait);
53-
54-
targetTime = [];
55-
responseKey = [];
56-
responseTime = [];
571

582
eventOnsets=zeros(numBlocks,numEventsPerBlock);
593
eventEnds=zeros(numBlocks,numEventsPerBlock);
604
eventDurations=zeros(numBlocks,numEventsPerBlock);
615

62-
responsesPerBlock=zeros(numBlocks,1);
6+
responsesPerBlock=zeros(numBlocks,1);6
637

648
playTime = zeros(numBlocks,1);
659

audioLocTranslational.m

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,69 @@
9393
cfg.experimentStart = GetSecs;
9494

9595
WaitSecs(expParameters.onsetDelay);
96+
97+
%% For Each Block
98+
99+
stopEverything = 0;
100+
101+
for iBlock = 1:expParameters.numBlocks
102+
103+
if stopEverything
104+
break;
105+
end
106+
107+
fprintf('\n - Running Block %.0f \n',iBlock)
108+
109+
eyeTracker('StartRecording', cfg, expParameters);
110+
111+
% For each event in the block
112+
for iEvent = 1:expParameters.numEventsPerBlock
113+
114+
115+
% Check for experiment abortion from operator
116+
[keyIsDown, ~, keyCode] = KbCheck(cfg.keyboard);
117+
if keyIsDown && keyCode(KbName(cfg.escapeKey))
118+
stopEverything = 1;
119+
warning('OK let us get out of here')
120+
break;
121+
end
122+
123+
124+
% set direction, speed of that event and if it is a target
125+
thisEvent.trial_type = 'dummy';
126+
thisEvent.direction = expParameters.designDirections(iBlock,iEvent);
127+
thisEvent.speed = expParameters.designSpeeds(iBlock,iEvent);
128+
thisEvent.target = expParameters.designFixationTargets(iBlock,iEvent);
129+
130+
% play the sounds and collect onset and duration of the event
131+
[onset, duration] = doAudMot(cfg, expParameters, thisEvent)
132+
133+
thisEvent.event = iEvent;
134+
thisEvent.block = iBlock;
135+
thisEvent.duration = duration;
136+
thisEvent.onset = onset - cfg.experimentStart;
137+
138+
139+
140+
141+
142+
143+
144+
145+
146+
147+
148+
149+
150+
151+
152+
153+
154+
155+
156+
157+
158+
96159

97160
catch
98161

0 commit comments

Comments
 (0)