You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

p300-tactile-target.lua 1.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. -- This Lua script generates target stimulations the 1x6 p300-tactile matrix
  2. --
  3. -- Author : Tobias Baumann
  4. -- Date : 2021-06-09
  5. -- this function is called when the box is initialized
  6. function initialize(box)
  7. dofile(box:get_config("${Path_Data}") .. "/plugins/stimulation/lua-stimulator-stim-codes.lua")
  8. math.randomseed(os.time())
  9. row_base = _G[box:get_setting(2)]
  10. n_tactilos = box:get_setting(3)
  11. delay = box:get_setting(4)
  12. free_spelling = box:get_setting(5)
  13. end
  14. -- this function is called when the box is uninitialized
  15. function uninitialize(box)
  16. end
  17. -- this function is called once by the box
  18. function process(box)
  19. -- loop until box:keep_processing() returns zero
  20. -- cpu will be released with a call to sleep
  21. -- at the end of the loop
  22. while box:keep_processing() do
  23. -- gets current simulated time
  24. t = box:get_current_time()
  25. -- loops on every received stimulation for a given input
  26. for stimulation = 1, box:get_stimulation_count(1) do
  27. -- gets stimulation
  28. stimulation_id, stimulation_time, stimulation_duration = box:get_stimulation(1, 1)
  29. if free_spelling == 'false' then
  30. if stimulation_id == OVTK_StimulationId_RestStart then
  31. -- triggers the target
  32. box:send_stimulation(1, row_base+math.random(1,n_tactilos)-1, t+delay, 0)
  33. elseif stimulation_id == OVTK_StimulationId_ExperimentStop then
  34. -- triggers train stimulation
  35. box:send_stimulation(1, OVTK_StimulationId_Train, t+delay+1, 0)
  36. end
  37. end
  38. -- discards it
  39. box:remove_stimulation(1, 1)
  40. end
  41. -- releases cpu
  42. box:sleep()
  43. end
  44. end