The fixation cross disappears and reappears

URL of experiment: https://run.pavlovia.org/arkadiym/od_e_1_test1/html

Description of the problem: The fixation cross is supposed to appear for a pre-set number of milliseconds. These are randomly sampled from a generated list of Ints. It appears as planned, but randomly disappears/reappears about 15 minutes into the experiment.

Here is the code pertaining to the fixation cross:

Python:

import random

# Get a variable number of ISI presentation times
ISI_Num= np.random.triangular(0.25, 0.5, 1.0, 10000)
np.random.shuffle(ISI_Num)
ISI_Num= ISI_Num.tolist()

Javascrip (ISI Num values are truncated for the purpose of this example, but there are 10,000 of them):

ISI_Num = [0.41455211, 0.71802275, 0.32057255, 0.67399222, 0.7005724,
       0.61799867, 0.37266446, 0.45349066, 0.53348465, 0.86651267,
       0.40217111, 0.32989753, 0.74102027, 0.46488324, 0.55745606]


// create a function to shuffle a list
function shuffle(a) {
  var j, x, i;
  for (i = a.length - 1; i > 0; i--) {
      j = Math.floor(Math.random() * (i + 1));
      x = a[i];
      a[i] = a[j];
      a[j] = x;
  }
  return a;
}


//create a list
x = [1,2,3,4,5,6,7,8] 


shuffle(ISI_Num);

Begin routing:

# Pop ISI Time
ISI_Time= ISI_Num.pop(0)

The ISI_Time variable is then entered into the “Duration” tab of the polygon.

What does .pop do? I would just use ISI_Time= ISI_Num[0];

(there’s also a missing semi-colon. Does that matter?)

Thank you for catching this! Fortunately the missing semi-colon is just in the example- I do have it in the code.

However, pop takes out the “0” element and also assigns it. The suggestion you provided just assigns it (if I am not mistaken) but does not remove it from the list. Regardless, however, it does not explain the strange issue of the inconsistent fixation cross times working for most blocks and “blinking” towards the end of the experiment. This also doesn’t seem so happen on every test run, which is strange.

I tried deleting and re-uploading, but no luck so far.

Thanks for the explanation of pop. I hadn’t considered that that command might exist so I increment a separate variable to address different members of the array, e.g. ISI_Num[trials.thisN] or ISI_Num[trialnum]

Is the fixation cross is a polygon builder object with the duration set every repeat?

I tried two approaches for the fixation:

First, using the polygon, and a second variation using a plus sign (form the text tool). Issue persists in both cases, and strangely only appears towards the end of the experiment. The weird thing is that the loop is set to repeat 40 times, each repetition contains 7 trials with fixation crosses. This strange “blink” comes up after about 30 loop repetitions.

For the duration:

I tried to set it to a variable (using the pop command) and also, experimented with a set number (just .05)- the issue persists in both cases. The duration property does not have a setting for every repeat per se (screenshot attached), but all the other properties are set to “constant”.

What else is happening in the experiment?

If you are consistently getting a problem around 30 trials in, when nothing different is happening to the fixation cross at that point, I’m wondering whether the issue is due to a memory overload error, perhaps due to an image being moved or edited “Each Frame”. For my first experiment here I had to ditch a moving image in favour of a simpler shape constructed from two polygons.

Thank you for this suggestion!

I just took a look at the settings, and can verify that presented stimuli are set to either “constant” or “every repeat”- there is nothing that changes every frame.

During the experiment, participants are presented with a series of rectangles (drawn using the polygon feature) that consist of different colors and sizes (at random) and pictures; each stimulus appears one at a time. Participants are asked to respond by pressing a left key to rectangles and a right key to pictures.

The following code gets executed at the beginning of every routing for a picture:

# Pop a Valence and a Stimulus Pic
Selected_Valence1= conds.pop(0)
Presented_Pic = Selected_Valence1['Pic'].pop(0)

# Pop ISI Time
ISI_Time= ISI_Num.pop(0)

And the following code is executed at the beginning of every frame for a polygon:

# Pop a Square
Selected_Square_1 = Square_colors.pop(0)

# Pop ISI Time
ISI_Time= ISI_Num.pop(0)

# Pop Square Size
Square_Size = Square_Sizes.pop(0)

At the end of every loop (thus, end of the routine, for the last routine of the loop), the following code is executed:

conds = []
conds.append(Selected_Valence1)
conds.append(Selected_Valence2)
conds.append(Selected_Valence3)

# Reset Square Colors
Square_colors= [(0.2980392156862745, 0.4470588235294118, 0.6901960784313725),
 (0.8666666666666667, 0.5176470588235295, 0.3215686274509804),
 (0.3333333333333333, 0.6588235294117647, 0.40784313725490196),
 (0.7686274509803922, 0.3058823529411765, 0.3215686274509804),
 (0.5058823529411764, 0.4470588235294118, 0.7019607843137254),
 (0.5764705882352941, 0.47058823529411764, 0.3764705882352941),
 (0.8549019607843137, 0.5450980392156862, 0.7647058823529411),
 (0.5490196078431373, 0.5490196078431373, 0.5490196078431373),
 (0.8, 0.7254901960784313, 0.4549019607843137),
 (0.39215686274509803, 0.7098039215686275, 0.803921568627451)]

if len(Square_Sizes) < 10:
    Square_Sizes= [(200.0,100.0),
    (207.5,107.5),
    (215.0,115.0),
    (222.5,122.5),
    (230.0,130.0),
    (237.5,137.5),
    (245.0,145.0),
    (252.5,152.5),
    (260.0,160.0),
    (267.5,167.5),
    (275.0,175.0),
    (282.5,182.5),
    (290.0,190.0),
    (297.5,197.5),
    (305.0,205.0),
    (312.5,212.5),
    (320.0,220.0),
    (327.5,227.5),
    (335.0,235.0),
    (342.5,242.5),
    (350.0,250.0),
    (357.5,257.5),
    (365.0,265.0),
    (372.5,272.5),
    (380.0,280.0),
    (387.5,287.5),
    (395.0,295.0),
    (402.5,302.5),
    (410.0,310.0),
    (417.5,317.5),
    (425.0,325.0),
    (432.5,332.5),
    (440.0,340.0),
    (447.5,347.5),
    (455.0,355.0),
    (462.5,362.5),
    (470.0,370.0),
    (477.5,377.5),
    (485.0,385.0),
    (492.5,392.5),
    (500.0,400.0)]

Do you think any of these are too memory intensive? If so, I can modify.

That doesn’t sound too bad. Are you remembering to switch append to push for the JavaScript?

Do you reuse the same rectangles or do you keep defining new ones?

Yes- push is used instead of append in javascript.

The rectangle stimulus is inserted into a psychopy routine- I think that means it draws a rectangle from scratch every time (set to constant, so not every frame).

Strange, that I just tested it again, and the fixation cross seems to have frozen completely after around 8 loops. The inconsistency is strange here…

You aren’t getting an error on-screen, but have you looked for errors in a console?

On the participant information screen select developer tools in Chrome (Ctl-Shift-I). I’ve found that this often gives me the line number of the error as well as more information about it.

Hi

Just to clarify
.pop() takes the final item in the list
.pop(0) takes the first item in the list in Python but needs to be replaced with .shift() for the same functionality in JavaScript

1 Like

Thank you for this! It will be useful to refer back to in the future.