Modifying contents of a loop table
Hello guys,
I have tricky questions today.
I wonder if it is possible to modify some values in a loop table (the built-in sequence structure) during the execution of the program. Is it also possible to read the contents of an Excel file into the loop table before execution of the program ?
Cheers,
Gérard
Comments
Hi Gérard,
Is it also possible to read the contents of an Excel file into the loop table before execution of the program ?
Yes, just select file as source for the loop table instead of table
I wonder if it is possible to modify some values in a loop table
Yes, that is possible. It is quite trivial to change the values of the current trial. Just set the value of the variable to whichever value you want.
If you want to change the entire table, you need to access the underlying datatable, which is possible but a little trickier. I think you can access it by
items['new_loop'].dmor whatever the loop is called. Allowed operations on that datamatrix object you can check in the dedicated documentation: https://datamatrix.cogsci.nl/Hope this helps,
Eduard
Hello Eduard,
Thank you for your fast reply. I realize that my explanations were not totally clear. Actually, what I want to do is to modify a value of a variable in a row of the table at a certain trial in order to influence the behavior of the program during the next occurence of that row (another trial on the same row).
In practice, I always use a file as the source of the loop table. That means that I would have to change the value in the Excel file itself, which is possible in theory but would probably be very "heavy". Another solution could be to load the full table from the file into the loop table of the experiment and to make the change in that table. But I don't know how to do that operation - and it is probably what your are referring to in you reply. I shall investigate in that direction but it is not obvious for me because I am not familiar with the 'underwears' of OpenSesame.
Any additional advise or correction on my perception of the project ?
Thank you in advance,
Gérard
Hello Eduard,
Another possibility could be to copy the contents of the loop Excel file into a table in memory using a Python script. I have been able to do that but the question is : is it possible to integrate (copy ?) that table into the regular loop table ? In other terms, I come back to the previous question : is there any possible access to that loop table, other than typing the values inside it ?
Thank you,
Gérard
Hi Gérard,
Sounds reasonable. Your situation should be covered by my second scenario. So yeah, you should look into the datamatrix documentation (and search the forum for datamatrix questions).
Another possibility could be to copy the contents of the loop Excel file into a table
Sure, you can do that as well. But this won't be much different that directly modifying the loop table with datamatrix. I don't think it matters much whether you do one or the other.
Good luck!
Eduard
Hi Eduard,
Because I wanted to keep the core structure and functionnalities of Open Sesame, especially the loop structure, I have created a complementary table in memory, using an index to link that table and the Excel data source file. You might be interested by the following:
Thank you again for your support.
Gérard