# Repitition of error trials in visual search experiment upto a certain limit

**URL:** <https://discourse.psychopy.org/t/repitition-of-error-trials-in-visual-search-experiment-upto-a-certain-limit/43509>\
**Category:** Coding\
**Created:** [January 15, 2025, 1:53pm UTC](https://discourse.psychopy.org/t/repitition-of-error-trials-in-visual-search-experiment-upto-a-certain-limit/43509 "2025-01-15T13:53:45Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tahiti](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/tahiti/32/44327_2.png) [@Tahiti](https://discourse.psychopy.org/u/Tahiti)\
**Post date:** [January 15, 2025, 1:53pm UTC](https://discourse.psychopy.org/t/repitition-of-error-trials-in-visual-search-experiment-upto-a-certain-limit/43509/1 "2025-01-15T13:53:45Z")

</div>

Hi, I am trying to create a visual search experiment which is basically searching for a target in a 4x4 array. Now, I want to repeat error trials upto a limited no of times, for example if there are 5 reps of each condition, then there should be upto a maximum of 7 reps per condition. I have 240 unique conditions and for each condition I need 5 reps minimum and my condition file already contains those 5 repititions for each unique condition, so the conditions file has 240x5=1200 rows(I did this to reduce coding since there were certain specifications about the target position in each trial, since I wanted to avoid too much coding). Now the logic I am trying to use for the repitition is that I am creating a variable that will contain all the conditions extracted from the excel file and then when the trials actually begin I can put for eg, $conditionData in the conditions field of the loop(conditionData is the variable or dictionary I am creating to store the trial conditions). Now depending on incorrect reponses I will add few line of code to update this variable by adding the trial conditions where participants gave a wrong response, to the end of the variable. To check whether this approach works at all i created the variable and gave a print command to check whether the variable is successfully getting created. The variable or dictionary is being created successfully. But psychopy is unable to recognise the conditions from $conditiondata. It is throwing this error: trialList=data.importConditions(trialConditions),  
File “C:\Program Files\PsychoPy\lib\site-packages\psychopy\data\utils.py”, line 358, in importConditions  
if not os.path.isfile(fileName):  
File “C:\Program Files\PsychoPy\lib\genericpath.py”, line 30, in isfile  
st = os.stat(path)  
TypeError: stat: path should be string, bytes, os.PathLike or integer, not list…  
Please suggest what to do. I am very new to Python and coding in general.

---

<div class="post-metadata">

**Author:** ![Tahiti](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/tahiti/32/44327_2.png) [@Tahiti](https://discourse.psychopy.org/u/Tahiti)\
**Post date:** [January 15, 2025, 2:04pm UTC](https://discourse.psychopy.org/t/repitition-of-error-trials-in-visual-search-experiment-upto-a-certain-limit/43509/2 "2025-01-15T14:04:42Z")

</div>

Just to clear up confusion, the actual variable name in my code is ‘trialConditions’ and the error is coming up for the line : trialList=data.importConditions(trialConditions), and this line is automatically being written by psychopy. I am just putting $trialCondition in the conditions field of the loop

---

<div class="post-metadata">

**Author:** ![JensBoelte](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/jensboelte/32/9060_2.png) [@JensBoelte](https://discourse.psychopy.org/u/JensBoelte)\
**Post date:** [January 16, 2025, 8:33am UTC](https://discourse.psychopy.org/t/repitition-of-error-trials-in-visual-search-experiment-upto-a-certain-limit/43509/3 "2025-01-16T08:33:55Z")

</div>

Hello @Tahiti

How do you set the value the of `trialConditions` ? Please show use the relevant line of code.

Best wishes Jens

---

<div class="post-metadata">

**Author:** ![Tahiti](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/tahiti/32/44327_2.png) [@Tahiti](https://discourse.psychopy.org/u/Tahiti)\
**Post date:** [January 16, 2025, 9:48am UTC](https://discourse.psychopy.org/t/repitition-of-error-trials-in-visual-search-experiment-upto-a-certain-limit/43509/4 "2025-01-16T09:48:20Z")

</div>

![reading xlsx1](https://us1.discourse-cdn.com/flex002/uploads/psychopy/original/3X/7/5/75e541326ec6cf9bb00c8dc64370cf879fc63994.png)  
 ![reading the xlsx](https://us1.discourse-cdn.com/flex002/uploads/psychopy/original/3X/4/3/4358eb0ad881ec7b22594917d7a146bc2ba98920.png)

---

<div class="post-metadata">

**Author:** ![Tahiti](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/tahiti/32/44327_2.png) [@Tahiti](https://discourse.psychopy.org/u/Tahiti)\
**Post date:** [January 16, 2025, 9:49am UTC](https://discourse.psychopy.org/t/repitition-of-error-trials-in-visual-search-experiment-upto-a-certain-limit/43509/5 "2025-01-16T09:49:01Z")

</div>

![reading xlsx 3](https://us1.discourse-cdn.com/flex002/uploads/psychopy/original/3X/f/2/f2a0a64968118ee4b0c5411991fc9e4b16f32be0.png)  
 ![reading xlsx2](https://us1.discourse-cdn.com/flex002/uploads/psychopy/original/3X/7/0/7083367794dd68f055fa7f575c0154c765a3dcfc.png)

---

<div class="post-metadata">

**Author:** ![JensBoelte](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/jensboelte/32/9060_2.png) [@JensBoelte](https://discourse.psychopy.org/u/JensBoelte)\
**Post date:** [January 16, 2025, 10:31am UTC](https://discourse.psychopy.org/t/repitition-of-error-trials-in-visual-search-experiment-upto-a-certain-limit/43509/6 "2025-01-16T10:31:24Z")

</div>

Hello @Tahiti

I do not understand what you are doing. You specify a condition file in your loop definition, then you use it to set up a **trialConditions** list which you seem to fill with information from the condition file. This is then stored in the result file.

There is actually no need to define **trialConditions** in a code component if you read the condition file in a loop, as you do. PsychopPy reads the condition file. So all columns in **exp1.xlsx** are accessible to you by referring to the column name, e.g. **target\_ImgNo** , and are stored in the result file.

Best wishes Jens

---

<div class="post-metadata">

**Author:** ![Tahiti](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/tahiti/32/44327_2.png) [@Tahiti](https://discourse.psychopy.org/u/Tahiti)\
**Post date:** [January 16, 2025, 10:39am UTC](https://discourse.psychopy.org/t/repitition-of-error-trials-in-visual-search-experiment-upto-a-certain-limit/43509/7 "2025-01-16T10:39:54Z")

</div>

I understand what you are saying . I already have the conditions data in a .xlsx file which I can directly put in the conditions field of the loop. I do not need to create trialConditions. But I also need the error trials to repeat. In the next block where my trials will run I want to dynamically add the error trials at the end of the trialConditions so that the error trials also run after the already defined trials are done. That was the logic I was using. I am really stuck with this one. Other than the extra code I need to write for the repitition of error trials, the experiment that I have set up in the builder mode is running fine. If You have any other logic for repitition of error trials please let me know. Thank you!

---

<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:** [January 16, 2025, 11:03am UTC](https://discourse.psychopy.org/t/repitition-of-error-trials-in-visual-search-experiment-upto-a-certain-limit/43509/8 "2025-01-16T11:03:24Z")

</div>

Have a loop at my Repeat Subset online demo.

> [@PsychoPy Online Demos](https://discourse.psychopy.org/t/psychopy-online-demos/22319):
>
> If you have routines or experiments that are likely to be useful to others, please create a post in this thread, editing your post to add new demos so there is one post per creator. Ideally set your demos so they can be tested without consuming a credit (if you don’t have a site license) by adding a final routine that can’t end, disabling save incomplete results and adding a small number of credits. Please do not discuss the demos in this thread or create more than one post unless you have a la…
