TMS4Threshold_MoBi.m 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. function TMS4Threshold_MoBi()
  2. %% this function allows one researcher to deliver a TMS pulse by pressing a key
  3. tinker = 0;
  4. %% set the parallel port communication (it requires io64 .mex files)
  5. ioObj = io64;
  6. status = io64(ioObj);
  7. % specify address where one wants to send triggers
  8. address = hex2dec('DFB8');
  9. io64(ioObj, address, 0);
  10. %% set the screen with a fixation cross in the center
  11. [window, screen_dimensions, screenNum, CenterX, CenterY, ifi] = MoBi_Screen_Settings_Brescia(tinker);
  12. screen_dimensions_ratio = screen_dimensions(4)/screen_dimensions(3);
  13. Screen('FillRect', window, [0 0 0], screen_dimensions);
  14. Screen('TextSize', window, 80);
  15. DrawFormattedText(window, '+', 'center',...
  16. 'center', [1 1 1]);
  17. Screen(window, 'Flip');
  18. % assuming less than 1000 pulses...
  19. for i = 1:1000
  20. % stroke a key
  21. [secs, keyCode] = KbStrokeWait;
  22. % check which key has been stroked
  23. key = sum(find(keyCode));
  24. switch key
  25. case 27 % Esc
  26. sca
  27. break
  28. case (17+163) % Ctrl
  29. % switch all the pins on (send trigger to TMS)
  30. io64(ioObj, address, 255);
  31. i
  32. WaitSecs(0.005);
  33. % switch the pin off
  34. io64(ioObj, address, 0);
  35. otherwise
  36. continue
  37. end
  38. end
  39. end