Convert PsychoPy coder to Pavlovia js script

Thank you for reading my post.

*A. Goal of the study

I have an online experiment where there are two order-counterbalanced conditions (Cond A, Cond B): each condition only randomly selects 1 out of 8 files (Cond A from list 1 to 8, Cond B from list 9 to 16).
**However, the two selected files are interdependent in that the files containing “w1” are mutually exclusive from that containing “w2”; “p1” files are mutually exclusive from “p2” files. E.g. if Cond A select “trainingList?_w1_p1”, Cond B has the only option of “trainingList?_w2_p2”.

*B. Builder’s current view:

The current design of the builder:
Flow

  1. “assignConditionType” loop reads from “masterConditionList” to determine the presentation order of Condition A or B.

image

  1. “assignConditionList” loops reads the “$PresentList” column from the “masterConditionList”.

image

  1. “training” loop reads the “$TrainList” column from either the “ConditionAList.xlsx” or “ConditionBList.xlsx”. (“testing” loops reads the “TestList” column).

  • C. My Problems

1. To only read 1 list from 8 lists.

-Currently, psychoPy automatically runs all the lists (8 times) listed in each ConditionList file.
-So, we wrote Python codes in the coder view to limit the running as once- See “Nye” in the code below.

2. To deal with the mutual exclusivity of the two selected files
-“The files containing “w1” are mutually exclusive from that containing “w2”; “p1” files are mutually exclusive from “p2” files. E.g. if Cond A select “trainingList?_w1_p1”, Cond B has the only option of “trainingList?_w2_p2”.”
-So we wrote the python codes below- see “Njt”.

Nye = 0

    for thisAssignmentMappingList in assignmentMappingList:
        if Njt == 1: # do some limitation on selection list
            if "w1_p1" in recorded_choice:
                if "w2_p2" not in  thisAssignmentMappingList['TrainList']:
                    continue
            elif "w2_p2" in recorded_choice:
                if "w1_p1" not in  thisAssignmentMappingList['TrainList']:
                    continue
            elif "w1_p2" in recorded_choice:
                if "w2_p1" not in  thisAssignmentMappingList['TrainList']:
                    continue
            elif "w2_p1" in recorded_choice:
                if "w1_p2" not in  thisAssignmentMappingList['TrainList']:
                    continue
     
   if Nye == 0:
            Nye += 1

:cold_sweat:Questions:
As we need to use builder view to convert the program online (pavlovia can only be converted online by using builder view w/codes in the builder).

  1. Can builder view randomly read one row from several rows? If yes, then how?
  2. Can builder view select two mutually exclusive file names? If yes, then how?
  3. Can the above Python script be translated to JS script, and be used in Pavlovia?
    Solution in whichever way is welcomed.

Much appreciate your help and time! (Thanks JT for the codes)
Best wishes,
Ye

Why not have one column called list, one called w and another called p with contents
1 1 1
1 1 2
1 2 1
1 2 2
2 1 1
2 1 2
2 2 1
2 2 2

Then you could have:

TrainList = "trainingList" + str(list) + "_w" + str(w) + "_p" + str(p) + ".csv"
TestList =  "testingList" + str(3-list) + "_w" + str(3-w) + "_p" + str(3-p) + ".csv"

If testingList can be 1 or 2 irrespective of trainigList choice then you could add an extra column.

The halt the loop after one iteration just add assignConditionList.finished=True in the loop (e.g. End Routine in testing or a new routine outside that loop).