Skip to content

Commit

Permalink
minor path adjustments and mturk script modificaitons for extra measures
Browse files Browse the repository at this point in the history
  • Loading branch information
daelsaid committed Oct 13, 2018
1 parent a418244 commit 2e5a3b6
Show file tree
Hide file tree
Showing 8 changed files with 88 additions and 158 deletions.
34 changes: 0 additions & 34 deletions post_scoring_compiled_csv/vmreact_extra_measures_combined.py

This file was deleted.

40 changes: 0 additions & 40 deletions post_scoring_compiled_csv/vmreact_gen_normed_tables.py

This file was deleted.

13 changes: 0 additions & 13 deletions post_scoring_compiled_csv/vmreact_typing_latency_by_subject.py

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,6 @@
display = (0, 1, 2)
ax2.legend([label for i, label in enumerate(labels) if i in display],
fontsize=10, bbox_to_anchor=(1.57, 1.00), ncol=1)
ax2.legend
pdf.savefig()


Expand Down
2 changes: 1 addition & 1 deletion vmreact-merges/morevmreact.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

# In[41]:

scored_dir = '/Users/lillyel-said/Desktop/vmreact/vmreact/2_vmreact/'
# scored_dir = '/Users/lillyel-said/Desktop/vmreact/vmreact/2_vmreact/'
parsed_list = []

for batch in range(1, 9):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,35 +2,42 @@
import pandas as pd


def extra_compiled_measures(datadir,compiled_csv,typing_test_csv,average_typing_csv,updated_compilation_csv):
# data_dir = '/Users/lillyel-said/Desktop/vmreact/vmreact/2_vmreact/'
# compiled_csv = '/Users/lillyel-said/Desktop/vmreact/vmreact/2_vmreact/mturk_vmreact_complete_compilation_initiation.csv'
# average_typing_csv= '/Users/lillyel-said/Desktop/vmreact/vmreact/2_vmreact/typing_test_averages.csv'
def extra_compiled_measures(datadir, compiled_csv, typing_test_csv, average_typing_csv, updated_compilation_csv):
# data_dir = '/Users/lillyel-said/Desktop/vmreact/vmreact/2_vmreact/'
# compiled_csv = '/Users/lillyel-said/Desktop/vmreact/vmreact/2_vmreact/mturk_vmreact_complete_compilation_initiation.csv'
# average_typing_csv= '/Users/lillyel-said/Desktop/vmreact/vmreact/2_vmreact/typing_test_averages.csv'

trials = ['trial1', 'trial2', 'trial3', 'trial4', 'trial5', 'listb', 'trial6', 'trial7']
trials = ['trial1', 'trial2', 'trial3', 'trial4',
'trial5', 'listb', 'trial6', 'trial7']

cols = ['values.response_latency', 'expressions.trial_recall_word_latency',
'values.recall_firstcharlatency', 'values.recall_lastcharlatency']
cols = ['values.response_latency', 'expressions.trial_recall_word_latency',
'values.recall_firstcharlatency', 'values.recall_lastcharlatency']

column_titles = ['subjid', 'date']
column_titles = ['subjid', 'date']

incorrect_df = pd.read_csv(os.path.join(data_dir, 'incorrect_response.csv'), dtype=str)
incorrect_df = pd.read_csv(os.path.join(
data_dir, 'incorrect_response.csv'), dtype=str)

vmreact_df = pd.read_csv(compiled, dtype='str')
vmreact_df = pd.read_csv(compiled, dtype='str')

avg_typing_df = pd.read_csv(average_typing_csv, dtype='str')
avg_typing_df = pd.read_csv(average_typing_csv, dtype='str')

vmreact_df['unique_identifier'] = vmreact_df['subject'] + '_' + vmreact_df['date']
vmreact_df['unique_identifier'] = vmreact_df['subject'] + \
'_' + vmreact_df['date']

add_avg_typing_merge= vmreact_df.merge(avg_typing_df, left_on='unique_identifier', right_on='unique_identifier', how='outer')
add_avg_typing_merge = vmreact_df.merge(
avg_typing_df, left_on='unique_identifier', right_on='unique_identifier', how='outer')

temp = pd.DataFrame(data=add_avg_typing_merge, dtype=str)
temp = pd.DataFrame(data=add_avg_typing_merge, dtype=str)

new_compiled["total_average_repeats"] = temp.loc[:, 'listb_#_repeats':'trial7_#_repeats'].astype(float).mean(
axis=1)
new_compiled["total_average_repeats"] = temp.loc[:, 'listb_#_repeats':'trial7_#_repeats'].astype(float).mean(
axis=1)

new_compiled["total_incorrect"] = new_compiled.loc[:, 'listb':'trial7'].astype(float).subtract(15, axis=0)
new_compiled["total_incorrect"] = new_compiled.loc[:,
'listb':'trial7'].astype(float).subtract(15, axis=0)

new_compiled[['listb_errors', 'trial1_errors', 'trial2_errors', 'trial3_errors', 'trial4_errors', 'trial5_errors', 'trial6_errors', 'trial7_errors']] = new_compiled.loc[:, 'listb':'trial7'].astype(float).subtract(15,axis=0).abs()
new_compiled[['listb_errors', 'trial1_errors', 'trial2_errors', 'trial3_errors', 'trial4_errors', 'trial5_errors',
'trial6_errors', 'trial7_errors']] = new_compiled.loc[:, 'listb':'trial7'].astype(float).subtract(15, axis=0).abs()

new_compiled.to_csv(os.path.join(updated_compilation_csv,'updated_mturk_vmreact_complete_compilation.csv'))
new_compiled.to_csv(os.path.join(updated_compilation_csv,
'updated_mturk_vmreact_complete_compilation.csv'))
Original file line number Diff line number Diff line change
Expand Up @@ -3,49 +3,55 @@

import pandas as pd

data_dir = '/Users/lillyel-said/Desktop/vmreact/vmreact/2_vmreact/'
data_dir = './vmreact/vmreact/2_vmreact/'

cols = ['date', 'subject', 'trial1', 'trial2', 'trial3', 'trial4', 'trial5', 'listb', 'trial6', 'trial7',
'total_learning', 'corrected_total_learning', 'learning_rate', 'proactive_interference',
'retroactive_interference', 'forgetting_and_retention']
trials = ['trial1', 'trial2', 'trial3', 'trial4', 'trial5', 'listb', 'trial6', 'trial7']
'total_learning', 'corrected_total_learning', 'learning_rate', 'proactive_interference',
'retroactive_interference', 'forgetting_and_retention']
trials = ['trial1', 'trial2', 'trial3', 'trial4',
'trial5', 'listb', 'trial6', 'trial7']

for compiled_file in glob(os.path.join(data_dir, 'mturk_vmreact_complete_compilation_initiation.csv')):
vmreact_compiled = pd.read_csv(compiled_file, dtype=str, index_col=['gender', 'age_range'])
bysubj = pd.read_csv(compiled_file, dtype='str')
test_df = vmreact_compiled.loc[:, 'list_type':'trial7_values.recall_lastcharlatency']
for t in trials:
for subj, subj_df in vmreact_compiled.groupby(level=[0, 1]):
if len(subj_df) > 3:
try:
response_latency = subj[0], subj[1], t + '_values.response_latency', round(
subj_df[t + '_values.response_latency'].astype(float).mean(axis=0), 4), round(
subj_df[t + '_values.response_latency'].astype(float).std(axis=0), 4), subj_df[
t + '_values.response_latency'].count()
initiation = subj[0], subj[1], t + '_values.recall_firstcharlatency', round(
subj_df[t + '_values.recall_firstcharlatency'].astype(float).mean(axis=0), 4), round(
subj_df[t + '_recency'].astype(float).std(axis=0), 4), subj_df[t + '_recency'].count()
repeats = subj[0], subj[1], t + '_#_repeats', round(
subj_df[t + '_#_repeats'].astype(float).mean(axis=0), 4), round(
subj_df[t + '_#_repeats'].astype(float).std(axis=0), 4), subj_df[t + '_#_repeats'].count()
trials = subj[0], subj[1], t, round(subj_df[t].astype(float).mean(axis=0), 4), round(
subj_df[t].astype(float).std(axis=0), 4), subj_df[t].count()
primacy = subj[0], subj[1], t + '_primacy', round(
subj_df[t + '_primacy'].astype(float).mean(axis=0), 4), round(
subj_df[t + '_primacy'].astype(float).std(axis=0), 4), subj_df[t + '_primacy'].count()
recency = subj[0], subj[1], t + '_recency', round(
subj_df[t + '_recency'].astype(float).mean(axis=0), 4), round(
subj_df[t + '_recency'].astype(float).std(axis=0), 4), subj_df[t + '_recency'].count()
composite = subj_df.loc[:, 'total_learning':'forgetting_and_retention'].astype(float)
composite_vals = composite.mean(axis=0), composite.std(axis=0), composite.count()
comp = composite.mean(axis=0), composite.std(axis=0), composite.count()
# # print comp[2].T
# print repeats
# print response_latency
# print initiation
# print trials
# print primacy
# print recency
except:
continue
# firstcharaverages
vmreact_compiled = pd.read_csv(
compiled_file, dtype=str, index_col=['gender', 'age_range'])
bysubj = pd.read_csv(compiled_file, dtype='str')
test_df = vmreact_compiled.loc[:,
'list_type':'trial7_values.recall_lastcharlatency']
for t in trials:
for subj, subj_df in vmreact_compiled.groupby(level=[0, 1]):
if len(subj_df) > 3:
try:
response_latency = subj[0], subj[1], t + '_values.response_latency', round(
subj_df[t + '_values.response_latency'].astype(float).mean(axis=0), 4), round(
subj_df[t + '_values.response_latency'].astype(float).std(axis=0), 4), subj_df[
t + '_values.response_latency'].count()
initiation = subj[0], subj[1], t + '_values.recall_firstcharlatency', round(
subj_df[t + '_values.recall_firstcharlatency'].astype(float).mean(axis=0), 4), round(
subj_df[t + '_recency'].astype(float).std(axis=0), 4), subj_df[t + '_recency'].count()
repeats = subj[0], subj[1], t + '_#_repeats', round(
subj_df[t + '_#_repeats'].astype(float).mean(axis=0), 4), round(
subj_df[t + '_#_repeats'].astype(float).std(axis=0), 4), subj_df[t + '_#_repeats'].count()
trials = subj[0], subj[1], t, round(subj_df[t].astype(float).mean(axis=0), 4), round(
subj_df[t].astype(float).std(axis=0), 4), subj_df[t].count()
primacy = subj[0], subj[1], t + '_primacy', round(
subj_df[t + '_primacy'].astype(float).mean(axis=0), 4), round(
subj_df[t + '_primacy'].astype(float).std(axis=0), 4), subj_df[t + '_primacy'].count()
recency = subj[0], subj[1], t + '_recency', round(
subj_df[t + '_recency'].astype(float).mean(axis=0), 4), round(
subj_df[t + '_recency'].astype(float).std(axis=0), 4), subj_df[t + '_recency'].count()
composite = subj_df.loc[:, 'total_learning':'forgetting_and_retention'].astype(
float)
composite_vals = composite.mean(
axis=0), composite.std(axis=0), composite.count()
comp = composite.mean(axis=0), composite.std(
axis=0), composite.count()
# # print comp[2].T
# print repeats
# print response_latency
# print initiation
# print trials
# print primacy
# print recency
except:
continue
# firstcharaverages
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,16 @@
import pandas as pd

final = []
data_dir=''
def typing_test_extraction(data_dir,output_csv_path):
for x in glob(os.path.join(data_dir, 'filtered_typing_test.csv')):
df = pd.read_csv(x, dtype='str')
for i, val in df.groupby(['subject', 'date']):
print i[0] + '_' + i[1], i[0], i[1], val['latency'].astype(int).mean()
vals=i[0] + '_' + i[1], i[0], i[1], val['latency'].astype(int).mean()
vals.to_csv(os.path.join(output_csv_path,'typing_test_average_latency.csv'))
data_dir = ''


def typing_test_extraction(data_dir, output_csv_path):
for x in glob(os.path.join(data_dir, 'filtered_typing_test.csv')):
df = pd.read_csv(x, dtype='str')
for i, val in df.groupby(['subject', 'date']):
print i[0] + '_' + \
i[1], i[0], i[1], val['latency'].astype(int).mean()
vals = i[0] + '_' + \
i[1], i[0], i[1], val['latency'].astype(int).mean()
vals.to_csv(os.path.join(output_csv_path,
'typing_test_average_latency.csv'))

0 comments on commit 2e5a3b6

Please sign in to comment.