| Reference | Downloads | Github

TrialHandler attributes are not updating

URL of experiment:

Description of the problem:
I am trying to create an online eye tracking experiment which contains presentation of successive images. The images are imported from a list created in excel and I have created a loop named trialList.
In the output csv file however, the attributes of the trialHandler such as .thisTrialN,.thisN and the name of the images presented in each trials do not match with the actual presentation.

In the tracking_pres routine, I have inserted the following code components:

Begin Experiment

trialList = 0;

Begin Routine

if((trialList !=5)){
    continueRoutine = false;

End Routine

trialList +=1;

I have created a simpler version of the experiment which contains everything apart from the eye tracking component and it works just fine.

Apart from seeking for a solution, I would also like to learn how to debug. It would be fantastic if anyone can also give me advices on how I should debug in this situation, thank you very much!

Hi There,

This sounds like a fun experiment! As a start point, please can I check what happens if you move

trialList = 0;

To the ‘before experiment’ tab?

It is great that you have also started narrowing down the problem by making a minimally working demo where this works and doesn’t. Have you also tried adding several console.log(trialList) statements to help pin down the problem? from there opening up your developer tools (ctl-shift-I on windows chrome) you will be able to see where that variable is updating.

If you share the URL to your gitlab project with us (in addition to the experiment URL) we can also take a look at the code if you would like us to. You might need to ensure this is set to public so that we can view it (if you cannot make this public we can give you details to add us as members)


Hello Becca,
Thank you very much for your reply and suggestion. I have just tried with moving trialList = 0;and the csv output remains the same. Information about the TrialHandler attribute is not updated. I have also added console.log(trialList) in the Begin Experiment, Each frame and End routine and the messages have suggested the TrialHandler attributes are not updating, and the name of images stored in the csv file in the loop remained constant (please see the attachment below).

The URL to my gitlab project is

Thank you very much for your time and help!


Hi Andre!

I am getting a 404 error when trying to access your project - please can I check that the permissions is set to public ? (View code <> > settings > permissions> public).

One thing is, I suddenly realised that you are trying to change a specific attribute, so let me provide some context here.

  1. to access and change a parameter of an object in python you need to use dot notation e.g. trialList = 0 wouldn’t change the trialList parameter of your TrialHandler, but trials.TrialList = 0 would (in theory) if trials is the name of your loop in builder (which is a trialHandler object).
  2. the trialList parameter actually expects a list of dictionaries, rather than an integer/numeric value. Typically, this list of dictionaries is created by importing a .csv or .xlsx file. In theory, you should be able to assign a list of dictionaries as input instead (but there are known issues with this currently online, so I would recommend using the standard method of importing a .csv).

What is your goal for changing the trialList attribute? if it is just to quit on trial 5 then that could be achieved by using

trialCounter = 0 #begin experiment tab

trialCounter +=1 #begin routine tab

if trialCounter >= 5: #begin routine tab
    continueRoutine = False #don't progress with this routine
    trials.finished = true # where 'trials' corresponds to the name of your loop #exit the loop 

Hope this helps,

Hello Becca,
Thank you very much for the update! My apologies, I hadn’t changed the permission yet and it is now available to the public.

In regards to your first point, I am going to try trials.TrialList = 0 and certainly changing the name of the loop in builder! The current name of the loop is trialList which can be confusing to myself, and also the others who are interested.

With your second point, it clears my another question actually which I haven’t included in the post, and that is the problem of using dictionaries. Before using Pavlovia I had dictionaries included in my local experiment and it would work. However, when I tried to run it online it didn’t, so I have deleted it.

My goal for changing the trialList attribute was not only to end the experiment after a number of trials, but also to see if the number of trials on the output file would be updated. I have never encountered trialCounter = 0 before and the first point has stated that I was wrong, which may lead to the undesirable output I am currently seeing. I am going to try it now! :slight_smile:


Hi Andre,

Please to hear this clarified some points. If you are attempting to clear the trialList on the fly I recommend trying trials.trialList = [] rather than trials.trialList = 0 (because this parameter expects a list and not an int :slight_smile:

All the best,