Hello,
I am having trouble with understanding/implementing the ‘addRowToConditionVariableTable(data)’ method
under the ‘IoHubConnection’ class.
Basically, my experiment loops through 4 trials and presents images that either contain a target object, or do not, and then measuring the subject’s confidence level as to whether the object was present or not in the image.
my experiment uses the ioHub framework by extending the ioHubExperimentRuntime class and implementing the run() method.
The logic flow of my experiment process:
conditionsToBeSeen = [dictionaries…]
trials = data.TrialHandler(conditionsToBeSeen, 1, method = ‘random’)
self.hub.createTrialHandlerRecordTable(trials)
t = 0
for thisTrial in trials:
.
flip_time = win.flip()
thisTrial[‘session_id’] = self.hub.getSessionID()
thisTrial[‘trial_id’] = t +1
thisTrial[‘Trial_start’] = flip_time
.
.
.
.
while rating.noResponse:
rating.draw()
win.flip()
thisTrial[‘response’] = rating.getRating()
self.hub.addRowToConditionVariableTable(list(thisTrial.values()))
for display purposes, the first list below depicts a dictionary the trialHandler uses at the beginning of the experiment. Lists two-four show the trialhandler dictionary at the end of each successive loop (or trial), with the added key:value pairs.
I think the problem may have to do with the mutability of the trial handler object as the trials progress from beginning to end and I add key:value pairs to the trial handler instance.
Error messages shown below:
()
Running: C:\Users\lab-admin\Desktop\experiment1RuntimeClass\Experiment1withRuntimeClass.1.0.py
[0, u’\0_target.png’, ‘Marker’, ‘target’]
[2, 70.89741324947681, u’\2_absent.png’, ‘Shovel’, 3, 3, 8, ‘absent’]
[3, 77.6787006490631, u’\3_target.png’, ‘Trashcan’, 3, 3, 6, ‘target’]
[1, 84.62616181967314, u’\1_absent.png’, ‘Mouse’, 3, 3, 3, ‘absent’]
<type ‘exceptions.ValueError’>
ValueError(‘size of tuple must match number of fields.’,)
[’ File “C:\Program Files (x86)\PsychoPy2\lib\site-packages\psychopy\iohub\datastore\init.py”, line 434, in _addRowToConditionVariableTable\n np_array= N.array([tuple(data),],dtype=self._EXP_COND_DTYPE)\n’]
<type ‘exceptions.ValueError’>
ValueError(‘size of tuple must match number of fields.’,)
[’ File “C:\Program Files (x86)\PsychoPy2\lib\site-packages\psychopy\iohub\datastore\init.py”, line 434, in _addRowToConditionVariableTable\n np_array= N.array([tuple(data),],dtype=self._EXP_COND_DTYPE)\n’]
<type ‘exceptions.ValueError’>
ValueError(‘size of tuple must match number of fields.’,)
[’ File “C:\Program Files (x86)\PsychoPy2\lib\site-packages\psychopy\iohub\datastore\init.py”, line 434, in _addRowToConditionVariableTable\n np_array= N.array([tuple(data),],dtype=self._EXP_COND_DTYPE)\n’]
<type ‘exceptions.ValueError’>
ValueError(‘size of tuple must match number of fields.’,)
[’ File “C:\Program Files (x86)\PsychoPy2\lib\site-packages\psychopy\iohub\datastore\init.py”, line 434, in _addRowToConditionVariableTable\n np_array= N.array([tuple(data),],dtype=self._EXP_COND_DTYPE)\n’]
ioHub Server Process Completed With Code: 0
I would appreciate any constructive feedback!
Thanks!