def connect_client(trig_queue): """Helper method that instantiates the StimClient. """ # just wait till the main thread reaches stim_server.start() time.sleep(0.2) # instantiate StimClient stim_client = StimClient('localhost', port=4218) # wait a bit more for script to reach stim_server.add_trigger() time.sleep(0.2) trig_queue.put(stim_client.get_trigger())
def _connect_client(trig_queue): """Instantiate the StimClient.""" # just wait till the main thread reaches stim_server.start() t0 = time.time() while (time.time() - t0 < _max_wait and (_server is None or not _server._running)): time.sleep(0.01) assert _server is not None and _server._running # instantiate StimClient stim_client = StimClient('localhost', port=4218) # wait for script to reach stim_server.add_trigger() t0 = time.time() while (time.time() - t0 < _max_wait and not _have_put_in_trigger): time.sleep(0.01) assert _have_put_in_trigger trig_queue.put(stim_client.get_trigger()) stim_client.close()
print __doc__ # Author: Mainak Jas <*****@*****.**> # # License: BSD (3-clause) from mne.realtime import StimClient from psychopy import visual, core # Instantiating stimulation client # Port number must match port number used to instantiate # StimServer. Any port number above 1000 should be fine # because they do not require root permission. stim_client = StimClient('localhost', port=4218) # create a window mywin = visual.Window([800, 600], monitor="testMonitor", units="deg") # create the stimuli # right checkerboard stimuli right_cb = visual.RadialStim(mywin, tex='sqrXsqr', color=1, size=5, visibleWedge=[0, 180], radialCycles=4, angularCycles=8, interpolate=False, autoLog=False) # left checkerboard stimuli left_cb = visual.RadialStim(mywin, tex='sqrXsqr', color=1, size=5, visibleWedge=[180, 360], radialCycles=4,
""" # Author: Mainak Jas <*****@*****.**> # # License: BSD (3-clause) from mne.realtime import StimClient import time print(__doc__) # Instantiating stimulation client # Port number must match port number used to instantiate # StimServer. Any port number above 1000 should be fine # because they do not require root permission. stim_client = StimClient('localhost', port=4218) ev_list = list() # list of events displayed # start with right checkerboard stimuli. This is required # because the ev_list.append(ev_list[-1]) will not work # if ev_list is empty. trig = 4 stim_duration = 1.0 # iterating over 50 epochs for ii in range(50): if trig is not None: ev_list.append(trig) # use the last trigger received