-
Notifications
You must be signed in to change notification settings - Fork 29
/
build_stimuli_set.py
69 lines (62 loc) · 1.44 KB
/
build_stimuli_set.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
# color naming: 1, word reading: -1
# returns array representation of 1HOT vector
def to1HOT(subfeatureNum, colValue):
i = 1
thisarr = []
while i < colValue:
thisarr.append(0)
i += 1
thisarr.append(1)
while (subfeatureNum - i) > 0:
thisarr.append(0)
i += 1
return thisarr
# initialize fields
color_stim = []
word_stim = []
color_task = []
word_task = []
reward = []
xor_dict = []
# number of feature stimuli
total_features = 8
subj_id = 1
trial_num = 0
feature_num = 1
while (trial_num <= 65):
if trial_num == 65:
trial_num = 0
if feature_num == 8:
feature_num = 1
xor_dict.append([color_stim, word_stim, color_task, word_task, reward])
if subj_id == 30:
break
else:
subj_id += 1
color_stim = []
word_stim = []
color_task = []
word_task = []
reward = []
freq = []
trial_type = []
else:
feature_num += 1
continue
color_stim.append(to1HOT(total_features, feature_num)) # congruent stimuli, x65
word_stim.append(to1HOT(total_features, 8))
color_task.append([1.32]) # given 1.32
word_task.append([-3.22]) # given 3.22
# reward.append([1,0])
# if feature_num <= 2:
# reward.append([1,0])
# else:
reward.append([0,1])
trial_num += 1
print("new color len: ", len(color_stim))
print("new word len: ", len(word_stim))
print("new color task len: ", len(color_task))
print("new word task len: ", len(word_task))
print("new reward len: ", len(reward))
print("reward: ", reward)
print(len(xor_dict))