-
Notifications
You must be signed in to change notification settings - Fork 0
/
generate_material_list.py
80 lines (69 loc) · 2.89 KB
/
generate_material_list.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
'''
Name: generate_material_list.py
Author: Jennifer Hu
Purpose: Generate the list of experimental materials expected by the
MATLAB experimental script. Only needs to be run once.
Only run this if you need to edit the materials/stimuli.
'''
import pandas as pd
def get_lists(key_path):
key = pd.read_csv(key_path, index_col=None)
return key[:64], key[64:]
def read_file(path):
with open(path, 'r') as f:
lines = f.readlines()
return [s.strip('\n') for s in lines]
def main():
headers = ['ItemNum', 'Condition', 'Item', 'List']
data = {h: [] for h in headers}
first_ev, last_ev = get_lists('keys/key_ev.csv')
first_ob, last_ob = get_lists('keys/key_ob.csv')
# SPROD, EVSEM, WPROD: LIST 1 1-64, LIST 2 65-128
for list_i in [1, 2]:
l_ev = first_ev if list_i == 1 else last_ev
l_ob = first_ob if list_i == 1 else last_ob
# SPROD
data['ItemNum'] += l_ev['ev_id'].values.tolist()
data['Condition'] += ['SPROD'] * len(l_ev.index)
data['Item'] += l_ev['img'].values.tolist()
data['List'] += [list_i] * len(l_ev.index)
# EVSEM
data['ItemNum'] += l_ev['ev_id'].values.tolist()
data['Condition'] += ['EVSEM'] * len(l_ev.index)
data['Item'] += l_ev['img'].values.tolist()
data['List'] += [list_i] * len(l_ev.index)
# WPROD
data['ItemNum'] += l_ob['ob_id'].values.tolist()
data['Condition'] += ['WPROD'] * len(l_ob.index)
data['Item'] += l_ob['img'].values.tolist()
data['List'] += [list_i] * len(l_ob.index)
# SCOMP, WCOMP: LIST 1 65-128, LIST 2 1-64
for list_i in [1, 2]:
l_ev = last_ev if list_i == 1 else first_ev
l_ob = last_ob if list_i == 1 else first_ob
# SCOMP
data['ItemNum'] += l_ev['ev_id'].values.tolist()
data['Condition'] += ['SCOMP'] * len(l_ev.index)
data['Item'] += [s.upper().strip('.') for s in l_ev['target'].values.tolist()]
data['List'] += [list_i] * len(l_ev.index)
# WCOMP
data['ItemNum'] += l_ob['ob_id'].values.tolist()
data['Condition'] += ['WCOMP'] * len(l_ob.index)
data['Item'] += [' '.join(w.upper().split(',')) for w in l_ob['target'].values.tolist()]
data['List'] += [list_i] * len(l_ob.index)
# NPROD (coded as ARTIC in scripts)
data['ItemNum'] += range(1,65)
data['ItemNum'] += range(1,65)
data['Condition'] += ['ARTIC'] * 64 * 2
nprod_stims = read_file('NProd/stimuli/nonwords.txt')
nprod_stims = [' '.join(s.upper().split(',')) for s in nprod_stims]
data['Item'] += nprod_stims
data['Item'] += nprod_stims
data['List'] += [1] * 64
data['List'] += [2] * 64
for k, v in data.items():
print(k, len(v))
df = pd.DataFrame(data, columns=headers)
df.to_csv('expt1-3/ProdLoc_materials.csv', index=False)
if __name__ == '__main__':
main()