Advertisement
Guest User

Untitled

a guest
Jul 9th, 2019
204
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 2.54 KB | None | 0 0
  1. patientID='testgav';
  2. alphabet=['a':'z' '0':'9' '0':'9'];
  3. outputvarFile=['D:\Timing Task\' patientID '_Timing_' alphabet(randi(46,1,7)) '.mat'];
  4. numTrials=15;
  5.  
  6. %% Triggers
  7. TrialStruct = struct();
  8. TrialStruct = Setup_DAQ_Stim(TrialStruct);
  9.  
  10. %Trigger codes
  11. Correct=1;
  12. Incorrect=2;
  13. TimedOut=3; %patient didn't hit target within window
  14.  
  15. %% Define Keypresses
  16. responseCodes = [0 0 0 0];
  17. TrialStruct.LeftKey = 'a';   % Corresponds to 1-key.
  18. TrialStruct.MidKey = 's';   % Corresponds to 2-key.
  19. TrialStruct.RightKey = 'd';   % Corresponds to 3-key.
  20. TrialStruct.EscKey = 'Escape';  % Corresponds to quit key.
  21. responseCodes(1) = KbName(TrialStruct.LeftKey);
  22. responseCodes(2) = KbName(TrialStruct.MidKey);
  23. responseCodes(3) = KbName(TrialStruct.RightKey);
  24. responseCodes(4) = KbName(TrialStruct.EscKey);
  25.  
  26. %%
  27. Screen('Preference', 'SkipSyncTests', 1);
  28. PsychDefaultSetup(2);
  29. screens = Screen('Screens');
  30. screenNumber = max(screens);
  31.  
  32. % Define black, white and grey
  33. black = BlackIndex(screenNumber);
  34. white = WhiteIndex(screenNumber);
  35. grey = white / 2;
  36.  
  37. % Open an on screen window and color it grey
  38. [window, windowRect] = PsychImaging('OpenWindow', screenNumber, grey);
  39.  
  40. % Set the blend funciton for the screen
  41. Screen('BlendFunction', window, 'GL_SRC_ALPHA', 'GL_ONE_MINUS_SRC_ALPHA');
  42.  
  43. % Get the size of the on screen window in pixels
  44. % For help see: Screen WindowSize?
  45. [screenXpixels, screenYpixels] = Screen('WindowSize', window);
  46.  
  47. % Get the centre coordinate of the window in pixels
  48. % For help see: help RectCenter
  49. [xCenter, yCenter] = RectCenter(windowRect);
  50.  
  51. line1 = 'This task is called "Mismatched Duration."';
  52. line2 = '\n Your goal is to determine which stimulus is longer or shorter.';
  53. line3 = '\n\n You will see a shape appear on the screen for a given amount of time, then disappear. Keep track of how long it is on the screen.';
  54. line4 = '\n\n\n After a pause, a second shape will appear for another amount of time.';
  55. line5 = '\n\n\n\n The second shape will disappear, and you will say if the second shape was on the screen longer or shorter than the first shape.';
  56. line6 = '\n\n\n\n\n Please use the A Key to indicate "shorter," and the D Key to indicate "longer."';
  57. line7 = '\n\n\n\n\n\n Ready?';
  58.  
  59. % Draw all the text in one go
  60. Screen('TextSize', window, 20);
  61. DrawFormattedText(window, [line1 line2 line3 line4 line5 line6 line7],...
  62.     'center', screenYpixels * 0.25, white);
  63.  
  64. % Flip to the screen
  65. Screen('Flip', window);
  66.  
  67. % Now we have drawn to the screen we wait for a keyboard button press (any
  68. % key) to terminate the demo
  69. KbStrokeWait;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement