Lines Will Not Disappear

Hi, here is the link to my experiment: tTraceTest8 [PsychoPy]

How do I get the lines to disappear after each trial?

Also, I downloaded this task from Pavlovia. I want to make another task where participants only select from A → B → C → etc., but I cannot find where in the code the stimuli A, B, C, 1, 2, 3, etc. is defined. I do not see where I can edit the A, B, C, 1, 2, 3. Please help. Thank you in advance.

I clicked on your link and can see the issue.

Please could you upload your psyexp file or show screenshots of your code so we can see how the lines are drawn?

tTraceTest8.psyexp (91.4 KB)

Thank you so much. Can you access it here?

Yes

Try the following in End Routine for trialCode

Python

if len(lines):
        for line in lines:
            line.setAutoDraw(False)

JS

if (lines.length) {
    for (var line, _pj_c = 0, _pj_a = lines, _pj_b = _pj_a.length; (_pj_c < _pj_b); _pj_c += 1) {
        line = _pj_a[_pj_c];
        line.setAutoDraw(false);
    }
}

I get this error when I do this.

Sorry, try replacing lines with shapeList

Python

if len(shapeList):
        for line in shapeList:
            line.setAutoDraw(False)

JS

if (shapeList.length) {
    for (var line, _pj_c = 0, _pj_a = shapeList, _pj_b = _pj_a.length; (_pj_c < _pj_b); _pj_c += 1) {
        line = _pj_a[_pj_c];
        line.setAutoDraw(false);
    }
}

The order is hard coded in the Each Frame code, but you need to scroll to the right to see it. There are a set of trial steps which look for the distance from trialTarget positions in order.

Hi,

Thank you for all of your help. The lines are still not disappearing when I uploaded this code.

Is there something I could do fix this? Thank you so much in advance.

I’m planning to have a go at this myself, either over the weekend or on Monday. I’ll post here when I have something you can test.

Thank you so much. I appreciate it.

Here’s my new version

https://run.pavlovia.org/vespr/tTraceTest8

I’ve modified @vuandre1’s original code so that the trace test can now use an arbitrary number of targets (set as a string in a spreadsheet).

Fork from VESPR / tTraceTest8 · GitLab

Thank you so much, I appreciate it a lot.

I’ve got one more update to make to the code so it can run on a mobile phone.

https://run.pavlovia.org/aboye/draft-whole-task/

tTraceTest8.psyexp (23.5 KB)

This works perfectly for 1->A->2->B etc.

When I make the condition in the Excel file ABCDEFG, the circles show up with the proper labels in them, but it does not register when I hover over the circles and it does not make the lines.

When I try to make the condition in the Excel file 12345678 I get the error:

Unfortunately we encountered the following error:

  • when building a range of numbers

  • stop should be an integer

Thanks in advance.

I’ve sorted the error with just numbers, but I’m not sure why you had an issue with just letters. It works when I test it (my demo now has a letters and a numbers trial).

It should now work on mobile devices.

Thank you so much, it works perfectly. You have been a tremendous help to me and my team!!!

Hi. My team and I are trying to measure how long it takes for a participant to complete these trials. Could you help with implementing this? The only measure we need is the time it takes to complete each trial. Thanks so much in advance.

If all of your sequences are the same length, then you should already have this in the final RTstep column. However, if you want to remove this data saving and only save on the final step then your Each Frame code should be:

CursorTargetDistance = sqrt((trialCursor.pos[0]-trialTargets[trialStep].pos[0])**2 + (trialCursor.pos[1]-trialTargets[trialStep].pos[1])**2)
if (CursorTargetDistance < .05):
    trialTargets[trialStep].setOpacity(0)
    if trialStep > 0:
        # Create new line
        shapeList.append(visual.ShapeStim(
        win=win, name="line"+trialStep,
        lineColor=white,
        lineWidth=2,
        vertices=[[posArray1[trialStep-1],posArray2[trialStep-1]],[posArray1[trialStep],posArray2[trialStep]]],
        ))
        shapeList[-1].setAutoDraw(True)
    trialStep += 1
    # End routine when last target located
    if trialStep == len(targetList):
        thisExp.addData('RT',round(t*1000))
        continueRoutine = False