MoBi_instructions.m 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. function MoBi_instructions(contraction_task, data_subject, volume, forces, bl)
  2. %% the function shows on the screen the stimulation parameters that have to be set
  3. cd 'C:\Users\neuro\Desktop\script_mobi_da_commentare'
  4. sca;
  5. close all;
  6. %% Do you want to tinker with small screen? (0 == no)
  7. tinker = 0;
  8. %% SCREEN SETTING
  9. [window, misure_schermo, screenNum, CenterX, CenterY, ifi] = MoBi_Screen_Settings_Brescia(tinker)
  10. % screen proportions
  11. proporzioni_schermo = misure_schermo(4)/misure_schermo(3);
  12. %% set the bus for MATLAB-arduino communication
  13. delete(instrfindall);
  14. clear s
  15. %Set up the serial port
  16. s = serial('COM5');
  17. set(s, 'BaudRate', 115200); % set BaudRate to 115200 (as in Arduino!!!!!)
  18. % open it
  19. fopen(s);
  20. WaitSecs(2);
  21. for d = 1:2
  22. MoBi_scrittura(s);
  23. end
  24. %% transform nominal delays (the ideal delay that one wants wait before a screen flip) into actual delays...
  25. %...(slightly smaller delays compared to the nominal ones so that Psychtoolbox flips the screen at the nominal time, see Peter Scarfe website on Psychtoolbox)
  26. % and see the explanation within the function
  27. [ifi_af...
  28. ifi_as...
  29. ifi_nf...
  30. ifi_ns] = MoBI_frames_Brescia(ifi, ifi);
  31. [onesec_af...
  32. onesec_as...
  33. onesec_nf...
  34. onesec_ns] = MoBI_frames_Brescia(1, ifi);
  35. %% we also have a black background.
  36. Bk.color = [0 0 0];
  37. Bk.dimension = misure_schermo;
  38. %% INSTRUCTIONS FOR the researcher
  39. Screen('FillRect', window, Bk.color, Bk.dimension);
  40. Screen('TextSize', window, 25);
  41. % text position on the screen
  42. hor_alignement = round(misure_schermo(3)*0.5,0);
  43. ver_alignement = round(misure_schermo(4)*0.25,0);
  44. TMS_cond = contraction_task{1,1};
  45. DrawFormattedText(window,TMS_cond, hor_alignement,...
  46. ver_alignement, [1 1 1]);
  47. clear hor_alignement ver_alignement
  48. testo_sx = contraction_task{1,2};
  49. hor_alignement = round(misure_schermo(3)*0.25,0);
  50. ver_alignement = round(misure_schermo(4)*0.75,0);
  51. DrawFormattedText(window,testo_sx, hor_alignement,...
  52. ver_alignement, [1 1 1]);
  53. clear hor_alignement ver_alignement
  54. testo_dx = contraction_task{1,3}
  55. hor_alignement = round(misure_schermo(3)*0.75,0);
  56. ver_alignement = round(misure_schermo(4)*0.75,0);
  57. DrawFormattedText(window,testo_dx, hor_alignement,...
  58. ver_alignement, [1 1 1]);
  59. clear hor_alignement ver_alignement
  60. [VBL]=Screen(window, 'Flip', ifi, 1);
  61. % wait for keyboard press
  62. WaitSecs(2)
  63. %% wait for keyboard button press
  64. while ~KbCheck
  65. end
  66. end