StateSwitch_practice_171023.m 33.3 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
%
% Input
%
% expInfo | experiment configuration (struct)
%    subj | identifier of subject (string)
% condSet | conditions (cell array of strings)
%_______________________________________________________________________
%
% 170707    | updated palamedes to take in more inputs
% 170821    | adapted to state switch variant; no more threshold estimation
% 170816    | included RT feedback + reward at end of each block
% 170908    | preallocated dynamic trial presentation
% 170911    | changed cue presentation
14
% 171023    | update word version to remove peripheral cues and have new settings
15

16
function StateSwitch_practice_171023(expInfo, setup)
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34

  %%
  %% sanitize function parameters
  %%
  if nargin == 0
    eval('help dotsExperiment')
    return
  end

  if not(exist('expInfo','var'))
    error('Missing input: expInfo')
  elseif isempty(expInfo) || not(isstruct(expInfo))
    error('Invalid input: expInfo (requires non-empty struct)')
  end

  if not(isfield(expInfo,'deployed'))
    expInfo.deployed = true;
  end
35
36
  
  commandwindow;
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

  %%
  %% for saving behavioural data
  %%

  sessionFile = [setup.subjectsPath, setup.subj, '_Practice_', datestr(now, 'yymmdd_HHMM'), '.mat'];
    
  %%
  %% prepare presentation
  %%
  displayList = Screen('Screens'); % There appears to be a problem in DEBUG mode.
  displayIdx = displayList(setup.disp);
  KbName('UnifyKeyNames'); % use portable key naming scheme
  oldVerbosityLevel = Screen('Preference', 'Verbosity', 2); % show errors and warning

    if setup.DEBUG == 1
        Screen('Preference', 'SkipSyncTests', 1);
        PsychDebugWindowConfiguration(0, setup.opacity);
    else
        clear Screen; %PsychDebugWindowConfiguration([], 1);
    end

  try

    %%
    %% prepare canvas
    %%
    screenInfo = openExperiment(50,50,displayIdx); clc; % open drawing canvas
    if numel(Screen('screens')) == 1 || expInfo.deployed
      HideCursor(screenInfo.curWindow);
    end
    Screen('TextFont', screenInfo.curWindow, 'Helvetica');
    Screen('TextSize', screenInfo.curWindow, 20);
    Screen('TextStyle', screenInfo.curWindow, 0); % regular
    Screen('TextColor', screenInfo.curWindow, 255); % white
    ifi = Screen('GetFlipInterval', screenInfo.curWindow); % Query the frame duration
    
    % get experimenter and subject keyboards
    keyboardIndices = GetKeyboardIndices;
    if setup.keyB == 1 % use primary keyboard for subject and experimenter
        screenInfo.keyboard_sub = keyboardIndices(1);
        screenInfo.keyboard_exp = keyboardIndices(1);
    elseif setup.keyB == 2
        screenInfo.keyboard_sub = min(keyboardIndices);
        screenInfo.keyboard_exp = max(keyboardIndices);
    else disp('Check setup: only 1 or 2 keyboards supported.');
    end
    
    ResultMat = [];
    
    ExperimentProtocol = cell(0);
    ExperimentProtocol = [ExperimentProtocol; {'SessionOnset'}, {GetSecs}, {[]}, {[]}, {[]}, {NaN},{NaN},{NaN} {[]}];

    %% Intro slide

    if strcmp(setup.task, 'dynamic')
93
        DrawFormattedText(screenInfo.curWindow, '\n Willkommen bei der StateSwitch Aufgabe \n\n Im folgenden werden Sie Vierecksmuster sehen, die verschiedene Charakteristika aufweisen: \n\n Farbton \n\n Bewegungsrichtung \n\n Gre \n\n Sttigung \n\n\n Zunchst werden wir die Attribute einzeln bearbeiten. \n\n Bitte geben Sie an, von welcher der beiden Optionen mehr prsentiert wurde. \n\n\n Bitte ENTER Taste zum Fortfahren drcken.', 'center', 'center');
94
    elseif strcmp(setup.task, 'words')
95
        DrawFormattedText(screenInfo.curWindow, '\n Willkommen bei der StateSwitch Aufgabe \n\n Im folgenden werden Ihnen Wrter prsentiert, zu denen verschiedene Fragen gestellt werden: \n\n Handelt es sich um ein TIER? \n\n Ist das Wort EINSILBIG? \n\n Ist die Buchstabenanzahl GERADE? \n\n Beinhaltet das Wort mind. ein H? \n\n Zunchst werden wir die Fragen einzeln ben. \n\n\n Bitte ENTER Taste zum Fortfahren drcken.', 'center', 'center');
96
    elseif strcmp(setup.task, 'visual')
97
        DrawFormattedText(screenInfo.curWindow, '\n Willkommen bei der StateSwitch Aufgabe \n\n Im folgenden werden Ihnen visuelle Symbole prsentiert, zu denen verschiedene Fragen gestellt werden: \n\n Welche FARBE hat es? \n\n Gibt es ein MUSTER? \n\n Gibt es einen RAND? \n\n Welche FORM hat es? \n\n Zunchst werden wir die Fragen einzeln ben. \n\n\n Bitte ENTER Taste zum Fortfahren drcken.', 'center', 'center');
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
    end
    Screen('Flip', screenInfo.curWindow);
    disp('Experimenter input required: Intro Example (1/2)');
    % wait for experimenter to resume session
    while true
        [exitSession, resumeSession] = checkKeys_byKeyB(expInfo, screenInfo.keyboard_exp);
    if resumeSession
        break
    elseif exitSession
        closeExperiment;
        return
    end
    end
    
    %% Instruction 2
    
    if strcmp(setup.task, 'dynamic')
115
        DrawFormattedText(screenInfo.curWindow, 'Wir beginnen mit der Farbe. \n\n\n Falls die grnen Punkte berwiegen, drcken Sie die linke Taste. \n\n Falls die roten Punkte berwiegen, dcken Sie die rechte Taste. \n\n\n Im Anschluss an Ihre Antwort erhalten Sie eine Rckmeldung. \n\n\n Bitte ENTER Taste zum Fortfahren drcken.', 'center', 'center');
116
    elseif strcmp(setup.task, 'words')
117
        DrawFormattedText(screenInfo.curWindow, 'Wir beginnen mit der Frage, ob das Wort ein Tier benennt. \n\n\n Falls NEIN, drcken Sie die linke Taste. \n\n Falls JA, dcken Sie die rechte Taste. \n\n\n Bitte ENTER Taste zum Fortfahren drcken.', 'center', 'center', [255 255 255]);
118
    elseif strcmp(setup.task, 'visual')
119
        DrawFormattedText(screenInfo.curWindow, 'Wir beginnen mit der Frage, welche Farbe das Muster besitzt. \n\n\n Falls GRN, drcken Sie die linke Taste. \n\n Falls ROT, dcken Sie die rechte Taste. \n\n\n Bitte ENTER Taste zum Fortfahren drcken.', 'center', 'center', [255 255 255]);
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
    end
    Screen('Flip', screenInfo.curWindow);
    disp('Experimenter input required: Intro Coulour --> Start Colour presentation');
    pause(1);
    % wait for experimenter to resume session
    while true
        [exitSession, resumeSession] = checkKeys_byKeyB(expInfo, screenInfo.keyboard_exp);
        if resumeSession
            break
        elseif exitSession
            closeExperiment;
            return
        end
    end
    
    %% 1st dimension
    
    % intiate parameters
    DisplayInfo.CombPositionByTrial = [];
    DisplayInfo.CombSamples = [];
    ResultMat = [];
    % get a single run containing only the target attribute
    expInfo = [];
    if strcmp(setup.task, 'dynamic')
        expInfo = StateSwitch_createExpInfo_dynamic_TEST_170922(1);
    elseif strcmp(setup.task, 'words')
146
        expInfo = StateSwitch_createExpInfo_words_TEST_171023(1);
147
148
149
150
151
152
153
154
155
156
157
158
159
160
    elseif strcmp(setup.task, 'visual')
        expInfo = StateSwitch_createExpInfo_visual_TEST_170829(1);
    end
    expInfo.deployed = true;
    expInfo.feedback = 1;
    
    for indRun = 1
        Timing.RunInitiation = GetSecs();
        Timing.lastTiming = 'NaN';
        for indBlock = 1
            % initialize state cues of current condition
            if strcmp(setup.task, 'dynamic')
                StateSwitch_addSurroundingCues_dynamic_170911(expInfo, screenInfo, 1, 1, 1);
            elseif strcmp(setup.task, 'words')
161
                StateSwitch_addSurroundingCues_words_171023(expInfo, screenInfo, 1, 1, 1);
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
            elseif strcmp(setup.task, 'visual')
                StateSwitch_addSurroundingCues_visual(expInfo, screenInfo, 1, 1, 1);
            end
            oldTextSize = Screen('TextSize', screenInfo.curWindow, 30);
            DrawFormattedText(screenInfo.curWindow, ['relevante Attribute: ', num2str(expInfo.StateOrderRun{indRun}(indBlock,1))], 'center', 'center');
            Screen('TextSize', screenInfo.curWindow, oldTextSize); clear oldTextSize;

            % ####### Block cue onset #####
            if strcmp(expInfo.timing, 'absolute') || strcmp(expInfo.timing, 'relativeITI')
                flipWhen = Timing.RunInitiation+(indBlock-1)*expInfo.durBlockOnset+(indBlock-1)*expInfo.blockLengthDim*expInfo.trialDuration.all+(indBlock-1)*expInfo.durReward-(ifi/2);
            elseif strcmp(expInfo.timing, 'relative')
                if strcmp(Timing.lastTiming, 'NaN')
                    flipWhen = 0;
                elseif strcmp(Timing.lastTiming, 'ITI')
                    flipWhen = Timing.ITIOnset+expInfo.durITI-(ifi/2);
                end                
            end
            Timing.BlockInitiation = Screen('Flip', screenInfo.curWindow, flipWhen);
            Timing.lastTiming = 'BlockCue';
            ExperimentProtocol = [ExperimentProtocol; {'BlockInitiation'}, {Timing.BlockInitiation}, {[]}, {[]}, {[]}, {indRun}, {indBlock}, {[]}, {[]}];
            for indTrial = 1:setup.pr.ntrials_single
                Timing.TrialInitiation = GetSecs();
                ExperimentProtocol = [ExperimentProtocol; {'TrialInitiation'}, {Timing.TrialInitiation}, {[]}, {[]}, {[]}, {indRun}, {indBlock}, {[]}, {[]}];
                if strcmp(setup.task, 'dynamic')
                    % create fixation
                    targets = makeDotTargets(screenInfo, expInfo); % initialize targets
                    %showTargets(screenInfo, targets, 1);
                    [~, expInfo, ExperimentProtocol,ResultMat,DisplayInfo,Timing] = ...
                    StateSwitch_trialPresentation_dynamic_170911(screenInfo, expInfo, targets, indRun, indBlock, indTrial, ...
                    ExperimentProtocol,ResultMat,DisplayInfo,Timing,setup);
                elseif strcmp(setup.task, 'words') || strcmp(setup.task, 'visual')
                    [~, expInfo, ExperimentProtocol,ResultMat,DisplayInfo,Timing] = ...
194
                    StateSwitch_trialPresentation_words_visual_171023(screenInfo, expInfo, [], indRun, indBlock, indTrial, ...
195
196
197
198
199
200
201
202
203
204
205
206
207
208
                    ExperimentProtocol,ResultMat,DisplayInfo,Timing,setup);
                end
            end
        end
    end
    
    Results{1,1} = expInfo;
    Results{2,1} = ExperimentProtocol;
    Results{3,1} = ResultMat;
    Results{4,1} = DisplayInfo;
    
    %% Instruction
    
    if strcmp(setup.task, 'dynamic')
209
        DrawFormattedText(screenInfo.curWindow, 'Als nchstes die Bewegungsrichtung. \n\n\n Falls die Bewegung nach links berwiegt, drcken Sie die linke Taste. \n\n Falls die Bewegung nach rechts berwiegt, dcken Sie die rechte Taste. \n\n\n Bitte ENTER Taste zum Fortfahren drcken.', 'center', 'center', [255 255 255]);
210
    elseif strcmp(setup.task, 'words')
211
        DrawFormattedText(screenInfo.curWindow, 'Als nchstes folgt die Frage, ob das Wort einsilbig ist. \n\n\n Falls NEIN, drcken Sie die linke Taste. \n\n Falls JA, dcken Sie die rechte Taste. \n\n\n Bitte ENTER Taste zum Fortfahren drcken.', 'center', 'center', [255 255 255]);
212
    elseif strcmp(setup.task, 'visual')
213
        DrawFormattedText(screenInfo.curWindow, 'Als nchstes folgt die Frage, ob das Symbol ein Muster beinhaltet. \n\n\n Falls NEIN, drcken Sie die linke Taste. \n\n Falls JA, dcken Sie die rechte Taste. \n\n\n Bitte ENTER Taste zum Fortfahren drcken.', 'center', 'center', [255 255 255]);
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
    end
    Screen('Flip', screenInfo.curWindow);    
    disp('Experimenter input required: Intro Direction --> Start Direction presentation');

    pause(1);

    % wait for experimenter to resume session
    while true
        [exitSession, resumeSession] = checkKeys_byKeyB(expInfo, screenInfo.keyboard_exp);
        if resumeSession
            break
        elseif exitSession
            closeExperiment;
            return
        end
    end
    
    %% 2nd dimension
    
    % intiate parameters
    DisplayInfo.CombPositionByTrial = [];
    DisplayInfo.CombSamples = [];
    ResultMat = [];
    % get a single run containing only the target attribute
    expInfo = [];
    if strcmp(setup.task, 'dynamic')
        expInfo = StateSwitch_createExpInfo_dynamic_TEST_170922(2);
    elseif strcmp(setup.task, 'words')
242
        expInfo = StateSwitch_createExpInfo_words_TEST_171023(2);
243
244
245
246
247
248
249
250
251
252
253
254
255
256
    elseif strcmp(setup.task, 'visual')
        expInfo = StateSwitch_createExpInfo_visual_TEST_170829(2);
    end
    expInfo.deployed = true;
    expInfo.feedback = 1;
    
    for indRun = 1
        Timing.RunInitiation = GetSecs();
        Timing.lastTiming = 'NaN';
        for indBlock = 1
            % initialize state cues of current condition
            if strcmp(setup.task, 'dynamic')
                StateSwitch_addSurroundingCues_dynamic_170911(expInfo, screenInfo, 1, 1, 1);
            elseif strcmp(setup.task, 'words')
257
                StateSwitch_addSurroundingCues_words_171023(expInfo, screenInfo, 1, 1, 1);
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
            elseif strcmp(setup.task, 'visual')
                StateSwitch_addSurroundingCues_visual(expInfo, screenInfo, 1, 1, 1);
            end
            oldTextSize = Screen('TextSize', screenInfo.curWindow, 30);
            DrawFormattedText(screenInfo.curWindow, ['relevante Attribute: ', num2str(expInfo.StateOrderRun{indRun}(indBlock,1))], 'center', 'center');
            Screen('TextSize', screenInfo.curWindow, oldTextSize); clear oldTextSize;

            % ####### Block cue onset #####
            if strcmp(expInfo.timing, 'absolute') || strcmp(expInfo.timing, 'relativeITI')
                flipWhen = Timing.RunInitiation+(indBlock-1)*expInfo.durBlockOnset+(indBlock-1)*expInfo.blockLengthDim*expInfo.trialDuration.all+(indBlock-1)*expInfo.durReward-(ifi/2);
            elseif strcmp(expInfo.timing, 'relative')
                if strcmp(Timing.lastTiming, 'NaN')
                    flipWhen = 0;
                elseif strcmp(Timing.lastTiming, 'ITI')
                    flipWhen = Timing.ITIOnset+expInfo.durITI-(ifi/2);
                end                
            end
            Timing.BlockInitiation = Screen('Flip', screenInfo.curWindow, flipWhen);
            Timing.lastTiming = 'BlockCue';
            ExperimentProtocol = [ExperimentProtocol; {'BlockInitiation'}, {Timing.BlockInitiation}, {[]}, {[]}, {[]}, {indRun}, {indBlock}, {[]}, {[]}];
            for indTrial = 1:setup.pr.ntrials_single
                Timing.TrialInitiation = GetSecs();
                ExperimentProtocol = [ExperimentProtocol; {'TrialInitiation'}, {Timing.TrialInitiation}, {[]}, {[]}, {[]}, {indRun}, {indBlock}, {[]}, {[]}];
                if strcmp(setup.task, 'dynamic')
                    % create fixation
                    targets = makeDotTargets(screenInfo, expInfo); % initialize targets
                    %showTargets(screenInfo, targets, 1);
                    [~, expInfo, ExperimentProtocol,ResultMat,DisplayInfo,Timing] = ...
                    StateSwitch_trialPresentation_dynamic_170911(screenInfo, expInfo, targets, indRun, indBlock, indTrial, ...
                    ExperimentProtocol,ResultMat,DisplayInfo,Timing,setup);
                elseif strcmp(setup.task, 'words') || strcmp(setup.task, 'visual')
                    [~, expInfo, ExperimentProtocol,ResultMat,DisplayInfo,Timing] = ...
290
                    StateSwitch_trialPresentation_words_visual_171023(screenInfo, expInfo, [], indRun, indBlock, indTrial, ...
291
292
293
294
295
296
297
298
299
300
301
302
303
                    ExperimentProtocol,ResultMat,DisplayInfo,Timing,setup);
                end
            end
        end
    end    
    Results{1,2} = expInfo;
    Results{2,2} = ExperimentProtocol;
    Results{3,2} = ResultMat;
    Results{4,2} = DisplayInfo;
    
    %% Instruction
    
    if strcmp(setup.task, 'dynamic')
304
        DrawFormattedText(screenInfo.curWindow, 'Als nchstes die Punktgre. \n\n\n Falls die kleineren Punkte berwiegen, drcken Sie die linke Taste. \n\n Falls die greren Punkte berwiegen, dcken Sie die rechte Taste. \n\n\n Bitte ENTER Taste zum Fortfahren drcken.', 'center', 'center', [255 255 255]);
305
    elseif strcmp(setup.task, 'words')
306
        DrawFormattedText(screenInfo.curWindow, 'Als nchstes folgt die Frage, ob das Wort eine gerade Anzahl an Buchstaben aufweist. \n\n\n Falls NEIN, drcken Sie die linke Taste. \n\n Falls JA, dcken Sie die rechte Taste. \n\n\n Bitte ENTER Taste zum Fortfahren drcken.', 'center', 'center', [255 255 255]);
307
    elseif strcmp(setup.task, 'visual')
308
        DrawFormattedText(screenInfo.curWindow, 'Als nchstes folgt die Frage, ob das Symbol einen weien Rand besitzt. \n\n\n Falls NEIN, drcken Sie die linke Taste. \n\n Falls JA, dcken Sie die rechte Taste. \n\n\n Bitte ENTER Taste zum Fortfahren drcken.', 'center', 'center', [255 255 255]);
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
    end
    Screen('Flip', screenInfo.curWindow);
    disp('Experimenter input required: Intro Size --> Start Size presentation');

    pause(1);
    
    % wait for experimenter to resume session
    while true
        [exitSession, resumeSession] = checkKeys_byKeyB(expInfo, screenInfo.keyboard_exp);
    if resumeSession
        break
    elseif exitSession
        closeExperiment;
        return
    end
    end
    
    %% 3rd dimension
    
    % intiate parameters
    DisplayInfo.CombPositionByTrial = [];
    DisplayInfo.CombSamples = [];
    ResultMat = [];
    % get a single run containing only the target attribute
    expInfo = [];
    if strcmp(setup.task, 'dynamic')
        expInfo = StateSwitch_createExpInfo_dynamic_TEST_170922(3);
    elseif strcmp(setup.task, 'words')
337
        expInfo = StateSwitch_createExpInfo_words_TEST_171023(3);
338
339
340
341
342
343
344
345
346
347
348
349
350
351
    elseif strcmp(setup.task, 'visual')
        expInfo = StateSwitch_createExpInfo_visual_TEST_170829(3);
    end
    expInfo.deployed = true;
    expInfo.feedback = 1;
    
    for indRun = 1
        Timing.RunInitiation = GetSecs();
        Timing.lastTiming = 'NaN';
        for indBlock = 1
            % initialize state cues of current condition
            if strcmp(setup.task, 'dynamic')
                StateSwitch_addSurroundingCues_dynamic_170911(expInfo, screenInfo, 1, 1, 1);
            elseif strcmp(setup.task, 'words')
352
                StateSwitch_addSurroundingCues_words_171023(expInfo, screenInfo, 1, 1, 1);
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
            elseif strcmp(setup.task, 'visual')
                StateSwitch_addSurroundingCues_visual(expInfo, screenInfo, 1, 1, 1);
            end
            oldTextSize = Screen('TextSize', screenInfo.curWindow, 30);
            DrawFormattedText(screenInfo.curWindow, ['relevante Attribute: ', num2str(expInfo.StateOrderRun{indRun}(indBlock,1))], 'center', 'center');
            Screen('TextSize', screenInfo.curWindow, oldTextSize); clear oldTextSize;

            % ####### Block cue onset #####
            if strcmp(expInfo.timing, 'absolute') || strcmp(expInfo.timing, 'relativeITI')
                flipWhen = Timing.RunInitiation+(indBlock-1)*expInfo.durBlockOnset+(indBlock-1)*expInfo.blockLengthDim*expInfo.trialDuration.all+(indBlock-1)*expInfo.durReward-(ifi/2);
            elseif strcmp(expInfo.timing, 'relative')
                if strcmp(Timing.lastTiming, 'NaN')
                    flipWhen = 0;
                elseif strcmp(Timing.lastTiming, 'ITI')
                    flipWhen = Timing.ITIOnset+expInfo.durITI-(ifi/2);
                end                
            end
            Timing.BlockInitiation = Screen('Flip', screenInfo.curWindow, flipWhen);
            Timing.lastTiming = 'BlockCue';
            ExperimentProtocol = [ExperimentProtocol; {'BlockInitiation'}, {Timing.BlockInitiation}, {[]}, {[]}, {[]}, {indRun}, {indBlock}, {[]}, {[]}];
            for indTrial = 1:setup.pr.ntrials_single
                Timing.TrialInitiation = GetSecs();
                ExperimentProtocol = [ExperimentProtocol; {'TrialInitiation'}, {Timing.TrialInitiation}, {[]}, {[]}, {[]}, {indRun}, {indBlock}, {[]}, {[]}];
                if strcmp(setup.task, 'dynamic')
                    % create fixation
                    targets = makeDotTargets(screenInfo, expInfo); % initialize targets
                    %showTargets(screenInfo, targets, 1);
                    [~, expInfo, ExperimentProtocol,ResultMat,DisplayInfo,Timing] = ...
                    StateSwitch_trialPresentation_dynamic_170911(screenInfo, expInfo, targets, indRun, indBlock, indTrial, ...
                    ExperimentProtocol,ResultMat,DisplayInfo,Timing,setup);
                elseif strcmp(setup.task, 'words') || strcmp(setup.task, 'visual')
                    [~, expInfo, ExperimentProtocol,ResultMat,DisplayInfo,Timing] = ...
385
                    StateSwitch_trialPresentation_words_visual_171023(screenInfo, expInfo, [], indRun, indBlock, indTrial, ...
386
387
388
389
390
391
392
393
394
395
396
397
398
399
                    ExperimentProtocol,ResultMat,DisplayInfo,Timing,setup);
                end
            end
        end
    end
    
    Results{1,3} = expInfo;
    Results{2,3} = ExperimentProtocol;
    Results{3,3} = ResultMat;
    Results{4,3} = DisplayInfo;
    
    %% Instruction
    
    if strcmp(setup.task, 'dynamic')
400
        DrawFormattedText(screenInfo.curWindow, 'Zuletzt die Sttigung. \n\n\n Falls die ungesttigteren Punkte berwiegen, drcken Sie die linke Taste. \n\n Falls die gesttigteren Punkte berwiegen, dcken Sie die rechte Taste. \n\n\n Bitte ENTER Taste zum Fortfahren drcken. \n\n\n Wichtig: Die Symbole sind stellvertretend fr Sttigung, es gibt KEINE gelben Vierecke. ', 'center', 'center', [255 255 255]);
401
    elseif strcmp(setup.task, 'words')
402
        DrawFormattedText(screenInfo.curWindow, 'Zuletzt die Frage, ob das Wort mind. ein H beinhaltet. \n\n\n Falls NEIN, drcken Sie die linke Taste. \n\n Falls JA, dcken Sie die rechte Taste. \n\n\n Bitte ENTER Taste zum Fortfahren drcken.', 'center', 'center', [255 255 255]);
403
    elseif strcmp(setup.task, 'visual')
404
        DrawFormattedText(screenInfo.curWindow, 'Zuletzt die Frage, nach der Form. \n\n\n Falls KREIS, drcken Sie die linke Taste. \n\n Falls RECHTECK, dcken Sie die rechte Taste. \n\n\n Bitte ENTER Taste zum Fortfahren drcken.', 'center', 'center', [255 255 255]);
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
    end
    Screen('Flip', screenInfo.curWindow);
    disp('Experimenter input required: Intro Luminance --> Start Luminance presentation');

    pause(1);
    
    % wait for experimenter to resume session
    while true
        [exitSession, resumeSession] = checkKeys_byKeyB(expInfo, screenInfo.keyboard_exp);
    if resumeSession
        break
    elseif exitSession
        closeExperiment;
        return
    end
    end
    
     %% 4th dimension
    
    % intiate parameters
    DisplayInfo.CombPositionByTrial = [];
    DisplayInfo.CombSamples = [];
    ResultMat = [];
    % get a single run containing only the target attribute
    expInfo = [];
    if strcmp(setup.task, 'dynamic')
        expInfo = StateSwitch_createExpInfo_dynamic_TEST_170922(4);
    elseif strcmp(setup.task, 'words')
433
        expInfo = StateSwitch_createExpInfo_words_TEST_171023(4);
434
435
436
437
438
439
440
441
442
443
444
445
446
447
    elseif strcmp(setup.task, 'visual')
        expInfo = StateSwitch_createExpInfo_visual_TEST_170829(4);
    end
    expInfo.deployed = true;
    expInfo.feedback = 1;
    
    for indRun = 1
        Timing.RunInitiation = GetSecs();
        Timing.lastTiming = 'NaN';
        for indBlock = 1
            % initialize state cues of current condition
            if strcmp(setup.task, 'dynamic')
                StateSwitch_addSurroundingCues_dynamic_170911(expInfo, screenInfo, 1, 1, 1);
            elseif strcmp(setup.task, 'words')
448
                StateSwitch_addSurroundingCues_words_171023(expInfo, screenInfo, 1, 1, 1);
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
            elseif strcmp(setup.task, 'visual')
                StateSwitch_addSurroundingCues_visual(expInfo, screenInfo, 1, 1, 1);
            end
            oldTextSize = Screen('TextSize', screenInfo.curWindow, 30);
            DrawFormattedText(screenInfo.curWindow, ['relevante Attribute: ', num2str(expInfo.StateOrderRun{indRun}(indBlock,1))], 'center', 'center');
            Screen('TextSize', screenInfo.curWindow, oldTextSize); clear oldTextSize;

            % ####### Block cue onset #####
            if strcmp(expInfo.timing, 'absolute') || strcmp(expInfo.timing, 'relativeITI')
                flipWhen = Timing.RunInitiation+(indBlock-1)*expInfo.durBlockOnset+(indBlock-1)*expInfo.blockLengthDim*expInfo.trialDuration.all+(indBlock-1)*expInfo.durReward-(ifi/2);
            elseif strcmp(expInfo.timing, 'relative')
                if strcmp(Timing.lastTiming, 'NaN')
                    flipWhen = 0;
                elseif strcmp(Timing.lastTiming, 'ITI')
                    flipWhen = Timing.ITIOnset+expInfo.durITI-(ifi/2);
                end                
            end
            Timing.BlockInitiation = Screen('Flip', screenInfo.curWindow, flipWhen);
            Timing.lastTiming = 'BlockCue';
            ExperimentProtocol = [ExperimentProtocol; {'BlockInitiation'}, {Timing.BlockInitiation}, {[]}, {[]}, {[]}, {indRun}, {indBlock}, {[]}, {[]}];
            for indTrial = 1:setup.pr.ntrials_single
                Timing.TrialInitiation = GetSecs();
                ExperimentProtocol = [ExperimentProtocol; {'TrialInitiation'}, {Timing.TrialInitiation}, {[]}, {[]}, {[]}, {indRun}, {indBlock}, {[]}, {[]}];
                if strcmp(setup.task, 'dynamic')
                    % create fixation
                    targets = makeDotTargets(screenInfo, expInfo); % initialize targets
                    %showTargets(screenInfo, targets, 1);
                    [~, expInfo, ExperimentProtocol,ResultMat,DisplayInfo,Timing] = ...
                    StateSwitch_trialPresentation_dynamic_170911(screenInfo, expInfo, targets, indRun, indBlock, indTrial, ...
                    ExperimentProtocol,ResultMat,DisplayInfo,Timing,setup);
                elseif strcmp(setup.task, 'words') || strcmp(setup.task, 'visual')
                    [~, expInfo, ExperimentProtocol,ResultMat,DisplayInfo,Timing] = ...
481
                    StateSwitch_trialPresentation_words_visual_171023(screenInfo, expInfo, [], indRun, indBlock, indTrial, ...
482
483
484
485
486
487
488
489
490
491
492
493
494
                    ExperimentProtocol,ResultMat,DisplayInfo,Timing,setup);
                end
            end
        end
    end
    
    Results{1,4} = expInfo;
    Results{2,4} = ExperimentProtocol;
    Results{3,4} = ResultMat;
    Results{4,4} = DisplayInfo;
    
    %% Instruction 1
    
495
496
497
498
499
    if strcmp(setup.task, 'dynamic')
        DrawFormattedText(screenInfo.curWindow, 'Nun kennen Sie alle Attribute. \n\n  Diese werden Ihnen im Folgenden gemeinsam prsentiert. \n\n Bitte geben Sie wie zuvor an, welche der beiden Optionen eines Attributs berwiegend vorhanden ist. \n\n Das relevante Attribut wird Ihnen dabei nach der Prsentation prsentiert. \n\n\n Bitte ENTER Taste zum Fortfahren drcken.', 'center', 'center', [255 255 255]);
    elseif strcmp(setup.task, 'words')
        DrawFormattedText(screenInfo.curWindow, 'Nun kennen Sie alle Attribute. \n\n  Diese werden Ihnen im Folgenden gemeinsam prsentiert. \n\n Bitte geben Sie wie zuvor an, welche der beiden Optionen eines Attributs berwiegend vorhanden ist. \n\n Das relevante Attribut wird Ihnen dabei erst kurz vor der Prsentation prsentiert. \n\n\n Bitte ENTER Taste zum Fortfahren drcken.', 'center', 'center', [255 255 255]);
    end
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
    Screen('Flip', screenInfo.curWindow);
    disp('Experimenter input required: Intro Realistic 1/3');

    pause(1);
    
    % wait for experimenter to resume session
    while true
        [exitSession, resumeSession] = checkKeys_byKeyB(expInfo, screenInfo.keyboard_exp);
    if resumeSession
        break
    elseif exitSession
        closeExperiment;
        return
    end
    end
    
    %% Instruction 1
    
518
519
520
521
522
    if strcmp(setup.task, 'dynamic')
        DrawFormattedText(screenInfo.curWindow, 'Vor jedem Durchgang erfahren Sie, welche Attribute abgefragt werden knnen. \n\n Dabei werden nun lediglich die Symbole ohne Namen gezeigt. \n\n Sie werden nun nicht mehr erfahren, ob Ihre Antworten korrekt waren. \n\n Bitte ENTER Taste zum Fortfahren drcken.', 'center', 'center', [255 255 255]);
    elseif strcmp(setup.task, 'words')
        DrawFormattedText(screenInfo.curWindow, 'Vor jedem Durchgang erfahren Sie, welche Attribute abgefragt werden knnen. \n\n Bitte ENTER Taste zum Fortfahren drcken.', 'center', 'center', [255 255 255]);
    end
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
    Screen('Flip', screenInfo.curWindow);
    disp('Experimenter input required: Intro Realistic 2/3');

    pause(1);
    
    % wait for experimenter to resume session
    while true
        [exitSession, resumeSession] = checkKeys_byKeyB(expInfo, screenInfo.keyboard_exp);
    if resumeSession
        break
    elseif exitSession
        closeExperiment;
        return
    end
    end
    
    %% Instruction 2
    
    if expInfo.durConf > 0
        DrawFormattedText(screenInfo.curWindow, 'Zudem bitten wir Sie im Anschluss um eine Einschtzung, wie sicher Sie sich bei der Entscheidung sind. \n\n  Bitte drcken Sie dann die linke Taste, falls sie sich eher unsicher sind. \n\n Bitte drcken Sie dann die rechte Taste, falls sie sich eher sicher sind. \n\n\n Bitte rechte Taste zum Fortfahren drcken.', 'center', 'center', [255 255 255]);
        Screen('Flip', screenInfo.curWindow);
        disp('Experimenter input required: Intro Realistic 3/3 --> Start Realistic cueing, no feedback');

        pause(1);

        % wait for experimenter to resume session
        while true
            [exitSession, resumeSession] = checkKeys_byKeyB(expInfo, screenInfo.keyboard_exp);
        if resumeSession
            break
        elseif exitSession
            closeExperiment;
            return
        end
        end
    end
    
    %% realistic without cue
    
    % intiate parameters
    DisplayInfo.CombPositionByTrial = [];
    DisplayInfo.CombSamples = [];
    ResultMat = [];
    % get a single run containing only the target attribute
    expInfo = [];
    if strcmp(setup.task, 'dynamic')
        expInfo = StateSwitch_createExpInfo_dynamic_TEST_170922(5);
    elseif strcmp(setup.task, 'words')
571
        expInfo = StateSwitch_createExpInfo_words_TEST_171023(5);
572
573
574
575
576
577
578
579
580
581
582
583
584
    elseif strcmp(setup.task, 'visual')
        expInfo = StateSwitch_createExpInfo_visual_TEST_170829(5);
    end
    expInfo.deployed = true;
    
    for indRun = 1
        Timing.RunInitiation = GetSecs();
        Timing.lastTiming = 'NaN';
        for indBlock = 1
            % initialize state cues of current condition
            if strcmp(setup.task, 'dynamic')
                StateSwitch_addSurroundingCues_dynamic_170911(expInfo, screenInfo, 1, 1, 1);
            elseif strcmp(setup.task, 'words')
585
                StateSwitch_addSurroundingCues_words_171023(expInfo, screenInfo, 1, 1, 1);
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
            elseif strcmp(setup.task, 'visual')
                StateSwitch_addSurroundingCues_visual(expInfo, screenInfo, 1, 1, 1);
            end
            oldTextSize = Screen('TextSize', screenInfo.curWindow, 30);
            DrawFormattedText(screenInfo.curWindow, ['relevante Attribute: ', num2str(expInfo.StateOrderRun{indRun}(indBlock,1))], 'center', 'center');
            Screen('TextSize', screenInfo.curWindow, oldTextSize); clear oldTextSize;

            % ####### Block cue onset #####
            if strcmp(expInfo.timing, 'absolute') || strcmp(expInfo.timing, 'relativeITI')
                flipWhen = Timing.RunInitiation+(indBlock-1)*expInfo.durBlockOnset+(indBlock-1)*expInfo.blockLengthDim*expInfo.trialDuration.all+(indBlock-1)*expInfo.durReward-(ifi/2);
            elseif strcmp(expInfo.timing, 'relative')
                if strcmp(Timing.lastTiming, 'NaN')
                    flipWhen = 0;
                elseif strcmp(Timing.lastTiming, 'ITI')
                    flipWhen = Timing.ITIOnset+expInfo.durITI-(ifi/2);
                end                
            end
            Timing.BlockInitiation = Screen('Flip', screenInfo.curWindow, flipWhen);
            Timing.lastTiming = 'BlockCue';
            ExperimentProtocol = [ExperimentProtocol; {'BlockInitiation'}, {Timing.BlockInitiation}, {[]}, {[]}, {[]}, {indRun}, {indBlock}, {[]}, {[]}];
            for indTrial = 1:setup.pr.ntrials_conj
                Timing.TrialInitiation = GetSecs();
                ExperimentProtocol = [ExperimentProtocol; {'TrialInitiation'}, {Timing.TrialInitiation}, {[]}, {[]}, {[]}, {indRun}, {indBlock}, {[]}, {[]}];
                if strcmp(setup.task, 'dynamic')
                    % create fixation
                    targets = makeDotTargets(screenInfo, expInfo); % initialize targets
                    %showTargets(screenInfo, targets, 1);
                    [~, expInfo, ExperimentProtocol,ResultMat,DisplayInfo,Timing] = ...
                    StateSwitch_trialPresentation_dynamic_170911(screenInfo, expInfo, targets, indRun, indBlock, indTrial, ...
                    ExperimentProtocol,ResultMat,DisplayInfo,Timing,setup);
                elseif strcmp(setup.task, 'words') || strcmp(setup.task, 'visual')
                    [~, expInfo, ExperimentProtocol,ResultMat,DisplayInfo,Timing] = ...
618
                    StateSwitch_trialPresentation_words_visual_171023(screenInfo, expInfo, [], indRun, indBlock, indTrial, ...
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
                    ExperimentProtocol,ResultMat,DisplayInfo,Timing,setup);
                end
            end
        end
    end
    
    Results{1,5} = expInfo;
    Results{2,5} = ExperimentProtocol;
    Results{3,5} = ResultMat;
    Results{4,5} = DisplayInfo;
        
     %% save practice files
    
    save(sessionFile, 'Results', 'setup')
    
    pause(1);
    
    %% inform the subject that the experiment is over
    
    DrawFormattedText(screenInfo.curWindow, 'Sie haben das Training nun beendet! \n\n Falls Sie noch Fragen haben, wenden Sie sich bitte an die Versuchsleiter.', 'center', 'center', [255 255 255]);
    Screen('Flip', screenInfo.curWindow);
    
    %% automatically close screen after 5 s
    
    pause(5);
    
%     disp('Experimenter input required: close experiment');
% %     while true
% %       [exitKeyPressed, resumeKeyPressed] = checkKeys_byKeyB(expInfo, screenInfo.keyboard_exp);
% %       if exitKeyPressed || resumeKeyPressed
% %         break
% %       end
% %     end

  catch exception
    getReport(exception) % show stack trace
  end

  closeExperiment; % close drawing canvas
  Screen('Preference', 'Verbosity', oldVerbosityLevel); % restore verbosity

end