# Using expInfo for counterbalancing to call upon different files

**URL:** https://discourse.psychopy.org/t/using-expinfo-for-counterbalancing-to-call-upon-different-files/20334
**Category:** Online experiments
**Tags:** randomization, pavlovia
**Created:** [February 9, 2021, 4:59pm UTC](https://discourse.psychopy.org/t/using-expinfo-for-counterbalancing-to-call-upon-different-files/20334 "2021-02-09T16:59:09Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![stelodae6](https://avatars.discourse-cdn.com/v4/letter/s/ed655f/32.png) [@stelodae6](https://discourse.psychopy.org/u/stelodae6)
#### Post date: [February 9, 2021, 4:59pm UTC](https://discourse.psychopy.org/t/using-expinfo-for-counterbalancing-to-call-upon-different-files/20334/1 "2021-02-09T16:59:09Z")

</div>

PsychoPy v2020.2.8, running on MacOS big sur v11.1. Pavlovia run from Google Chrome v87.0.4280.141 (x86\_64)

Hello all,  
I am continuing to set up my experiment on builder and syncing it every now and then to pavlovia to make sure that it pilots on there as well. I’ve run into a problem that is leaving me rather dumbfounded.

 ![Screen Shot 2021-02-09 at 5.34.49 PM](https://us1.discourse-cdn.com/flex002/uploads/psychopy/original/3X/1/8/185811ed70aaf35c522ab74e22174149e796a8c0.png)  
My setup is as such. I have first an instruction routine where a jpg of the instructions is presented (semanticGo), then an experimental routine that loops over a csv (semanticExp). There are 2 versions of each (v1.jpg, v2.jpg, and v1.csv, v2.csv). Odd numbered participants should get the first one, even numbered should get the other. Sounds simple enough, right?

**My first solution (didn’t work):**  
I added a field to expInfo “SEMVERS” with the default value “v1”. For odd participants I will manually enter v1 and for even numbered participants v2. I call upon this information for the instruction routine, then again in the Conditions field for the exp routine.

 ![Screen Shot 2021-02-09 at 5.28.46 PM](https://us1.discourse-cdn.com/flex002/uploads/psychopy/original/3X/6/4/6498515617a0d83a595c3d5fc2ef20e4abf001cc.jpeg)

Locally, it works great. As soon as I put it online I get the error:

 ![Screen Shot 2021-02-09 at 5.18.51 PM](https://us1.discourse-cdn.com/flex002/uploads/psychopy/original/3X/6/9/691b17dc67918da582fe7eb325db48c4f8ab5357.png)  
This is frustrating because I have done the exact same thing earlier on in the experiment (calling upon an expInfo condition in the ‘conditions field’) and it works great both online and locally. I’ve tripled checked that the files have been synced properly, that the cache has been cleared before running the experiment, and that a copy of the materials are in the path html/resources.

**Second attempted solution (didn’t work):**  
I removed the newly added expInfo field mentioned above and instead added a code component in the “begin routine” part of the instructions routine, written in JS. I then call upon this item in my imageStim “$semGroup”. Now, the experiment doesn’t even run locally, and much less online! (It works locally with the same code in python by the way, just not with javascript). I tried changing the Image field from constant to set every repeat and that doesn’t change anything either.

 ![Screen Shot 2021-02-09 at 5.44.47 PM](https://us1.discourse-cdn.com/flex002/uploads/psychopy/original/3X/0/8/08b2f9150e5e92c174112274b382ef1ad5918923.jpeg)

The error:  
`NameError: name 'semGroup' is not defined`

I am truly so frustrated because I feel that this should be so simple yet I am struggling so much. Does anyone have any ideas?? I’d appreciate it so much.

---

<div class="post-metadata">

### Author: ![wakecarter](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/wakecarter/32/5753_2.png) [@wakecarter](https://discourse.psychopy.org/u/wakecarter)
#### Post date: [February 9, 2021, 5:08pm UTC](https://discourse.psychopy.org/t/using-expinfo-for-counterbalancing-to-call-upon-different-files/20334/2 "2021-02-09T17:08:20Z")

</div>

When you add resources in code you need to tell PsychoPy about them in Online tab of Experiment Settings or download them on the fly. I’d recommend downloading both v1.jpg and v2.jpg in addition to both Excel files.

You should put semGroup="" above the if statement to get rid of the not defined error.

---

<div class="post-metadata">

### Author: ![stelodae6](https://avatars.discourse-cdn.com/v4/letter/s/ed655f/32.png) [@stelodae6](https://discourse.psychopy.org/u/stelodae6)
#### Post date: [February 9, 2021, 6:17pm UTC](https://discourse.psychopy.org/t/using-expinfo-for-counterbalancing-to-call-upon-different-files/20334/3 "2021-02-09T18:17:12Z")

</div>

Hi @wakecarter thanks for your quick reply.

I’ve added the code you suggested, but I’m still getting the NameError.

 ![Screen Shot 2021-02-09 at 7.05.18 PM](https://us1.discourse-cdn.com/flex002/uploads/psychopy/original/3X/9/2/9249103e1365fb771ec3fd7ff2b84d4e57fba620.jpeg)

I didn’t know about the Online tab of Experiment Settings, I’ve added the resources there as well. I’m not sure if I have to fill out the rest of the fields

 ![Screen Shot 2021-02-09 at 7.06.07 PM](https://us1.discourse-cdn.com/flex002/uploads/psychopy/original/3X/8/9/89d63ee124bb3bfedef437a26335dcdf787b56f0.jpeg)

What do you mean in your comment about " downloading resources on the fly" ?

---

<div class="post-metadata">

### Author: ![wakecarter](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/wakecarter/32/5753_2.png) [@wakecarter](https://discourse.psychopy.org/u/wakecarter)
#### Post date: [February 9, 2021, 6:31pm UTC](https://discourse.psychopy.org/t/using-expinfo-for-counterbalancing-to-call-upon-different-files/20334/4 "2021-02-09T18:31:59Z")

</div>

Sorry, I meant put it in a Begin Experiment tab.

On the fly means after the experiment has started.

---

<div class="post-metadata">

### Author: ![stelodae6](https://avatars.discourse-cdn.com/v4/letter/s/ed655f/32.png) [@stelodae6](https://discourse.psychopy.org/u/stelodae6)
#### Post date: [February 9, 2021, 6:41pm UTC](https://discourse.psychopy.org/t/using-expinfo-for-counterbalancing-to-call-upon-different-files/20334/5 "2021-02-09T18:41:03Z")

</div>

@wakecarter even with

```auto
semGroup = "";

```

in the Begin Experiment tab, I still get the NameError

I’m not sure if there’s a third alternative way to do what I’m trying to do? Do you have any suggestions?

---

<div class="post-metadata">

### Author: ![wakecarter](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/wakecarter/32/5753_2.png) [@wakecarter](https://discourse.psychopy.org/u/wakecarter)
#### Post date: [February 9, 2021, 6:47pm UTC](https://discourse.psychopy.org/t/using-expinfo-for-counterbalancing-to-call-upon-different-files/20334/6 "2021-02-09T18:47:10Z")

</div>

I’ve just noticed that you are writing in JS only code components .

As per my crib sheet I strongly recommend coding in Python in Auto translate code components. This will help check your syntax.

expInto[‘participant’] will be text so I use int(expInfo[‘participant’])
