コード例 #1
0
 def __init__(self,
              TTL=True,
              photosensor=None,
              photosensor_position="bottomleft",
              stimtracker=False,
              stimtracker_duration=5):
     self.method = method
     self.photosensor = photosensor
     self.photosensor_position = photosensor_position
     self.stimtracker = stimtracker
     self.stimtracker_duration = stimtracker_duration
     if self.method == "TTL":
         try:
             from ctypes import windll
             global io
             io = windll.dlportio  # requires dlportio.dll !
         except:
             print(
                 "NEUROPSYDIA WARNING: Trigger(): The parallel port couldn't be opened"
             )
     if self.stimtracker == True:
         import pyxid
         global device
         device = pyxid.get_xid_devices()
         device = device[0]
         device.set_pulse_duration(self.stimtracker_duration)
コード例 #2
0
ファイル: triggers.py プロジェクト: ociepkam/SST
def create_nirs_dev():
    try:
        import pyxid
        devices = pyxid.get_xid_devices()
        dev = devices[0]
        return dev
    except:
        raise Exception("Can't connect to NIRS")
コード例 #3
0
ファイル: triggers.py プロジェクト: ociepkam/Go_No-Go
def create_nirs_dev():
    try:
        import pyxid
        devices = pyxid.get_xid_devices()
        dev = devices[0]
        return dev
    except:
        raise Exception("Can't connect to NIRS")
コード例 #4
0
ファイル: _input_controllers.py プロジェクト: nordme/expyfun
 def __init__(self, ec, force_quit_keys):
     import pyxid
     pyxid.use_response_pad_timer = True
     dev = pyxid.get_xid_devices()[0]
     dev.reset_base_timer()
     assert dev.is_response_device()
     self._dev = dev
     super(CedrusBox, self).__init__(ec, force_quit_keys)
     ec._time_correction_maxs['keypress'] = 1e-3  # higher tolerance
コード例 #5
0
ファイル: _input_controllers.py プロジェクト: LABSN/expyfun
 def __init__(self, ec, force_quit_keys):
     import pyxid
     pyxid.use_response_pad_timer = True
     dev = pyxid.get_xid_devices()[0]
     dev.reset_base_timer()
     assert dev.is_response_device()
     self._dev = dev
     self._keyboard_buffer = []
     super(CedrusBox, self).__init__(ec, force_quit_keys)
     ec._time_correction_maxs['keypress'] = 1e-3  # higher tolerance
コード例 #6
0
    def __init__(self, device_ID=0, error_screen=True):
        """Create a Cedrus Device Input.

        Notes
        -----
        If no Cedrus device is connected, an error text screen will be
        presented informing that the device could not be found and suggesting
        to check the connection and to switch on the device. After keypress the
        class tries to reconnect with the device. Use <q> to quit this
        procedure.

        Parameters
        ----------
        device_id : int, optional
            device ID (default=0). Only required if more than one
            Cedrus Devices are connected.
        error_screen : bool, optional
            set False to switch off the 'device not found' error screen.
            An exception will be raise instead (default=True)

        """

        Input.__init__(self)
        if type(_pyxid) is not types.ModuleType:
            message = """CedrusDevice can not be initialized, because the Python package
            'pyxid' is not installed. See Expyriment online documentation."""
            raise ImportError(message)

        while True:
            devices = _pyxid.get_xid_devices()
            if len(devices) < 1:
                message = "Could not find a Cedrus Device. Please check the connection and \n"\
                + " ensure that the device is switch on."
            else:
                if not devices[device_ID].is_response_device():
                    message = "Cedrus Device #{0} is not a response device.".format(
                        device_ID)
                else:
                    self._xid = devices[device_ID]
                    break
            if error_screen and expyriment._active_exp.is_initialized:
                expyriment.stimuli.TextScreen(
                    "Error", message +
                    " Press a key to reconnect to the device.").present()
                expyriment._active_exp.keyboard.wait()
                expyriment.stimuli.BlankScreen().present()
                expyriment._active_exp.clock.wait(300)
            else:
                raise IOError(message)

        self._xid.reset_base_timer()
        self._xid.reset_rt_timer()
        self._device_ID = device_ID
        self._buffer = expyriment.misc.Buffer(
            name="Cedrus Device {0}".format(device_ID))
コード例 #7
0
def get_stimtracker(trigger_duration=5):
    for dev in pyxid.get_xid_devices():
        if dev.is_stimtracker():
            dev.set_pulse_duration(trigger_duration)
            return dev
    print "STIMTRACKER NOT FOUND!"
    decision=raw_input('Continue anyway? [y/n]: ')
    if decision=='y':
        return NullStimtracker()
    else:
        core.quit()
コード例 #8
0
    def __init__(self, device_ID=0, error_screen=True):
        """Create a Cedrus Device Input.

        Notes
        -----
        If no Cedrus device is connected, an error text screen will be
        presented informing that the device could not be found and suggesting
        to check the connection and to switch on the device. After keypress the
        class tries to reconnect with the device. Use <q> to quit this
        procedure.

        Parameters
        ----------
        device_id : int, optional
            device ID (default=0). Only required if more than one
            Cedrus Devices are connected.
        error_screen : bool, optional
            set False to switch off the 'device not found' error screen.
            An exception will be raise instead (default=True)

        """

        Input.__init__(self)
        if not isinstance(_pyxid, ModuleType):
            message = """CedrusDevice can not be initialized, because the Python package
            'pyxid' is not installed. See Expyriment online documentation."""
            raise ImportError(message)

        while True:
            devices = _pyxid.get_xid_devices()
            if len(devices) < 1:
                message = "Could not find a Cedrus Device. Please check the connection and \n"\
                + " ensure that the device is switch on."
            else:
                if not devices[device_ID].is_response_device():
                    message = "Cedrus Device #{0} is not a response device.".format(
                                                                    device_ID)
                else:
                    self._xid = devices[device_ID]
                    break
            if error_screen and _internals.active_exp.is_initialized:
                stimuli.TextScreen("Error", message +
                        " Press a key to reconnect to the device.").present()
                _internals.active_exp.keyboard.wait()
                stimuli.BlankScreen().present()
                _internals.active_exp.clock.wait(300)
            else:
                raise IOError(message)

        self._xid.reset_base_timer()
        self._xid.reset_rt_timer()
        self._device_ID = device_ID
        self._buffer = misc.Buffer(name="Cedrus Device {0}".format(
                                                        device_ID))
コード例 #9
0
ファイル: voicekey.py プロジェクト: aufrank/VisualWorld
    def __init__(self):
        """Find the device on the system and initialize it
        """

        ## declare some variables that are used to interact with the
        ## voice key
        self.vk = None
        self.response = None

        ## assume that the voice key is the only XID device currently
        ## plugged in
        devices = pyxid.get_xid_devices()
        ## According to documentation, Windows machines may have to
        ## check twice
        if len(devices) > 0:
            self.vk = devices[0]
        else:
            devices = pyxid.get_xid_devices()
            self.vk = devices[0]

        ## reset the experiment timer
        self.vk.reset_base_timer()
コード例 #10
0
    def __init__(self):
        """Find the device on the system and initialize it
        """

        ## declare some variables that are used to interact with the
        ## voice key
        self.vk = None
        self.response = None

        ## assume that the voice key is the only XID device currently
        ## plugged in
        devices = pyxid.get_xid_devices()
        ## According to documentation, Windows machines may have to
        ## check twice
        if len(devices) > 0:
            self.vk = devices[0]
        else:
            devices = pyxid.get_xid_devices()
            self.vk = devices[0]

        ## reset the experiment timer
        self.vk.reset_base_timer()
コード例 #11
0
ファイル: resting.py プロジェクト: tqbwqing/DrThesis
def StartResponsePad():
    import pyxid
    global green, blue

    dev = pyxid.get_xid_devices()[0]
    dev.reset_base_timer()

    while True:
        dev.poll_for_response()
        if dev.response_queue_size() > 0:
            response = dev.get_next_response()
            if response['pressed'] == True:
                if response['key'] == 3:
                    blue = True
                if response['key'] == 7:
                    green = True
コード例 #12
0
                               mask=None,
                               ori=0,
                               pos=[0, 0],
                               size=[0.35, 0.45],
                               color=[1, 1, 1],
                               colorSpace='rgb',
                               opacity=1,
                               flipHoriz=False,
                               flipVert=False,
                               texRes=128,
                               interpolate=True,
                               depth=0.0)
p_port_circle = parallel.ParallelPort(address=u'0xD010')
for n in range(10):  #Cedrus connection doesn't always work first time!
    try:
        devices = pyxid.get_xid_devices()
        core.wait(0.1)
        buttonBox_Response = devices[0]
        break  #once we found the device we can break the loop
    except:
        pass
buttonBox_Response.status = NOT_STARTED
buttonBox_Response.clock = core.Clock()

# Initialize components for Routine "response"
responseClock = core.Clock()
textPreFback = visual.TextStim(win=win,
                               ori=0,
                               name='textPreFback',
                               text=u'+',
                               font=u'Arial',
コード例 #13
0
expName='None'#from the Builder filename that created this script
expInfo={'participant':'', 'session':'001'}
dlg=gui.DlgFromDict(dictionary=expInfo,title=expName)
if dlg.OK==False: core.quit() #user pressed cancel
expInfo['date']=data.getDateStr()#add a simple timestamp
expInfo['expName']=expName
#setup files for saving
if not os.path.isdir('data'):
    os.makedirs('data') #if this fails (e.g. permissions) we will get error
filename='data' + os.path.sep + '%s_%s' %(expInfo['participant'], expInfo['date'])
psychopy.log.console.setLevel(psychopy.log.WARNING)#this outputs to the screen, not a file
logFile=psychopy.log.LogFile(filename+'.log', level=psychopy.log.EXP)

# get a list of all attached XID devices
for i in range(5):
    devices = pyxid.get_xid_devices()
    if len(devices)>0: break
print devices
dev = devices[0] # get the first device to use
if dev.is_response_device():
    dev.reset_base_timer()
    dev.reset_rt_timer()
#set key_num as the inded key for responses
key_num = 3

def wait_for_response(dev, key_num, action):
    if action=='press': action=True
    elif action=='release': action=False
    
    dev.clear_response_queue()
    print 'response_queue:', dev.response_queue