Selecting one condition for practice before the actual routine

I’m trying to insert a practice routine before the actual routine so participants can understand how it works. Considering that I’ll use the same file with the task conditions, is it possible to select just one condition in the file for practice purposes?

I tried to create specific columns in the same file hoping the practice routine will always show the same image to the participants in the practice routine.

every time I run the experiment I got an error saying the name I chose is not defined despite the column name is the same I put in the practice routine image ($exemplormet).

here’s my experiment chart flow

Any suggestions?

The reason why it does not work is the empty cells (A1:G1) in your excel file. Psychopy does not “like” them.

One way to do it is to create 2 routines, one will be the practice, the other will be the experimental trials. You can keep the same conditions file if you wish for both but:

  1. move the A row to the left so that there are no empty cells.
  2. choose which rows to show i.e. practice or experimental, in the appropriate field in the loop.

P.S. consider LibreOffice and you will not be getting silly messages about product activation$$

1 Like

How can define in the loop if the routine is for practice or experimental?

I do not have psychopy installed in my home laptop but if I remember well, if you click on the loop there should be a field called selected rows(?). This refers to the rows of the conditions file (I believe it starts with 0 for first row but I may be wrong).

So, if I were you, I would create two identical routines; one for practice and one experimental. I would then wrap each one of them in a separate loop. Both loops are “connected” to the same conditions file but the practice loop has selected row as 0 (or 1?) and the other loop will have selected rows the rest of the rows in the conditions file e.g. [2:500].

Does it make sense?

1 Like

If you wanted to practice the whole experiment for a single practice run with specific conditions, an alternative method would be to use the experiment settings dialogue to set up a file name variable that you can use to determine at the beginning of the experiment whether the load a practice or test conditions file. To do this, you could add a “phase” variable to experiment settings, and give it arguments like “prac” or “test”. This information can then be used to load one of two condition files called “RMET_prac.xlsx” and “RMET_test.xlsx”. In the loop dialogue, you would add the following code for the Conditions variable:

$'RMET_' + expInfo['phase'] + '.xlsx'

if you added ‘prac’ to the dialogue box at the beginning of the experiment, the output load a file called RMET_prac.xlsx. You would have to do this for any conditions files that separate practice and test run trials, and adapt the code above to fit those tasks.

1 Like

Hey @dvbridges

I’m approaching this issue using what you posted on my last topic.

I tried this in the rmet_exemplo loop and it’s almost working, but the main problem is that the image I need to appear is not showing, just a gray rectangle. Also, the rmet_example loop is repeating everytime, like rmet_exemplo routine → oRMET (until all the conditions are finished). The rmet_exemplo routine shows a gray image with the word options that will appear next in the oRMET routine. Let me know if you need a better explanation.


What can I do to select the image I desire to appear in this routie example?

here are the coder specifications:
Begin experiment:
cancelimagem_exemplo = 0

Begin Routine:

if Tarefas_loop.thisN <= 2 and not cancelimagem_exemplo > 0:
    cancelimagem_exemplo = cancelinstrucoes_1 + nReps1
    imagem_exemplo.setAutoDraw(True)
    win.flip()
else:
    continueRoutine = False
    pass

End Routine:

if cancelimagem_exemplo > 0:
    myText.setAutoDraw(False)
    win.flip()

Maybe a command different from the .setText one. Any suggestions?

Hi @Bruno_Dalpiaz, I cannot tell why your image is not being drawn from your post. However, you should not need imagem_exemplo.setAutoDraw if you have created the image component in builder. If the image presents, then when the conditional is satisfied you can set the opacity of the image to zero so that it is not seen on other trials e.g., imagem_exemplo.setOpacity(0). I am wondering where is cancelinstrucoes_1 defined? You may want to change cancelimagem_exemplo = cancelinstrucoes_1 + nReps1 to cancelimagem_exemplo = cancelimagem_exemplo + nReps1.

Thanks, @dvbridges
I modified some things and now the image is showing in the practice routine. I created an excel file with just one condition using an example image. The only thing I’m not able to solve is the practice routine repeating every time I begin the actual routine. Every time the oRMET routine begins it returns to the rmet_example routine and keeps this loop until all the oRMET conditions are over.

As you said, I excluded imagem_exemplo.setAutoDraw , now the coder component looks like this:

Begin experiment:
cancelimagem_exemplo = 0

Begin Routine:

if Tarefas_loop.thisN <= 2 and not cancelimagem_exemplo > 0:
    cancelimagem_exemplo = cancelimagem_exemplo + nReps1
    win.flip()
else:
    continueRoutine = False
    pass

End Routine:

if cancelimagem_exemplo > 0:
    win.flip()

No problem @Bruno_Dalpiaz . I think you are still seeing the image after practice because you are not making the image invisible once the condition of cancelimagem_exemplo > 0 is satisfied. Try the following: Replace the End Routine code with:

if cancelimagem_exemplo > 0 and imagem_exemplo.opacity == 1:
    imagem_exemplo.setOpacity(0)
    win.flip()

This conditional should make your example image invisible after the first trial.

I tried to set the end routine as you recommended but nothing changed. the rmet_exemplo condition is still showing before every oRMET routine condition.

Ok well we need to do some debugging. If you add some print statements we can see what is happening. So, print cancelimagem_exemplo after the Begin Routine conditional -after the addition has taken place, and in the End Routine tab after the if statement e.g.,

if cancelimagem_exemplo > 0 and imagem_exemplo.opacity == 1:
    imagem_exemplo.setOpacity(0)
    print(cancelimagem_exemplo)
    win.flip()

still the same problem

Thats fine it was not a fix, we are debugging with print statements to find out if the variables are defined correctly, and conditional statements are allowing the experiment to flow correctly. If you could let me know the output of the print statements that would be useful.

Oh, sorry for that. I didn’t get it because the output is the same as before

Ok it looks like the addition of cancelimagem_exemplo = cancelimagem_exemplo + nReps1 is not taking place, perhaps because nreps1 is not defined in your nested loop. It doesn’t matter, as I think we can simplify this. In the example routine, replace the code in the code component tabs with this:

Begin experiment

cancelimagem_exemplo = 0

Begin routine

if not cancelimagem_exemplo > 0:
    cancelimagem_exemplo = cancelimagem_exemplo + 1
else:
    continueRoutine = False

End Routine

if cancelimagem_exemplo > 0:
    imagem_exemplo.setOpacity(0)
    win.flip()

If this does not work, let me know and perhaps you can upload your experiment.

1 Like

Thank you so much, @dvbridges!
now it works beautifully.

keep the great work!

1 Like