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):
    """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()
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()
示例#5
0
        ev_list.append(ev_list[-1])  # use the last stimuli

    # draw left or right checkerboard according to ev_list
    if ev_list[ii] == 3:
        left_cb.draw()
    else:
        right_cb.draw()

    fixation.draw()  # draw fixation
    mywin.flip()  # show the stimuli

    timer1.reset()  # reset timer
    timer1.add(0.75)  # display stimuli for 0.75 sec

    # return within 0.2 seconds (< 0.75 seconds) to ensure good timing
    trig = stim_client.get_trigger(timeout=0.2)

    # wait till 0.75 sec elapses
    while timer1.getTime() < 0:
        pass

    fixation.draw()  # draw fixation
    mywin.flip()  # show fixation dot

    timer2.reset()  # reset timer
    timer2.add(0.25)  # display stimuli for 0.25 sec

    # display fixation cross for 0.25 seconds
    while timer2.getTime() < 0:
        pass
示例#6
0

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
    else:
        ev_list.append(ev_list[-1])  # use the last stimuli

    # draw left or right checkerboard according to ev_list
    if ev_list[ii] == 3:
        print('Stimulus: left checkerboard')
    else:
        print('Stimulus: right checkerboard')

    last_stim_time = time.time()
    trig = stim_client.get_trigger(timeout=(stim_duration - 0.05))

    time.sleep(max(stim_duration - (time.time() - last_stim_time), 0))

    print('Stimulus: Fixation Cross')
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
    else:
        ev_list.append(ev_list[-1])  # use the last stimuli

    # draw left or right checkerboard according to ev_list
    if ev_list[ii] == 3:
        print('Stimulus: left checkerboard')
    else:
        print('Stimulus: right checkerboard')

    last_stim_time = time.time()
    trig = stim_client.get_trigger(timeout=(stim_duration - 0.05))

    time.sleep(max(stim_duration - (time.time() - last_stim_time), 0))

    print('Stimulus: Fixation Cross')
    time.sleep(0.25)