-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreaderCalibrateStimulus.m
More file actions
96 lines (73 loc) · 3.28 KB
/
readerCalibrateStimulus.m
File metadata and controls
96 lines (73 loc) · 3.28 KB
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
% Run configuration file to get all the required parameters
configReader();
% Make the target sequence
tgtSeq = mkStimSeqRand(nFunction,nSequence);
clf;
set(gcf,'color',[0 0 0],'toolbar','none','menubar','none'); % Black figure
set(gca,'visible','off','color',[0 0 0]); % Black axes
h=text(0.5,0.9,'text','HorizontalAlignment','center','VerticalAlignment','middle',...
'FontUnits','normalized','fontsize',.1,'color',[1 1 1],'visible','off');
set(h,'string','We appreciate your enthusiasm!','visible','on');
msg = msgbox({'Click OK when you are ready.'},'Start?');
while ishandle(msg);
pause(.2);
end;
% Reset figure to start the experiment
clf;
set(gcf,'color',[0 0 0],'toolbar','none','menubar','none'); % Black figure
set(gca,'visible','off','color',[0 0 0]); % Black axes
% Draw a cross to get participant's attention
h=text(0.5,0.5,'+','HorizontalAlignment','center','VerticalAlignment','middle',...
'FontUnits','normalized','fontsize',.3,'color',tgtColor,'visible','on');
% Set marker to start training
sendEvent('stimulus.training','start');
pause(3);
for bi=1:nBlock;
sendEvent('stimulus.block','start');
for si=1:nSequence;
sleepSec(intertrialDuration);
% Redraw figure at the beginning - just to be consistent
% Alert the subject - trial start alert = red baseline fixation cross
clf;
set(gcf,'color',[0 0 0],'toolbar','none','menubar','none');
set(gca,'visible','off','color',[0 0 0]);
h=text(.5,.5,'+','HorizontalAlignment','center','VerticalAlignment','middle',...
'FontUnits','normalized','fontsize',.3,'color',fixColor,'visible','on');
drawnow;
sendEvent('stimulus.baseline','start'); % Baseline marker - starts
sleepSec(baselineDuration);
sendEvent('stimulus.baseline','end'); % Baseline marker - ends
% Erase fixation
set(h,'color',bgColor);
drawnow;
% Present target stimulus
fprintf('%d) tgt=%d : ',si,find(tgtSeq(:,si)==1));
set(h,'string',stimulus(find(tgtSeq(:,si)==1),:),'color',tgtColor,'visible','on'); % White stimulus = trial under progress
drawnow;
sendEvent('stimulus.target',find(tgtSeq(:,si)==1));
sendEvent('stimulus.trial','start');
sleepSec(trialDuration); % Wait for the trial to end (=stimulus presentation time).
% Blank screen to indicate trial has ended
set(h,'color',bgColor);
drawnow;
sendEvent('stimulus.trial','end');
ftime=getwTime();
fprintf('\n');
end % End of sequences
if(bi<nBlock) % If there are more training blocks left, show this message.
msg=msgbox({'You did great! Press OK to go to the next training block.'},'Continue?');
while ishandle(msg);
pause(.2);
end;
end
% End block marker
sendEvent('stimulus.block','end');
end
% End training marker
sendEvent('stimulus.training','end');
% Express eternal gratitude
clf;
set(gcf,'color',[0 0 0],'toolbar','none','menubar','none'); % black figure
set(gca,'visible','off','color',[0 0 0]); % black axes
h=text(0.5,0.9,'Thank you for being your awesome self.','HorizontalAlignment','center','fontsize',.2,'color',tgtColor,'visible','on');
pause(3);