In [1]:
%matplotlib inline
In [2]:
import sys
sys.dont_write_bytecode = True
import seaborn as sns
sns.set(style="whitegrid", color_codes=True, font_scale=1.3)
from ggplot import *
from dataMethods import *
from testRuns import *
import pandas as pd
import matplotlib.pyplot as plt
In [3]:
dataColumns = ['lHR', 'rHR', 'wHR', 'lK', 'rK', 'wK', 'lfaR', 'rfaR', 'wfaR', 'lHitRT', 'rHitRT', 'wHitRT', 'lFaRT'
, 'rFaRT', 'wFaRT', 'ldP', 'rdP', 'wdP', 'lCrit', 'rCrit', 'wCrit']
In [4]:
def createDF(testRuns):
data = pd.DataFrame()
i = 0
for (s,r) in testRuns:
stats = extractPerformance(s,r,'stim1')
leftHRs = stats['lHRs']
rightHRs = stats['rHRs']
wholeHRs = stats['wHRs']
leftKs = stats['lKs']
rightKs = stats['rKs']
wholeKs = stats['wKs']
leftfaRates = stats['lfaRates']
rightfaRates = stats['rfaRates']
wholefaRates = stats['wfaRates']
leftHitRTs = stats['lHitRTs']
rightHitRTs = stats['rHitRTs']
wholeHitRTs = stats['wHitRTs']
leftFaRTs = stats['lFaRTs']
rightFaRTs = stats['rFaRTs']
wholeFaRTs = stats['wFaRTs']
leftdPs = stats['ldPs']
rightdPs = stats['rdPs']
wholedPs = stats['wdPs']
leftCrits = stats['lCrits']
rightCrits = stats['rCrits']
wholeCrits = stats['wCrits']
for key in HFconds:
row = pd.Series([leftHRs[key],rightHRs[key], wholeHRs[key], leftKs[key], rightKs[key],
wholeKs[key], leftfaRates[key], rightfaRates[key], wholefaRates[key],
leftHitRTs[key], rightHitRTs[key], wholeHitRTs[key], leftFaRTs[key],
rightFaRTs[key], wholeFaRTs[key], leftdPs[key], rightdPs[key],
wholedPs[key], leftCrits[key], rightCrits[key], wholeCrits[key]],
name = str(i), index=dataColumns)
row['targs'] = str(HFconds[key][0])
row['dists'] = str(HFconds[key][1])
row['subj'] = int(s)
row['run'] = int(r)
data = data.append(row)
i += 1
return data
In [5]:
lstimData = createDF(lstimTestRuns)
rstimData = createDF(rstimTestRuns)
shamData = createDF(shamTestRuns)
#TODO combine these data sets, have stim condition as column
In [ ]:
lstimData
In [ ]:
lstimWKPlot = sns.factorplot(data=lstimData,x='dists',y='wK',hue='targs')
lstimWKPlot.fig.suptitle('whole-K under lstim')
lstimWKPlot.set_axis_labels('dists', 'K')
lstimWKPlot.fig.subplots_adjust(top=.9)
plt.ylim(0, 1.8)
In [ ]:
lstimLKPlot = sns.factorplot(data=lstimData,x='dists',y='lK',hue='targs')
lstimLKPlot.fig.suptitle('left-K under lstim')
lstimLKPlot.set_axis_labels('dists', 'K')
lstimLKPlot.fig.subplots_adjust(top=.9)
plt.ylim(0, 1.8)
In [ ]:
lstimRKPlot = sns.factorplot(data=lstimData,x='dists',y='rK',hue='targs')
lstimRKPlot.fig.suptitle('right-K under lstim')
lstimRKPlot.set_axis_labels('dists', 'K')
lstimRKPlot.fig.subplots_adjust(top=.9)
plt.ylim(0, 1.8)
In [ ]:
lstimWdPPlot = sns.factorplot(data=lstimData,x='dists',y='wdP',hue='targs')
lstimWdPPlot.fig.suptitle('whole-dP under lstim')
lstimWdPPlot.set_axis_labels('dists', 'dP')
lstimWdPPlot.fig.subplots_adjust(top=.9)
plt.ylim(1, 3.5)
In [ ]:
lstimLdPPlot = sns.factorplot(data=lstimData,x='dists',y='ldP',hue='targs')
lstimLdPPlot.fig.suptitle('left-dP under lstim')
lstimLdPPlot.set_axis_labels('dists', 'dP')
lstimLdPPlot.fig.subplots_adjust(top=.9)
plt.ylim(0, 2.5)
In [ ]:
lstimRdPPlot = sns.factorplot(data=lstimData,x='dists',y='rdP',hue='targs')
lstimRdPPlot.fig.suptitle('right-dP under lstim')
lstimRdPPlot.set_axis_labels('dists', 'dP')
lstimRdPPlot.fig.subplots_adjust(top=.9)
plt.ylim(0, 2.5)
In [ ]:
rstimWKPlot = sns.factorplot(data=rstimData,x='dists',y='wK',hue='targs')
rstimWKPlot.fig.suptitle('whole-K under rstim')
rstimWKPlot.set_axis_labels('dists', 'K')
rstimWKPlot.fig.subplots_adjust(top=.9)
plt.ylim(0, 1.8)
In [ ]:
rstimLKPlot = sns.factorplot(data=rstimData,x='dists',y='lK',hue='targs')
rstimLKPlot.fig.suptitle('left-K under rstim')
rstimLKPlot.set_axis_labels('dists', 'K')
rstimLKPlot.fig.subplots_adjust(top=.9)
plt.ylim(0, 1.8)
In [ ]:
rstimRKPlot = sns.factorplot(data=rstimData,x='dists',y='rK',hue='targs')
rstimRKPlot.fig.suptitle('right-K under rstim')
rstimRKPlot.set_axis_labels('dists', 'K')
rstimRKPlot.fig.subplots_adjust(top=.9)
plt.ylim(0, 1.8)
In [ ]:
rstimWdPPlot = sns.factorplot(data=rstimData,x='dists',y='wdP',hue='targs')
rstimWdPPlot.fig.suptitle('whole-dP under rstim')
rstimWdPPlot.set_axis_labels('dists', 'dP')
rstimWdPPlot.fig.subplots_adjust(top=.9)
plt.ylim(1, 3.5)
In [ ]:
rstimLdPPlot = sns.factorplot(data=rstimData,x='dists',y='ldP',hue='targs')
rstimLdPPlot.fig.suptitle('left-dP under rstim')
rstimLdPPlot.set_axis_labels('dists', 'dP')
rstimLdPPlot.fig.subplots_adjust(top=.9)
plt.ylim(0, 2.5)
In [ ]:
rstimRdPPlot = sns.factorplot(data=rstimData,x='dists',y='rdP',hue='targs')
rstimRdPPlot.fig.suptitle('right-dP under rstim')
rstimRdPPlot.set_axis_labels('dists', 'dP')
rstimRdPPlot.fig.subplots_adjust(top=.9)
plt.ylim(0, 2.5)
In [ ]:
shamWdPPlot = sns.factorplot(data=shamData,x='dists',y='wdP',hue='targs')
shamWdPPlot.fig.suptitle('whole-dP under sham')
shamWdPPlot.set_axis_labels('dists', 'dP')
shamWdPPlot.fig.subplots_adjust(top=.9)
plt.ylim(1, 3.5)
In [ ]:
shamLdPPlot = sns.factorplot(data=shamData,x='dists',y='ldP',hue='targs')
shamLdPPlot.fig.suptitle('left-dP under sham')
shamLdPPlot.set_axis_labels('dists', 'dP')
shamLdPPlot.fig.subplots_adjust(top=.9)
plt.ylim(0, 2.5)
In [ ]:
shamRdPPlot = sns.factorplot(data=shamData,x='dists',y='rdP',hue='targs')
shamRdPPlot.fig.suptitle('right-dP under sham')
shamRdPPlot.set_axis_labels('dists', 'dP')
shamRdPPlot.fig.subplots_adjust(top=.9)
plt.ylim(0, 2.5)
In [ ]:
leftLHRPlot = sns.factorplot(data=lstimData,x='dists',y='lHR',hue='targs')
leftLHRPlot.fig.suptitle('left-HR under lstim')
leftLHRPlot.set_axis_labels('dists', 'HR')
leftLHRPlot.fig.subplots_adjust(top=.9)
plt.ylim(0, 1)
In [ ]:
leftRHRPlot = sns.factorplot(data=lstimData,x='dists',y='rHR',hue='targs')
leftRHRPlot.fig.suptitle('right-HR under lstim')
leftRHRPlot.set_axis_labels('dists', 'HR')
leftRHRPlot.fig.subplots_adjust(top=.9)
plt.ylim(0, 1)
In [ ]:
rightLHRPlot = sns.factorplot(data=rstimData,x='dists',y='lHR',hue='targs')
rightLHRPlot.fig.suptitle('left-HR under rstim')
rightLHRPlot.set_axis_labels('dists', 'HR')
rightLHRPlot.fig.subplots_adjust(top=.9)
plt.ylim(0, 1)
In [ ]:
rightRHRPlot = sns.factorplot(data=rstimData,x='dists',y='rHR',hue='targs')
rightRHRPlot.fig.suptitle('right-HR under rstim')
rightRHRPlot.set_axis_labels('dists', 'HR')
rightRHRPlot.fig.subplots_adjust(top=.9)
plt.ylim(0, 1)
In [ ]:
shamLHRPlot = sns.factorplot(data=shamData,x='dists',y='lHR',hue='targs')
shamLHRPlot.fig.suptitle('left-HR under sham')
shamLHRPlot.set_axis_labels('dists', 'HR')
shamLHRPlot.fig.subplots_adjust(top=.9)
plt.ylim(0, 1)
In [ ]:
shamRHRPlot = sns.factorplot(data=shamData,x='dists',y='rHR',hue='targs')
shamRHRPlot.fig.suptitle('right-HR under sham')
shamRHRPlot.set_axis_labels('dists', 'HR')
shamRHRPlot.fig.subplots_adjust(top=.9)
plt.ylim(0, 1)
In [ ]:
leftLRTPlot = sns.factorplot(data=lstimData,x='dists',y='lHitRT',hue='targs')
leftLRTPlot.fig.suptitle('left-RT under lstim')
leftLRTPlot.set_axis_labels('dists', 'RT')
leftLRTPlot.fig.subplots_adjust(top=.9)
plt.ylim(0, 1)
In [ ]:
leftRRTPlot = sns.factorplot(data=lstimData,x='dists',y='rHitRT',hue='targs')
leftRRTPlot.fig.suptitle('right-RT under lstim')
leftRRTPlot.set_axis_labels('dists', 'RT')
leftRRTPlot.fig.subplots_adjust(top=.9)
plt.ylim(0, 1)
In [ ]:
rightLRTPlot = sns.factorplot(data=rstimData,x='dists',y='lHitRT',hue='targs')
rightLRTPlot.fig.suptitle('left-RT under rstim')
rightLRTPlot.set_axis_labels('dists', 'RT')
rightLRTPlot.fig.subplots_adjust(top=.9)
plt.ylim(0, 1)
In [ ]:
rightRRTPlot = sns.factorplot(data=rstimData,x='dists',y='rHitRT',hue='targs')
rightRRTPlot.fig.suptitle('right-RT under rstim')
rightRRTPlot.set_axis_labels('dists', 'RT')
rightRRTPlot.fig.subplots_adjust(top=.9)
plt.ylim(0, 1)
In [ ]:
shamLRTPlot = sns.factorplot(data=shamData,x='dists',y='lHitRT',hue='targs')
shamLRTPlot.fig.suptitle('left-RT under sham')
shamLRTPlot.set_axis_labels('dists', 'RT')
shamLRTPlot.fig.subplots_adjust(top=.9)
plt.ylim(0, 1)
In [ ]:
shamRRTPlot = sns.factorplot(data=shamData,x='dists',y='rHitRT',hue='targs')
shamRRTPlot.fig.suptitle('right-RT under sham')
shamRRTPlot.set_axis_labels('dists', 'RT')
shamRRTPlot.fig.subplots_adjust(top=.9)
plt.ylim(0, 1)
In [ ]:
lData = lstimData.reset_index()
rData = rstimData.reset_index()
sData = shamData.reset_index()
normData = pd.DataFrame()
normData['lstimLK'] = lData['lK'].sub(sData['lK'], axis=0)
normData['lstimRK'] = lData['rK'].sub(sData['rK'], axis=0)
normData['rstimLK'] = rData['lK'].sub(sData['lK'], axis=0)
normData['rstimRK'] = rData['rK'].sub(sData['rK'], axis=0)
normData['lstimLdP'] = lData['ldP'].sub(sData['ldP'], axis=0)
normData['lstimRdP'] = lData['rdP'].sub(sData['rdP'], axis=0)
normData['rstimLdP'] = rData['ldP'].sub(sData['ldP'], axis=0)
normData['rstimRdP'] = rData['rdP'].sub(sData['rdP'], axis=0)
normData['targs'] = rData['targs']
normData['dists'] = rData['dists']
In [ ]:
lnormLdPPlot = sns.factorplot(data=normData,x='dists',y='lstimLdP',hue='targs')
lnormLdPPlot.fig.suptitle('left-dP normalized under lstim')
lnormLdPPlot.set_axis_labels('dists', 'dP')
lnormLdPPlot.fig.subplots_adjust(top=.9)
plt.ylim(-1, 1)
In [ ]:
lnormRdPPlot = sns.factorplot(data=normData,x='dists',y='lstimRdP',hue='targs')
lnormRdPPlot.fig.suptitle('right-dP normalized under lstim')
lnormRdPPlot.set_axis_labels('dists', 'dP')
lnormRdPPlot.fig.subplots_adjust(top=.9)
plt.ylim(-1, 1)
In [ ]:
rnormLdPPlot = sns.factorplot(data=normData,x='dists',y='rstimLdP',hue='targs')
rnormLdPPlot.fig.suptitle('left-dP normalized under rstim')
rnormLdPPlot.set_axis_labels('dists', 'dP')
rnormLdPPlot.fig.subplots_adjust(top=.9)
plt.ylim(-1, 1)
In [ ]:
rnormRdPPlot = sns.factorplot(data=normData,x='dists',y='rstimRdP',hue='targs')
rnormRdPPlot.fig.suptitle('right-dP normalized under rstim')
rnormRdPPlot.set_axis_labels('dists', 'dP')
rnormRdPPlot.fig.subplots_adjust(top=.9)
plt.ylim(-1, 1)
In [ ]:
lnormLHRPlot = sns.factorplot(data=normData,x='dists',y='lstimLK',hue='targs')
lnormLHRPlot.fig.suptitle('left-K normalized under lstim')
lnormLHRPlot.set_axis_labels('dists', 'K')
lnormLHRPlot.fig.subplots_adjust(top=.9)
plt.ylim(-1, 1)
In [ ]:
lnormRKPlot = sns.factorplot(data=normData,x='dists',y='lstimRK',hue='targs')
lnormRKPlot.fig.suptitle('right-K normalized under lstim')
lnormRKPlot.set_axis_labels('dists', 'K')
lnormRKPlot.fig.subplots_adjust(top=.9)
plt.ylim(-1, 1)
In [ ]:
rnormLKPlot = sns.factorplot(data=normData,x='dists',y='rstimLK',hue='targs')
rnormLKPlot.fig.suptitle('left-K normalized under rstim')
rnormLKPlot.set_axis_labels('dists', 'K')
rnormLKPlot.fig.subplots_adjust(top=.9)
plt.ylim(-1, 1)
In [ ]:
rnormRKPlot = sns.factorplot(data=normData,x='dists',y='rstimRK',hue='targs')
rnormRKPlot.fig.suptitle('right-K normalized under rstim')
rnormRKPlot.set_axis_labels('dists', 'K')
rnormRKPlot.fig.subplots_adjust(top=.9)
plt.ylim(-1, 1)
In [ ]: