Description of the problem:
URL of experiment: Pavlovia
Description of the problem: I’ve uploaded an experiment to Pavlovia and when piloting it I get the following error RefereceError: PornCond is not defined
PornCond is a component of the experiment that randomises participants into 1 or 2 conditions. One about porn/arousal and one about neutral stimuli. All the components for the study are defined in a routine at the start if the experiment and PornCond is either 0 or 1 using the randint (0,2). After this some particpants choose from a set of sex stimuli and the others get a neutral stimuli
I’ve attached a pic of what the routine looks like in builder
Unfortunately a colleague who has since left wrote the ‘initialise routine’ and the code components.
the study works fine offline on psychopy and I’ve made sure I’m using the latest version. I’m a bit stumped as to why it has stopped one Pavlovia
I’ve looked at other solutions suggested in other threads with similar problems. The only one I saw that looked relevant to mine was selecting ‘both’ in the code component. I’ve tried adding a randint(0,2) to the code component in builder in a begin experiment both with and without disabling the component in the initialise routine
mponents.
the experiment is currently public
Any help greatly appreciated
You can’t put randint() into component. It has to be in a code component.
Please check my crib sheet
I’ve taken out the randint from the PornCond component. I’ve added it to a code component under the begin experiment tab as Porncond == randint(0,2) but it is still not working. I’ve tried this with the PornCond component disabled as well. The only change is that I get the error right away whereas before It was only showing at the moment the randomisation would occur
do you have a link to thee crib sheet thanks
Sorry I’m on my phone. Please search the forum for crib sheet
Okay,
I do that.
thanks
A
HI,
I’ve looked at the reference error bit on the cribsheet. I moved the randint from the PornCond component in the initialise routine into a begin experiment tab as PornCond == randint(0,2). The error is still occurring online but now with that change it no longer works on my computer with the error NameError: name ‘PornCond’ is not defined)
Before the error was online only.
If I put it back to where it was in the component, it works again offline on my computer but not online.
Sorry, I’ve just realised that PomCond is a variable component, which is an alternative to a code component. If you define PomCond in a code component (and also use addData to save its value) then the variable component is redundant. I suspect that they should be avoided altogether but I haven’t tested them myself because I don’t routinely use them.
hi,
thanks for your reply.
I’m using the variable component as randomisation int the experimental and control conditions. With the randint if it is 0 they get condition A if it is 1 they get condition B.
If I can’t use randint (or use in this way) to do this online, is there another way I can look at to do it?
Check my crib sheet for how to do randint in code components
thanks,
I’m using randint in that way. Is it a case that it is doing the randint calculation, but not saving the result (for lack of a more technical way of putting it).
So when its gets to the ‘if PornCon == 0’ bit of the code component it doesn’t have the value (result) from the randit calculation?
So do I need to remove/disable the PornCon variable component from the initialise routine, and use randint in a begin experiment tab along with addData?
If I’ve got that right, where do I put the ‘addData’ bit
If you want it to appear in every row the put it in a code component Begin or End Routine tab in your main trial routine
when I disable the variable component and replaced it with a begin experiment code component I’m back to getting the PornCond not defined message.
If I try to put in addData (with the variable component enabled) it crashes with addData not defined.
I’ve not used add data before so an trying t work from https://www.psychopy.org/api/data.html
thisExp.addData(‘PomCond’,PomCond) but make sure you’ve got the thisExp bit in code_JS
I still can’t get it to work
In a begin experiment tab I have
PornCond == randint(0,2)
In an End routine
thisExp.addData(‘PornCond’,PornCond)
With PornCond variable component in the initialise routine enabled
Offline: works
Online: ReferenceError: PornCond is not defined
With PornCond variable component disabled
Offline: PornCond == randint(0,2) NameError: name ‘PornCond’ is not defined
Online: ReferenceError: PornCond is not defined
with the appearing in every row.I 'm not sure what you mean. Do you mean from an xls sheet? I’m not using one for this bit
thanks
PornCond == randint(0,2)
should be
PornCond = randint(0,2)
== is used to test for equality, not to assign a value
Arrg. Sorry,I hadn’t noticed that. Its got over the PornCond error. Thanks!
I’m getting a ‘thisExp is not defined’ error but only on Pavlovia. Do I need something in the begin experiment tab?
in the experiment settings it is thisExp.
also, i can open a new thread for this one since its a different problem if that is easier
thanks
You need thisExp=psychoJS.experiment; in code_JS as per my crib sheet