Beispiel #1
0
    def __init__(self, exp, parentName, name='mic_1',
                 startType='time (s)', startVal=0.0,
                 stopType='duration (s)', stopVal=2.0, startEstim='',
                 durationEstim='', stereo=False, channel=0):
        super(MicrophoneComponent, self).__init__(
            exp, parentName, name=name,
            startType=startType, startVal=startVal,
            stopType=stopType, stopVal=stopVal,
            startEstim=startEstim, durationEstim=durationEstim)

        self.type = 'Microphone'
        self.url = "http://www.psychopy.org/builder/components/microphone.html"
        self.exp.requirePsychopyLibs(['microphone'])

        # params
        msg = _translate(
            "Record two channels (stereo) or one (mono, smaller file)")
        self.params['stereo'] = Param(
            stereo, valType='bool', inputType="bool", categ='Basic',
            hint=msg,
            label=_localized['stereo'])

        self.params['stopType'].allowedVals = ['duration (s)']

        msg = _translate(
            'The duration of the recording in seconds; blank = 0 sec')
        self.params['stopType'].hint = msg

        msg = _translate("Enter a channel number. Default value is 0. If unsure, run 'sound.backend.get_input_devices()'"
                         " to locate the system's selected device/channel.")
        self.params['channel'] = Param(channel, valType='code', hint=msg, label=_localized['channel'])
Beispiel #2
0
    def __init__(self, exp, parentName, name='ptc_init', id=0, datafile='data.tsv', embed=False):
        super(ptc_init_component, self).__init__(exp, parentName, name)
        self.type='ptc_init'
        self.url='https://github.com/hsogo/psychopy_tobii_controller/'

        #params
        self.order = ['name', 'id', 'datafile', 'embed']
        self.params['id'] = Param(id, valType='code', allowedTypes=[],
            updates='constant', allowedUpdates=[],
            hint='ID of Tobii eyetracker (0, 1, 2, ...)',
            label='Tobii eyetracker ID')
        self.params['datafile'] = Param(datafile, valType='str', allowedTypes=[],
            updates='constant', allowedUpdates=[],
            hint='Name of tobii_controller data file.',
            label='Tobii_controller Data File')
        self.params['embed'] = Param(embed, valType='bool', allowedTypes=[],
            updates='constant', allowedUpdates=[],
            hint='If checked, event data is embeded into gaze data.',
            label='Embed event', categ='Advanced')
        
        # these inherited params are harmless but might as well trim:
        for p in ('startType', 'startVal', 'startEstim', 'stopVal',
                  'stopType', 'durationEstim',
                  'saveStartStop', 'syncScreenRefresh'):
            if p in self.params:
                del self.params[p]
Beispiel #3
0
    def __init__(self, exp, parentName, name='brush',
                 lineColor='$[1,1,1]', lineColorSpace='rgb',
                 lineWidth=1.5, opacity=1,
                 startType='time (s)', startVal=0.0,
                 stopType='duration (s)', stopVal=1.0,
                 startEstim='', durationEstim=''):
        super(BrushComponent, self).__init__(
            exp, parentName, name=name,
            startType=startType, startVal=startVal,
            stopType=stopType, stopVal=stopVal,
            startEstim=startEstim, durationEstim=durationEstim)

        self.type = 'Brush'
        self.url = "http://www.psychopy.org/builder/components/brush.html"
        self.exp.requirePsychopyLibs(['visual'])
        self.targets = ['PsychoPy', 'PsychoJS']
        self.order = ['lineWidth', 'opacity']

        del self.params['color']  # because color is defined by lineColor
        del self.params['colorSpace']
        del self.params['size']  # because size determined by lineWidth
        del self.params['ori']
        del self.params['pos']
        del self.params['units']  # always in pix

        # params
        msg = _translate("Line color of this brush; Right-click to bring"
                         " up a color-picker (rgb only)")
        self.params['lineColor'] = Param(
            lineColor, valType='str', allowedTypes=[],
            updates='constant',
            allowedUpdates=['constant', 'set every repeat'],
            hint=msg,
            label=_localized['lineColor'], categ='Advanced')

        msg = _translate("Width of the brush's line (always in pixels and limited to 10px max width)")
        self.params['lineWidth'] = Param(
            lineWidth, valType='code', allowedTypes=[],
            updates='constant',
            allowedUpdates=['constant', 'set every repeat'],
            hint=msg,
            label=_localized['lineWidth'])

        msg = _translate("Choice of color space for the fill color "
                         "(rgb, dkl, lms, hsv)")
        self.params['lineColorSpace'] = Param(
            lineColorSpace, valType='str',
            allowedVals=['rgb', 'dkl', 'lms', 'hsv'],
            updates='constant',
            hint=msg,
            label=_localized['lineColorSpace'], categ='Advanced')

        msg = _translate("The line opacity")
        self.params['opacity'] = Param(
            opacity, valType='str',
            allowedVals=[],
            updates='constant',
            allowedUpdates=['constant', 'set every repeat'],
            hint=msg,
            label=_localized['opacity'])
Beispiel #4
0
    def __init__(self, exp, parentName, name='eyes',
                 startType='time (s)', startVal=0.0,
                 stopType='duration (s)', stopVal=1.0,
                 startEstim='', durationEstim='',
                 save='final', configFile='myTracker.yaml'):
        self.type = 'Eyetracker'
        self.url = "https://www.psychopy.org/builder/components/eyetracker.html"
        self.parentName = parentName
        self.exp = exp  # so we can access the experiment if necess
        self.exp.requirePsychopyLibs(['iohub'])
        # params
        self.params = {}
        self.order = ['Config file']  # first param after the name

        # useful params for the eyetracker - keep to a minimum if possible! ;-)
        self.params['Config file'] = Param(
            configFile, valType='str', categ='Hardware',
            hint=_translate("Config file for eyetracker parameters"))

        msg = _translate(
            "How often should the eyetracker state (x,y,"
            "pupilsize...) be stored? On every video frame, every click "
            "or just at the end of the Routine?")
        self.params['saveState'] = Param(
            save, valType='str', inputType="choice", categ='Data',
            allowedVals=['final', 'every frame', 'never'],
            hint=msg,
            label="Save eyetracker state")
Beispiel #5
0
    def __init__(self, exp, parentName, name='text',
                 # effectively just a display-value
                 text=_translate('Any text\n\nincluding line breaks'),
                 font='Arial', units='from exp settings',
                 color='white', colorSpace='rgb',
                 pos=(0, 0), letterHeight=0.1, ori=0,
                 startType='time (s)', startVal=0.0,
                 stopType='duration (s)', stopVal=1.0,
                 flip='', startEstim='', durationEstim='', wrapWidth=''):
        super(TextComponent, self).__init__(exp, parentName, name=name,
                                            units=units,
                                            color=color,
                                            colorSpace=colorSpace,
                                            pos=pos,
                                            ori=ori,
                                            startType=startType,
                                            startVal=startVal,
                                            stopType=stopType,
                                            stopVal=stopVal,
                                            startEstim=startEstim,
                                            durationEstim=durationEstim)
        self.type = 'Text'
        self.url = "http://www.psychopy.org/builder/components/text.html"

        # params
        _allow3 = ['constant', 'set every repeat', 'set every frame']  # list
        self.params['text'] = Param(
            text, valType='str', allowedTypes=[],
            updates='constant', allowedUpdates=_allow3[:],  # copy the list
            hint=_translate("The text to be displayed"),
            label=_localized['text'])
        self.params['font'] = Param(
            font, valType='str', allowedTypes=[],
            updates='constant', allowedUpdates=_allow3[:],  # copy the list
            hint=_translate("The font name (e.g. Comic Sans)"),
            label=_localized['font'])
        del self.params['size']  # because you can't specify width for text
        self.params['letterHeight'] = Param(
            letterHeight, valType='code', allowedTypes=[],
            updates='constant', allowedUpdates=_allow3[:],  # copy the list
            hint=_translate("Specifies the height of the letter (the width"
                            " is then determined by the font)"),
            label=_localized['letterHeight'])

        self.params['wrapWidth'] = Param(
            wrapWidth, valType='code', allowedTypes=[],
            updates='constant', allowedUpdates=['constant'],
            hint=_translate("How wide should the text get when it wraps? (in"
                            " the specified units)"),
            label=_localized['wrapWidth'])
        self.params['flip'] = Param(
            flip, valType='str', allowedTypes=[],
            updates='constant', allowedUpdates=_allow3[:],  # copy the list
            hint=_translate("horiz = left-right reversed; vert = up-down"
                            " reversed; $var = variable"),
            label=_localized['flip'])
        for prm in ('ori', 'opacity', 'colorSpace', 'units', 'wrapWidth',
                    'flip'):
            self.params[prm].categ = 'Advanced'
Beispiel #6
0
    def __init__(self,
                 exp,
                 parentName,
                 name='eeg_marker',
                 startType='time (s)',
                 startVal=0.0,
                 stopType='time (s)',
                 stopVal=2,
                 startEstim='',
                 durationEstim='0.1',
                 label='label',
                 value='1',
                 stop_marker=False):
        super(EmotivMarkingComponent, self).__init__(exp,
                                                     parentName,
                                                     name=name,
                                                     startType=startType,
                                                     startVal=startVal,
                                                     stopType=stopType,
                                                     stopVal=stopVal,
                                                     startEstim=startEstim,
                                                     durationEstim=0.01)

        # params
        _allow2 = ['constant', 'set every repeat']  # list
        msg = _translate(
            "Label of the marker to be inserted (interpreted as a string)")
        self.params['marker_label'] = Param(label,
                                            valType='str',
                                            categ='Basic',
                                            updates='constant',
                                            allowedUpdates=_allow2[:],
                                            hint=msg,
                                            label=_localized['marker_label'])

        msg = _translate(
            "Value of the marker to be inserted (interpreted as a string)")
        self.params['marker_value'] = Param(value,
                                            valType='str',
                                            categ='Basic',
                                            updates='constant',
                                            allowedUpdates=_allow2[:],
                                            hint=msg,
                                            label=_localized['marker_value'])

        msg = _translate("Check this box to include a stop marker")
        self.params['stop_marker'] = Param(stop_marker,
                                           valType='bool',
                                           categ='Basic',
                                           allowedVals=[True, False],
                                           updates='constant',
                                           allowedUpdates=[],
                                           hint=msg,
                                           label=_localized["stop_marker"])

        self.type = 'EmotivMarking'
        self.exp.requireImport(importName='emotiv',
                               importFrom='psychopy.hardware')
        self.order += ['marker_label', 'marker_value', 'stop_marker']
Beispiel #7
0
    def __init__(self,
                 exp,
                 parentName,
                 name='GazeParserGetPos',
                 filler='-10000',
                 binocular='Average',
                 ma=1,
                 units='from exp settings'):
        self.type = 'GazeParserGetPos'
        self.url = "http://gazeparser.sourceforge.net/"
        super(GazeParserGetPosComponent, self).__init__(exp, parentName, name)

        #params
        self.order = [
            'name'
        ] + paramNames[:]  # want a copy, else codeParamNames list gets mutated
        self.params['filler'] = Param(
            filler,
            valType='code',
            allowedTypes=[],
            updates='constant',
            allowedUpdates=['constant', 'set every repeat'],
            hint=
            "If gaze position is not available, gaze position is filled by this value.",
            label="Filler",
            categ="Advanced")
        self.params['binocular'] = Param(
            binocular,
            valType='str',
            allowedTypes=[],
            allowedVals=['Average', 'L', 'R'],
            updates='constant',
            allowedUpdates=['constant', 'set every repeat'],
            hint="Average: average of two eyes L: left eye, R: right eye",
            label="Binocular Data",
            categ="Advanced")
        self.params['ma'] = Param(
            ma,
            valType='code',
            allowedTypes=[],
            updates='constant',
            allowedUpdates=['constant', 'set every repeat'],
            hint="Integer equal or greater than 1.",
            label="Moving average",
            categ="Advanced")

        # these inherited params are harmless but might as well trim:
        for p in [
                'startType', 'startVal', 'startEstim', 'stopVal', 'stopType',
                'durationEstim'
        ]:
            del self.params[p]

        # these inherited params are harmless but might as well trim:
        for p in ['color', 'opacity', 'colorSpace', 'pos', 'size', 'ori']:
            del self.params[p]
Beispiel #8
0
    def __init__(self, exp, parentName, name='buttonBox',
                 store='first key',
                 useTimer=True, deviceNumber=0, allowedKeys="",
                 getReleaseTime=False,  # not yet supported
                 forceEndRoutine=True, storeCorrect=False, correctAns="",
                 discardPrev=True,
                 startType='time (s)', startVal=0.0,
                 stopType='duration (s)', stopVal=1.0,
                 startEstim='', durationEstim='',):
        super(cedrusButtonBoxComponent, self).__init__(
            exp, parentName, name=name,
            allowedKeys=allowedKeys, store=store, discardPrev=discardPrev,
            forceEndRoutine=forceEndRoutine, storeCorrect=storeCorrect,
            correctAns=correctAns, startType=startType, startVal=startVal,
            stopType=stopType, stopVal=stopVal,
            startEstim=startEstim, durationEstim=durationEstim)

        self.type = 'cedrusButtonBox'
        self.url = "http://www.psychopy.org/builder/components/cedrusButtonBox.html"
        self.exp.requirePsychopyLibs(['hardware'])

        self.params['correctAns'].hint = _translate(
            "What is the 'correct' response? NB, buttons are labelled 0 to "
            "6 on a 7-button box. Enter 'None' (no quotes) if withholding "
            "a response is correct. Might be helpful to add a correctAns "
            "column and use $correctAns to compare to the key press.")

        self.params['correctAns'].valType = 'code'

        self.params['allowedKeys'].hint = _translate(
            'Keys to be read (blank for any) or key numbers separated by '
            'commas')

        msg = _translate('Device number, if you have multiple devices which'
                         ' one do you want (0, 1, 2...)')
        self.params['deviceNumber'] = Param(
            deviceNumber, valType='code', allowedTypes=[],
            updates='constant', allowedUpdates=[],
            hint=msg,
            label=_localized['deviceNumber'], categ='Advanced')

        # self.params['getReleaseTime'] = Param(getReleaseTime,
        #    valType='bool', allowedVals=[True, False],
        #    updates='constant', allowedUpdates=[],
        #    hint="Wait for the key to be released and store the time
        #       that it was held down",
        #    label="Get release time")

        msg = _translate('According to Cedrus the response box timer has '
                         'a drift - use with caution!')
        self.params['useBoxTimer'] = Param(
            getReleaseTime, valType='bool', allowedVals=[True, False],
            updates='constant', allowedUpdates=[],
            hint=msg,
            label=_localized['useBoxTimer'], categ='Advanced')
Beispiel #9
0
    def __init__(self,
                 exp,
                 parentName,
                 name='ezTriggerConnection',
                 serverIp='',
                 serverPort='233333',
                 clientType='PPY',
                 clientId=''):
        super(ezTriggerConnectionComponent,
              self).__init__(exp, parentName, name)

        self.type = 'ezTriggerConnection'
        self.targets = ['PsychoPy']
        self.url = "https://github.com/ezPsycho"
        # params
        # want a copy, else codeParamNames list gets mutated

        msg = _translate(
            "The address of the server - an IP address or an domain.")
        self.params['serverIp'] = Param(serverIp,
                                        valType='str',
                                        allowedTypes=[],
                                        hint=msg,
                                        label=_localized["serverIp"])

        msg = _translate(
            "The port of the server - a number between 1 and 65535.")
        self.params['serverPort'] = Param(serverPort,
                                          valType='int',
                                          allowedTypes=[],
                                          hint=msg,
                                          label=_localized["serverPort"])

        msg = _translate(
            "The type of this client - fill 'PPY' if you dont know what does it means."
        )
        self.params['clientType'] = Param(clientType,
                                          valType='str',
                                          allowedTypes=[],
                                          hint=msg,
                                          label=_localized["clientType"])

        msg = _translate(
            "The ID of this client - to distinguish this device from other devices, you can set an IP for each one."
        )
        self.params['clientId'] = Param(clientId,
                                        valType='str',
                                        allowedTypes=[],
                                        hint=msg,
                                        label=_localized["clientId"])

        for p in ('startType', 'startVal', 'startEstim', 'stopVal', 'stopType',
                  'durationEstim'):
            del self.params[p]
Beispiel #10
0
    def __init__(self, exp, parentName, name='sound_1', sound='A', volume=1,
                 startType='time (s)', startVal='0.0',
                 stopType='duration (s)', stopVal='1.0',
                 startEstim='', durationEstim='',
                 syncScreenRefresh=True):
        super(SoundComponent, self).__init__(
            exp, parentName, name,
            startType=startType, startVal=startVal,
            stopType=stopType, stopVal=stopVal,
            startEstim=startEstim, durationEstim=durationEstim)
        self.type = 'Sound'
        self.url = "https://www.psychopy.org/builder/components/sound.html"
        self.exp.requirePsychopyLibs(['sound'])
        self.targets = ['PsychoPy', 'PsychoJS']
        self.order += [
            "sound",  # Basic tab
            "volume", "hammingWindow",  # Playback tab
        ]
        # params
        self.params['stopType'].allowedVals = ['duration (s)']
        self.params['stopType'].hint = _translate('The maximum duration of a'
                                                  ' sound in seconds')
        hnt = _translate("When does the component end? (blank to use the "
                         "duration of the media)")
        self.params['stopVal'].hint = hnt

        hnt = _translate("A sound can be a note name (e.g. A or Bf), a number"
                         " to specify Hz (e.g. 440) or a filename")
        self.params['sound'] = Param(
            sound, valType='str', inputType="file", allowedTypes=[], updates='constant', categ='Basic',
            allowedUpdates=['constant', 'set every repeat'],
            hint=hnt,
            label=_localized['sound'])
        _allowed = ['constant', 'set every repeat', 'set every frame']
        self.params['volume'] = Param(
            volume, valType='num', inputType="single", allowedTypes=[], updates='constant', categ='Playback',
            allowedUpdates=_allowed[:],  # use a copy
            hint=_translate("The volume (in range 0 to 1)"),
            label=_localized["volume"])
        msg = _translate(
            "A reaction time to a sound stimulus should be based on when "
            "the screen flipped")
        self.params['syncScreenRefresh'] = Param(
            syncScreenRefresh, valType='bool', inputType="bool", categ='Basic',
            updates='constant',
            hint=msg,
            label=_localized['syncScreenRefresh'])
        self.params['hamming'] = Param(
            True, valType='bool', inputType="bool", updates='constant', categ='Playback',
            hint=_translate(
                  "For tones we can apply a Hamming window to prevent 'clicks' that "
                  "are caused by a sudden onset. This delays onset by roughly 1ms."),
            label=_translate('Hamming window'))
Beispiel #11
0
    def __init__(self,
                 exp,
                 parentName,
                 name='vrdisplay',
                 image='kotek.jpg',
                 ipd='0',
                 startType='time (s)',
                 startVal=0.0,
                 stopType='duration (s)',
                 stopVal=1.0,
                 startEstim='',
                 durationEstim=''):
        super(VRDisplayComponent, self).__init__(exp,
                                                 parentName,
                                                 name=name,
                                                 startType=startType,
                                                 startVal=startVal,
                                                 stopType=stopType,
                                                 stopVal=stopVal,
                                                 startEstim=startEstim,
                                                 durationEstim=durationEstim)
        self.type = 'VRDisplay'
        self.targets = ['PsychoPy', 'PsychoJS']
        self.url = "http://www.psychopy.org/builder/components/image.html"
        self.exp.requirePsychopyLibs(['visual'])
        # params
        self.order += ['image', 'ipd', 'chroma']

        msg = _translate(
            "The image to be displayed - a filename, including path")
        self.params['image'] = Param(image,
                                     valType='str',
                                     allowedTypes=[],
                                     hint=msg,
                                     label=_localized["image"])

        msg = _translate(
            "The interpupillary distance - a value between 60 and 75mm")
        self.params['ipd'] = Param(ipd,
                                   valType='str',
                                   allowedTypes=[],
                                   hint=msg,
                                   label=_localized["ipd"])

        self.params['chroma'] = Param(
            False,
            valType='bool',
            updates='constant',
            hint=_translate(
                "Add correction for chromatic aberration caused by Fresnel lenses"
            ),
            label=_translate('Color correction'))
Beispiel #12
0
    def __init__(self,
                 exp,
                 parentName,
                 name='sound_1',
                 sound='A',
                 volume=1,
                 startType='time (s)',
                 startVal='0.0',
                 stopType='duration (s)',
                 stopVal='1.0',
                 startEstim='',
                 durationEstim=''):
        super(SoundComponent, self).__init__(exp,
                                             parentName,
                                             name,
                                             startType=startType,
                                             startVal=startVal,
                                             stopType=stopType,
                                             stopVal=stopVal,
                                             startEstim=startEstim,
                                             durationEstim=durationEstim)
        self.type = 'Sound'
        self.url = "http://www.psychopy.org/builder/components/sound.html"
        self.exp.requirePsychopyLibs(['sound'])
        # params
        self.params['stopType'].allowedVals = ['duration (s)']
        self.params['stopType'].hint = _translate('The maximum duration of a'
                                                  ' sound in seconds')
        hnt = _translate("When does the component end? (blank to use the "
                         "duration of the media)")
        self.params['stopVal'].hint = hnt

        hnt = _translate("A sound can be a note name (e.g. A or Bf), a number"
                         " to specify Hz (e.g. 440) or a filename")
        self.params['sound'] = Param(
            sound,
            valType='str',
            allowedTypes=[],
            updates='constant',
            allowedUpdates=['constant', 'set every repeat'],
            hint=hnt,
            label=_localized['sound'])
        _allowed = ['constant', 'set every repeat', 'set every frame']
        self.params['volume'] = Param(
            volume,
            valType='code',
            allowedTypes=[],
            updates='constant',
            allowedUpdates=_allowed[:],  # use a copy
            hint=_translate("The volume (in range 0 to 1)"),
            label=_localized["volume"])
Beispiel #13
0
    def __init__(self, exp, parentName, name='p_port',
                 startType='time (s)', startVal=0.0,
                 stopType='duration (s)', stopVal=1.0,
                 startEstim='', durationEstim='',
                 address=None, startData="1", stopData="0",
                 syncScreen=True):
        super(ParallelOutComponent, self).__init__(
            exp, parentName, name,
            startType=startType, startVal=startVal,
            stopType=stopType, stopVal=stopVal,
            startEstim=startEstim, durationEstim=durationEstim)

        self.type = 'ParallelOut'
        self.url = "http://www.psychopy.org/builder/components/parallelout.html"
        self.categories = ['I/O']
        self.exp.requirePsychopyLibs(['parallel'])

        # params
        self.order = ['address', 'startData', 'stopData']

        # main parameters
        addressOptions = prefs.hardware['parallelPorts'] + [u'LabJack U3'] + [u'USB2TTL8'] 
        if not address:
            address = addressOptions[0]

        msg = _translate("Parallel port to be used (you can change these "
                         "options in preferences>general)")
        self.params['address'] = Param(
            address, valType='str', allowedVals=addressOptions,
            hint=msg,
            label=_localized['address'])

        self.params['startData'] = Param(
            startData, valType='code', allowedTypes=[],
            hint=_translate("Data to be sent at 'start'"),
            label=_localized['startData'])

        self.params['stopData'] = Param(
            stopData, valType='code', allowedTypes=[],
            hint=_translate("Data to be sent at 'end'"),
            label=_localized['stopData'])

        msg = _translate("If the parallel port data relates to visual "
                         "stimuli then sync its pulse to the screen refresh")
        self.params['syncScreen'] = Param(
            syncScreen, valType='bool',
            allowedVals=[True, False],
            updates='constant', allowedUpdates=[],
            hint=msg,
            label=_localized['syncScreen'])
Beispiel #14
0
    def __init__(self, exp, parentName, name='mic_1',
                 startType='time (s)', startVal=0.0,
                 stopType='duration (s)', stopVal=2.0, startEstim='',
                 durationEstim='', stereo=False):
        super(MicrophoneComponent, self).__init__(
            exp, parentName, name=name,
            startType=startType, startVal=startVal,
            stopType=stopType, stopVal=stopVal,
            startEstim=startEstim, durationEstim=durationEstim)

        self.type = 'Microphone'
        self.url = "http://www.psychopy.org/builder/components/microphone.html"
        self.exp.requirePsychopyLibs(['microphone'])

        # params
        msg = _translate(
            "Record two channels (stereo) or one (mono, smaller file)")
        self.params['stereo'] = Param(
            stereo, valType='bool',
            hint=msg,
            label=_localized['stereo'])

        self.params['stopType'].allowedVals = ['duration (s)']

        msg = _translate(
            'The duration of the recording in seconds; blank = 0 sec')
        self.params['stopType'].hint = msg
Beispiel #15
0
    def __init__(
            self,
            exp,
            parentName,
            name='etRecord',
            startType='time (s)',
            startVal=0.0,
            stopType='duration (s)',
            stopVal=1.0,
            startEstim='',
            durationEstim='',
            actionType="Start and Stop",
            #legacy
            save='final',
            configFile='myTracker.yaml'):
        BaseComponent.__init__(self,
                               exp,
                               parentName,
                               name=name,
                               startType=startType,
                               startVal=startVal,
                               stopType=stopType,
                               stopVal=stopVal,
                               startEstim=startEstim,
                               durationEstim=durationEstim)
        self.type = 'EyetrackerRecord'
        self.url = "https://www.psychopy.org/builder/components/eyetracker.html"
        self.exp.requirePsychopyLibs(['iohub', 'hardware'])

        self.params['actionType'] = Param(
            actionType,
            valType='str',
            inputType='choice',
            categ='Basic',
            allowedVals=["Start and Stop", "Start Only", "Stop Only"],
            hint=_translate(
                "Should this component start and / or stop eye tracker recording?"
            ),
            label=_translate("Record Actions"))

        self.depends.append({
            "dependsOn": "actionType",  # must be param name
            "condition": "=='Start Only'",  # val to check for
            "param": "stop",  # param property to alter
            "true": "hide",  # what to do with param if condition is True
            "false": "show",  # permitted: hide, show, enable, disable
        })

        self.depends.append({
            "dependsOn": "actionType",  # must be param name
            "condition": "=='Stop Only'",  # val to check for
            "param": "start",  # param property to alter
            "true": "hide",  # what to do with param if condition is True
            "false": "show",  # permitted: hide, show, enable, disable
        })

        # TODO: Display actionType control after component name.
        #       Currently, adding params before start / stop time
        #       in .order has no effect
        self.order = self.order[:1] + ['actionType'] + self.order[1:]
Beispiel #16
0
    def __init__(self,
                 exp,
                 parentName,
                 name='ISI',
                 startType='time (s)',
                 startVal=0.0,
                 stopType='duration (s)',
                 stopVal=0.5,
                 startEstim='',
                 durationEstim=''):
        BaseComponent.__init__(self, exp, parentName, name=name)
        self.updatesList = []  # a list of dicts {compParams, fieldName}
        self.type = 'Static'
        self.url = "http://www.psychopy.org/builder/components/static.html"
        hnt = _translate(
            "Custom code to be run during the static period (after updates)")
        self.params['code'] = Param("",
                                    valType='code',
                                    hint=hnt,
                                    label=_localized['Custom code'])
        self.order = ['name']  # make name come first (others don't matter)

        hnt = _translate("How do you want to define your start point?")
        self.params['startType'] = Param(startType,
                                         valType='str',
                                         allowedVals=['time (s)', 'frame N'],
                                         hint=hnt)
        hnt = _translate("How do you want to define your end point?")
        _allow = ['duration (s)', 'duration (frames)', 'time (s)', 'frame N']
        self.params['stopType'] = Param(
            stopType,
            valType='str',
            allowedVals=_allow,  # copy not needed
            hint=hnt)
        hnt = _translate("When does the component start?")
        self.params['startVal'] = Param(startVal,
                                        valType='code',
                                        allowedTypes=[],
                                        hint=hnt)
        hnt = _translate("When does the component end? (blank is endless)")
        self.params['stopVal'] = Param(stopVal,
                                       valType='code',
                                       allowedTypes=[],
                                       updates='constant',
                                       allowedUpdates=[],
                                       hint=hnt)
        hnt = _translate("(Optional) expected start (s), purely for "
                         "representing in the timeline")
        self.params['startEstim'] = Param(startEstim,
                                          valType='code',
                                          allowedTypes=[],
                                          hint=hnt)
        hnt = _translate("(Optional) expected duration (s), purely for "
                         "representing in the timeline")
        self.params['durationEstim'] = Param(durationEstim,
                                             valType='code',
                                             allowedTypes=[],
                                             hint=hnt)
Beispiel #17
0
    def __init__(self,
                 exp,
                 parentName,
                 name='ptc_message',
                 time='',
                 timeType='condition',
                 text='event'):
        super(ptc_message_component, self).__init__(exp, parentName, name)
        self.type = 'ptc_message'
        self.url = 'https://github.com/hsogo/psychopy_tobii_controller/'

        #params
        self.order = ['name', 'time', 'timeType', 'text']
        self.params['time'] = Param(time,
                                    valType='code',
                                    allowedTypes=[],
                                    updates='constant',
                                    allowedUpdates=[],
                                    hint='When this event should be recorded?',
                                    label='time')
        self.params['timeType'] = Param(
            timeType,
            valType='str',
            inputType='choice',
            allowedTypes=[],
            allowedVals=['time (s)', 'frame N', 'condition'],
            updates='constant',
            allowedUpdates=[],
            hint='How do you want to define time?',
            label='time type')
        self.params['text'] = Param(text,
                                    valType='str',
                                    allowedTypes=[],
                                    updates='constant',
                                    allowedUpdates=[],
                                    hint='Event text',
                                    label='Event')
        # these inherited params are harmless but might as well trim:
        for p in ('startType', 'startVal', 'startEstim', 'stopVal', 'stopType',
                  'durationEstim', 'saveStartStop', 'syncScreenRefresh'):
            if p in self.params:
                del self.params[p]
Beispiel #18
0
 def __init__(self, exp, parentName, name='ptc_rec', start_msg='', stop_msg=''):
     super(ptc_rec_component, self).__init__(exp, parentName, name)
     self.type='ptc_rec'
     self.url='https://github.com/hsogo/psychopy_tobii_controller/'
     
     #params
     self.order = ['name', 'start_msg', 'stop_msg']
     self.params['start_msg'] = Param(start_msg, valType='code', allowedTypes=[],
         updates='constant', allowedUpdates=[],
         hint='This text is inserted at the beginning of the recording.',
         label='Event (start)', categ='Advanced')
     self.params['stop_msg'] = Param(stop_msg, valType='code', allowedTypes=[],
         updates='constant', allowedUpdates=[],
         hint='This text is inserted at the end of the recording.',
         label='Event (stop)', categ='Advanced')
         
     # these inherited params are harmless but might as well trim:
     for p in ('startType', 'startVal', 'startEstim', 'stopVal',
               'stopType', 'durationEstim',
               'saveStartStop', 'syncScreenRefresh'):
         if p in self.params:
             del self.params[p]
Beispiel #19
0
 def __init__(self, exp, parentName, name='ISI',
              startType='time (s)', startVal=0.0,
              stopType='duration (s)', stopVal=0.5,
              startEstim='', durationEstim=''):
     BaseComponent.__init__(self, exp, parentName, name=name)
     self.updatesList = []  # a list of dicts {compParams, fieldName}
     self.type = 'Static'
     self.url = "https://www.psychopy.org/builder/components/static.html"
     hnt = _translate(
         "Custom code to be run during the static period (after updates)")
     self.params['code'] = Param("", valType='code', inputType="multi", categ='Custom',
                                 hint=hnt,
                                 label=_localized['Custom code'])
Beispiel #20
0
 def __init__(self, exp, parentName, name=''):
     self.type = 'Unknown'
     self.exp = exp  # so we can access the experiment if necess
     self.parentName = parentName  # to access the routine too if needed
     self.params = {}
     self.depends = []
     _hint = _translate("Name of this component (alpha-numeric or _, "
                        "no spaces)")
     self.params['name'] = Param(name,
                                 valType='code',
                                 hint=_hint,
                                 label=_localized['name'])
     self.order = ['name']  # name first, then timing, then others
Beispiel #21
0
    def __init__(self,
                 exp,
                 parentName,
                 name='ptc_getpos',
                 filler=-10000,
                 binocular='Average'):
        super(ptc_getpos_component, self).__init__(exp, parentName, name)
        self.type = 'ptc_getpos'
        self.url = 'https://github.com/hsogo/psychopy_tobii_controller/'

        #params
        self.order = ['name', 'start_msg', 'stop_msg']
        self.params['filler'] = Param(
            filler,
            valType='code',
            allowedTypes=[],
            updates='constant',
            allowedUpdates=[],
            hint=
            'If gaze position is not available, gaze position is filled by this value.',
            label='Filler')
        self.params['binocular'] = Param(
            binocular,
            valType='str',
            inputType='choice',
            allowedTypes=[],
            allowedVals=['Average', 'LR'],
            updates='constant',
            allowedUpdates=[],
            hint=
            'Average: (average_x, average_y) LR: {\'left\':(left_x, left_y), \'right\':(right_x, right_y)}',
            label='Binocular Data')
        # these inherited params are harmless but might as well trim:
        for p in ('startType', 'startVal', 'startEstim', 'stopVal', 'stopType',
                  'durationEstim', 'saveStartStop', 'syncScreenRefresh'):
            if p in self.params:
                del self.params[p]
Beispiel #22
0
 def __init__(self, exp, parentName, name=''):
     self.type = 'Unknown'
     self.exp = exp  # so we can access the experiment if necess
     self.parentName = parentName  # to access the routine too if needed
     self.params = {}
     self.depends = []
     _hint = _translate("Name of this component (alphanumeric or _, "
                        "no spaces)")
     self.params['name'] = Param(name,
                                 valType='code',
                                 inputType="multi",
                                 hint=_hint,
                                 label=_localized['name'])
     super(UnknownComponent, self).__init__(exp, parentName)
     self.order += []
Beispiel #23
0
    def __init__(self,
                 exp,
                 parentName,
                 name='code',
                 beforeExp="",
                 beginExp="",
                 beginRoutine="",
                 eachFrame="",
                 endRoutine="",
                 endExperiment="",
                 codeType=None,
                 translator="manual"):
        super(CodeComponent, self).__init__(exp, parentName, name)
        self.type = 'Code'
        self.targets = ['PsychoPy', 'PsychoJS']
        self.url = "https://www.psychopy.org/builder/components/code.html"
        # params
        # want a copy, else codeParamNames list gets mutated
        self.order = [
            'name',
            'Code Type',
            'disabled',
            'Before Experiment',
            'Begin Experiment',
            'Begin Routine',
            'Each Frame',
            'End Routine',
            'End Experiment',
            'Before JS Experiment',
            'Begin JS Experiment',
            'Begin JS Routine',
            'Each JS Frame',
            'End JS Routine',
            'End JS Experiment',
        ]
        if not codeType:
            codeType = prefs.builder['codeComponentLanguage']

        msg = _translate("Display Python or JS Code")
        self.params['Code Type'] = Param(
            codeType,
            valType='str',
            inputType="choice",
            allowedTypes=[],
            allowedVals=['Py', 'JS', 'Both', 'Auto->JS'],
            hint=msg,
            label=_localized['Code Type'])

        msg = _translate("Code to run before the experiment starts "
                         "(initialization); right-click checks syntax")
        self.params['Before Experiment'] = Param(
            beforeExp,
            valType='code',
            inputType="multi",
            allowedTypes=[],
            updates='constant',
            allowedUpdates=[],
            hint=msg,
            label=_localized['Before Experiment'])

        msg = _translate("Code at the start of the experiment ; right-click "
                         "checks syntax")
        self.params['Begin Experiment'] = Param(
            beginExp,
            valType='code',
            inputType="multi",
            allowedTypes=[],
            updates='constant',
            allowedUpdates=[],
            hint=msg,
            label=_localized['Begin Experiment'])

        msg = _translate("Code to be run at the start of each repeat of the "
                         "Routine (e.g. each trial); "
                         "right-click checks syntax")
        self.params['Begin Routine'] = Param(beginRoutine,
                                             valType='code',
                                             inputType="multi",
                                             allowedTypes=[],
                                             updates='constant',
                                             allowedUpdates=[],
                                             hint=msg,
                                             label=_localized['Begin Routine'])

        msg = _translate("Code to be run on every video frame during for the"
                         " duration of this Routine; "
                         "right-click checks syntax")
        self.params['Each Frame'] = Param(eachFrame,
                                          valType='code',
                                          inputType="multi",
                                          allowedTypes=[],
                                          updates='constant',
                                          allowedUpdates=[],
                                          hint=msg,
                                          label=_localized['Each Frame'])

        msg = _translate("Code at the end of this repeat of the Routine (e.g."
                         " getting/storing responses); "
                         "right-click checks syntax")
        self.params['End Routine'] = Param(endRoutine,
                                           valType='code',
                                           inputType="multi",
                                           allowedTypes=[],
                                           updates='constant',
                                           allowedUpdates=[],
                                           hint=msg,
                                           label=_localized['End Routine'])

        msg = _translate("Code at the end of the entire experiment (e.g. "
                         "saving files, resetting computer); "
                         "right-click checks syntax")
        self.params['End Experiment'] = Param(
            endExperiment,
            valType='code',
            inputType="multi",
            allowedTypes=[],
            updates='constant',
            allowedUpdates=[],
            hint=msg,
            label=_localized['End Experiment'])
        # todo: copy initial vals once javscript interp can do comments
        msg = _translate(
            "Code before the start of the experiment (initialization"
            "); right-click checks syntax")
        self.params['Before JS Experiment'] = Param(
            '',
            valType='code',
            inputType="multi",
            allowedTypes=[],
            updates='constant',
            allowedUpdates=[],
            hint=msg,
            label=_localized['Before JS Experiment'])
        msg = _translate("Code at the start of the experiment (initialization"
                         "); right-click checks syntax")
        self.params['Begin JS Experiment'] = Param(
            '',
            valType='code',
            inputType="multi",
            allowedTypes=[],
            updates='constant',
            allowedUpdates=[],
            hint=msg,
            label=_localized['Begin JS Experiment'])

        msg = _translate("Code to be run at the start of each repeat of the "
                         "Routine (e.g. each trial); "
                         "right-click checks syntax")
        self.params['Begin JS Routine'] = Param(
            '',
            valType='code',
            inputType="multi",
            allowedTypes=[],
            updates='constant',
            allowedUpdates=[],
            hint=msg,
            label=_localized['Begin JS Routine'])

        msg = _translate("Code to be run on every video frame during for the"
                         " duration of this Routine; "
                         "right-click checks syntax")
        self.params['Each JS Frame'] = Param('',
                                             valType='code',
                                             inputType="multi",
                                             allowedTypes=[],
                                             updates='constant',
                                             allowedUpdates=[],
                                             hint=msg,
                                             label=_localized['Each JS Frame'])

        msg = _translate("Code at the end of this repeat of the Routine (e.g."
                         " getting/storing responses); "
                         "right-click checks syntax")
        self.params['End JS Routine'] = Param(
            '',
            valType='code',
            inputType="multi",
            allowedTypes=[],
            updates='constant',
            allowedUpdates=[],
            hint=msg,
            label=_localized['End JS Routine'])

        msg = _translate("Code at the end of the entire experiment (e.g. "
                         "saving files, resetting computer); "
                         "right-click checks syntax")
        self.params['End JS Experiment'] = Param(
            '',
            valType='code',
            inputType="multi",
            allowedTypes=[],
            updates='constant',
            allowedUpdates=[],
            hint=msg,
            label=_localized['End JS Experiment'])

        # these inherited params are harmless but might as well trim:
        for p in ('startType', 'startVal', 'startEstim', 'stopVal', 'stopType',
                  'durationEstim', 'saveStartStop', 'syncScreenRefresh'):
            if p in self.params:
                del self.params[p]
Beispiel #24
0
    def __init__(self, exp, parentName, name='key_resp',
                 allowedKeys="'y','n','left','right','space'",
                 store='last key', forceEndRoutine=True, storeCorrect=False,
                 correctAns="", discardPrev=True,
                 startType='time (s)', startVal=0.0,
                 stopType='duration (s)', stopVal='',
                 startEstim='', durationEstim='',
                 syncScreenRefresh=True):
        super(KeyboardComponent, self).__init__(
            exp, parentName, name,
            startType=startType, startVal=startVal,
            stopType=stopType, stopVal=stopVal,
            startEstim=startEstim, durationEstim=durationEstim)

        self.type = 'Keyboard'
        self.url = "https://www.psychopy.org/builder/components/keyboard.html"
        self.exp.requirePsychopyLibs(['gui'])

        # params

        # NB name and timing params always come 1st
        self.order += ['forceEndRoutine',  # Basic tab
                       'allowedKeys', 'store', 'storeCorrect', 'correctAns'  # Data tab
                       ]

        msg = _translate(
            "A comma-separated list of keys (with quotes), such as "
            "'q','right','space','left'")
        self.params['allowedKeys'] = Param(
            allowedKeys, valType='list', inputType="single", allowedTypes=[],
            categ='Basic',
            updates='constant',
            allowedUpdates=['constant', 'set every repeat'],
            hint=(msg),
            label=_localized['allowedKeys'])

        # hints say 'responses' not 'key presses' because the same hint is
        # also used with button boxes
        msg = _translate("Do you want to discard all responses occurring "
                         "before the onset of this component?")
        self.params['discard previous'] = Param(
            discardPrev, valType='bool', inputType="bool", allowedTypes=[], categ='Data',
            updates='constant',
            hint=msg,
            label=_localized['discard previous'])

        msg = _translate("Choose which (if any) responses to store at the "
                         "end of a trial")
        self.params['store'] = Param(
            store, valType='str', inputType="choice", allowedTypes=[], categ='Data',
            allowedVals=['last key', 'first key', 'all keys', 'nothing'],
            updates='constant',
            hint=msg,
            label=_localized['store'])

        msg = _translate("Should a response force the end of the Routine "
                         "(e.g end the trial)?")
        self.params['forceEndRoutine'] = Param(
            forceEndRoutine, valType='bool', inputType="bool", allowedTypes=[], categ='Basic',
            updates='constant',
            hint=msg,
            label=_localized['forceEndRoutine'])

        msg = _translate("Do you want to save the response as "
                         "correct/incorrect?")
        self.params['storeCorrect'] = Param(
            storeCorrect, valType='bool', inputType="bool", allowedTypes=[], categ='Data',
            updates='constant',
            hint=msg,
            label=_localized['storeCorrect'])

        self.depends += [  # allows params to turn each other off/on
            {"dependsOn": "storeCorrect",  # must be param name
             "condition": "== True",  # val to check for
             "param": "correctAns",  # param property to alter
             "true": "enable",  # what to do with param if condition is True
             "false": "disable",  # permitted: hide, show, enable, disable
             }
        ]

        msg = _translate(
            "What is the 'correct' key? Might be helpful to add a "
            "correctAns column and use $correctAns to compare to the key "
            "press.")
        self.params['correctAns'] = Param(
            correctAns, valType='str', inputType="single", allowedTypes=[], categ='Data',
            updates='constant',
            hint=msg,
            label=_localized['correctAns'])

        msg = _translate(
            "A reaction time to a visual stimulus should be based on when "
            "the screen flipped")
        self.params['syncScreenRefresh'] = Param(
            syncScreenRefresh, valType='bool', inputType="bool", categ='Data',
            updates='constant',
            hint=msg,
            label=_localized['syncScreenRefresh'])
Beispiel #25
0
    def __init__(
            self,
            exp,
            parentName,
            name='text',
            # effectively just a display-value
            text=_translate('Any text\n\nincluding line breaks'),
            font='Open Sans',
            units='from exp settings',
            color='white',
            colorSpace='rgb',
            pos=(0, 0),
            letterHeight=0.1,
            ori=0,
            startType='time (s)',
            startVal=0.0,
            stopType='duration (s)',
            stopVal=1.0,
            flip='None',
            startEstim='',
            durationEstim='',
            wrapWidth='',
            languageStyle='LTR'):
        super(TextComponent, self).__init__(exp,
                                            parentName,
                                            name=name,
                                            units=units,
                                            color=color,
                                            colorSpace=colorSpace,
                                            pos=pos,
                                            ori=ori,
                                            startType=startType,
                                            startVal=startVal,
                                            stopType=stopType,
                                            stopVal=stopVal,
                                            startEstim=startEstim,
                                            durationEstim=durationEstim)
        self.type = 'Text'
        self.url = "https://www.psychopy.org/builder/components/text.html"

        # params
        _allow3 = ['constant', 'set every repeat', 'set every frame']  # list
        self.params['text'] = Param(
            text,
            valType='str',
            inputType="multi",
            allowedTypes=[],
            categ='Basic',
            updates='constant',
            allowedUpdates=_allow3[:],  # copy the list
            hint=_translate("The text to be displayed"),
            canBePath=False,
            label=_localized['text'])
        self.params['font'] = Param(
            font,
            valType='str',
            inputType="single",
            allowedTypes=[],
            categ='Formatting',
            updates='constant',
            allowedUpdates=_allow3[:],  # copy the list
            hint=_translate("The font name (e.g. Comic Sans)"),
            label=_localized['font'])
        del self.params['size']  # because you can't specify width for text
        self.params['letterHeight'] = Param(
            letterHeight,
            valType='num',
            inputType="single",
            allowedTypes=[],
            categ='Formatting',
            updates='constant',
            allowedUpdates=_allow3[:],  # copy the list
            hint=_translate("Specifies the height of the letter (the width"
                            " is then determined by the font)"),
            label=_localized['letterHeight'])

        self.params['wrapWidth'] = Param(
            wrapWidth,
            valType='num',
            inputType="single",
            allowedTypes=[],
            categ='Layout',
            updates='constant',
            allowedUpdates=['constant'],
            hint=_translate("How wide should the text get when it wraps? (in"
                            " the specified units)"),
            label=_localized['wrapWidth'])
        self.params['flip'] = Param(
            flip,
            valType='str',
            inputType="single",
            allowedTypes=[],
            categ='Layout',
            allowedVals=["horiz", "vert", "None"],
            updates='constant',
            allowedUpdates=_allow3[:],  # copy the list
            hint=_translate("horiz = left-right reversed; vert = up-down"
                            " reversed; $var = variable"),
            label=_localized['flip'])
        self.params['languageStyle'] = Param(
            languageStyle,
            valType='str',
            inputType="choice",
            categ='Formatting',
            allowedVals=['LTR', 'RTL', 'Arabic'],
            hint=_translate(
                "Handle right-to-left (RTL) languages and Arabic reshaping"),
            label=_localized['languageStyle'])

        del self.params['fillColor']
        del self.params['borderColor']
Beispiel #26
0
    def __init__(self, exp, parentName, name='pump',
                 startType='time (s)', startVal=0.0,
                 stopType='duration (s)', stopVal=1.0,
                 startEstim='', durationEstim='',
                 pumpIndex=0,
                 syringeType='50 mL glass',
                 pumpAction='dispense',
                 flowRate=1.0,
                 flowRateUnit='mL/s',
                 switchValveWhenDone=True,
                 syncToScreen=True):

        super(QmixPumpComponent, self).__init__(
            exp, parentName, name,
            startType=startType, startVal=startVal,
            stopType=stopType, stopVal=stopVal,
            startEstim=startEstim, durationEstim=durationEstim)

        self.type = 'QmixPump'
        self.url = 'http://www.psychopy.org/builder/components/pump.html'
        self.categories = ['I/O']

        self.exp.requireImport(importName='qmix',
                               importFrom='psychopy.hardware')

        code = ('# Initialize all pumps so they are ready to be used when we\n'
                '# need them later. This enables us to dynamically select\n'
                '# pumps during the experiment without worrying about their\n'
                '# initialization.\n'
                'qmix._init_all_pumps()')
        self.exp.runOnce(code)

        # Order in which the user-settable parameters will be displayed
        # in the component's properties window.
        self.order = ['pumpIndex', 'syringeType', 'pumpAction',
                      'flowRate', 'flowRateUnit', 'switchValveWhenDone',
                      'syncToScreen']

        self.params['pumpIndex'] = Param(
            pumpIndex,
            valType='code',
            hint=_translate('The index of the pump(s) (first pump is 0).'),
            label=_localized['pumpIndex'])

        self.params['syringeType'] = Param(
            syringeType,
            valType='str',
            allowedVals=qmix.syringeTypes,
            hint=_translate('Syringe type and dimensions'),
            label=_localized['syringeType'])

        self.params['pumpAction'] = Param(
            pumpAction,
            valType='str',
            allowedVals=['aspirate', 'dispense'],
            hint=_translate('Whether the syringe should be filled (aspirate) '
                            'or emptied (dispense'),
            label=_localized['pumpAction'])

        self.params['flowRate'] = Param(
            flowRate,
            valType='code',
            hint='The flow rate',
            label=_localized['flowRate'])

        self.params['flowRateUnit'] = Param(
            flowRateUnit,
            valType='str',
            allowedVals=qmix.flowRateUnits,
            hint='The unit of the flow rate',
            label=_localized['flowRateUnit'])

        self.params['switchValveWhenDone'] = Param(
            switchValveWhenDone, valType='bool',
            allowedVals=[True, False],
            hint=_translate('Switch the valve after pump operation'),
            label=_localized['switchValveWhenDone'])

        self.params['syncToScreen'] = Param(
            syncToScreen, valType='bool',
            allowedVals=[True, False],
            hint=_translate('Sync pump onset to the screen refresh'),
            label=_localized['syncToScreen'])
Beispiel #27
0
    def __init__(self,
                 exp,
                 parentName,
                 name='image',
                 image='',
                 mask='None',
                 interpolate='linear',
                 units='from exp settings',
                 color='$[1,1,1]',
                 colorSpace='rgb',
                 pos=(0, 0),
                 size=(0.5, 0.5),
                 ori=0,
                 texRes='128',
                 flipVert=False,
                 flipHoriz=False,
                 startType='time (s)',
                 startVal=0.0,
                 stopType='duration (s)',
                 stopVal=1.0,
                 startEstim='',
                 durationEstim=''):
        super(ImageComponent, self).__init__(exp,
                                             parentName,
                                             name=name,
                                             units=units,
                                             color=color,
                                             colorSpace=colorSpace,
                                             pos=pos,
                                             size=size,
                                             ori=ori,
                                             startType=startType,
                                             startVal=startVal,
                                             stopType=stopType,
                                             stopVal=stopVal,
                                             startEstim=startEstim,
                                             durationEstim=durationEstim)
        self.type = 'Image'
        self.targets = ['PsychoPy', 'PsychoJS']
        self.url = "http://www.psychopy.org/builder/components/image.html"
        self.exp.requirePsychopyLibs(['visual'])
        # params
        # was set by BaseVisual but for this stim it's advanced
        self.params['color'].categ = "Advanced"
        self.params['colorSpace'].categ = "Advanced"
        self.order += ['image', 'pos', 'size', 'ori', 'opacity']

        msg = _translate(
            "The image to be displayed - a filename, including path")
        self.params['image'] = Param(
            image,
            valType='str',
            allowedTypes=[],
            updates='constant',
            allowedUpdates=['constant', 'set every repeat', 'set every frame'],
            hint=msg,
            label=_localized["image"])

        msg = _translate(
            "An image to define the alpha mask through which the image is "
            "seen - gauss, circle, None or a filename (including path)")
        self.params['mask'] = Param(
            mask,
            valType='str',
            allowedTypes=[],
            updates='constant',
            allowedUpdates=['constant', 'set every repeat', 'set every frame'],
            hint=msg,
            label=_localized["mask"],
            categ="Advanced")

        msg = _translate("Resolution of the mask if one is used.")
        self.params['texture resolution'] = Param(
            texRes,
            valType='code',
            allowedVals=['32', '64', '128', '256', '512'],
            updates='constant',
            allowedUpdates=[],
            hint=msg,
            label=_localized["texture resolution"],
            categ="Advanced")

        msg = _translate(
            "How should the image be interpolated if/when rescaled")
        self.params['interpolate'] = Param(interpolate,
                                           valType='str',
                                           allowedVals=['linear', 'nearest'],
                                           updates='constant',
                                           allowedUpdates=[],
                                           hint=msg,
                                           label=_localized["interpolate"],
                                           categ="Advanced")

        msg = _translate(
            "Should the image be flipped vertically (top to bottom)?")
        self.params['flipVert'] = Param(flipVert,
                                        valType='bool',
                                        updates='constant',
                                        allowedUpdates=[],
                                        hint=msg,
                                        label=_localized["flipVert"],
                                        categ="Advanced")

        msg = _translate(
            "Should the image be flipped horizontally (left to right)?")
        self.params['flipHoriz'] = Param(flipHoriz,
                                         valType='bool',
                                         updates='constant',
                                         allowedUpdates=[],
                                         hint=msg,
                                         label=_localized["flipHoriz"],
                                         categ="Advanced")
Beispiel #28
0
    def __init__(self,
                 exp,
                 parentName,
                 name='button_resp',
                 allowedKeys="0,1,2,3,4",
                 store='last key',
                 forceEndRoutine=True,
                 storeCorrect=False,
                 correctAns="",
                 startType='time (s)',
                 startVal=0.0,
                 stopType='duration (s)',
                 stopVal='',
                 startEstim='',
                 durationEstim='',
                 deviceNumber='0',
                 syncScreenRefresh=True):
        super(JoyButtonsComponent, self).__init__(exp,
                                                  parentName,
                                                  name,
                                                  startType=startType,
                                                  startVal=startVal,
                                                  stopType=stopType,
                                                  stopVal=stopVal,
                                                  startEstim=startEstim,
                                                  durationEstim=durationEstim)

        self.type = 'JoyButtons'
        self.url = "http://www.psychopy.org/builder/components/joyButtons.html"
        self.exp.requirePsychopyLibs(['gui'])

        # params

        # NB name and timing params always come 1st
        self.order = [
            'forceEndRoutine', 'allowedKeys', 'store', 'storeCorrect',
            'correctAns', 'deviceNumber'
        ]

        msg = _translate("A comma-separated list of button numbers, such as "
                         "0,1,2,3,4")
        self.params['allowedKeys'] = Param(
            allowedKeys,
            valType='code',
            allowedTypes=[],
            updates='constant',
            allowedUpdates=['constant', 'set every repeat'],
            hint=(msg),
            label=_localized['allowedKeys'])

        msg = _translate("Choose which (if any) responses to store at the "
                         "end of a trial")
        self.params['store'] = Param(
            store,
            valType='str',
            allowedTypes=[],
            allowedVals=['last key', 'first key', 'all keys', 'nothing'],
            updates='constant',
            hint=msg,
            label=_localized['store'])

        msg = _translate("Should a response force the end of the Routine "
                         "(e.g end the trial)?")
        self.params['forceEndRoutine'] = Param(
            forceEndRoutine,
            valType='bool',
            allowedTypes=[],
            updates='constant',
            hint=msg,
            label=_localized['forceEndRoutine'])

        msg = _translate("Do you want to save the response as "
                         "correct/incorrect?")
        self.params['storeCorrect'] = Param(storeCorrect,
                                            valType='bool',
                                            allowedTypes=[],
                                            updates='constant',
                                            hint=msg,
                                            label=_localized['storeCorrect'])

        msg = _translate(
            "What is the 'correct' key? Might be helpful to add a "
            "correctAns column and use $correctAns to compare to the key "
            "press.")
        self.params['correctAns'] = Param(correctAns,
                                          valType='str',
                                          allowedTypes=[],
                                          updates='constant',
                                          hint=msg,
                                          label=_localized['correctAns'])

        msg = _translate(
            "A reaction time to a visual stimulus should be based on when "
            "the screen flipped")
        self.params['syncScreenRefresh'] = Param(
            syncScreenRefresh,
            valType='bool',
            updates='constant',
            hint=msg,
            label=_localized['syncScreenRefresh'])

        msg = _translate("Device number, if you have multiple devices which"
                         " one do you want (0, 1, 2...)")
        self.params['deviceNumber'] = Param(deviceNumber,
                                            valType='code',
                                            allowedTypes=[],
                                            updates='constant',
                                            allowedUpdates=[],
                                            hint=msg,
                                            label=_localized['deviceNumber'],
                                            categ='Advanced')
Beispiel #29
0
    def __init__(self,
                 exp,
                 parentName,
                 name='noise',
                 noiseImage='None',
                 mask='None',
                 sf='None',
                 interpolate='nearest',
                 units='from exp settings',
                 color='$[1,1,1]',
                 colorSpace='rgb',
                 pos=(0, 0),
                 size=(0.5, 0.5),
                 ori=0,
                 phase=0.0,
                 contrast=1.0,
                 texRes='128',
                 noiseType='Binary',
                 noiseElementSize=0.0625,
                 noiseBaseSf=8.0,
                 noiseBW=1,
                 noise_BWO=30,
                 noiseFractalPower=0.0,
                 noiseFilterOrder=0.0,
                 noiseFilterUpper=8.0,
                 noiseFilterLower=1.0,
                 noiseClip=3.0,
                 noiseNewSample='None',
                 noiseNewSampleWhen='1',
                 startType='time (s)',
                 startVal=0.0,
                 stopType='duration (s)',
                 stopVal=1.0,
                 blendmode='avg',
                 startEstim='',
                 durationEstim=''):
        super(NoiseStimComponent, self).__init__(exp,
                                                 parentName,
                                                 name=name,
                                                 units=units,
                                                 color=color,
                                                 colorSpace=colorSpace,
                                                 pos=pos,
                                                 size=size,
                                                 ori=ori,
                                                 startType=startType,
                                                 startVal=startVal,
                                                 stopType=stopType,
                                                 stopVal=stopVal,
                                                 startEstim=startEstim,
                                                 durationEstim=durationEstim)

        #self._noiseNewSample='None'
        self._forceUpdateRepeat = False
        self._forceUpdateFrames = False
        self._forceUpdateSeconds = False

        self.type = 'NoiseStim'
        self.url = "http://www.psychopy.org/builder/components/NoiseStim.html"
        self.order = ['tex', 'mask']

        # params

        msg = _translate(
            "An image from which to derive the frequency spectrum for the noise. Give filename (including path)"
        )
        self.params['noiseImage'] = Param(
            noiseImage,
            valType='str',
            allowedTypes=[],
            updates='constant',
            allowedUpdates=['constant', 'set every repeat', 'set every frame'],
            hint=msg,
            label=_localized['noiseImage'],
            categ="Image noise")

        self.params['ori'] = Param(
            ori,
            valType='code',
            allowedTypes=[],
            updates='constant',
            allowedUpdates=['constant', 'set every repeat', 'set every frame'],
            hint=_translate("Orientation of this stimulus (in deg)"),
            label=_localized['ori'],
            categ="Advanced")

        msg = _translate("An image to define the alpha mask (ie shape)- "
                         "gauss, circle... or a filename (including path)")
        self.params['mask'] = Param(
            mask,
            valType='str',
            allowedTypes=[],
            updates='constant',
            allowedUpdates=['constant', 'set every repeat', 'set every frame'],
            hint=msg,
            label=_localized['mask'],
            categ="Advanced")

        msg = _translate("Michaelson contrast of the image")
        self.params['contrast'] = Param(
            contrast,
            valType='code',
            allowedTypes=[],
            updates='constant',
            allowedUpdates=['constant', 'set every repeat', 'set every frame'],
            hint=msg,
            label=_localized['contrast'],
            categ="Advanced")

        msg = _translate(
            "Final spatial frequency of image in 1 or 2 dimensions, e.g. 4 or [2,3] use None to set to 1 cycle per unit length or 1 cycle per image if units=pix"
        )
        self.params['sf'] = Param(
            sf,
            valType='code',
            allowedTypes=[],
            updates='constant',
            allowedUpdates=['constant', 'set every repeat', 'set every frame'],
            hint=msg,
            label=_localized['sf'],
            categ="Advanced")

        msg = _translate("Spatial positioning of the image  "
                         "(wraps in range 0-1.0)")
        self.params['phase'] = Param(
            phase,
            valType='code',
            allowedTypes=[],
            updates='constant',
            allowedUpdates=['constant', 'set every repeat', 'set every frame'],
            hint=msg,
            label=_localized['phase'],
            categ="Advanced")

        msg = _translate(
            "Resolution of the texture for standard ones such as sin, sqr "
            "etc. For most cases a value of 256 pixels will suffice")
        self.params['texture resolution'] = Param(
            texRes,
            valType='code',
            allowedVals=['32', '64', '128', '256', '512'],
            updates='constant',
            allowedUpdates=[],
            hint=msg,
            label=_localized['texture resolution'],
            categ="Advanced")

        msg = _translate("How should the image be interpolated if/when "
                         "rescaled")
        self.params['interpolate'] = Param(interpolate,
                                           valType='str',
                                           allowedVals=['linear', 'nearest'],
                                           updates='constant',
                                           allowedUpdates=[],
                                           hint=msg,
                                           label=_localized['interpolate'],
                                           categ="Advanced")

        msg = _translate(
            "Type of noise (Binary, Normal, Gabor, Isotropic, White, Coloured, Filtered, Image)"
        )
        self.params['noiseType'] = Param(noiseType,
                                         valType='str',
                                         allowedTypes=[],
                                         allowedVals=[
                                             'Binary', 'Normal', 'Uniform',
                                             'Gabor', 'Isotropic', 'White',
                                             'Filtered', 'Image'
                                         ],
                                         updates='constant',
                                         allowedUpdates=[],
                                         hint=msg,
                                         label=_localized['noiseType'],
                                         categ=" Noise")

        msg = _translate(
            "(Binary, Normal an Uniform only) Size of noise elements")
        self.params['noiseElementSize'] = Param(
            noiseElementSize,
            valType='code',
            allowedTypes=[],
            updates='constant',
            allowedUpdates=['constant', 'set every repeat', 'set every frame'],
            hint=msg,
            label=_localized['noiseElementSize'],
            categ="Binary/Normal/Uniform")

        msg = _translate("Base spatial frequency")
        self.params['noiseBaseSf'] = Param(
            noiseBaseSf,
            valType='code',
            allowedTypes=[],
            updates='constant',
            allowedUpdates=['constant', 'set every repeat', 'set every frame'],
            hint=msg,
            label=_localized['noiseBaseSf'],
            categ="Gabor/Isotropic")

        msg = _translate(
            "Spatial frequency bandwidth in octaves - Full width half height")
        self.params['noiseBW'] = Param(
            noiseBW,
            valType='code',
            allowedTypes=[],
            updates='constant',
            allowedUpdates=['constant', 'set every repeat', 'set every frame'],
            hint=msg,
            label=_localized['noiseBW'],
            categ="Gabor/Isotropic")

        msg = _translate(
            "Orientation bandwidth in degrees (Gabor only) - Full width half height"
        )
        self.params['noiseBWO'] = Param(
            noiseBW,
            valType='code',
            allowedTypes=[],
            updates='constant',
            allowedUpdates=['constant', 'set every repeat', 'set every frame'],
            hint=msg,
            label=_localized['noiseBWO'],
            categ="Gabor/Isotropic")

        msg = _translate(
            "Exponent for spectral slope (A=f^Exponent) of noise negative exponents look nice. -1='pink noise', 0='white noise' (changes the spatial frequency spectrum - does not make the noise colourful)"
        )
        self.params['noiseFractalPower'] = Param(
            noiseFractalPower,
            valType='code',
            allowedTypes=[],
            updates='constant',
            allowedUpdates=['constant', 'set every repeat', 'set every frame'],
            hint=msg,
            label=_localized['noiseFractalPower'],
            categ="Filtered")

        msg = _translate(
            "Order of filter - higher = steeper fall off, zero = no filter")
        self.params['noiseFilterOrder'] = Param(
            noiseFilterOrder,
            valType='code',
            allowedTypes=[],
            updates='constant',
            allowedUpdates=['constant', 'set every repeat', 'set every frame'],
            hint=msg,
            label=_localized['noiseFilterOrder'],
            categ="Filtered")

        msg = _translate("Upper cutoff frequency")
        self.params['noiseFilterUpper'] = Param(
            noiseFilterUpper,
            valType='code',
            allowedTypes=[],
            updates='constant',
            allowedUpdates=['constant', 'set every repeat', 'set every frame'],
            hint=msg,
            label=_localized['noiseFilterUpper'],
            categ="Filtered")

        msg = _translate("Lower cutoff frequency")
        self.params['noiseFilterLower'] = Param(
            noiseFilterLower,
            valType='code',
            allowedTypes=[],
            updates='constant',
            allowedUpdates=['constant', 'set every repeat', 'set every frame'],
            hint=msg,
            label=_localized['noiseFilterLower'],
            categ="Filtered")

        msg = _translate(
            "Truncate high and low values beyound stated standard deviations from mean (not used for binary or uniform noise; scales rather than clips normal noise). The higher this is the lower the final RMS contrast. If low noise may appear binary"
        )
        self.params['noiseClip'] = Param(
            noiseClip,
            valType='code',
            allowedTypes=[],
            updates='constant',
            allowedUpdates=['constant', 'set every repeat', 'set every frame'],
            hint=msg,
            label=_localized['noiseClip'],
            categ=" Noise")

        msg = _translate(
            "How to update noise if not otherwise required by other changes (none, repeat, N-frames, Seconds)"
        )
        self.params['noiseNewSample'] = Param(
            noiseNewSample,
            valType='str',
            allowedVals=['None', 'Repeat', 'N-frames', 'Seconds'],
            updates='constant',
            allowedUpdates=[],
            hint=msg,
            label=_localized['noiseNewSample'],
            categ=" Noise")

        msg = _translate(
            "How often to update noise (in frames or seconds) - can be a variable, ignored if any noise characteristic is updating on every frame"
        )
        self.params['noiseNewSampleWhen'] = Param(
            noiseNewSampleWhen,
            valType='str',
            allowedVals=[],
            updates='constant',
            allowedUpdates=[],
            hint=msg,
            label=_localized['noiseNewSampleWhen'],
            categ=" Noise")

        msg = _translate(
            "OpenGL Blendmode [avg, add (avg is most common mode in PsychoPy, add is used if you want to generate the sum of two components)]"
        )
        self.params['blendmode'] = Param(
            blendmode,
            valType='str',
            allowedVals=['avg', 'add'],
            updates='constant',
            allowedUpdates=['constant', 'set every repeat', 'set every frame'],
            hint=msg,
            label=_localized['blendmode'],
            categ="Basic")
Beispiel #30
0
    def __init__(
            self,
            exp,
            parentName,
            name='form',
            items='.csv',
            textHeight=0.03,
            font="Open Sans",
            randomize=False,
            fillColor='',
            borderColor='',
            itemColor='white',
            responseColor='white',
            markerColor='red',
            size=(1, .7),
            pos=(0, 0),
            style='dark',
            itemPadding=0.05,
            startType='time (s)',
            startVal='0.0',
            stopType='duration (s)',
            stopVal='',
            startEstim='',
            durationEstim='',
            # legacy
            color='white'):

        super(FormComponent, self).__init__(exp,
                                            parentName,
                                            name=name,
                                            pos=pos,
                                            size=size,
                                            color=color,
                                            fillColor=fillColor,
                                            borderColor=borderColor,
                                            startType=startType,
                                            startVal=startVal,
                                            stopType=stopType,
                                            stopVal=stopVal,
                                            startEstim=startEstim,
                                            durationEstim=durationEstim)

        # these are defined by the BaseVisual but we don't want them
        del self.params['ori']
        del self.params['units']  # we only support height units right now
        del self.params['color']

        self.type = 'Form'
        self.url = "https://www.psychopy.org/builder/components/form.html"
        self.exp.requirePsychopyLibs(['visual', 'event', 'logging'])

        # params
        self.order += [
            'Items',
            'Randomize',  # Basic tab
            'Data Format',  # Data tab
        ]
        self.order.insert(self.order.index("units"), "Item Padding")

        # normal params:
        # = the usual as inherited from BaseComponent plus:

        self.params['Items'] = Param(
            items,
            valType='file',
            inputType="table",
            allowedTypes=[],
            categ='Basic',
            updates='constant',
            hint=_translate(
                "The csv filename containing the items for your survey."),
            label=_localized['Items'])

        self.params['Text Height'] = Param(
            textHeight,
            valType='num',
            inputType="single",
            allowedTypes=[],
            categ='Formatting',
            updates='constant',
            hint=_translate("The size of the item text for Form"),
            label=_localized['Text Height'])

        self.params['Font'] = Param(
            font,
            valType='str',
            inputType="single",
            allowedTypes=[],
            categ='Formatting',
            updates='constant',
            allowedUpdates=["constant"],
            hint=_translate("The font name (e.g. Comic Sans)"),
            label=_translate('Font'))

        self.params['Randomize'] = Param(
            randomize,
            valType='bool',
            inputType="bool",
            allowedTypes=[],
            categ='Basic',
            updates='constant',
            hint=_translate(
                "Do you want to randomize the order of your questions?"),
            label=_localized['Randomize'])

        self.params['Item Padding'] = Param(
            itemPadding,
            valType='num',
            inputType="single",
            allowedTypes=[],
            categ='Layout',
            updates='constant',
            hint=_translate("The padding or space between items."),
            label=_localized['Item Padding'])

        self.params['Data Format'] = Param(
            'rows',
            valType='str',
            inputType="choice",
            allowedTypes=[],
            categ='Basic',
            allowedVals=['columns', 'rows'],
            updates='constant',
            hint=_translate("Store item data by columns, or rows"),
            label=_localized['Data Format'])

        # Appearance
        for param in [
                'fillColor', 'borderColor', 'itemColor', 'responseColor',
                'markerColor', 'Style'
        ]:
            if param in self.order:
                self.order.remove(param)
            self.order.insert(self.order.index("colorSpace"), param)

        self.params['Style'] = Param(
            style,
            valType='str',
            inputType="choice",
            categ="Appearance",
            updates='constant',
            allowedVals=knownStyles + ["custom..."],
            hint=_translate("Styles determine the appearance of the form"),
            label=_localized['Style'])

        for param in [
                'fillColor', 'borderColor', 'itemColor', 'responseColor',
                'markerColor'
        ]:
            self.depends += [{
                "dependsOn": "Style",  # must be param name
                "condition": "=='custom...'",  # val to check for
                "param": param,  # param property to alter
                "true": "enable",  # what to do with param if condition is True
                "false": "disable",  # permitted: hide, show, enable, disable
            }]

        self.params['fillColor'].hint = _translate(
            "Color of the form's background")

        self.params['borderColor'].hint = _translate(
            "Color of the outline around the form")

        self.params['itemColor'] = Param(
            itemColor,
            valType='color',
            inputType="color",
            categ='Appearance',
            updates='constant',
            allowedUpdates=['constant', 'set every repeat', 'set every frame'],
            hint=_translate("Base text color for questions"),
            label=_translate("Item Color"))

        self.params['responseColor'] = Param(
            responseColor,
            valType='color',
            inputType="color",
            categ='Appearance',
            updates='constant',
            allowedUpdates=['constant', 'set every repeat', 'set every frame'],
            hint=_translate(
                "Base text color for responses, also sets color of lines in sliders and borders of textboxes"
            ),
            label=_translate("Response Color"))

        self.params['markerColor'] = Param(
            markerColor,
            valType='color',
            inputType="color",
            categ='Appearance',
            updates='constant',
            allowedUpdates=['constant', 'set every repeat', 'set every frame'],
            hint=_translate("Color of markers and the scrollbar"),
            label=_translate("Marker Color"))

        self.params['pos'].allowedUpdates = []
        self.params['size'].allowedUpdates = []