if trialNum < trials.nTotal: #When you abort early, correct and other columns are not numeric because have value of "-"
        #converting to numeric
        df = df.convert_objects(convert_numeric=True)
        print('df.dtypes=', df.dtypes) #df.dtypes in my case are  "objects". you can't take the mean
        print('dfFromPP =', df)
if eyetracking and getEyeTrackingFileFromEyetrackingMachineAtEndOfExperiment:
    tracker.closeConnectionToEyeTracker(eyeMoveFile)
logging.info('finishing at '+timeAndDateStr)
#print('%corr = ', round( correct*1.0/trialNum*100., 2)  , '% of ',trialNum,' trials', end=' ')
print('%corr each speed: ', end=' ')
print(np.around( numRightWrongEachSpeed[:,1] / ( numRightWrongEachSpeed[:,0] + numRightWrongEachSpeed[:,1]), 2))
print('\t\t\t\tnum trials each speed =', numRightWrongEachSpeed[:,0] + numRightWrongEachSpeed[:,1])
logging.flush()
myWin.close()
if quitFinder:
        applescript="\'tell application \"Finder\" to launch\'" #turn Finder back on
        shellCmd = 'osascript -e '+applescript
        os.system(shellCmd)

#Fit and plot data
plotData = False
if trialNum >0 and plotData:
    import plotHelpers
    fig = plotHelpers.plotDataAndPsychometricCurve(df, dataFileName=None)
    figName = 'pythonFig'
    figFnameWithPath = os.path.join('analysis/figs/', figName + '.png')
    import pylab
    pylab.savefig( figFnameWithPath ) #, bbox_inches='tight')
    print('The plot has been saved, as', figFnameWithPath)
    pylab.show() #pauses until window manually closed. Have to save before calling this, because closing the window loses the figure
示例#2
0
        nDone+=1

logging.flush()
myWin.close()

if expStop:
    print("Experiment stopped because user stopped it.")
else: 
    print("Experiment finished")
if  nDone >0:
    print("Data was saved on each trial to", fileNameWithPath+'MANUAL.txt')
    fileNamePP = fileNameWithPath
    dfFromPP = trials.saveAsWideText(fileNamePP)
    print("Psychopy's wideText has been saved as", fileNamePP)
    #dfFromPP.to_pickle(fileNameWithPath+"_DataFrame.pickle") #doing this to have a dataframe to test plotDataAndPsychometricCurve with in analyzeData.py
    fileNamePickle = fileNameWithPath #.psydat will automatically be appended
    trials.saveAsPickle(fileNamePickle)
    print("Most Psychopy-ic method: trials trialHandler has been saved as", fileNamePickle, "should include copy of code")
                      
    #df.dtypes in my case are  "objects". you can't take the mean
    df = dfFromPP
    print('df.dtypes=\n',df.dtypes)
   
    #Fit and plot data
    fig = plotDataAndPsychometricCurve(df, dataFileName=None)
    figFnameWithPath = os.path.join('figures/', fName + '.png')
    pylab.savefig( figFnameWithPath ) #, bbox_inches='tight')
    print('The plot has been saved, as', figFnameWithPath)
    pylab.show() #pauses until window manually closed. Have to save before calling this, because closing the window loses the figure

示例#3
0
import sys
sys.path.append(
    '/Users/alexh/Documents/attention_tempresltn/multiple object tracking/newTraj/newTraj_repo'
)
import plotHelpers
import pylab
#datFile = psychopy.tools.filetools.fromFile(filenamePickle+'.psydat')
#print datFile.data     #doing this to have a dataframe to test plotDataAndPsychometricCurve with in analyzeData.py
#Only way to convert it from idiosyncratic psychopy format to dataframe is with saveAsWideText
#df = datFile.saveAsWideText("temp.txt") #wide is useful for analysis with R or SPSS. Also returns dataframe df
#print('dataframe returned from saveAsWideText df.dtypes=\n',df.dtypes)
#fig = plotDataAndPsychometricCurve(df, dataFileName=None)
fig = plotHelpers.plotDataAndPsychometricCurve(
    df=None, dataFileName="exampleData/auto_10Jun2015_16-04.psydat")
pylab.show(
)  #pauses until window manually closed. Have to save before calling this, because closing the window loses the figure
示例#4
0
import sys
sys.path.append('/Users/alexh/Documents/attention_tempresltn/multiple object tracking/newTraj/newTraj_repo')
import plotHelpers
import pylab
#datFile = psychopy.tools.filetools.fromFile(filenamePickle+'.psydat')
#print datFile.data     #doing this to have a dataframe to test plotDataAndPsychometricCurve with in analyzeData.py
#Only way to convert it from idiosyncratic psychopy format to dataframe is with saveAsWideText
#df = datFile.saveAsWideText("temp.txt") #wide is useful for analysis with R or SPSS. Also returns dataframe df
#print('dataframe returned from saveAsWideText df.dtypes=\n',df.dtypes)
#fig = plotDataAndPsychometricCurve(df, dataFileName=None)
fig = plotHelpers.plotDataAndPsychometricCurve(df=None, dataFileName="exampleData/auto_10Jun2015_16-04.psydat")
pylab.show() #pauses until window manually closed. Have to save before calling this, because closing the window loses the figure