psychopy.org | Reference | Downloads | Github

"NaN" appears when using spacebar to denote empty cell in pavlovia

Hello everyone. I’m a graduate student trying to code her masters project and I’m struggling. I am trying to create a sternberg-like memory task where participants will see a list of words (vertically) and then see a probe where they have to decide if the word was in the list or was not. I have varying set sizes of 4,6, and 8 words. I currently have it set up where each word is represented by a cell in excel (screenshot below) and then a corresponding text item for each word. When there are only 4 or 6 words I put spaces into the corresponding cells in excel and it works perfect locally (psychopy on my Mac). However, when I sync to pavlovia, I get “NaN” where the spaces are in the excel file. How can I get a blank to show when there are less words than spots? Should I be setting this up a different way? Any help would be greatly appreciated.

I think I recognise this bug - we were having issues recently with blank text components appearing as NaN because of differences in how PsychoPy handles blank values between Python and JS. I put in a bug fix for it in version 2020.2.5, so if you update your PsychoPy version then sync your experiment again it should compile correctly. Let me know if it doesn’t!

Thank you for the response! The URL to my study for reference is https://run.pavlovia.org/kmcgatlin/sternberg-practice-trials/html. Now, it runs locally fine but when uploading to pavlovia I am stuck on the initializing screen. Wnen I opened the console, the error I was getting is Uncaught SyntaxError: Unexpected token ‘,’. I am unsure what this means.

Ah this was my mistake - I do have a fix in but it’s not in 2020.2.5, it’ll be in the next release (hopefully soon). For the time being, just putting a placeholder bit of text like a full stop is probably the best method.

Can you go more in depth about that means? Thank you for your help!

We noticed that blank Text components weren’t working in Pavlovia some time between versions 2020.2.4 and 2020.2.5, so I fixed it and thought the fix was in 2020.2.5 but we missed it, so it will be in 2020.2.6 instead (which should be out in the next few days).

Sorry, I meant about adding a full stop place holder? I’m still pretty new to coding. Thank you!

@TParsons

Oh I see! Sorry, by that I mean set the value of blank cells in the excel sheet to be a full stop rather than blank.

Will I need to restructure how I’m giving the words to the participants? I want the list of words to be vertical not horizontal so each word is in a separate cell. How would I incorporate a full stop to help? Thank you!!

Hi @TParsons, I went ahead and replaced all spaces with a period, even though I’m not super happy with how that looks when shown to the participants it works for now. However, when I try running on Pavlovia I still get the same error. I have checked all the code I hand wrote but still isn’t working.

The long term fix for this should be in the standalone version now, could you try updating to this version and see if you still get the error?


If you do, could you share the .py and .js files generated in the same folder as the experiment when you try to run it?

Hello! Thank you, it now runs on psychopy and pavlovia but still shows NaN when ran on pavlovia. metaFile.xlsx (8.6 KB) OApractice.psyexp (137.3 KB) practice1.xlsx (13.1 KB) practice2.xlsx (12.7 KB)

It says the .js files are not authorized to be uploaded.

I’m also having this problem. Would it be possible to store them as raw   when converting them to Javascript? That would possibly work around this. Currently if I do   it appears verbatim!

I’m on Windows 10 and using 2020.2.10.

What I do is put an x in the Excel file and then update the text component in code if the value of the variable isn’t x

2 Likes

Hi! I have the same issue with the empty cell generating a NaN when run on Pavlovia. I think that your idea to put an “x” in the Excel file works best, but can you explain how to update the text component in code?
I thought about modifying the js file by opening the coder view and then editing this file, but would this update the experiment code even if the rest is all made on Builder? Or do I need to open another file? Sorry if that’s too obvious, but I’m pretty new to coding.
Thanks in advance

There are two options. The following needs the code component to be above the text component set to $displayText Each Repeat.

displayText=columnName
if displayText=='x':
     displayText=' '

The alternative needs the code component to be below the text component and set to columnName Each Repeat.

if columnName=='x';
     text_component.text=' '

Thanks for your help! Now, after modifying the .py file, when I run it on Coder I see the desired result, but when I run it through Builder, it still shows ‘x’, instead of a blank screen. Same when I run it online. Should I make the same changes in the .js file too to get it running online? And what about the Builder? How do I push the changes also there? Thanks again!

Don’t make changes in Coder if you want to run your experiment online.