“opponent_condition” is a column inside ‘choose_opponent.xlsx’ which has a list of filenames.xlsx. Now, within each opponent_condition file is a bunch of parameters. For example, there is one called ID_text which i would like to have in a text component on each trial. So in the text box I type $ID_text.
However, when I run the experiment I get the following error:
I haven’t found a satisfactory resolution to that error. However, I did try something based on a different answer (which annoyingly I now can’t find again). It basically said to delete the reference to the condition file in the outer block and instead define the block files in the Begin Experiment tab (i.e. block = [‘name1.xlsx’, name2.xlsx]), and then in the trials condition box, put: $block.pop(). When I do that I get this error:
Any recommendations welcomed. I have read and re-read the post I linked above and can’t figure out what I’m doing differently, so I’m quite confused.
@Anthony I am assuming what you are trying to achieve is you want the trials loop to run upto opponent_condition from the file choose_opponent.xlsx. For that you would have to enter in the Conditions tab as ‘choose_opponent.xlsx’ and in the random seed $ as $opponent_condition.
Thanks for your reply. Unfortunately that hasn’t done the trick. ‘opponent_condition’ is a column header in the choose_opponent.xlsx file. The column then lists other excel files which normally be the conditions for the trials loop (if there was not the outer, blocks, loop). I’m trying to get the trials loop to read the condition from the choose_opponent file, so that it can then loop through the information in the correct opponent_condition file. I’m not sure entering something in the random seed field is the correct approach, at least not as stated in the post I linked to in the original question.
Oh ok. I suppose I had mistakenly read your query. Apologies for that!
In order to randomize the other excel files that are written in one excel file, you would essentially need a code component. I would recommend looking into Randomly present all blocks and then in a reverse order. You would need to redesign the code according to your need.
Also, check if you have set the text box ‘Text’ column set at ‘set every repeat’ or else it will not loop. And as @dvbridges pointed out, there is a simple error of calling ‘opponent_file’ as ‘opponent_condition’. That should do the trick!
@Anthony, not sure if you need to reload your conditions file, but it appears in your image that your column is labelled opponent_file, but you are calling opponent_condition, and that may be why you get your not defined error.
Ok, perhaps something is not working with the Excel sheets. I have an example of nested loops already made. Have a look at this simple example, and see how yours differ. I would make sure my conditions sheets have all the correct information as well.
In the outer Blocks loop, I open the orderA.xlsx sheet, which has entries for A.xlsx and B.xlsx. A and B sheets have text entries for formatting the text component.
As far as I can tell I have everything set up exactly as you have. Very odd.
However, I’ve now written code as outlined by the link @Shardul_Shankar provided and this method is working now. It’s the same approach I used in the second half of my original post, but this time it worked. There were a few changes in the meantime so I’m not 100% sure what is different.
Thanks for your help. It’s a shame I can’t get the simpler, GUI approach to work. I’m not averse to coding, I just don’t like having perplexing questions left over!
Thanks for this. This is the link I was referring to in the second half of my original post but couldn’t find it again!
I’ve used this now and it is working. I’m not 100% what changed from this iteration to the one that didn’t work before, but such is the nature of these things sometimes!
Hi @Miao, if you click the link to the psyexp file, copy the text and paste it into a text editor e.g., PsychoPy Coder, then save that file with a .psyexp file extension, this should work.