-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_simulation.py
104 lines (90 loc) · 6.83 KB
/
test_simulation.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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
# Joseph J Glavan 2023-09-15
# Test simulation to validate conversion from R to Python
# Simulates the same subject 100 times through 100 adaptive trials and 1000 GRT trials
import AGRT
import os
from psychopy import data, core
print("Started: {}".format(data.getDateStr()))
nReps = 100
nAdaptTrials = 144
# Create and open file
if not os.path.isdir('data'):
os.makedirs('data') #if this fails (e.g. permissions) we will get error
filename = 'data' + os.path.sep + data.getDateStr()
file = filename+'.txt'
logFile=open(file, 'a')
# Write header
logFile.write("Version\tDate\tSubject\tCondition\tParams\tBlock\tTrial\tStimulus\tResponse\tRT\tLambda\n")
# Simulate the study
for i in range(nReps):
# expInfo = [1.0, # Version
# data.getDateStr(), # Date
# i, # Participant
# 'a'] # Cond
# Subject Model with no violations of Perceptual Separability or Perceptual Independence (e.g., Parameter Recovery)
expInfo = ["Recovery", data.getDateStr(), i, 'a']
AGRT.RunAdaptiveGRTExperiment(trialFunction=AGRT.GRTSubjectModel, nAdaptiveTrials=nAdaptTrials, nGRTtrials=1000,
dim1range=(100, 800), dim2range=(1, 12), dim1steps=100, dim2steps=100,
lapse=0.04, overallAccuracy=0.75, blockingFactor=2,
adaptiveFunArgs=((600, 4), (0, 0), (100, .8), (0, 0), (0, 0), (0, 0, 0, 0), .04),
grtFunArgs=((600, 4), (0, 0), (100, .8), (0, 0), (0, 0), (0, 0, 0, 0), .04),
info=expInfo, logfile=logFile)
# Subject Model with violation of Perceptual Separability by mean
expInfo = ["PSM", data.getDateStr(), i, 'a']
AGRT.RunAdaptiveGRTExperiment(trialFunction=AGRT.GRTSubjectModel, nAdaptiveTrials=nAdaptTrials, nGRTtrials=1000,
dim1range=(100, 800), dim2range=(1, 12), dim1steps=100, dim2steps=100,
lapse=0.04, overallAccuracy=0.75, blockingFactor=2,
adaptiveFunArgs=((600, 4), (0, 0), (100, .8), (.1, 0), (0, 0), (0, 0, 0, 0), .04),
grtFunArgs=((600, 4), (0, 0), (100, .8), (.1, 0), (0, 0), (0, 0, 0, 0), .04),
info=expInfo, logfile=logFile)
# Subject Model with violation of Perceptual Separability by variance
expInfo = ["PSV", data.getDateStr(), i, 'a']
AGRT.RunAdaptiveGRTExperiment(trialFunction=AGRT.GRTSubjectModel, nAdaptiveTrials=nAdaptTrials, nGRTtrials=1000,
dim1range=(100, 800), dim2range=(1, 12), dim1steps=100, dim2steps=100,
lapse=0.04, overallAccuracy=0.75, blockingFactor=2,
adaptiveFunArgs=((600, 4), (0, 0), (100, .8), (0, 0), (0, .4), (0, 0, 0, 0), .04),
grtFunArgs=((600, 4), (0, 0), (100, .8), (0, 0), (0, .4), (0, 0, 0, 0), .04),
info=expInfo, logfile=logFile)
# Subject Model with violation of Perceptual Separability by mean and variance
expInfo = ["PSMV", data.getDateStr(), i, 'a']
AGRT.RunAdaptiveGRTExperiment(trialFunction=AGRT.GRTSubjectModel, nAdaptiveTrials=nAdaptTrials, nGRTtrials=1000,
dim1range=(100, 800), dim2range=(1, 12), dim1steps=100, dim2steps=100,
lapse=0.04, overallAccuracy=0.75, blockingFactor=2,
adaptiveFunArgs=((600, 4), (0, 0), (100, .8), (.1, 0), (0, .4), (0, 0, 0, 0), .04),
grtFunArgs=((600, 4), (0, 0), (100, .8), (.1, 0), (0, .4), (0, 0, 0, 0), .04),
info=expInfo, logfile=logFile)
# Subject Model with violation of Perceptual Independence
expInfo = ["PI", data.getDateStr(), i, 'a']
AGRT.RunAdaptiveGRTExperiment(trialFunction=AGRT.GRTSubjectModel, nAdaptiveTrials=nAdaptTrials, nGRTtrials=1000,
dim1range=(100, 800), dim2range=(1, 12), dim1steps=100, dim2steps=100,
lapse=0.04, overallAccuracy=0.75, blockingFactor=2,
adaptiveFunArgs=((600, 4), (0, 0), (100, .8), (0, 0), (0, 0), (.9, 0, -.9, 0), .04),
grtFunArgs=((600, 4), (0, 0), (100, .8), (0, 0), (0, 0), (.9, 0, -.9, 0), .04),
info=expInfo, logfile=logFile)
# Subject Model with violation of Perceptual Independence and violation of Perceptual Separability by mean
expInfo = ["PI.PSM", data.getDateStr(), i, 'a']
AGRT.RunAdaptiveGRTExperiment(trialFunction=AGRT.GRTSubjectModel, nAdaptiveTrials=nAdaptTrials, nGRTtrials=1000,
dim1range=(100, 800), dim2range=(1, 12), dim1steps=100, dim2steps=100,
lapse=0.04, overallAccuracy=0.75, blockingFactor=2,
adaptiveFunArgs=((600, 4), (0, 0), (100, .8), (.1, 0), (0, 0), (.9, 0, -.9, 0), .04),
grtFunArgs=((600, 4), (0, 0), (100, .8), (.1, 0), (0, 0), (.9, 0, -.9, 0), .04),
info=expInfo, logfile=logFile)
# Subject Model with violation of Perceptual Independence and violation of Perceptual Separability by variance
expInfo = ["PI.PSV", data.getDateStr(), i, 'a']
AGRT.RunAdaptiveGRTExperiment(trialFunction=AGRT.GRTSubjectModel, nAdaptiveTrials=nAdaptTrials, nGRTtrials=1000,
dim1range=(100, 800), dim2range=(1, 12), dim1steps=100, dim2steps=100,
lapse=0.04, overallAccuracy=0.75, blockingFactor=2,
adaptiveFunArgs=((600, 4), (0, 0), (100, .8), (0, 0), (0, .4), (.9, 0, -.9, 0), .04),
grtFunArgs=((600, 4), (0, 0), (100, .8), (0, 0), (0, .4), (.9, 0, -.9, 0), .04),
info=expInfo, logfile=logFile)
# Subject Model with violation of Perceptual Independence and violation of Perceptual Separability by mean and variance
expInfo = ["PI.PSMV", data.getDateStr(), i, 'a']
AGRT.RunAdaptiveGRTExperiment(trialFunction=AGRT.GRTSubjectModel, nAdaptiveTrials=nAdaptTrials, nGRTtrials=1000,
dim1range=(100, 800), dim2range=(1, 12), dim1steps=100, dim2steps=100,
lapse=0.04, overallAccuracy=0.75, blockingFactor=2,
adaptiveFunArgs=((600, 4), (0, 0), (100, .8), (.1, 0), (0, .4), (.9, 0, -.9, 0), .04),
grtFunArgs=((600, 4), (0, 0), (100, .8), (.1, 0), (0, .4), (.9, 0, -.9, 0), .04),
info=expInfo, logfile=logFile)
print("Finished: {}".format(data.getDateStr()))
logFile.close()
core.quit()