本文整理汇总了Python中psychopy.iohub.launchHubServer函数的典型用法代码示例。如果您正苦于以下问题:Python launchHubServer函数的具体用法?Python launchHubServer怎么用?Python launchHubServer使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了launchHubServer函数的19个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: testEnabledDataStore
def testEnabledDataStore():
"""
testEnabledDataStore is the same as testUsingPsychoPyMonitorConfig above,
but by adding an experiment_code parameter the ioHub DataStore will
be enabled, using a auto generated session_code each time it is run.
Experiment and session metadata is printed at the end of the demo.
Considerations:
* A Keyboard, Mouse, Monitor, and Experiment device are created by default.
* If the psychopy_monitor_name is valid, the ioHub Display is updated to
use the display size and viewing distance specified in the psychopy monitor config.
* ioHub DataStore is enabled because experiment_code is provided.
session_code will be auto generated using the current time.
"""
psychopy_mon_name='testMonitor'
exp_code='gap_endo_que'
io=launchHubServer(psychopy_monitor_name=psychopy_mon_name, experiment_code=exp_code)
display=io.devices.display
print('Display Psychopy Monitor Name: ', display.getPsychopyMonitorName())
print('Display Default Eye Distance: ', display.getDefaultEyeDistance())
print('Display Physical Dimensions: ', display.getPhysicalDimensions())
from pprint import pprint
print('Experiment Metadata: ')
pprint(io.getExperimentMetaData())
print('\nSession Metadata: ')
pprint(io.getSessionMetaData())
io.quit()
开发者ID:natsn,项目名称:psychopy,代码行数:31,代码来源:launchHub.py
示例2: start_iohub
def start_iohub(sess_code=None):
import time, os
# Create initial default session code
if sess_code is None:
sess_code='S_{0}'.format(long(time.mktime(time.localtime())))
# Ask for session name / hdf5 file name
save_to = fileSaveDlg(initFilePath=os.path.dirname(__file__),initFileName=sess_code,
prompt="Set Session Output File",
allowed="ioHub Datastore Files (*.hdf5)|*.hdf5")
if save_to:
# session code should equal results file name
fdir, sess_code = os.path.split(save_to)
sess_code=sess_code[0:min(len(sess_code),24)]
if sess_code.endswith('.hdf5'):
sess_code = sess_code[:-5]
if save_to.endswith('.hdf5'):
save_to = save_to[:-5]
else:
save_to = sess_code
exp_code='wintab_evts_test'
kwargs={'experiment_code':exp_code,
'session_code':sess_code,
'datastore_name':save_to,
'wintab.WintabTablet':{'name':'tablet',
'mouse_simulation': {'enable':False,
'leave_region_timeout':2.0
}
}
}
return launchHubServer(**kwargs)
开发者ID:isolver,项目名称:OpenHandWrite,代码行数:35,代码来源:wintab_test.py
示例3: testWithNoKwargs
def testWithNoKwargs():
"""
testWithNoKwargs illustrates using the launchHubServer function with no
parameters at all. Considerations:
* A Keyboard, Mouse, Monitor, and Experiment device are created by default.
* All devices use their default parameter settings. Therefore, not very useful in real studies.
* ioHub DataStore is not enabled.
"""
io=launchHubServer()
# Get the default keyboard device created.
keyboard=io.devices.keyboard
print()
print("** PRESS A KEY TO CONTINUE.....")
# Check for new events every 1/4 second.
# By using the io.wait() fucntion, the ioHub Process is checked for
# events every 50 msec or so, and they are cached in the PsychoPy process
# until the next getEvents() call is made. On Windows, messagePump() is also
# called periodically so that any Window you have created does not lock up.
#
while not keyboard.getEvents():
io.wait(0.25)
print("A Keyboard Event was Detected; exiting Test.")
io.quit()
开发者ID:natsn,项目名称:psychopy,代码行数:28,代码来源:launchHub.py
示例4: testUsingPsychoPyMonitorConfig
def testUsingPsychoPyMonitorConfig():
"""
testUsingPsychoPyMonitorConfig illustrates using the launchHubServer function
and providing a PsychoPy monitor configuration file name.
Considerations:
* A Keyboard, Mouse, Monitor, and Experiment device are created by default.
* If the psychopy_monitor_name is valid, the ioHub Display is updated to
use the display size and viewing distance specified in the psychopy monitor config.
* ioHub DataStore is not enabled.
"""
io=launchHubServer(psychopy_monitor_name='testMonitor')
# Get the default display device created.
#
display=io.devices.display
# print(the display's physical characteristics, showing they have
# been updated based on the settings in the PsychoPy monitor config.
#
print('Display Psychopy Monitor Name: ', display.getPsychopyMonitorName())
print('Display Default Eye Distance: ', display.getDefaultEyeDistance())
print('Display Physical Dimensions: ', display.getPhysicalDimensions())
# That's it, shut doqn the ioHub Proicess and exit. ;)
#
io.quit()
开发者ID:natsn,项目名称:psychopy,代码行数:27,代码来源:launchHub.py
示例5: startHubProcess
def startHubProcess():
io = launchHubServer()
assert io != None
io_proc = Computer.getIoHubProcess()
io_proc_pid = io_proc.pid
assert io_proc != None and io_proc_pid > 0
return io
开发者ID:ChenTzuYin,项目名称:psychopy,代码行数:9,代码来源:testutil.py
示例6: start_iohub
def start_iohub(sess_info):
'''
Starts the iohub server process, using data from the dict returned by
showSessionInfoDialog() to create the hdf5 file name. If the file
already exists, the existing file is renamed so that it is not
overwritten by the current sessions data.
iohub device configuration information is read from an
'iohub_config.yaml' file which must be in the same folder as this file.
The created ioHubConnection object is returned after the iohub
server has started and is ready for interaction with the experiment
runtime.
:param sess_info: dict returned from showSessionInfoDialog()
:return: ioHubConnection object
'''
import os, shutil
save_to = os.path.join(os.path.dirname(__file__),u'results',
sess_info['Session Code'])
save_to = os.path.normpath(save_to)
if not save_to.endswith('.hdf5'):
save_to = save_to+u'.hdf5'
fdir, sess_code = os.path.split(save_to)
if not os.path.exists(fdir):
os.mkdir(fdir)
#TODO: Ask if file should be overwritten, or new session code entered.
si = 1
save_dest = save_to
while os.path.exists(save_dest):
sname, sext = sess_code.rsplit(u'.',1)
save_dest = os.path.join(fdir, u"{}_{}.{}".format(sname,si,sext))
si+=1
if save_dest is not save_to:
shutil.move(save_to,save_dest)
sess_code=sess_code[0:min(len(sess_code),24)]
if sess_code.endswith(u'.hdf5'):
sess_code = sess_code[:-5]
if save_to.endswith(u'.hdf5'):
save_to = save_to[:-5]
kwargs={'experiment_code':EXP_NAME,
'session_code':sess_code,
'datastore_name':save_to,
'iohub_config_name': 'iohub_config.yaml'
}
return launchHubServer(**kwargs)
开发者ID:g-no,项目名称:OpenHandWrite,代码行数:52,代码来源:util.py
示例7: __init__
def __init__(self):
# Set up iohub and internal clock. Use existing ioHubServer if it exists.
from psychopy import iohub, core, sys
self._sys = sys
self._core = core
self._timeAtLastReset = core.getTime()
self._EventConstants = iohub.EventConstants
existing_iohub = iohub.ioHubConnection.ACTIVE_CONNECTION
self._io = existing_iohub if existing_iohub else iohub.launchHubServer()
import numpy
self._np = numpy
开发者ID:lhugrass,项目名称:psychopy-course,代码行数:13,代码来源:ppc_iohub+trash.py
示例8: startIOHub
def startIOHub():
"""
Starts the ioHub process, saving events to events.hdf5, recording data from
all standard devices as well as the ioSync MCU device.
"""
global io
import time
psychopy_mon_name = 'testMonitor'
exp_code = 'events'
sess_code = 'S_{0}'.format(int(time.mktime(time.localtime())))
iohub_config = {
"psychopy_monitor_name": psychopy_mon_name,
"mcu.iosync.MCU": dict(serial_port='auto',
monitor_event_types=['AnalogInputEvent',
'DigitalInputEvent']),
"experiment_code": exp_code,
"session_code": sess_code
}
return launchHubServer(**iohub_config)
开发者ID:ChenTzuYin,项目名称:psychopy,代码行数:19,代码来源:statusPanel.py
示例9: testEnabledDataStoreAutoSessionCode
def testEnabledDataStoreAutoSessionCode():
"""
testEnabledDataStoreAutoSessionCode is the same as testEnabledDataStore
above, but session_code is provided by the script instead of being
auto-generated. The ioHub DataStore will be enabled, using the
experiment and session_code provided each time it is run. Experiment
and session metadata is printed at the end of the demo.
Considerations:
* A Keyboard, Mouse, Monitor, and Experiment device are created by
default.
* If the psychopy_monitor_name is valid, the ioHub Display is
updated to use the display size and viewing distance specified
in the psychopy monitor config.
* ioHub DataStore is enabled because experiment_code and
session_code are provided.
"""
import time
from pprint import pprint
psychopy_mon_name = 'testMonitor'
exp_code = 'gap_endo_que'
sess_code = 'S_{0}'.format(int(time.mktime(time.localtime())))
print('Current Session Code will be: ', sess_code)
io = launchHubServer(psychopy_monitor_name=psychopy_mon_name,
experiment_code=exp_code,
session_code=sess_code)
display = io.devices.display
print('Display Psychopy Monitor Name: ', display.getPsychopyMonitorName())
print('Display Default Eye Distance: ', display.getDefaultEyeDistance())
print('Display Physical Dimensions: ', display.getPhysicalDimensions())
print('Experiment Metadata: ')
pprint(io.getExperimentMetaData())
print('\nSession Metadata: ')
pprint(io.getSessionMetaData())
io.quit()
开发者ID:jonathanoroberts,项目名称:psychopy,代码行数:41,代码来源:launchHub.py
示例10: normalizedValue2Coord
from psychopy import visual, core
from psychopy.iohub import launchHubServer, EventConstants
def normalizedValue2Coord(normed_position,normed_magnitude,display_coord_area):
x,y=normed_position[0]*normed_magnitude,normed_position[1]*normed_magnitude
w,h=display_coord_area
return x*(w/2.0),y*(h/2.0)
if __name__ == '__main__':
# Start the ioHub Event Server, requesting an XInput Gamepad Device to be
# created along with the default devices. Since the configuration dict
# for the Gamepad is empty, all default values will be used.
#
kwargs={'psychopy_monitor_name':'default','xinput.Gamepad':{}}
io=launchHubServer(**kwargs)
display = io.devices.display
mouse = io.devices.mouse
display = io.devices.display
keyboard = io.devices.keyboard
gamepad = io.devices.gamepad
display_resolution=display.getPixelResolution()
psychopy_monitor=display.getPsychopyMonitorName()
unit_type=display.getCoordinateType()
screen_index=display.getIndex()
dl,dt,dr,db=display.getCoordBounds()
coord_size=dr-dl,dt-db
myWin=visual.Window(display_resolution, monitor=psychopy_monitor,
开发者ID:9173860,项目名称:psychopy,代码行数:31,代码来源:xinputGamepadDevice.py
示例11:
Displays event information from ioHub Keyboard Events.
Inital Version: May 6th, 2013, Sol Simpson
"""
from psychopy import visual
from psychopy.iohub import launchHubServer,EventConstants
# launchHubServer is a fucntion that can be used to create an instance of the
# ioHub Process within a procedural PsychoPy Script and without the need for
# external configuration files. It is useful when devices like the Keyboard,
# Mouse, Display, and Experiment are all that is needed. By default the
# Display device will use pixel units and display index 0 of a multimonitor setup.
# The returned 'io' variable gives access to the ioHub Process.
#
io=launchHubServer(experiment_code='key_evts',psychopy_monitor_name='default')
# Devices that have been created on the ioHub Process and will be monitored
# for events during the experiment can be accessed via the io.devices.* attribute.
#
# save some 'dots' during the trial loop
#
display = io.devices.display
keyboard = io.devices.keyboard
mouse=io.devices.mouse
# Hide the 'system mouse cursor'.
mouse.setSystemCursorVisibility(False)
# Get settings needed to create the PsychoPy full screen window.
# - display_resolution: the current resolution of diplsay specified by the screen_index.
开发者ID:DiogoamCoutinho,项目名称:stimulus.py,代码行数:31,代码来源:iohub_keyboard.py
示例12: launchHubServer
fetching and processing events from hardware; mice, keyboards, eyetrackers).
Inital Version: May 6th, 2013, Sol Simpson
Abbrieviated: May 2013, Jon Peirce
Updated July, 2013, Sol, Added timeouts
"""
from __future__ import division
import sys
from psychopy import visual, core
from psychopy.iohub import launchHubServer
# create the process that will run in the background polling devices
io = launchHubServer()
# some default devices have been created that can now be used
display = io.devices.display
keyboard = io.devices.keyboard
mouse = io.devices.mouse
# Hide the 'system mouse cursor'.
mouse.setSystemCursorVisibility(False)
# We can use display to find info for the Window creation, like the resolution
# (which means PsychoPy won't warn you that the fullscreen does not match your requested size)
display_resolution = display.getPixelResolution()
# ioHub currently supports the use of a single full-screen PsychoPy Window
win = visual.Window(display_resolution, units="pix", fullscr=True, allowGUI=False, screen=0)
开发者ID:papr,项目名称:psychopy,代码行数:31,代码来源:mouse.py
示例13: dict
SERIAL_PORT = 'COM5'
BAUDRATE = 19200
# ioHub configuration.
psychopy_mon_name = 'Monitor_01'
exp_code = 'pstbox'
sess_code = 'S_{0}'.format(int(time.mktime(time.localtime())))
iohubkwargs = {
'psychopy_monitor_name': psychopy_mon_name,
'experiment_code': exp_code,
'session_code': sess_code,
'serial.Pstbox': dict(name='pstbox', port=SERIAL_PORT, baud=BAUDRATE)
}
# Start the iohub server and set up devices.
io = launchHubServer(**iohubkwargs)
computer = Computer
display = io.devices.display
pstbox = io.devices.pstbox
print('Switching on lamp #3...')
pstbox.setLampState([0, 0, 1, 0, 0])
print('...done.')
# Create a window.
win = visual.Window(
display.getPixelResolution(),
units='pix', fullscr=True, allowGUI=False,
screen=0
)
开发者ID:balajisriram,项目名称:psychopy,代码行数:30,代码来源:pstbox.py
示例14: loggedFlip
"""
Created on Thu Oct 17 22:46:06 2013
@author: Sol
"""
from __future__ import print_function
from builtins import str
from psychopy import visual,core
from psychopy.data import TrialHandler,importConditions
from psychopy.iohub import launchHubServer,Computer,EventConstants
getTime=Computer.getTime
psychopy_mon_name='testMonitor'
exp_code='io_stroop'
io=launchHubServer(psychopy_monitor_name=psychopy_mon_name, experiment_code=exp_code)
io.sendMessageEvent(category='EXP',text='Experiment Started')
kb=io.devices.keyboard
mouse = io.devices.mouse
win = visual.Window(allowGUI=False,fullscr=True)
gabor = visual.GratingStim(win,tex="sin",mask="gauss",texRes=256,
size=[200.0,200.0], sf=[4,0], ori = 0, name='gabor1')
letter = visual.TextStim(win,pos=(0.0,0.0),text='X')
retrace_count=0
def loggedFlip(letter_char,letter_color):
global retrace_count
gabor.draw()
开发者ID:balajisriram,项目名称:psychopy,代码行数:31,代码来源:iohub_demo.py
示例15:
logFile = logging.LogFile(filename+'.log', level=logging.DEBUG)
logging.console.setLevel(logging.WARNING) # this outputs to the screen, not a file
# An ExperimentHandler isn't essential but helps with data saving
thisExp = data.ExperimentHandler(name=expName, version='',
extraInfo=expInfo, runtimeInfo=None,
originPath=None,
savePickle=True, saveWideText=True,
dataFileName=filename)
#-------------------------------------------------------------------------------
# iohub stuff
#-------------------------------------------------------------------------------
# create the process that will run in the background polling devices
io=launchHubServer(experiment_code='target-sequences', psychopy_monitor_name='default')
# some default devices have been created that can now be used
display = io.devices.display
keyboard = io.devices.keyboard
mouse=io.devices.mouse
# Hide the 'system mouse cursor'.
mouse.setSystemCursorVisibility(False)
mouse.enableEventReporting(True)
# We can use display to find info for the Window creation, like the resolution
# (which means PsychoPy won't warn you that the fullscreen does not match your requested size)
display_resolution=display.getPixelResolution()
#-------------------------------------------------------------------------------
开发者ID:awellis,项目名称:target-sequences,代码行数:31,代码来源:run-target-sequences-iohub.py
示例16: len
Demonstrate iohub module versus event module with a flip-loop.
iohub registers responses during win.flip(), thus always scores
responses as faster than event.getKeys() which timestamps according
to the time that the function is called.
Jonas Kristoffer Lindeløv, 2015.
"""
import psychopy
psychopy.useVersion("1.81.02")
from psychopy import iohub, visual, event
win = visual.Window()
textStim = visual.TextStim(win, text="press now", height=0.1, wrapWidth=100)
io = iohub.launchHubServer()
keyboard = io.devices.keyboard
# Comparing iohub.
while True:
# Animate and show results
textStim.ori += 0.1
textStim.draw()
win.flip()
# Get responses
event_getkeys = event.getKeys(timeStamped=True)
io_getpresses = keyboard.getPresses()
# Update text if a matching response was found
if len(event_getkeys) and len(io_getpresses):
开发者ID:lhugrass,项目名称:psychopy-course,代码行数:31,代码来源:ppc2_iohub_compareToEvent.py
示例17: launchHubServer
# -*- coding: utf-8 -*-
"""
keyboard_rt.run.py
Keyboard Reaction Time Calculation shown within a line length matching task.
Initial Version: May 6th, 2013, Sol Simpson
"""
from __future__ import absolute_import, division, print_function
from psychopy import core, visual
from psychopy.iohub import launchHubServer
from math import fabs
io = launchHubServer(psychopy_monitor_name='default')
display = io.devices.display
win = visual.Window(display.getPixelResolution(), monitor='default',
units='pix', fullscr=True, allowGUI=False)
# save some 'dots' during the trial loop
keyboard = io.devices.keyboard
# constants for use in example
line_size_match_delay = 5 + int(core.getTime() * 1000) % 5
full_length = win.size[0] / 2
latest_length = 0
static_bar = visual.ShapeStim(win=win, lineColor='Firebrick',
fillColor='Firebrick',
vertices=[[0, 0], [full_length, 0], [full_length, 5], [0, 5]],
开发者ID:dgfitch,项目名称:psychopy,代码行数:31,代码来源:keyboardreactiontime.py
示例18:
import time
from psychopy import core
from psychopy.iohub import launchHubServer
getTime=core.getTime
try:
psychopy_mon_name='testMonitor'
exp_code='events'
sess_code='S_{0}'.format(long(time.mktime(time.localtime())))
iohub_config={
"psychopy_monitor_name":psychopy_mon_name,
"mcu.iosync.MCU":dict(serial_port='auto',monitor_event_types=['DigitalInputEvent',]),
"experiment_code":exp_code,
"session_code":sess_code
}
io=launchHubServer(**iohub_config)
mcu=io.devices.mcu
kb=io.devices.keyboard
core.wait(0.5)
mcu.enableEventReporting(True)
io.clearEvents("all")
while not kb.getEvents():
mcu_events= mcu.getEvents()
for mcu_evt in mcu_events:
print'{0}\t{1}'.format(mcu_evt.time,mcu_evt.state)
core.wait(0.002,0)
io.clearEvents('all')
except Exception:
import traceback
traceback.print_exc()
开发者ID:DennisEckmeier,项目名称:psychopy,代码行数:31,代码来源:digitalInTest.py
示例19: launchHubServer
# standard
from __future__ import print_function, division
from psychopy.iohub import launchHubServer
_IO_HUB = launchHubServer()
开发者ID:bryancort,项目名称:magnoparvo-stim,代码行数:6,代码来源:__init__.py
注:本文中的psychopy.iohub.launchHubServer函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论