Пример #1
0
def testTrialTypeImport():
    fromCSV = data.importTrialList(os.path.join(thisDir, 'trialTypes.csv'))
    fromXLSX = data.importTrialList(os.path.join(thisDir, 'trialTypes.xlsx'))

    for trialN, trialCSV in enumerate(fromCSV):
        trialXLSX = fromXLSX[trialN]
        assert trialXLSX.keys() == trialCSV.keys()
        for header in trialCSV.keys():
            if trialXLSX[header] == None and numpy.isnan(trialCSV[header]):
                trialCSV[header] = None  #this is ok
            if trialXLSX[header] != trialCSV[header]:
                print header, trialCSV[header], trialXLSX[header]
            assert trialXLSX[header] == trialCSV[header]
Пример #2
0
def testTrialTypeImport():
    fromCSV = data.importTrialList(os.path.join(thisDir, 'trialTypes.csv'))
    fromXLSX = data.importTrialList(os.path.join(thisDir, 'trialTypes.xlsx'))
    
    for trialN, trialCSV in enumerate(fromCSV):
        trialXLSX = fromXLSX[trialN]
        assert trialXLSX.keys()==trialCSV.keys()
        for header in trialCSV.keys():
            if trialXLSX[header]==None and numpy.isnan(trialCSV[header]):
                trialCSV[header]=None#this is ok
            if trialXLSX[header] != trialCSV[header]:
                print header, trialCSV[header], trialXLSX[header]
            assert trialXLSX[header] == trialCSV[header]
Пример #3
0
 def testQuest(self):
     conditions = data.importTrialList(pjoin(TESTSDATA_PATH, "multiStairConds.xlsx"))
     stairs = data.MultiStairHandler(stairType="quest", conditions=conditions, method="random", nTrials=5)
     for intensity, condition in stairs:
         # make data that will cause different stairs to finish different times
         if random() > condition["startVal"]:
             corr = 1
         else:
             corr = 0
         stairs.addData(corr)
     stairs.saveAsExcel("multiQuestOut")
     stairs.saveAsPickle("multiQuestOut")  # contains more info
Пример #4
0
 def testQuest(self):
     conditions = data.importTrialList('testData/multiStairConds.xlsx')
     stairs = data.MultiStairHandler(stairType='quest', conditions=conditions,
                 method='random', nTrials=5)
     for intensity,condition in stairs:
         #make data that will cause different stairs to finish different times
         if random()>condition['startVal']:
             corr=1
         else:corr=0
         stairs.addData(corr)
     stairs.saveAsExcel('multiQuestOut')
     stairs.saveAsPickle('multiQuestOut')#contains more info
Пример #5
0
 def testSimple(self):
     conditions = data.importTrialList(
         pjoin(TESTSDATA_PATH, 'multiStairConds.xlsx'))
     stairs = data.MultiStairHandler(stairType='simple', conditions=conditions,
             method='random', nTrials=20)
     for intensity,condition in stairs:
         #make data that will cause different stairs to finish different times
         if random()>condition['startVal']:
             corr=1
         else:corr=0
         stairs.addData(corr)
     stairs.saveAsExcel(pjoin(self.temp_dir, 'multiStairOut'))
     stairs.saveAsPickle(pjoin(self.temp_dir, 'multiStairOut'))#contains more info
Пример #6
0

#create our own class to store info from keyboard
class KeyResponse:
    def __init__(self):
        self.keys = []  #the key(s) pressed
        self.corr = 0  #was the resp correct this trial? (0=no, 1=yes)
        self.rt = None  #response time
        self.clock = None  #we'll use this to measure the rt


#set up handler to look after randomisation of trials etc
repsA = data.TrialHandler(nReps=1,
                          method='random',
                          extraInfo=expInfo,
                          trialList=data.importTrialList('trialTypes.xlsx'))
thisReps = repsA.trialList[0]  #so we can initialise stimuli with some values
#abbrieviate parameter names if possible (e.g. rgb=thisReps.rgb)
if thisReps != None:
    for paramName in thisReps.keys():
        exec(paramName + '=thisReps.' + paramName)

#Initialise components for routine:A
AClock = core.Clock()
msgA = visual.TextStim(win=win,
                       ori=0,
                       text='You chose A (the blue pill?)',
                       pos=[0, 0],
                       height=0.1,
                       color=letterColor,
                       colorSpace='rgb')
Пример #7
0
            if thisTrial["absPhase"] > 0:
                if key in ["up"]:
                    return 1  # test patch is higher than reference patch
                elif key in ["down"]:
                    error.play()
                    return 0  # test patch is lower than reference patch
        else:
            print "hit up or down (or q) (you hit %s)" % key
            return None


# Setting the phase of the reference patch
setGratingPhase(90, leftPatch)

# Trial Handler
stimList = data.importTrialList("PracticeVernierList.xlsx")
trials = data.TrialHandler(stimList, info["cycles"])
trials.data.addDataType("response")  # 1 for higher, 0 for lower

nDone = 0
for thisTrial in trials:
    setGratingPhase(90, rightPatch)
    rightPatch.setPhase(thisTrial["absPhase"])

    #    print thisTrial
    reactionClock.reset()  # start RT timer
    fixation.draw()
    leftPatch.draw()
    rightPatch.draw()
    myWin.flip()
    core.wait(info["displayT"])
Пример #8
0
    ori=0,
    wrapWidth=2.0,
    bold=True,
    font='Courier',
    text=
    u'    Wci\u015bnij klawisz SPACE zawsze wtedy,kiedy    \n prezentowane s\u0142owo b\u0119dzie zwi\u0105zane z emocjami. \nAby przej\u015b\u0107 do sesji treningowej naci\u015bnij SPACE.',
    pos=[0, 0],
    height=0.08,
    color=u'black',
    colorSpace=u'rgb')

#set up handler to look after randomisation of trials etc
trialskjhk = data.TrialHandler(nReps=1,
                               method=u'sequential',
                               extraInfo=expInfo,
                               trialList=data.importTrialList('samples.csv'))
thisTrialskjh = trialskjhk.trialList[
    0]  #so we can initialise stimuli with some values
#abbrieviate parameter names if possible (e.g. rgb=thisTrialskjh.rgb)
if thisTrialskjh != None:
    for paramName in thisTrialskjh.keys():
        exec(paramName + '=thisTrialskjh.' + paramName)

#Initialise components for routine:test
testClock = core.Clock()
fxxxxx = visual.TextStim(win=win,
                         ori=0,
                         text='+',
                         pos=[0, 0],
                         height=0.1,
                         color='black',
Пример #9
0
#setup the Window
win = visual.Window(size=[1024, 768], fullscr=True, screen=0, allowGUI=False, allowStencil=False,
    monitor='testMonitor', color=[0,0,0], colorSpace='rgb')

#Initialise components for routine:Instructions
InstructionsClock=core.Clock()
Instruct=visual.TextStim(win=win, ori=0,
    text=u'Press the key that corresponds to the colour of the text\nred = left\ngreen = down\nblue = right\nPress any key to continue',
    font=u'Arial',
    pos=[0, 0], height=0.1,
    color=u'white', colorSpace=u'rgb')

#set up handler to look after randomisation of trials etc
trials=data.TrialHandler(nReps=1, method=u'random', 
    extraInfo=expInfo, originPath=u'C:\\Documents and Settings\\lpxrs\\My Documents\\Code\\Experiments\\Builder\\stroopTest.psyexp',
    trialList=data.importTrialList(u'trialTypes.xlsx'))
thisTrial=trials.trialList[0]#so we can initialise stimuli with some values
#abbrieviate parameter names if possible (e.g. rgb=thisTrial.rgb)
if thisTrial!=None:
    for paramName in thisTrial.keys():
        exec(paramName+'=thisTrial.'+paramName)

#Initialise components for routine:trial
trialClock=core.Clock()
stroop=visual.TextStim(win=win, ori=0,
    text=text,
    font=u'Arial',
    pos=[0, 0], height=0.1,
    color=letterColor, colorSpace=u'rgb')

#Initialise components for routine:FeedBack
    text=u' Skupiaj swoj\u0105 uwag\u0119 na znaku + \n        na \u015brodku ekranu.        \n                                \n                +                \n                                \n Staraj si\u0119 mruga\u0107 tylko wtedy,  \n gdy pojawi si\u0119 taka instrukcja. \nAby przej\u015b\u0107 dalej naci\u015bnij SPACE.',
    pos=[0, 0], height=0.08,
    color='black', colorSpace='rgb')

#Initialise components for routine:int5
int5Clock=core.Clock()
sodfsdlkj=visual.TextStim(win=win, ori=0,
    wrapWidth=2.0, bold=True, font='Courier',
    text=u'      Wci\u015bnij klawisz Czerwony zawsze wtedy,       \n    kiedy prezentowane s\u0142owo b\u0119dzie zwi\u0105zane z    \n                    emocjamia,                     \na klawisz Zielony je\u015bli b\u0119dzie to s\u0142owo neutralne. \n         Nie naciskaj \u017cadnego z klawiszy,         \n           je\u015bli b\u0119dzie to s\u0142owo Drewno.           \n Aby przej\u015b\u0107 do sesji treningowej naci\u015bnij SPACE. ',
    pos=[0, 0], height=0.08,
    color='black', colorSpace='rgb')


#set up handler to look after randomisation of trials etc
trialskjhk=data.TrialHandler(nReps=1, method='sequential', extraInfo=expInfo, 
    trialList=data.importTrialList('samples.csv'))
thisTrialskjh=trialskjhk.trialList[0]#so we can initialise stimuli with some values
#abbrieviate parameter names if possible (e.g. rgb=thisTrialskjh.rgb)
if thisTrialskjh!=None:
    for paramName in thisTrialskjh.keys():
        exec(paramName+'=thisTrialskjh.'+paramName)

#Initialise components for routine:test
testClock=core.Clock()
fxxxxx=visual.TextStim(win=win, ori=0,
    text='+',
    pos=[0, 0], height=0.1,
    color='black', colorSpace='rgb')
lkhkkki=visual.TextStim(win=win, ori=0,
    text=word,
    pos=[0, 0], height=0.1,
Пример #11
0
# Initialise components for routine:Instructions
InstructionsClock = core.Clock()
Instruct = visual.TextStim(
    win=win,
    ori=0,
    text=u"Press the key that corresponds to the colour of the text\nred = left\ngreen = down\nblue = right\nPress any key to continue",
    font=u"Arial",
    pos=[0, 0],
    height=0.1,
    color=u"white",
    colorSpace=u"rgb",
)

# set up handler to look after randomisation of trials etc
trials = data.TrialHandler(
    nReps=1, method=u"random", extraInfo=expInfo, originPath=None, trialList=data.importTrialList(u"trialTypes.xlsx")
)
thisTrial = trials.trialList[0]  # so we can initialise stimuli with some values
# abbrieviate parameter names if possible (e.g. rgb=thisTrial.rgb)
if thisTrial != None:
    for paramName in thisTrial.keys():
        exec(paramName + "=thisTrial." + paramName)

# Initialise components for routine:trial
trialClock = core.Clock()
stroop = visual.TextStim(
    win=win, ori=0, text=text, font=u"Arial", pos=[0, 0], height=0.1, color=letterColor, colorSpace=u"rgb"
)

# Initialise components for routine:FeedBack
FeedBackClock = core.Clock()