Problem to read a code on Pavlovia

URL of experiment: Sign in · GitLab

Description of the problem:

Hi,
This code uses all the previus responses to do a final feedback. The message appears properly on Psychopy, but on Pavlovia appear just “doh!” and not the right message (msg) that I really want.
To build this code, I’ve just copy from others experiments, so I don’t understend it very well, but it is working on Pshophy… What could I do to fix this on Pavlovia?
Thank you


Hi There,

Please could you show the full text in the left hand panel for us? I think using this instead should work:

nCorr = sum(study.data['totalacertos'])
meanRT = average(study.data['key_resp_2.rt')
msg = 'Voce acertou' + str(nCorr) + 'operacoes de 192....' + str(meanRT)

In general, plus concatenation is smoother to translate to JS over formatted strings. and using the methods sum and average in this new way translate smoother than calling the method on the object as you have done (and as would be normal in python)

Hope this helps,
Becca

Great.
This will be very helpful.
Here is the full text of the code:

nCorr = study.data['totalacertos'].sum() #.std(), .mean() also available
meanRt = study.data['key_resp_2.rt'].mean()
msg = "Você acertou %i operações de 192, com tempo de reação médio de %.2f segundos. Pressione [→] para continuar." %(ei,ui/192)

It is in portuguese (Brazil) and says that:
-You hit %i operations out of 192, with an average reaction time of %.2f seconds. Press [→] to continue." %(ei,ui/192)

  • [totalacertos] is the sum of a colum in the output witch all the right answers will be iqual to 1. So I have to divide this sum for 192 (total of tasks) and after show the mean of reaction time.

Now I have to write:

nCorr = sum(study.data['totalacertos'])
meanRT = average(study.data['key_resp_2.rt')
msg = 'Voce acertou' + str(nCorr) + 'operacoes de 192, with an average reaction time of' + str(meanRT)  [?]

Thank you very much in advance

Yes that sounds about right! could you give that second code snippet a go and let us know if that works for you?

Thank-you!
Becca

Hello,

I tried the changes but it still appearing just ‘doh!’. Are there something wrong with my code?

nCorr = sum(study.data[‘totalacertos’])
meanRT = average(study.data[‘key_resp_2.rt’)
msg = 'Voce acertou ’ + str(nCorr) + ’ operaçõeses de 192, com tempo médio de reação de ’ + str(meanRT)

Hi,

I keep trying but I still need help to fix this.
What more could I do? Is the code correct now or have something wrong?

Hi There,

Sorry for the delay responding here. I think there were 2 things:

  1. the quotation marks had formatted to “curly” quotations - a way to avoid that in future might be to use double (") rather than single (’) quotes.
  2. there was a missing closing square bracket on the second line.

This correctly auto translted for me:

nCorr = sum(study.data['totalacertos'])
meanRT = average(study.data['key_resp_2.rt'])
msg = 'Voce acertou ' + str(nCorr) + ' operaçõeses de 192, com tempo médio de reação de ' + str(meanRT)

Thanks for the corrections.

I believe they worked. The only problem is that after the correction the variable [totalacertos] is not being recognized and this generates an error. Even though the variable is being created in the output, Pavlovia is not recognizing it. Any idea what I should change?

I will put the images with the codes related to the variable [totalacertos].



I think the issue is that study.data is undefined. If you comment out line 1 of Begin Routine, you’ll probably get an error message related to line 2 instead.

I’m not sure about the automatic creation of results dictionaries. Does this code work offline?

I had to change part of the code. Pavlovia reads JAVA and for this I had to change de way to add data. First I used study.addData(‘totalacertos’, Acerto) and it runs on Psychopy, affter I changed to thisExp.addData(‘totalacertors’, Acerto) to run on Pavlovia and to have this data on the output.
So, Have I to change the name study.Data to thisExp.Data? Or is there another way to this data be recognized on Pavlovia?

What does the variable study correspond to in your experiment? could you show us where you first define it?

Thanks,
Becca

I am really glade for all help

The variable study is the name of the loop on my experiment.

My idea is add a colum on the output (called [totalacertos]) and in each correct answer will appear the number “1” to be summed and showed all the correct answers on the last feedback of the experiment [Feedback_Fim].

image

I am trying to follow the original experiment. They aks to answer some tasks with a feedback, then give a pause, and repeat this oder times, then give a final feedback with the number of correct answers and the reaction time.

To the best of my knowledge loops don’t have a data method so you can’t access data from a loop by using study.data[‘varname’]. I’d be interested to find out where you got this suggestion from.

What I do is, for example, append to a custom list of scores or reaction times and then calculate the sum, mean or median of that list.

yes loops don’t have an inbuilt attribute called data (but I though perhaps this was a custom attribute that had been added? )

Dear Becca and Wakecarter, thank you for your feedback. I am working with gustavo in this specific experiment. I honestly dont remember where we got the orientation for getting data from the loop using the study.data[‘varname’], but it did work when running the task in psychopy. But when we moved to pavlovia we didnt get the right feedback (sum of hits and average of reaction times) anymore. It probably is a thing with this unconventional strategy. What would you recommend us to do? I am not very experienced with psychopy so I didnt understand very well the suggestion to “append to a custom list of scores or reaction times and then calculate the sum, mean…”.

Best regards and thank you for the help
Ricardo

Hi. Just writing to tell I managed to do it. I created an empty variable at the beginning and add 1 for each correct answer.