Randomize DashedSentence

PennController for IBEX Forums Support Randomize DashedSentence

Viewing 13 posts - 1 through 13 (of 13 total)
  • Author
    Posts
  • #4186
    adamliter
    Participant

    Is it possible to randomize the presentation of sentences using PCIbex’s randomize function with DashedSentence? I have not been able to find a straightforward way to do this. The following does not work:

    PennController.ResetPrefix(null);
    
    PennController.Template( randomize(PennController.GetTable("mystimuli.csv")) ,
        row => [
            "DashedSentence", {s: row.Sentence},
        ]
    );

    I’ve also tried this, which didn’t work, either:

    PennController.ResetPrefix(null);
    
    PennController.Sequence(randomize("DashedSentence"), "send");
    
    PennController.Template( PennController.GetTable("mystimuli.csv") ,
        row => [
            "DashedSentence", {s: row.Sentence},
        ]
    );
    
    PennController.SendResults("send");
    #4188
    Jeremy
    Keymaster

    Hi Adam,

    The latter method is the correct one, you just need to properly label your items so you can refer to them in Sequence:

    PennController.ResetPrefix(null);
    
    PennController.Sequence( randomize("dashed") , "send" );
    
    PennController.Template( PennController.GetTable("mystimuli.csv") ,
        row => [
            "dashed", "DashedSentence", {s: row.Sentence},
        ]
    );
    
    PennController.SendResults("send");

    This will only work starting with PennController 1.4 though (newly created experiments on expt.pcibex.net currently come with version 1.5).

    NB: you don’t need to use GetTable if you’re not filtering your table, you can directly pass the string "mystimuli.csv" as the first argument of Template.

    Jeremy

    #4189
    adamliter
    Participant

    Ah, thanks, Jeremy! I really appreciate the quick response.

    #6628
    adamliter
    Participant

    Hi Jeremy,

    I have a followup question to this for a different experiment. Is it possible to use the syntax of “Template( row => ["label", "controllername", options, "controllername", options, ...] )” with both controllers from Ibex but also the newTrial/PennController command?

    I’m trying to do an experiment where, in one trial, I (i) play an audio file, (ii) present a sentence using rapid serial visual presentation (RSVP), then (iii) have the participant type something in a text box, and finally (iv) collect a recording from them at the end of the trial. It seems like there are straightforward ways to do everything but the RSVP with PennController. I was thinking I could use the DashedSentence controller with the display set to “in place” from Ibex to do the RSVP, but I’m not sure if it’s possible to mix these things. Given the expected syntax, it doesn’t seem like Template(row => ["trials", newTrial("trial-begin", newAudio("trial-begin", "trial-begin.mp3")), {}, DashedSentence, {s: row.sentence}, ... ]); unfortunately. Am I correct in thinking this won’t work? If not, do you have any suggestions for a good way to do this? Maybe it’s easier to do RSVP of a full sentence with just PCIbex than I think. Thanks again in advance for your time!

    #6629
    Jeremy
    Keymaster

    Hi,

    Yes, it is possible, but the proper syntax is:

    Template(row => [
      "trials",
      "PennController", newTrial("trial-begin", newAudio("trial-begin", "trial-begin.mp3").play().wait() ),
      "DashedSentence", {s: row.sentence},
      // ... 
    ])

    Also, in case you missed it, you can inject native-Ibex controllers into PennController trials since version 1.7

    Jeremy

    #6630
    adamliter
    Participant

    Thanks! I did not know about the ability to inject controllers into PennController trials. Thanks for the reference, Jeremy

    #6665
    adamliter
    Participant

    Sorry, I have another followup question. 🙂

    I’m currently trying to use newController with the AcceptabilityJudgment and Question controllers from Ibex, but nothing shows up on the screen. I also don’t see any errors with the debugger. Do you have any idea what might be going on? Here’s what I have:

    PennController.Template("final_pilot_03_cnp_subj_items_all_lists.csv",
        row => PennController("trials",
            defaultText
                .settings.center()
                .print()
            ,
            newController("AcceptabilityJudgment", {s: row.Sentence, as: ["1", "2", "3", "4", "5", "6", "7"], presentAsScale: true, leftComment: "very bad", rightComment: "very good"})
                .print()
                .log()
                .wait()
                .remove()
            ,
            (row.Question != "NA" ?
                newController("Question", {s: row.Question, as: ["Yes", "No"], hasCorrect: row.Answer})
                    .print()
                    .log()
                    .wait()
                    .remove()
            :
            {})
        )
        .log("ParticipantID", ParticipantID)
        .log("Group", row.Group)
        .log("UniqID", row.UniqID)
        .log("Sentence", '"' + row.Sentence + '"')
        .log("Question", '"' + row.Question + '"')
        .log("Answer", row.Answer)
    );
    #6666
    Jeremy
    Keymaster

    Hi,

    Your code works well for me. (Note that I replaced s: with q: in the Question controller, but that wouldn’t make the experiment crash anyway)

    If you are using a Sequence command, did you make sure to include the trials labeled "trials" in it?

    Jeremy

    #6667
    adamliter
    Participant

    Hmm, that’s interesting. I do have "trials" in the Sequence command. I’ve pasted the full code below. I do still have this on expt.pcibex.net, not farm.pcibex.net, and I noticed the version of PennController I have is 1.8-dev, whereas it looks like the PennController version on farm.pcibex.net is 1.9. Could that be the issue?

    const ParticipantID = b64_md5((Date.now() + Math.random()).toString());
    
    //PennController.DebugOff();
    
    PennController.Sequence("setcounter", "consent", "demographics", "description", "trials", "send", "exit");
    
    PennController.ResetPrefix(null);
    
    PennController("consent",
        newHtml("consent form", "consent.html")
            .print()
        ,
        newText("my_consent_clear", "<br/><br/>")
            .print()
        ,
        newButton("consent button", "By clicking this button, I consent to participate in this study.")
            .settings.center()
            .print()
            .wait()
    )
    .log("ParticipantID", ParticipantID);
    
    PennController("demographics",
        defaultText
            .print()
        ,
        newText("age_text", "What is your age?")
        ,
        newTextInput("age_response")
            .settings.log()
            .settings.length(3)
            .print()
        ,
        newText("my_age_clear", "<br/><br/>")
        ,
        newText("live_in_text", "Did you live in the United States from birth until (at least) age 13?")
        ,
        newScale("live_in_response", "Yes", "No")
            .settings.log()
            .settings.labelsPosition("left")
            .settings.size("auto")
            .print()
        ,
        newText("my_live_in_clear", "<br/><br/>")
        ,
        newText("native_lang_text", "Did your parents/guardians speak English to you at home?")
        ,
        newScale("native_lang_response", "Yes", "No")
            .settings.log()
            .settings.labelsPosition("left")
            .settings.size("auto")
            .print()
        ,
        newText("my_native_lang_clear", "<br/><br/>")
        ,
        newText("town_text", "Which state did you grow up in (two letter abbreviation)?")
        ,
        newTextInput("town_response")
            .settings.log()
            .settings.length(100)
            .print()
        ,
        newText("my_town_clear", "<br/><br/>")
        ,
        newButton("submit", "Submit")
            .print()
            .wait(getTextInput("age_response").testNot.text("") &&
                  getScale("live_in_response").test.selected() &&
                  getScale("native_lang_response").test.selected() &&
                  getTextInput("town_response").testNot.text(""))
    )
    .log("ParticipantID", ParticipantID);
    
    PennController("description",
        newHtml("description", "description.html")
            .print()
        ,
        newButton("start", "Begin experiment")
            .settings.center()
            .print()
            .wait()
    )
    .log("ParticipantID", ParticipantID);
    
    PennController.Template("final_pilot_03_cnp_subj_items_all_lists.csv",
        row => PennController("trials",
            defaultText
                .settings.center()
                .print()
            ,
            newController("AcceptabilityJudgment", {s: row.Sentence, as: ["1", "2", "3", "4", "5", "6", "7"], presentAsScale: true, leftComment: "very bad", rightComment: "very good"})
                .print()
                .log()
                .wait()
                .remove()
            ,
            (row.Question != "NA" ?
                newController("Question", {q: row.Question, as: ["Yes", "No"], hasCorrect: row.Answer})
                    .print()
                    .log()
                    .wait()
                    .remove()
            :
            {})
        )
        .log("ParticipantID", ParticipantID)
        .log("Group", row.Group)
        .log("UniqID", row.UniqID)
        .log("Sentence", '"' + row.Sentence + '"')
        .log("Question", '"' + row.Question + '"')
        .log("Answer", row.Answer)
    );
    
    PennController.SendResults("send");
    
    PennController.SetCounter("setcounter");
    
    PennController("exit",
        defaultText
            .print()
        ,
        newText("thankyou", "<h1>Thank you!</h1><p>Thank you for participating in our study.</p>")
        ,
        newText("code", "<p>To receive payment through Amazon Mechanical Turk, enter your unique identifying code in the other tab/window.</p><p>Your unique identifying code is: ".concat(ParticipantID, "</p>"))
        ,
        newText("close", "<p>After copying your unique identifying code above, you can close this tab/window. Your results have been saved.</p>")
        ,
        // A faux timer that is never started
        // in order to stay on page forever
        newTimer("faux", 10)
            .wait()
    )
    .log("ParticipantID", ParticipantID)
    .setOption("countsForProgressBar", false);
    #6668
    adamliter
    Participant

    I just created an account with the new farm.pcibex.net and moved things to there, and it does seem to be working.

    #6669
    Jeremy
    Keymaster

    Glad it ended up working! I don’t know what might have caused an issue with PennController 1.8, but it’s good to know that PennController 1.9 seems to have fixed it (whatever “it” is)

    Jeremy

    #8012
    Carlos
    Participant

    Jeremy said:

    Note that I replaced s: with q: in the Question controller, but that wouldn’t make the experiment crash anyway

    However, this replacement (i.e. using q: row.Sentence) will show nothing with PennController 2.0, at least from my browser, Chrome Ver 100.0.4896.60(Official Build, 64bit, in normal mode [not in incognito mode]). Does anybody replicate the behaviour from the following link?: https://farm.pcibex.net/r/VfHNoP/

    
    PennController.ResetPrefix(null) // Keep here
    
    ParticipantID = GetURLParameter("id")
    
    PennController.Template("final_pilot_03_cnp_subj_items_all_lists.csv",
        row => PennController("trials",
            defaultText
                .settings.center()
                .print()
            ,
            //q: row.Sentence will show nothing
            //s: row.Sentence will show the question and judgement options
            newController("AcceptabilityJudgment", {q: row.Sentence, as: ["1", "2", "3", "4", "5", "6", "7"], presentAsScale: true, leftComment: "very bad", rightComment: "very good"})
                .print()
                .log()
                .wait()
                .remove()
            ,
            (row.Question != "NA" ?
                newController("Question", {q: row.Question, as: ["Yes", "No"], hasCorrect: row.Answer})
                    .print()
                    .log()
                    .wait()
                    .remove()
            :
            {})
        )
        .log("ParticipantID", ParticipantID)
        .log("Group", row.Group)
        .log("UniqID", row.UniqID)
        .log("Sentence", '"' + row.Sentence + '"')
        .log("Question", '"' + row.Question + '"')
        .log("Answer", row.Answer)
    );
    #8029
    Jeremy
    Keymaster
Viewing 13 posts - 1 through 13 (of 13 total)
  • You must be logged in to reply to this topic.