Creating clickable text alternatives

@dvbridges No problem. I tried to use the mouse components you attached but i still couldn’t get the ‘ResponseAcc’ column in the data file :disappointed: I’m just getting the specific button I pressed and the axis numerical value.

Ok @Bruno_Dalpiaz, could I see your code component code please?

Here is the each frame component

if mouse.isPressedIn(eval(corrPos)):
    corr = 1
else:
    corr = 0

And this is the end routine component

thisExp.addData('responseAcc', corr)

these are the ones you were asking for, right?

Ok @Bruno_Dalpiaz that looks fine, but looking at your output I am wondering why you have duplicate information in your RMET_loop output?

I don’t think it’s duplicated data, @dvbridges

I’m getting pretty specific data from each button of the mouse component. Maybe specifying just the left button in the code? Is that possible? You think it may work?

Thanks @Bruno_Dalpiaz, I was not sure why you had so many columns, but that is fine. I’m not sure what is happening, but it may be worth adding some print statements to debug. For example, add a print statement after the conditional in the code component, just to make sure that the conditional if mouse.isPressedIn is working correctly. So, perhaps do:

if mouse.isPressedIn(eval(corrPos)):
    corr = 1
    print("{} for mouse function, and {} for corr variable".format(mouse.isPressedIn(eval(corrPos)), corr))
else:
    corr = 0

Then for the code in End Routine

print(corr)

This will at least show in the output whether the corr variable is defined properly.

Hi,

It seems that you have a similar issue to what I was doing recently. Perhaps this will help:

in short, it might be enough to use the following:

# check if the mouse is pressed within the current one:
if mouseresp.isPressedIn(your target image name):
    thisExp.addData('correct', '1')
else:
    trhisExp.addData('correct', '0')

However, I’m not sure this will work the same, since your 4 images appear to be text objects? Are you presenting your participants with images or words?

1 Like

This is what I got in the output after I add the print statements, @dvbridges :

Running: C:\Users\Bruno Dalpiaz\Desktop\experimento\julgamento moral\experimentoJM_lastrun.py
pyo version 0.8.7 (uses single precision)
0
True for mouse function, and 1 for corr variable
True for mouse function, and 1 for corr variable
0
0
0
True for mouse function, and 1 for corr variable
1
True for mouse function, and 1 for corr variable
True for mouse function, and 1 for corr variable
False for mouse function, and 1 for corr variable
True for mouse function, and 1 for corr variable
1
0
True for mouse function, and 1 for corr variable
1
True for mouse function, and 1 for corr variable
1
0
True for mouse function, and 1 for corr variable
True for mouse function, and 1 for corr variable
True for mouse function, and 1 for corr variable
True for mouse function, and 1 for corr variable
1
True for mouse function, and 1 for corr variable
True for mouse function, and 1 for corr variable
True for mouse function, and 1 for corr variable
True for mouse function, and 1 for corr variable
True for mouse function, and 1 for corr variable
1
0
0
0
0
0
True for mouse function, and 1 for corr variable
True for mouse function, and 1 for corr variable
True for mouse function, and 1 for corr variable
0
0
0
0
0
0
0
True for mouse function, and 1 for corr variable
True for mouse function, and 1 for corr variable
True for mouse function, and 1 for corr variable
0
True for mouse function, and 1 for corr variable
1
True for mouse function, and 1 for corr variable
1
True for mouse function, and 1 for corr variable
1
True for mouse function, and 1 for corr variable
True for mouse function, and 1 for corr variable
True for mouse function, and 1 for corr variable
0
True for mouse function, and 1 for corr variable
1
0
0
True for mouse function, and 1 for corr variable
1
True for mouse function, and 1 for corr variable
1
0
True for mouse function, and 1 for corr variable
1
True for mouse function, and 1 for corr variable
1
11.4746 ERROR avbin.dll failed to load. Try importing psychopy.visual
as the first library (before anything that uses scipy)
and make sure that avbin is installed.

Running: C:\Users\Bruno Dalpiaz\Desktop\experimento\julgamento moral\experimentoJM_lastrun.py
pyo version 0.8.7 (uses single precision)
0
True for mouse function, and 1 for corr variable
1
0
True for mouse function, and 1 for corr variable
1
True for mouse function, and 1 for corr variable
True for mouse function, and 1 for corr variable
True for mouse function, and 1 for corr variable
1
True for mouse function, and 1 for corr variable
1
True for mouse function, and 1 for corr variable
1
True for mouse function, and 1 for corr variable
1
True for mouse function, and 1 for corr variable
1
0
0
0
0
0
0
0
True for mouse function, and 1 for corr variable
1
True for mouse function, and 1 for corr variable
True for mouse function, and 1 for corr variable
True for mouse function, and 1 for corr variable
True for mouse function, and 1 for corr variable
True for mouse function, and 1 for corr variable
1
True for mouse function, and 1 for corr variable
True for mouse function, and 1 for corr variable
True for mouse function, and 1 for corr variable
True for mouse function, and 1 for corr variable
True for mouse function, and 1 for corr variable
1
0
0
True for mouse function, and 1 for corr variable
1
0
True for mouse function, and 1 for corr variable
1
True for mouse function, and 1 for corr variable
True for mouse function, and 1 for corr variable
1
True for mouse function, and 1 for corr variable
1
True for mouse function, and 1 for corr variable
1
0
0
0
True for mouse function, and 1 for corr variable
0
True for mouse function, and 1 for corr variable
True for mouse function, and 1 for corr variable
True for mouse function, and 1 for corr variable
False for mouse function, and 1 for corr variable
True for mouse function, and 1 for corr variable
1
0
True for mouse function, and 1 for corr variable
True for mouse function, and 1 for corr variable
1
True for mouse function, and 1 for corr variable
True for mouse function, and 1 for corr variable
True for mouse function, and 1 for corr variable
1
0
0
3.9482 ERROR avbin.dll failed to load. Try importing psychopy.visual
as the first library (before anything that uses scipy)
and make sure that avbin is installed.

Thanks, you should not be getting False for mouse function, and 1 for corr variable because False would mean that the mouse was not pressed in the shape and so corr should be zero. As @agata suggested, perhaps this can be simplified if you do not need a response variable to work with. So, remove all code from the Each Frame tab, and clear the End Routine tab and enter the following:

if mouse.isPressedIn(eval(corrPos)):
    thisExp.addData('responseAcc', '1')
else:
    thisExp.addData('responseAcc', '0')

@dvbridges I’m getting the same output data file I did before, even if I change the column variable name.


@agata The responses are not images contained in my condition file, they’re translucid objects over the four text alternatives. Therefore, the condition file contains wich object is correct for each image that is presented in the center of the screen.

Ok @Bruno_Dalpiaz, would you be able to upload your experiment files here (not the jpgs, I will just delete the jpg presentation)? This would be very helpful as I cannot tell from this information why this problem persists, as it works ok in my example.

I belive this is all I got for the experiment, @dvbridges

condition_rmet.xlsx (10.0 KB)
Dilemas_Morais_A.xlsx (15.3 KB)
Dilemas_Morais_B.xlsx (14.0 KB)
experimentoJM.psyexp (73.7 KB)

I see, so one thing to do (which I did) would be to randomise location and always have your correct response in the same column, but that would require a lot of changes in your experiment, so see if @dvbridges can help, especially because that’s a messy solution.
Looking at your files though (and I’m quite new to psychopy so might be wrong here), have you tried to change the code to:

if mouse.isPressedIn(eval(corAns)):
    thisExp.addData('responseAcc', '1')
else:
    thisExp.addData('responseAcc', '0')

as in, referring to your correct answer column directly?

@Bruno_Dalpiaz, the problem was that trial handler is called RMET_loop, whereas in my example it was called thisExp. So, change the code to the following in the End Routine tab, and it will (should) work:

RMET_loop.addData('responseAcc', corr)

See example data attached _untitled_2018_Mar_09_1603.xlsx (12.1 KB)

Now it’s working great! Thank you so much, @dvbridges. It had to be something that simple, now I feel a little silly because of that lol. I really appreciate the time you spend helping me, now I understand better the software and willing to learn more.

Thanks @agata for the tips too.

keep the awesome work.

Best Regards

1 Like

Hi @dvbridges
Is possible to add the RT of each text click and, if possible, the full RT of the routine? I’m not pretty sure how to code something like that.

Thank you very much.

Hi @Bruno_Dalpiaz, you can add the following to your code component under relevant tabs (assuming your mouse click ends the routine):

Begin Routine

stimOnset = []

Each Frame

if fixation.status == STOPPED and len(stimOnset) < 1:
    stimOnset.append(t)
if mouse.isPressedIn(eval(corrPos)):
    corr = 1
else:
    corr = 0

End Routine

fromFixationRT = t
fromStimRT = t - stimOnset.pop()
RMET_loop.addData('responseAcc', corr)
RMET_loop.addData('fromFixationRT', fromFixationRT)
RMET_loop.addData('fromStimRT', fromStimRT)
2 Likes

Works great, thank you very much, @dvbridges

Hey @dvbridges,
Experiment is working great, I just want to know if it’s possible to add a column next to responseAcc with the response that the participant gave (even if he clicked the wrong answer).

Thanks