Adding a Flag Trial Button

Hello! I am trying to build an experiment in psychopy, where there are two images and each plays a different sound upon being tapped and there are 10 taps total per routine. However, I have been trying to build in a “bad trial” button for the experimenter to flag any trials (a single tap) where there might have been an accidental tap or something of that sort, so we know to exclude that trial later. I have tried inserting a button but cannot really get an output. Any help is appreciated, thank you!

Do you mean you’ve added a touchscreen button?

How about:

if mouse.isPressedIn(badtrial):
     thisExp.addData('Flag','Bad Trial')

Yes, a touchscreen button. I did try that code and I just cant seem to get an output. The button appears on the screen and I can click it. A file appears on my desktop that I think the data should be in (for the bad trials), but it does not give me any.

I think you need to be more specific about what you are trying to do. That code will just save information to you standard CSV file. Are you trying to save information to a separate file so that future runs of that (or perhaps any) participant will skip those trials? I assume you are running the experiment locally.

Okay got it. We just need there to be indication in that csv file that the button was clicked and for which trial it was clicked. Right now nothing is appearing in the file once the experiment has ended.

Please could you show your trial routine and any code you are using to save additional data?

Are you getting standard data from your trial routine in your data file?

I will attach a photo of the experiment. We just get output data in a log file, which happened automatically when we started building the task and running it on pilot mode. I’m new to PsychoPy so I am not sure if I am supposed to be adding extra code to store data. I will also attach a photo of the button settings.