def __init__(self, exp, parentName, name='mouse', startType='time (s)', startVal=0.0, stopType='duration (s)', stopVal=1.0, startEstim='', durationEstim='', save='final',forceEndRoutineOnPress=True, timeRelativeTo='routine'): super(MouseComponent, self).__init__(exp, parentName, name=name, startType=startType, startVal=startVal, stopType=stopType, stopVal=stopVal, startEstim=startEstim, durationEstim=durationEstim) self.type='Mouse' self.url="http://www.psychopy.org/builder/components/mouse.html" self.exp.requirePsychopyLibs(['event']) self.categories=['Inputs'] #params self.params['saveMouseState']=Param(save, valType='str', allowedVals=['final','on click', 'every frame', 'never'], hint=_translate("How often should the mouse state (x,y,buttons) be stored? On every video frame, every click or just at the end of the Routine?"), label=_localized['saveMouseState']) self.params['forceEndRoutineOnPress']=Param(forceEndRoutineOnPress, valType='bool', allowedTypes=[], updates='constant', allowedUpdates=[], hint=_translate("Should a button press force the end of the routine (e.g end the trial)?"), label=_localized['forceEndRoutineOnPress']) self.params['timeRelativeTo']=Param(timeRelativeTo, valType='str', allowedVals=['experiment','routine'], updates='constant', allowedUpdates=[], hint=_translate("What should the values of mouse.time should be relative to?"), label=_localized['timeRelativeTo'])
def __init__(self, exp, parentName, name="loop_type"): super(LoopTypeComponent, self).__init__(exp, parentName, name) self.params["function_name"] = Param(name, valType="str", label="function name") self.params["Begin Experiment"] = Param("", valType="code", label="Begin Experiment") self.order = ["name", "function_name", "Begin Experiment"]
def __init__(self, exp, parentName, name=''): self.type='Base' self.exp=exp#so we can access the experiment if necess self.parentName=parentName#to access the routine too if needed self.params={} self.params['name']=Param(name, valType='code', hint="Name of this component") self.order=['name']#make name come first (others don't matter)
def __init__(self, exp, parentName, name='mouse', startType='time (s)', startVal=0.0, stopType='duration (s)', stopVal=1.0, startEstim='', durationEstim='', save='final',forceEndRoutineOnPress=True, timeRelativeTo='routine'): self.type='Mouse' self.url="http://www.psychopy.org/builder/components/mouse.html" self.parentName=parentName self.exp=exp#so we can access the experiment if necess self.exp.requirePsychopyLibs(['event']) self.categories=['Inputs'] #params self.params={} self.order=[] self.params['name']=Param(name, valType='code', allowedTypes=[], hint="Even mice need names!", label="Name") self.params['startType']=Param(startType, valType='str', allowedVals=['time (s)', 'frame N', 'condition'], hint="How do you want to define your start point?") self.params['stopType']=Param(stopType, valType='str', allowedVals=['duration (s)', 'duration (frames)', 'time (s)', 'frame N', 'condition'], hint="How do you want to define your end point?") self.params['startVal']=Param(startVal, valType='code', allowedTypes=[], hint="When does the mouse start being checked?") self.params['stopVal']=Param(stopVal, valType='code', allowedTypes=[], updates='constant', allowedUpdates=[], hint="When does the mouse stop being checked?") self.params['startEstim']=Param(startEstim, valType='code', allowedTypes=[], hint="(Optional) expected start (s), purely for representing in the timeline") self.params['durationEstim']=Param(durationEstim, valType='code', allowedTypes=[], hint="(Optional) expected duration (s), purely for representing in the timeline") self.params['saveMouseState']=Param(save, valType='str', allowedVals=['final','on click', 'every frame', 'never'], hint="How often should the mouse state (x,y,buttons) be stored? On every video frame, every click or just at the end of the Routine?", label="Save mouse state") self.params['forceEndRoutineOnPress']=Param(forceEndRoutineOnPress, valType='bool', allowedTypes=[], updates='constant', allowedUpdates=[], hint="Should a button press force the end of the routine (e.g end the trial)?", label="End Routine on press") self.params['timeRelativeTo']=Param(timeRelativeTo, valType='str', allowedVals=['experiment','routine'], updates='constant', allowedUpdates=[], hint="What should the values of mouse.time should be relative to?", label="Time relative to")
def __init__(self, exp, parentName, name='ISI', startType='time (s)', startVal=0.0, stopType='duration (s)', stopVal=0.5, startEstim='', durationEstim=''): _base.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" self.params['code'] = Param( "", valType='code', hint=_( "Custom code to be run during the static period (after updates)" ), label=_localized['Custom code']) self.order = ['name'] #make name come first (others don't matter) self.params['startType'] = Param( startType, valType='str', allowedVals=['time (s)', 'frame N'], hint=_("How do you want to define your start point?")) self.params['stopType'] = Param( stopType, valType='str', allowedVals=[ 'duration (s)', 'duration (frames)', 'time (s)', 'frame N' ], hint=_("How do you want to define your end point?")) self.params['startVal'] = Param( startVal, valType='code', allowedTypes=[], hint=_("When does the component start?")) self.params['stopVal'] = Param( stopVal, valType='code', allowedTypes=[], updates='constant', allowedUpdates=[], hint=_("When does the component end? (blank is endless)")) self.params['startEstim'] = Param( startEstim, valType='code', allowedTypes=[], hint= _("(Optional) expected start (s), purely for representing in the timeline" )) self.params['durationEstim'] = Param( durationEstim, valType='code', allowedTypes=[], hint= _("(Optional) expected duration (s), purely for representing in the timeline" ))
def __init__(self, exp, parentName, name='', startTime=0.0, duration=1.0): self.type = 'Base' self.exp = exp #so we can access the experiment if necess self.params = {} self.params['name'] = Param(name, valType='code', hint="Name of this component") self.order = ['name', 'startTime', 'duration'] #make name come first (others don't matter)
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.params['name'] = Param( name, valType='code', hint=_translate( "Name of this component (alpha-numeric or _, no spaces)"), label=_localized['name']) self.order = ['name'] # name first, then timing, then others
def __init__(self, exp, parentName, name='mouse', startTime=0.0, duration='', save='final', forceEndTrialOnPress=True, timeRelativeTo='routine'): self.type='Mouse' self.url="http://www.psychopy.org/builder/components/mouse.html" self.exp=exp#so we can access the experiment if necess self.exp.requirePsychopyLibs(['event']) #params self.order = ['name', 'startTime','duration']#make sure that 'name' is at top of dlg self.params={} self.params['name']=Param(name, valType='code', allowedTypes=[], hint="Even mice have names!") self.params['startTime']=Param(startTime, valType='code', allowedTypes=[], updates='constant', allowedUpdates=[], hint="The time that the mouse starts being checked") self.params['duration']=Param(duration, valType='code', allowedTypes=[], updates='constant', allowedUpdates=[], hint="The duration during which the mouse is checked") self.params['saveMouseState']=Param(save, valType='str', allowedVals=['final','on click', 'every frame', 'never'], hint="How often should the mouse state (x,y,buttons) be stored? On every video frame, every click or just at the end of the Routine?") self.params['forceEndTrialOnPress']=Param(forceEndTrialOnPress, valType='bool', allowedTypes=[], updates='constant', allowedUpdates=[], hint="Should a button press force the end of the routine (e.g end the trial)?") self.params['timeRelativeTo']=Param(timeRelativeTo, valType='str', allowedVals=['experiment','routine'], updates='constant', allowedUpdates=[], hint="What should the values of mouse.time should be relative to?")
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="http://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 #standard params (can ignore) self.params['name']=Param(name, valType='code', allowedTypes=[], hint=_translate("Name of this component (alpha-numeric or _, no spaces)"), label="Name") self.params['startType']=Param(startType, valType='str', allowedVals=['time (s)', 'frame N', 'condition'], hint=_translate("How do you want to define your start point?")) self.params['stopType']=Param(stopType, valType='str', allowedVals=['duration (s)', 'duration (frames)', 'time (s)', 'frame N', 'condition'], hint=_translate("How do you want to define your end point?")) self.params['startVal']=Param(startVal, valType='code', allowedTypes=[], hint=_translate("When does the component start?")) self.params['stopVal']=Param(stopVal, valType='code', allowedTypes=[], updates='constant', allowedUpdates=[], hint=_translate("When does the component end? (blank is endless)")) self.params['startEstim']=Param(startEstim, valType='code', allowedTypes=[], hint=_translate("(Optional) expected start (s), purely for representing in the timeline")) self.params['durationEstim']=Param(durationEstim, valType='code', allowedTypes=[], hint=_translate("(Optional) expected duration (s), purely for representing in the timeline")) #useful params for the eyetracker - keep to a minimum if possible! ;-) self.params['Config file'] = Param(configFile, valType='str', hint=_translate("How do you want to define your start point?")) self.params['saveState']=Param(save, valType='str', allowedVals=['final', 'every frame', 'never'], hint=_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?"), label="Save eyetracker state")
def __init__(self, exp, parentName, name='code', beginExp="", beginRoutine="", eachFrame="", endRoutine="", endExperiment=""): self.type = 'Code' self.url = "http://www.psychopy.org/builder/components/code.html" self.exp = exp #so we can access the experiment if necess #params self.order = [ 'name', 'Begin Experiment', 'Begin Routine', 'Each Frame', 'End Routine', 'End Experiment' ] #make sure that 'name' is at top of dlg self.params = {} self.params['name'] = Param( name, valType='code', allowedTypes=[], hint= "This name does not actually need to be independent of the others." ) self.params['Begin Experiment'] = Param( beginExp, valType='code', allowedTypes=[], updates='constant', allowedUpdates=[], hint="Code at the start of the experiment (initialization)") self.params['Begin Routine'] = Param( beginRoutine, valType='code', allowedTypes=[], updates='constant', allowedUpdates=[], hint= "Code to be run at the start of each repeat of the Routine (e.g. each trial)" ) self.params['Each Frame'] = Param( eachFrame, valType='code', allowedTypes=[], updates='constant', allowedUpdates=[], hint= "Code to be run on every video frame during for the duration of this Routine" ) self.params['End Routine'] = Param( endRoutine, valType='code', allowedTypes=[], updates='constant', allowedUpdates=[], hint= "Code at the end of this repeat of the Routine (e.g. getting/storing responses)" ) self.params['End Experiment'] = Param( endRoutine, valType='code', allowedTypes=[], updates='constant', allowedUpdates=[], hint= "Code at the end of the entire experiment (e.g. saving files, resetting computer)" )
def __init__(self, exp, parentName, name='rating', scaleDescription='', categoryChoices='', visualAnalogScale=False, low=1, high=7, size=1.0, pos='0, -0.4', startTime=0, duration='', forceEndTrial=True, storeRating=True, storeRatingTime=True, lowAnchorText='', highAnchorText='', customize_everything=''): self.type = 'RatingScale' self.url = "http://www.psychopy.org/builder/components/ratingscale.html" self.exp = exp self.exp.requirePsychopyLibs(['visual', 'event']) #params self.order = [ 'name', 'visualAnalogScale', 'categoryChoices', 'scaleDescription', 'low', 'high', 'size' ] self.params = {} self.params['advancedParams'] = [ 'startTime', 'forceEndTrial', 'size', 'pos', 'duration', 'storeRatingTime', 'storeRating', 'lowAnchorText', 'highAnchorText', 'customize_everything' ] # normal params: self.params['name'] = Param( name, valType='code', allowedTypes=[], hint= "A rating scale only collects the response; it does not display the stimulus to be rated." ) self.params['visualAnalogScale'] = Param( visualAnalogScale, valType='bool', allowedTypes=[], updates='constant', allowedUpdates=[], hint= "Show a continuous visual analog scale; returns 0.00 to 1.00; takes precedence over numeric scale or categorical choices" ) self.params['categoryChoices'] = Param( categoryChoices, valType='str', allowedTypes=[], updates='constant', allowedUpdates=[], hint= "A list of categories (non-numeric alternatives) to present, space or comma-separated; these take precedence over a numeric scale" ) self.params['scaleDescription'] = Param( scaleDescription, valType='str', allowedTypes=[], updates='constant', allowedUpdates=[], hint= "Brief instructions, such as a description of the scale numbers as seen by the subject." ) self.params['low'] = Param( low, valType='code', allowedTypes=[], updates='constant', allowedUpdates=[], hint= "Lowest rating (low end of the scale); not used for categories.") self.params['high'] = Param( high, valType='code', allowedTypes=[], updates='constant', allowedUpdates=[], hint= "Highest rating (top end of the scale); not used for categories.") # advanced params: self.params['size'] = Param( size, valType='code', allowedTypes=[], updates='constant', allowedUpdates=[], hint= "Relative size on the screen; size > 1 is larger than default; size < 1 is smaller" ) self.params['storeRating'] = Param(storeRating, valType='bool', allowedTypes=[], updates='constant', allowedUpdates=[], hint="store the rating") self.params['storeRatingTime'] = Param( storeRatingTime, valType='bool', allowedTypes=[], updates='constant', allowedUpdates=[], hint="store the time taken to make the choice (in seconds)") self.params['pos'] = Param(pos, valType='str', allowedTypes=[], updates='constant', allowedUpdates=[], hint="x,y position on the screen") self.params['duration'] = Param( duration, valType='code', allowedTypes=[], updates='constant', allowedUpdates=[], hint= "How many seconds to wait for a response; leave blank for 'forever'" ) self.params['forceEndTrial'] = Param( forceEndTrial, valType='bool', allowedTypes=[], updates='constant', allowedUpdates=[], hint= "Should accepting a rating cause the end of the routine (e.g. trial)?" ) self.params['lowAnchorText'] = Param( lowAnchorText, valType='str', allowedTypes=[], updates='constant', allowedUpdates=[], hint="Description of the low end of the scale") self.params['highAnchorText'] = Param( highAnchorText, valType='str', allowedTypes=[], updates='constant', allowedUpdates=[], hint="Description of the high end of the scale") self.params['customize_everything'] = Param( customize_everything, valType='str', allowedTypes=[], updates='constant', allowedUpdates=[], hint= "Use this text to create the rating scale as you would in a code component; OVERRIDES ALL other settings" ) # required (?) self.params['startTime'] = Param(0.0, valType='code', allowedTypes=[], updates='constant', allowedUpdates=[], hint="")
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.general['parallelPorts'] + [u'LabJack U3'] if not address: address = addressOptions[0] self.params['address'] = Param( address, valType='str', allowedVals=addressOptions, hint=_translate( "Parallel port to be used (you can change these options in preferences>general)" ), 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']) self.params['syncScreen'] = Param( syncScreen, valType='bool', allowedVals=[True, False], updates='constant', allowedUpdates=[], hint=_translate( "If the parallel port data relates to visual stimuli then sync its pulse to the screen refresh" ), label=_localized['syncScreen'])
def __init__(self, exp, parentName, name='rating', scaleDescription='', categoryChoices='', visualAnalogScale=False, low='1', high='7', singleClick=False, showAccept=True, labels='', size='1.0', tickHeight='', pos='0, -0.4', startType='time (s)', startVal='0.0', stopType='condition', stopVal='', startEstim='', durationEstim='', forceEndRoutine=True, disappear=False, marker='triangle', markerStart='', storeRating=True, storeRatingTime=True, storeHistory=False, customize_everything=''): super(RatingScaleComponent, self).__init__(exp, parentName, name, startType=startType, startVal=startVal, stopType=stopType, stopVal=stopVal, startEstim=startEstim, durationEstim=durationEstim) self.type = 'RatingScale' self.url = "http://www.psychopy.org/builder/components/ratingscale.html" self.exp.requirePsychopyLibs(['visual', 'event']) #params self.order = [ 'name', 'visualAnalogScale', 'categoryChoices', 'scaleDescription', 'low', 'high', 'labels', 'markerStart', 'size', 'pos', 'tickHeight' ] # normal params: # = the usual as inherited from BaseVisual plus: self.params['visualAnalogScale'] = Param( visualAnalogScale, valType='bool', allowedTypes=[], updates='constant', allowedUpdates=[], hint=_translate( "Show a continuous visual analog scale; returns 0.00 to 1.00; takes precedence over numeric scale or categorical choices" ), label=_localized['visualAnalogScale']) self.params['categoryChoices'] = Param( categoryChoices, valType='str', allowedTypes=[], updates='constant', allowedUpdates=[], hint=_translate( "A list of categories (non-numeric alternatives) to present, space or comma-separated; these take precedence over a numeric scale" ), label=_localized['categoryChoices']) self.params['scaleDescription'] = Param( scaleDescription, valType='str', allowedTypes=[], updates='constant', allowedUpdates=[], hint=_translate( "Brief instructions, such as a description of the scale numbers as seen by the subject." ), label=_localized['scaleDescription']) self.params['low'] = Param( low, valType='code', allowedTypes=[], updates='constant', allowedUpdates=[], hint=_translate( "Lowest rating (low end of the scale); not used for categories." ), label=_localized['low']) self.params['high'] = Param( high, valType='code', allowedTypes=[], updates='constant', allowedUpdates=[], hint=_translate( "Highest rating (top end of the scale); not used for categories." ), label=_localized['high']) self.params['labels'] = Param( labels, valType='str', allowedTypes=[], updates='constant', allowedUpdates=[], #categ="Advanced", hint=_translate( "Labels for the ends of the scale, separated by commas"), label=_localized['labels']) self.params['marker'] = Param( marker, valType='str', allowedTypes=[], updates='constant', allowedUpdates=[], #categ="Advanced", hint=_translate( "Style for the marker: triangle, circle, glow, slider, hover"), label=_localized['marker']) self.params['markerStart'] = Param( markerStart, valType='str', allowedTypes=[], updates='constant', allowedUpdates=[], #categ="Advanced", hint=_translate("initial position for the marker"), label=_localized['markerStart']) # advanced params: self.params['singleClick'] = Param( singleClick, valType='bool', allowedTypes=[], updates='constant', allowedUpdates=[], categ="Advanced", hint=_translate( "Should clicking the line accept that rating (without needing to confirm via 'accept')?" ), label=_localized['singleClick']) self.params['disappear'] = Param( disappear, valType='bool', allowedTypes=[], updates='constant', allowedUpdates=[], categ="Advanced", hint=_translate( "Hide the scale when a rating has been accepted; False to remain on-screen" ), label=_localized['disappear']) self.params['showAccept'] = Param( showAccept, valType='bool', allowedTypes=[], updates='constant', allowedUpdates=[], categ="Advanced", hint=_translate("Should the accept button by visible?"), label=_localized['showAccept']) self.params['storeRating'] = Param(storeRating, valType='bool', allowedTypes=[], updates='constant', allowedUpdates=[], categ="Advanced", hint=_translate("store the rating"), label=_localized['storeRating']) self.params['storeRatingTime'] = Param( storeRatingTime, valType='bool', allowedTypes=[], updates='constant', allowedUpdates=[], categ="Advanced", hint=_translate( "store the time taken to make the choice (in seconds)"), label=_localized['storeRatingTime']) self.params['storeHistory'] = Param( storeHistory, valType='bool', allowedTypes=[], updates='constant', allowedUpdates=[], categ="Advanced", hint=_translate("store the history of (selection, time)"), label=_localized['storeHistory']) self.params['forceEndRoutine'] = Param( forceEndRoutine, valType='bool', allowedTypes=[], updates='constant', allowedUpdates=[], categ="Advanced", hint=_translate( "Should accepting a rating cause the end of the routine (e.g. trial)?" ), label=_localized['forceEndRoutine']) self.params['size'] = Param( size, valType='code', allowedTypes=[], updates='constant', allowedUpdates=[], categ="Advanced", hint=_translate( "Relative size on the screen; size > 1 is larger than default; size < 1 is smaller" ), label=_localized['size']) self.params['tickHeight'] = Param( tickHeight, valType='str', allowedTypes=[], updates='constant', allowedUpdates=[], categ="Advanced", hint=_translate( "height of tick marks (1 is upward, 0 is hidden, -1 is downward)" ), label=_localized['tickHeight']) self.params['pos'] = Param( pos, valType='str', allowedTypes=[], updates='constant', allowedUpdates=[], categ="Advanced", hint=_translate("x,y position on the screen"), label=_localized['pos']) # customization: self.params['customize_everything'] = Param( customize_everything, valType='str', allowedTypes=[], updates='constant', allowedUpdates=[], categ="Custom", hint=_translate( "Use this text to create the rating scale as you would in a code component; overrides all" " dialog settings except time parameters, forceEndRoutine, storeRatingTime, storeRating" ), label=_localized['customize_everything'])
def __init__(self, exp, parentName, name="haptic", startType="time (s)", startVal=0.0, stopType="duration (s)", stopVal=1.0, startEstim="", durationEstim=1.0): self.type = "Haptic stimulation" self.exp = exp self.parentName = parentName self.params = { "name": Param(name, valType="code", hint="A name for this object", label="Name"), "startType": Param(startType, valType="str", allowedVals=["time (s)", "frame N", "condition"], hint="How to specify the start time", label=""), "stopType": Param(stopType, valType="str", allowedVals=[ 'duration (s)', 'duration (frames)', 'time (s)', 'frame N', 'condition' ], hint="How duration is defined"), "startVal": Param(startVal, valType="code", allowedTypes=[], hint="Time of appliance timestamp"), "stopVal": Param(stopVal, allowedVals=[1], valType="code", allowedTypes=[], updates='constant', allowedUpdates=[], hint="One-shot"), "startEstim": Param( startEstim, valType='code', allowedTypes=[], hint= "(Optional) expected start (s), purely for representing in the timeline" ), "durationEstim": Param(durationEstim, valType="code", allowedVals=[0.02], allowedTypes=[], hint="One-shot"), "channel": Param('1', valType="code", allowedTypes=[], updates='set every repeat', hint="Index of active channel for haptic stimulator", label="haptic channel"), } self.order = ["channel"]
def __init__(self, exp, parentName, name='', startType='time (s)', startVal='', stopType='duration (s)', stopVal='', startEstim='', durationEstim=''): self.type = 'Base' self.exp = exp #so we can access the experiment if necess self.parentName = parentName #to access the routine too if needed self.params = {} self.params['name'] = Param( name, valType='code', hint=_translate( "Name of this component (alpha-numeric or _, no spaces)"), label=_localized['name']) self.params['startType'] = Param( startType, valType='str', allowedVals=['time (s)', 'frame N', 'condition'], hint=_translate("How do you want to define your start point?"), label=_localized['startType']) self.params['stopType'] = Param( stopType, valType='str', allowedVals=[ 'duration (s)', 'duration (frames)', 'time (s)', 'frame N', 'condition' ], hint=_translate("How do you want to define your end point?"), label=_localized['stopType']) self.params['startVal'] = Param( startVal, valType='code', allowedTypes=[], hint=_translate("When does the component start?"), label=_localized['startVal']) self.params['stopVal'] = Param( stopVal, valType='code', allowedTypes=[], updates='constant', allowedUpdates=[], hint=_translate("When does the component end? (blank is endless)"), label=_localized['stopVal']) self.params['startEstim'] = Param( startEstim, valType='code', allowedTypes=[], hint=_translate( "(Optional) expected start (s), purely for representing in the timeline" ), label=_localized['startEstim']) self.params['durationEstim'] = Param( durationEstim, valType='code', allowedTypes=[], hint=_translate( "(Optional) expected duration (s), purely for representing in the timeline" ), label=_localized['durationEstim']) self.order = ['name'] # name first, then timing, then others
def __init__(self, exp, parentName, name='code', beginExp="", beginRoutine="", eachFrame="", endRoutine="", endExperiment=""): super(CodeComponent, self).__init__(exp, parentName, name) self.type = 'Code' self.url = "http://www.psychopy.org/builder/components/code.html" #params self.order = [ 'name', 'Begin Experiment', 'Begin Routine', 'Each Frame', 'End Routine', 'End Experiment' ] # want a copy, else codeParamNames list gets mutated self.params['Begin Experiment'] = Param( beginExp, valType='extendedCode', allowedTypes=[], updates='constant', allowedUpdates=[], hint=_translate( "Code at the start of the experiment (initialization); right-click checks syntax" ), label=_localized['Begin Experiment']) self.params['Begin Routine'] = Param( beginRoutine, valType='extendedCode', allowedTypes=[], updates='constant', allowedUpdates=[], hint=_translate( "Code to be run at the start of each repeat of the Routine (e.g. each trial); right-click checks syntax" ), label=_localized['Begin Routine']) self.params['Each Frame'] = Param( eachFrame, valType='extendedCode', allowedTypes=[], updates='constant', allowedUpdates=[], hint=_translate( "Code to be run on every video frame during for the duration of this Routine; right-click checks syntax" ), label=_localized['Each Frame']) self.params['End Routine'] = Param( endRoutine, valType='extendedCode', allowedTypes=[], updates='constant', allowedUpdates=[], hint=_translate( "Code at the end of this repeat of the Routine (e.g. getting/storing responses); right-click checks syntax" ), label=_localized['End Routine']) self.params['End Experiment'] = Param( endRoutine, valType='extendedCode', allowedTypes=[], updates='constant', allowedUpdates=[], hint=_translate( "Code at the end of the entire experiment (e.g. saving files, resetting computer); right-click checks syntax" ), label=_localized['End Experiment']) # these inherited params are harmless but might as well trim: for p in [ 'startType', 'startVal', 'startEstim', 'stopVal', 'stopType', 'durationEstim' ]: del self.params[p]
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): self.type = 'ParallelOut' self.url = "http://www.psychopy.org/builder/components/parallelout.html" self.parentName = parentName self.exp = exp #so we can access the experiment if necess self.categories = ['I/O'] self.exp.requirePsychopyLibs(['parallel']) #params self.params = {} self.order = ['address', 'startData', 'stopData'] self.params['name'] = Param(name, valType='code', allowedTypes=[], hint="Everything needs a name", label="Name") self.params['startType'] = Param( startType, valType='str', allowedVals=['time (s)', 'frame N', 'condition'], hint="How do you want to define your start point?") self.params['stopType'] = Param( stopType, valType='str', allowedVals=[ 'duration (s)', 'duration (frames)', 'time (s)', 'frame N', 'condition' ], hint="How do you want to define your end point?") self.params['startVal'] = Param( startVal, valType='code', allowedTypes=[], hint="When does the 'start' data get sent?") self.params['stopVal'] = Param( stopVal, valType='code', allowedTypes=[], updates='constant', allowedUpdates=[], hint="When does the 'end' data get sent?") self.params['startEstim'] = Param( startEstim, valType='code', allowedTypes=[], hint= "(Optional) expected start (s), purely for representing in the timeline" ) self.params['durationEstim'] = Param( durationEstim, valType='code', allowedTypes=[], hint= "(Optional) expected duration (s), purely for representing in the timeline" ) #main parameters addressOptions = prefs.general['parallelPorts'] self.params['address'] = Param( address, valType='str', allowedVals=addressOptions, hint= "Parallel port to be used (you can change these options in preferences>general)" ) self.params['startData'] = Param(startData, valType='code', allowedTypes=[], hint="Data to be sent at 'start'") self.params['stopData'] = Param(stopData, valType='code', allowedTypes=[], hint="Data to be sent at 'end'") self.params['syncScreen'] = Param( syncScreen, valType='bool', allowedVals=[True, False], updates='constant', allowedUpdates=[], hint= "If the parallel port data relates to visual stimuli then sync its pulse to the screen refresh", label="Sync to screen")
def param(self, name, val, valType='code', hint=None, label=None, updates='constant', categ="Basic", dropdownVals=None, dropdownTypes=None, dropdownUpdates=None, readOnly=False): ''' name the param name val the value for the param valType='code' ('num','str','code','bool') how to interpret the value hint=name simple description label=name name presented in settings dialog categ="Basic" don't know, unused by me updates='constant' when is the param value updated ('constant','experiment', 'routine', 'set every frame') dropdownVals=None provide a sequence of valid values to restrict given vals to those vals (and provide dropdown list to choose from) dropdownTypes=None "if other types are allowed then this is the possible types this parameter can have (e.g. rgb can be 'red' or [1,0,1])" dropdown list of valid options if provided dropdownUpdates=None dropdown options for valid update settings ['constant', 'routine', 'set every frame']. Supply True to have it filled with the common types. ''' if dropdownTypes: allowedTypes = dropdownTypes else: allowedTypes = [] if dropdownVals: allowedVals = dropdownVals else: allowedVals = [] if dropdownUpdates is True: allowedUpdates = [ 'constant', 'experiment', 'routine', 'set every frame' ] elif dropdownUpdates: allowedUpdates = dropdownUpdates else: allowedUpdates = [] if label is None: label = name if hint is None: hint = name label = translate(label) hint = translate(hint) param = Param(val, valType=valType, allowedVals=allowedVals, allowedTypes=allowedTypes, updates=updates, allowedUpdates=allowedUpdates, hint=hint, label=label, categ=categ) param.readOnly = readOnly self.params[name] = param self.order.append(name)
def __init__(self, exp, parentName, name="pool", resources=None): super(ResourcePoolComponent, self).__init__(exp, parentName, name) del self.params["name"] if resources is None: resources = {} self.params["resources"] = Param(resources, "resources")
def __init__(self, exp, parentName, name='code', beginExp="", beginRoutine="", eachFrame="", endRoutine="", endExperiment=""): self.type = 'Code' self.url = "http://www.psychopy.org/builder/components/code.html" self.exp = exp #so we can access the experiment if necess #params self.categories = ['misc'] self.order = [ 'name', 'Begin Experiment', 'Begin Routine', 'Each Frame', 'End Routine', 'End Experiment' ] # want a copy, else codeParamNames list gets mutated self.params = {} self.params['name'] = Param( name, valType='code', allowedTypes=[], hint="", label="Name" ) #This name does not actually need to be independent of the others. self.params['Begin Experiment'] = Param( beginExp, valType='extendedCode', allowedTypes=[], updates='constant', allowedUpdates=[], hint= "Code at the start of the experiment (initialization); right-click checks syntax" ) self.params['Begin Routine'] = Param( beginRoutine, valType='extendedCode', allowedTypes=[], updates='constant', allowedUpdates=[], hint= "Code to be run at the start of each repeat of the Routine (e.g. each trial); right-click checks syntax" ) self.params['Each Frame'] = Param( eachFrame, valType='extendedCode', allowedTypes=[], updates='constant', allowedUpdates=[], hint= "Code to be run on every video frame during for the duration of this Routine; right-click checks syntax" ) self.params['End Routine'] = Param( endRoutine, valType='extendedCode', allowedTypes=[], updates='constant', allowedUpdates=[], hint= "Code at the end of this repeat of the Routine (e.g. getting/storing responses); right-click checks syntax" ) self.params['End Experiment'] = Param( endRoutine, valType='extendedCode', allowedTypes=[], updates='constant', allowedUpdates=[], hint= "Code at the end of the entire experiment (e.g. saving files, resetting computer); right-click checks syntax" )
def __init__(self, parentName, name='', units='window units', color='$[1,1,1]', pos=[0, 0], size=[0, 0], ori=0, startTime=0.0, duration='', colorSpace='rgb'): self.psychopyLibs = ['visual'] #needs this psychopy lib to operate self.order = ['name', 'startTime', 'duration'] #make name come first (others don't matter) self.params = {} self.params['name'] = Param(name, valType='code', updates='constant', hint="Name of this stimulus") self.params['units'] = Param( units, valType='str', allowedVals=['window units', 'deg', 'cm', 'pix', 'norm'], hint="Units of dimensions for this stimulus") self.params['color'] = Param( color, valType='str', allowedTypes=[], updates='constant', allowedUpdates=['constant', 'set every repeat', 'set every frame'], hint="Color of this stimulus (e.g. $[1,1,0], red )") self.params['colorSpace'] = Param( colorSpace, valType='str', allowedVals=['rgb', 'dkl', 'lms'], updates='constant', allowedUpdates=['constant'], hint="Choice of color space for the color (rgb, dkl, lms)") self.params['pos'] = Param( pos, valType='code', allowedTypes=[], updates='constant', allowedUpdates=['constant', 'set every repeat', 'set every frame'], hint="Position of this stimulus (e.g. [1,2] ") self.params['size'] = Param( size, valType='code', allowedTypes=[], updates='constant', allowedUpdates=['constant', 'set every repeat', 'set every frame'], hint= "Size of this stimulus (either a single value or x,y pair, e.g. 2.5, [1,2] " ) self.params['ori'] = Param( ori, valType='code', allowedTypes=[], updates='constant', allowedUpdates=['constant', 'set every repeat', 'set every frame'], hint="Orientation of this stimulus (in deg)") self.params['startTime'] = Param( startTime, valType='code', allowedTypes=[], updates='constant', allowedUpdates=[], hint="The time that the stimulus is first presented") self.params['duration'] = Param( duration, valType='code', allowedTypes=[], updates='constant', allowedUpdates=[], hint="The duration for which the stimulus is presented")
def __init__(self, exp, parentName, name='rating', scaleDescription='', categoryChoices='', visualAnalogScale=False, low=1, high=7, singleClick=False, size=1.0, pos='0, -0.4', startType='time (s)', startVal=0.0, stopType='condition', stopVal='', startEstim='', durationEstim='', forceEndRoutine=True, disappear=False, storeRating=True, storeRatingTime=True, lowAnchorText='', highAnchorText='', customize_everything=''): self.type = 'RatingScale' self.url = "http://www.psychopy.org/builder/components/ratingscale.html" self.exp = exp self.parentName = parentName self.exp.requirePsychopyLibs(['visual', 'event']) #params self.order = [ 'name', 'visualAnalogScale', 'categoryChoices', 'scaleDescription', 'low', 'high', 'size' ] self.params = {} self.params['advancedParams'] = [ 'singleClick', 'forceEndRoutine', 'size', 'disappear', 'pos', 'storeRatingTime', 'storeRating', 'lowAnchorText', 'highAnchorText', 'customize_everything' ] # normal params: self.params['name'] = Param( name, valType='code', allowedTypes=[], hint= "A rating scale only collects the response; it does not display the stimulus to be rated.", label="Name") self.params['startType'] = Param( startType, valType='str', allowedVals=['time (s)', 'frame N', 'condition'], hint="How do you want to define your start point?") self.params['stopType'] = Param( stopType, valType='str', allowedVals=[ 'duration (s)', 'duration (frames)', 'time (s)', 'frame N', 'condition' ], hint="How do you want to define your end point?") self.params['startVal'] = Param( startVal, valType='code', allowedTypes=[], hint="When does the rating scale start being shown?") self.params['stopVal'] = Param( stopVal, valType='code', allowedTypes=[], updates='constant', allowedUpdates=[], hint="How long to wait for a response (blank is forever)") self.params['startEstim'] = Param( startEstim, valType='code', allowedTypes=[], hint= "(Optional) expected start (s) of stimulus, purely for representing in the timeline" ) self.params['durationEstim'] = Param( durationEstim, valType='code', allowedTypes=[], hint= "(Optional) expected duration (s) of stimulus, purely for representing in the timeline" ) self.params['visualAnalogScale'] = Param( visualAnalogScale, valType='bool', allowedTypes=[], updates='constant', allowedUpdates=[], hint= "Show a continuous visual analog scale; returns 0.00 to 1.00; takes precedence over numeric scale or categorical choices", label="Visual analog scale") self.params['categoryChoices'] = Param( categoryChoices, valType='str', allowedTypes=[], updates='constant', allowedUpdates=[], hint= "A list of categories (non-numeric alternatives) to present, space or comma-separated; these take precedence over a numeric scale", label="Category choices") self.params['scaleDescription'] = Param( scaleDescription, valType='str', allowedTypes=[], updates='constant', allowedUpdates=[], hint= "Brief instructions, such as a description of the scale numbers as seen by the subject.", label="Scale description") self.params['low'] = Param( low, valType='code', allowedTypes=[], updates='constant', allowedUpdates=[], hint= "Lowest rating (low end of the scale); not used for categories.", label="Low") self.params['high'] = Param( high, valType='code', allowedTypes=[], updates='constant', allowedUpdates=[], hint= "Highest rating (top end of the scale); not used for categories.", label="High") # advanced params: self.params['singleClick'] = Param( singleClick, valType='bool', allowedTypes=[], updates='constant', allowedUpdates=[], hint= "Should clicking the line accept that rating (without needing to confirm via 'accept')?" ) self.params['disappear'] = Param( disappear, valType='bool', allowedTypes=[], updates='constant', allowedUpdates=[], hint= "Hide the scale when a rating has been accepted; False to remain on-screen" ) self.params['size'] = Param( size, valType='code', allowedTypes=[], updates='constant', allowedUpdates=[], hint= "Relative size on the screen; size > 1 is larger than default; size < 1 is smaller" ) self.params['storeRating'] = Param(storeRating, valType='bool', allowedTypes=[], updates='constant', allowedUpdates=[], hint="store the rating") self.params['storeRatingTime'] = Param( storeRatingTime, valType='bool', allowedTypes=[], updates='constant', allowedUpdates=[], hint="store the time taken to make the choice (in seconds)") self.params['pos'] = Param(pos, valType='str', allowedTypes=[], updates='constant', allowedUpdates=[], hint="x,y position on the screen") self.params['forceEndRoutine'] = Param( forceEndRoutine, valType='bool', allowedTypes=[], updates='constant', allowedUpdates=[], hint= "Should accepting a rating cause the end of the routine (e.g. trial)?" ) self.params['lowAnchorText'] = Param( lowAnchorText, valType='str', allowedTypes=[], updates='constant', allowedUpdates=[], hint="Description of the low end of the scale") self.params['highAnchorText'] = Param( highAnchorText, valType='str', allowedTypes=[], updates='constant', allowedUpdates=[], hint="Description of the high end of the scale") self.params['customize_everything'] = Param( customize_everything, valType='str', allowedTypes=[], updates='constant', allowedUpdates=[], hint= "Use this text to create the rating scale as you would in a code component; overrides all" + " dialog settings except time parameters, forceEndRoutine, storeRatingTime, storeRating" )
def __init__(self, exp, parentName, name='', units='from exp settings', color='$[1,1,1]', pos=[0, 0], size=[0, 0], ori=0, colorSpace='rgb', opacity=1, startType='time (s)', startVal='', stopType='duration (s)', stopVal='', startEstim='', durationEstim=''): self.psychopyLibs = ['visual'] #needs this psychopy lib to operate self.order = [ ] #make sure these are at top (after name and time params) self.params = {} self.exp = exp self.parentName = parentName self.params['startType'] = Param( startType, valType='str', allowedVals=['time (s)', 'frame N', 'condition'], hint="How do you want to define your start point?") self.params['stopType'] = Param( stopType, valType='str', allowedVals=[ 'duration (s)', 'duration (frames)', 'time (s)', 'frame N', 'condition' ], hint="How do you want to define your end point?") self.params['startVal'] = Param(startVal, valType='code', allowedTypes=[], hint="When does the stimulus start?") self.params['stopVal'] = Param(stopVal, valType='code', allowedTypes=[], updates='constant', allowedUpdates=[], hint="When does the stimulus end?") self.params['startEstim'] = Param( startEstim, valType='code', allowedTypes=[], hint= "(Optional) expected start (s) of stimulus, purely for representing in the timeline" ) self.params['durationEstim'] = Param( durationEstim, valType='code', allowedTypes=[], hint= "(Optional) expected duration (s) of stimulus, purely for representing in the timeline" ) self.params['name'] = Param(name, valType='code', updates='constant', hint="Name of this stimulus", label="Name") self.params['units'] = Param( units, valType='str', allowedVals=['from exp settings', 'deg', 'cm', 'pix', 'norm'], hint="Units of dimensions for this stimulus", label="Units") self.params['color'] = Param( color, valType='str', allowedTypes=[], updates='constant', allowedUpdates=['constant', 'set every repeat', 'set every frame'], hint= "Color of this stimulus (e.g. $[1,1,0], red ); Right-click to bring up a color-picker (rgb only)", label="Color") self.params['opacity'] = Param( opacity, valType='code', allowedTypes=[], updates='constant', allowedUpdates=['constant', 'set every repeat', 'set every frame'], hint= "Opacity of the stimulus (1=opaque, 0=fully transparent, 0.5=translucent)", label="Opacity") self.params['colorSpace'] = Param( colorSpace, valType='str', allowedVals=['rgb', 'dkl', 'lms'], updates='constant', hint="Choice of color space for the color (rgb, dkl, lms)", label="Color space") self.params['pos'] = Param( pos, valType='code', allowedTypes=[], updates='constant', allowedUpdates=['constant', 'set every repeat', 'set every frame'], hint="Position of this stimulus (e.g. [1,2] )", label="Position [x,y]") self.params['size'] = Param( size, valType='code', allowedTypes=[], updates='constant', allowedUpdates=['constant', 'set every repeat', 'set every frame'], hint= "Size of this stimulus (either a single value or x,y pair, e.g. 2.5, [1,2] ", label="Size [w,h]") self.params['ori'] = Param( ori, valType='code', allowedTypes=[], updates='constant', allowedUpdates=['constant', 'set every repeat', 'set every frame'], hint="Orientation of this stimulus (in deg)", label="Orientation")
def __init__(self, *args, **kwargs): self._param = Param(*args, **kwargs)