Scheduled service maintenance on November 22


On Friday, November 22, 2024, between 06:00 CET and 18:00 CET, GIN services will undergo planned maintenance. Extended service interruptions should be expected. We will try to keep downtimes to a minimum, but recommend that users avoid critical tasks, large data uploads, or DOI requests during this time.

We apologize for any inconvenience.

main.m 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. function main
  2. % This experiment is to examine the difference between ASP and TN groups
  3. % using reproduction and central tendency effect.
  4. % coded by Strongway (shi@lmu.de)
  5. % date: 25th July., 2018
  6. % experiment related parameters
  7. para.viewDistance = 57; % viewing distance 57 cm
  8. para.monitor = 22; % monitor size
  9. para.fntSize = 24; % font size
  10. para.bkColor = [128,128,128]; % background color
  11. para.fColorCircle = [128,128,0]; % foreground color
  12. para.fColorRectangle = [0,200,200]; % white color
  13. para.fColorW = [200];
  14. para.green = [0, 192, 0];
  15. para.red = [192, 0, 0];
  16. para.xPosition = 0; % 0 degree above
  17. para.yPosition = 0; % 0 degree above
  18. para.iti = [0.8, 1]; % range of inter-trial interval
  19. para.iprp = 0.5; % inter production-reproduction interval
  20. para.xyFeedbackArray = [-2,0; -1, 0; 0, 0; 1, 0; 2, 0]; % location of feedback array
  21. para.fbRange = [-100, -0.3; -0.3, -0.1; -0.1, 0.1; 0.1, 0.3; 0.3, 100]; %feedback range with respect to the reproduction error
  22. para.withFeedback = true;
  23. para.vSize = 10; % 10 degree
  24. para.vFeedDivid = 10;
  25. nTrlsBlk = 25;
  26. numHalfTrial = 250;
  27. %[para.nDurations(1,:) , para.nDurations(2,:)] = genDurSeq(numHalfTrial, 1);
  28. %[withblkFactors, nDurs] = size(para.nDurations);
  29. %sessionType = withblkFactors;% 1: short matched to circle and long matched to square
  30. %inBlkRep = 1; %inblock repetition
  31. try
  32. % kb = CInput('k',[1], {'downArrow'});
  33. kb = CInput('m'); % replace with mouse
  34. myexp = CExp(1, numHalfTrial, 'blockFactors', 2,...
  35. 'blockRepetition',1);
  36. % acquire subject information
  37. myexp.subInfo('Sequence', '1');
  38. % load sequence w1 from subfolder 'seqs'
  39. load(['seqs', filesep, 'seq', num2str(myexp.sPara)],'w1');
  40. % Dur, session, ntrl, nblock
  41. %production duration, session (1= predictive sequence, 2 = non predictive sequence)
  42. myexp.seq( myexp.seq(:, 2) == 1, 1) = w1;
  43. myexp.seq( myexp.seq(:, 2) == 2, 1) = w1(randperm( length(w1) ) ); % randomized sequence
  44. % set second column ad block number, 4th colum as block information
  45. myexp.seq(:,3) = 1: myexp.maxTrls; % trial sequence no.
  46. myexp.seq(:,4) = floor((myexp.seq(:,3)-1)/nTrlsBlk) + 1;
  47. v = CDisplay('bgColor',para.bkColor,'fontSize',para.fntSize,'monitorSize',para.monitor,...
  48. 'viewDistance',para.viewDistance,'fullWindow',1, 'skipSync',1);
  49. HideCursor;
  50. % create stimuli
  51. para.vObjCircle = v.createShape('circle',para.vSize,para.vSize,'color',para.fColorCircle);
  52. para.vObjRectangle = v.createShape('rectangle',para.vSize,para.vSize,'color',para.fColorRectangle);
  53. % create feedback stimuli
  54. vGreenDisk = v.createShape('circle', para.vSize/para.vFeedDivid, para.vSize/para.vFeedDivid, 'color',para.green);
  55. vRedDisk = v.createShape('circle', para.vSize/para.vFeedDivid, para.vSize/para.vFeedDivid, 'color',para.red);
  56. vDiskFrame = v.createShape('circle',para.vSize/para.vFeedDivid, para.vSize/para.vFeedDivid, 'color',para.fColorW,'fill',0);
  57. para.vFullFrames = [vDiskFrame, vDiskFrame, vDiskFrame, vDiskFrame, vDiskFrame];
  58. para.vFullDisks = [vRedDisk, vGreenDisk, vGreenDisk, vGreenDisk, vRedDisk];
  59. %initialize text
  60. infoText = init_text;
  61. % start instruction
  62. v.dispText(infoText.instruction);
  63. kb.wait;
  64. WaitSecs(2);
  65. for iTrl = 1:myexp.maxTrls
  66. %get current condition
  67. cond = myexp.getCondition; % duration, range
  68. curDuration = cond(1); % current standard
  69. %start trial presentation
  70. results = trialPresentation(v,kb, cond, curDuration, para);
  71. %store results
  72. myexp.setResp(results);%
  73. % debugging
  74. if kb.wantStop
  75. break;
  76. end
  77. % ITI 0.8-1 seconds
  78. WaitSecs(para.iti(1) + (para.iti(2)-para.iti(1))*rand);
  79. if mod(iTrl,nTrlsBlk) == 0
  80. v.dispText(infoText.startBlock);
  81. kb.wait;
  82. end
  83. if iTrl == numHalfTrial
  84. myexp.saveData; %save data
  85. v.dispText(infoText.sessionBreak);
  86. kb.wait;
  87. WaitSecs(2);
  88. kb.wait;
  89. end
  90. end
  91. myexp.saveData; %save data
  92. v.dispText(infoText.thankyou);
  93. kb.wait;
  94. v.close;
  95. ShowCursor;
  96. catch ME
  97. % debugging
  98. v.close;
  99. disp(ME.message);
  100. disp(ME.stack);
  101. for i=1:length(ME.stack)
  102. disp(ME.stack(i).name);
  103. disp(ME.stack(i).line);
  104. end
  105. v.close;
  106. ShowCursor;
  107. end
  108. end
  109. function results = trialPresentation(v, kb, cond, curDuration, para)
  110. v.dispFixation(20);
  111. WaitSecs(0.500); %at least 500 ms
  112. % initiated by key pressing, and measured by key release
  113. v.dispFixation(5,2); % change fixation from cross to a dot
  114. [key, keyInitTime] = kb.response;
  115. dispObj = para.vObjCircle;
  116. v.dispItems([para.xPosition, para.yPosition], dispObj,[para.vSize para.vSize],0,0); % draw texture
  117. [vbl, vInitTime] = v.flip;
  118. WaitSecs(curDuration - 0.005); % 5 ms earlier, so make sure to clear next frame on time.
  119. [vbl, vStopTime] = v.flip(1);
  120. keyReleaseTime = kb.keyRelease;
  121. v.flip(1); %clear screen
  122. phyDuration = vStopTime - vInitTime; %visual duration
  123. proDuration = keyReleaseTime - keyInitTime; %key production
  124. % reproduction
  125. WaitSecs(para.iprp); %wait at least 250 ms
  126. v.dispFixation(5,2);
  127. [key, keyInitTime] = kb.response;
  128. v.dispItems([para.xPosition, para.yPosition], dispObj,[para.vSize para.vSize],0,0);
  129. [vbl, vInitTime] = v.flip;
  130. keyReleaseTime = kb.keyRelease;
  131. [vbl, vStopTime]=v.flip(1);
  132. repDuration = keyReleaseTime - keyInitTime; % key reproduction
  133. repVDuration = vStopTime - vInitTime; % visual reproduction
  134. %store results
  135. results = [curDuration, phyDuration, proDuration, repVDuration, repDuration];
  136. if para.withFeedback
  137. % present a feedback display
  138. feedbackDisplay = para.vFullFrames;
  139. delta = (repDuration - phyDuration)/phyDuration;
  140. % find the range of the error
  141. cIdx = para.fbRange > delta; % column index of left and right boundary
  142. idx = find(xor(cIdx(:,1),cIdx(:,2)));
  143. feedbackDisplay(idx(1)) = para.vFullDisks(idx(1));
  144. WaitSecs(0.25); % wait 250 ms
  145. v.dispItems(para.xyFeedbackArray, feedbackDisplay,[para.vSize/para.vFeedDivid para.vSize/para.vFeedDivid]); % draw texture
  146. WaitSecs(0.500); % display the feedback for 500 ms
  147. v.flip;
  148. end
  149. end
  150. function infoText = init_text
  151. % specify experimental text
  152. infoText.instruction = [ 'Erklärung \n\n',...
  153. 'Die folgende Sitzung starten Sie durch Drücken der linken Maustaste. ', ...
  154. 'Bitte fixieren Sie das Kreuz in der Mitte des Bildschirms. ' ...
  155. 'Nach einer sehr kurzen Zeit wird das Kreuz zu einem Punkt. Nun kann das Experiment starten. ', ...
  156. 'Halten Sie nun die Maustaste solange gedrückt wie Sie den gelben Kreis sehen. Bitte achten Sie genau auf die Dauer. ', ...
  157. 'Der Kreis verschwindet automatisch. Lassen Sie die Maustaste wieder los sobald der Kreis verschwindet. ' ...
  158. 'Nachdem Sie nun wieder den kleinen Punkt sehen sollen Sie die Dauer des gelben Kreises reproduzieren. ' ...
  159. 'Hierfür halten Sie die Maustaste solange gedrückt wie Sie die Dauer eingeschätzt haben. ' ...
  160. 'Der gelbe Kreis erscheint dabei als Hilfsmittel. \n'];
  161. infoText.blockInfo = 'Bitte machen Sie eine Pause. Wenn Sie bereit sind drücken Sie die Maustaste. \n ';
  162. infoText.endTrial = 'Bitte lassen Sie die Maustaste los';
  163. infoText.production = '+';
  164. infoText.reproduction = '+';
  165. infoText.sessionBreak = ' Die erste Sitzung ist beendet! Bitte öffnen Sie die Tür und machen eine kurze Pause! \n';
  166. infoText.startBlock = ' Bitte machen Sie eine Pause! \n\n Bitte drücken Sie die Maustaste um den Block zu starten.\n';
  167. infoText.goingon = ' Bitte machen Sie eine Pause! \n\n Bitte drücken Sie die Maustaste um den Block fortzufahren.';
  168. infoText.thankyou = 'Das Experiment ist beendet! \nVielen herzlichen Dank!';
  169. end