|
9 | 9 |
|
10 | 10 | for blocks = 1:numBlocks |
11 | 11 |
|
12 | | - timeLogger.block(blocks).startTime = GetSecs - experimentStartTime; % Get the start time of the block |
13 | | - timeLogger.block(blocks).condition = condition(blocks); % Get the condition of the block (motion or static) |
14 | | - timeLogger.block(blocks).names = names(blocks); % Get the name of the block |
15 | | - |
16 | | - responseCount=0; |
17 | | - |
18 | 12 | for iEvent = 1: numEventsPerBlock |
19 | 13 |
|
20 | | - Sound=[]; |
21 | | - |
22 | | - if isTarget(blocks,iEvent)==0 |
23 | | - |
24 | | - if strcmp(directions(blocks,iEvent),'S') |
25 | | - Sound= soundData.S; |
26 | | - elseif strcmp(directions(blocks,iEvent),'U') |
27 | | - Sound= soundData.U; |
28 | | - elseif strcmp(directions(blocks,iEvent),'D') |
29 | | - Sound= soundData.D; |
30 | | - elseif strcmp(directions(blocks,iEvent),'R') |
31 | | - Sound= soundData.R; |
32 | | - elseif strcmp(directions(blocks,iEvent),'L') |
33 | | - Sound= soundData.L; |
34 | | - end |
35 | | - |
36 | | - elseif isTarget(blocks,iEvent)==1 |
37 | | - |
38 | | - if strcmp(directions(blocks,iEvent),'S') |
39 | | - Sound= soundData.S_T; |
40 | | - elseif strcmp(directions(blocks,iEvent),'U') |
41 | | - Sound= soundData.U_T; |
42 | | - elseif strcmp(directions(blocks,iEvent),'D') |
43 | | - Sound= soundData.D_T; |
44 | | - elseif strcmp(directions(blocks,iEvent),'R') |
45 | | - Sound= soundData.R_T; |
46 | | - elseif strcmp(directions(blocks,iEvent),'L') |
47 | | - Sound= soundData.L_T; |
48 | | - end |
49 | | - |
50 | | - end |
51 | | - |
52 | | - eventOnsets(blocks,iEvent)=GetSecs-experimentStartTime; |
53 | | - |
54 | | - PsychPortAudio('FillBuffer',phandle,Sound); |
55 | | - playTime(blocks,1) = PsychPortAudio('Start',phandle); |
56 | | - |
57 | | - %length(playedAudio)/freq |
58 | | - |
59 | | - while GetSecs() <= eventOnsets(blocks,iEvent)+ experimentStartTime + (length(Sound)/freq) |
60 | | - |
61 | | - if strcmp(device,'Scanner') |
62 | | - [sbutton,secs] = TakeSerialButton(SerPor); |
63 | | - %[sbutton,secs] = MT_TakeSerialButtonPerFrame(SerPor); |
64 | | - %responseKey(end+1)= sbutton; |
65 | | - if sbutton~= 0 |
66 | | - responseTime(end+1)= secs - experimentStartTime; |
67 | | - |
68 | | - %%%%%%%%%%%%%%%%%%%%% |
69 | | - % while you are pressing, wait till it is |
70 | | - % released |
71 | | - while sbutton ~= 0 |
72 | | - [sbutton,secs]= TakeSerialButton(Cfg.SerPor); |
73 | | - end |
74 | | - %%%%%%%%%%%%%%%%%%%%% |
75 | | - |
76 | | - responseCount = responseCount + 1; |
77 | | - end |
78 | | - |
79 | | - |
80 | | - |
81 | | - elseif strcmp(device,'PC') |
82 | | - |
83 | | - [keyIsDown, secs, ~ ] = KbCheck(); |
84 | | - |
85 | | - if keyIsDown |
86 | | - responseTime(end+1)= secs - experimentStartTime; |
87 | | - while keyIsDown ==1 |
88 | | - [keyIsDown , ~] = KbCheck(); |
89 | | - end |
90 | | - |
91 | | - responseCount = responseCount + 1; |
92 | | - end |
93 | | - end |
94 | | - |
95 | | - end |
96 | 14 |
|
97 | 15 | eventEnds(blocks,iEvent)=GetSecs-experimentStartTime; |
98 | 16 | eventDurations(blocks,iEvent)=eventEnds(blocks,iEvent)-eventOnsets(blocks,iEvent); |
|
0 commit comments