Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 73 additions & 0 deletions individual_tests
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Tue Oct 15 14:47:35 2019

@author: katieemmons
"""

import pandas as pd
#replace file with path to individuals data in .txt format
file = r'/Users/katieemmons/Desktop/behavioral/100/clouds_2bo_raw.txt'

df = pd.read_csv(file)
print(file)

#creates two additional columns in df
df['correct resp'] = df.resp == df.want
df['unknown resp'] = df.resp == "????"

#list of experimental conditions
conditions = ["maintain space", "maintain pitch", "maintain both", "switch space", "switch pitch", "switch both"]


# calculates perent correct for each condition for an individual participant
def percentCorrect(str):
correct_responses = (df.loc[df['cond'] == str, 'correct resp'].sum())
total_trials = ((df['cond'] == str).sum())
return (correct_responses/total_trials * 100)

for x in conditions:
percentCorrect(x)
print(x, "percent correct:", percentCorrect(x))

# calculates the total number of unknown responses for each condition for an individual participant
def unknownResponse(str):
unknown_resp = (df.loc[df['cond'] == str, 'unknown resp'].sum())
return(unknown_resp)

for x in conditions :
unknownResponse(x)
print(x, "unknowns :", unknownResponse(x))

# 0 = 'want'
# 1 = 'resp'
# 2 = 'cond'
# 3 = 'correct resp' (boolean)
# 4 = 'unknown resp' (boolean)

# calculates percent correct for each syllable position for an individual participant
def syllablePercentCorrect (int):
n=0
total_trials = len(df.index)
for ind in df.index:
if(((df.iat[ind,0])[int]) == ((df.iat[ind,1][int]))):
n=n+1
return (n/total_trials)

for x in range (0,4):
syllablePercentCorrect(x)
print (x+1, "th syllable:", syllablePercentCorrect(x))

# calculates the number of unknown responses for each syllable for an individual participant

def unknownSyllable (int):
n=0
for ind in df.index:
if("?" == ((df.iat[ind,1][int]))):
n = n+1
return (n)

for x in range (0,4):
unknownSyllable(x)
print(unknownSyllable(x), "unknown responses in", x+1, "th syllable")