Extremely slow compiling .js script from Builder

Every time I attempt to compile the .js script from the Builder after making small changes to the task, it eventually does compile, but it takes >15mins to do so each time.

Here is the link to the project I am changing: Sign in · GitLab, but I believe it’s also doing this with other projects I’ve made that have successfully been run in the past. I am working with Mac OS Ventura 13.5.2 and PsychoPy 2024.2.4 compatibility+ with no version specified, though the project was made from scratch on this platform.

Is there any fix for this?

Do you have lots of similar routines and/or similar components.

Do you have a large payload of resources?

Right now there are two routines, one routine has several components that are similar to one another. I am using one conditions csv.

That should be fine unless by several you mean 20+.

In experiment settings, the use version should be blank but I thought you’d already said that.

I believe it was slow because my conditions file was quite large / had many conditions, which I’ve cut down on as needed.

I’m now encountering two issues:

  1. I currently have stimuli/text that flash very quickly on the screen for 1 frame at the beginning of routines.
    These stimuli/text are either deliberately shown later in time in the current routine or are leftover from the previous routine, and just flash very quickly at the beginning of the current routine for no reason.
    The text stimuli are consistently in the former, and the rectangle stimuli (of which I am changing the border thickness & width with a constant parameter) consist of the latter and also briefly flash with no border at all.
    I have tried variations of.setAutoDraw(false), re-defining these stimuli at the beginning/end of routines, and setting specific durations.

  2. I am attempting to proportionally locate a word at a specific horizontal distance from another location based on the length of the word. The .anchorHoriz function threw an error saying it was undefined, and when I attempt to add whitespace characters/spaces behind the word itself, it is not registered in PsychoPy when these characters are added behind the word (but work when added in front of the word). Unfortunately I need the space behind the word.

I’m hoping for solutions to all of these if possible? Thank you for your help!

Hello

This could be a version issue. Try the latest version or 2024.1.4

How do you try to achieve this? In flanker experiments, I use the following code to construct the flanker-target stimulus
Begin experiment

TarFlank = " "

Begin routine

Tarflank = Flanker + " " + Target + " " + Flanker

TarFlank is the combined stimulus. Flanker and Target are the column names in the condition file for the respective stimuli.

Thank you for the response!

Unfortunately this issue still remains after specifying the version. Also, in case it is relevant information, I am running the task in Pilot mode on the browser from Pavlovia.

I use $Word + ' ' in the Text property of the Text stim, where Word is the respective column name in the condition file. Intuitively, it also does not work in the instance of: $Word + space_cons where space_cons = ' '.
The adding of spaces and/or white characters works when it is $' ' + Word, but not when the spaces are the last input in the Text property after the word itself (the first example).

I then set the Position[x,y] of the Text stim to a $position variable such that the word is offset from this position by the amount of space added above, which again works when the space is added before the word.

Compiling is always slower when you specify a version as opposed to leaving that field blank, because PsychoPy has to download the libraries for the specified version before it can compile.

@wakecarter Apologies for the confusion, by “this issue” I am now referring to these:

Hello

As I wrote, I set the flanker-stimulus via code and then refer to the constructed stimulus in the text-property of the Text stim. So, what about trying it?

Best wishes Jens

@JensBoelte Unfortunately that did not address the issue either.

Could you try a textbox instead of a text stim? It has more alignment/anchor parameters.

Please explain more about the white space? Have you seen my letter detection demo which calculates the letter being clicked on backed on the coordinates and a monospace font. Letter detection task

  1. Unfortunately the textbox also does not take into account the spaces I incorporate to the right of the word.
    I did take a look at this demo, thank you for sending!
    I am trying to place this word offset from a location that is to the right of the word, proportional to the size of the word.
    Ideally, I am trying to place two words in a box, one that is offset to the right from the center of the box, the other that is offset to the left from the center of the box. I can’t just put in a specific location (e.g. center of box - 1/6 the length of the box) because these words vary in size so I want them to proportionally be placed in the box, one on the left and one on the right based on their length. The two words cannot be in the same text stimuli because they each have to be different colors.
    Adding a constant number of spaces to the word in the text field and setting the location to the center of the box I think did the trick with the one word where the spaces were placed on the left. I am currently attempting to right-anchor & right-align the textbox and set that location to be a specific distance from the center to see if this achieves what I am looking for.

  2. I have also been trying to solve the flashing issue to no success.
    I believe one of the issues contributing is that for one of the rectangle stimuli I set border color & width based on parameters that update each frame, which I then set back to [-1,-1,-1] and 5 at the end of the routine (and I also set these at the beginning of the routine). When the routine starts up again in the loop, it seems as though these parameters briefly retain the values of what they were set to during the frame update, even though I am actively setting them back in the End Routine and Begin Routine tabs.

I think there may be a lag in displaying stimuli with parameters set to specific conditions (e.g. opacity, border color/width), in which they are displayed briefly before these parameters are set/applied from the code chunk.

If you want a constant gap between two words then a right aligned and right anchored textbox to the left of a left aligned left anchored textbox would be the easiest solution. If you want the gap to vary then you could update the x coordinates based on the number of characters in the word. Alternatively you could use normal centred text and adjust the x coordinates accordingly – though you would need to use a monospaced font to be accurate.

I have had issues with changing textbox borders on a frame by frame basis.

The alternative would be to use a separate coloured polygon.

If you have a setting set to update every frame then it will show one frame left from the previous trial unless you actually set the colour (e.g. using textbox.setBorderColor() ) in Begin Routine. However, this may have other issues – hence polygons

If you want a constant gap between two words then a right aligned and right anchored textbox to the left of a left aligned left anchored textbox would be the easiest solution. If you want the gap to vary then you could update the x coordinates based on the number of characters in the word. Alternatively you could use normal centred text and adjust the x coordinates accordingly – though you would need to use a monospaced font to be accurate.

I have had issues with changing textbox borders on a frame by frame basis.

Thank you this is very helpful! The specific lines of code to find number of characters in the word would be calling lines.length after lines = msg.split("\n"); ?

The alternative would be to use a separate coloured polygon.

If you have a setting set to update every frame then it will show one frame left from the previous trial unless you actually set the colour (e.g. using textbox.setBorderColor() ) in Begin Routine. However, this may have other issues – hence polygons

Unfortunately none of the flashing is from textboxes (which I have not used up until this discussion above). All of it is from standard text stimuli and polygon stimuli.
I am setting border width/color and opacity to a $variable and then manipulating these variables based on conditionals in Each Frame. I set them to 0 opacity and standard colors/widths in Begin Routine and End Routine. I’m beginning to wonder if I should use the .lineColor, .lineWidth and .opacity functions instead, to see if this helps.

I’ve solved the flashing issue by utilizing the functions .lineColor, .lineWidth, .opacity in Begin Routine, and setting .setAutoDraw(false) and the variables that I use as parameters in the components themselves back to their original values in End Routine.

I am now encountering the issue described here: Textbox2 unexpectedly reset its text in the center in PsychJS (fine in PsychoPy) - #4 by wakecarter, where I am changing the color of the words in the textboxes when a specific key is pressed, updated every frame.

Upon a key press, the text in the textboxes flick to the center of the screen for one frame while changing color, before returning to their correct locations. Is there currently a fix/workaround for this?

1 Like

How many colours do you need? Could you work with one textbox of each colour on each side?

I only use three colors, but I have 4 pairs of words (8 total) that are now textboxes and exhibit this issue.
I need them to stay in their locations as they change color, upon multiple key presses back and forth between these colors, until a response is made via mouse-click and the routine ends.

I was imagining 6 textboxes which update the word in Begin Routine and then manipulate which textboxes are visible on each frame using opacity, position or using setAutoDraw(True) / setAutoDraw(False) to show/hide. In this final case the textboxes should be created in an earlier routine (possibly off screen using position)