#Scenario to test USB control of TMS machine #Use Up/Down arrows to increase/decrease intensity #Use Space to toggle arming/disarming of TMS #Use enter to fire the TMS pulse write_codes = true; response_port_output = false;# this is very important (and silly!!) pulse_width = indefinite_port_code; active_buttons = 4; button_codes = 1,2,3,4; no_logfile = true; begin; trial { trial_type = first_response; trial_duration = forever; all_responses = true; stimulus_event { nothing {}; } InStrEvent; stimulus_event { nothing {}; } CueEvent; } WaitForResponse; begin_pcl; include "new_TMS_library.pcl"; bool arm_toggle = false; int intensity = 0; WaitForResponse.present(); loop int resp_count = 0 until resp_count == 500 begin if response_manager.response_data_count() > resp_count then resp_count = response_manager.response_data_count(); term.print("# of key strikes: " + string(response_manager.response_data_count()) + "\n"); if response_manager.last_response() == 1 then if intensity < 100 then intensity = intensity + 5; term.print("TMS_intensity now " + string(intensity) + "%\n"); end; elseif response_manager.last_response() == 2 then if intensity > 0 then intensity = intensity - 5; term.print("TMS_intensity now " + string(intensity) + "%\n"); end; elseif response_manager.last_response() == 3 then if arm_toggle == false then arm_toggle = true; enable_TMS(); elseif arm_toggle == true then arm_toggle = false; disable_TMS(); end; elseif response_manager.last_response() == 4 then trigger_TMS(); end; set_TMS_strength(intensity); end; end; disable_TMS();