Need help implementing an “abort trial” option for a SPR design

PennController for IBEX Forums Support Need help implementing an “abort trial” option for a SPR design

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #10826
    newebste
    Participant

    Hello,

    I am running a specific type of Self-Paced Reading experiment called SMS (“Stops Making Sense”), where trials proceed as simple self-paced reading, but with the option to “abort” the trial if they find the sentence really “bad”/”unacceptable”. I found another thread in this forum that talked about implementing an abort trial keypress for a different reason (re: loading media issues), and saw that one option could be to create a new command like this:

    newKey(“Q”).callback( end() )

    Unfortunately, I am a complete novice with IBEX and am not entirely sure how exactly to incorporate this into the code, and also, what it would look like in the results file. Ideally, I want to be able to see the word at which a participant decided to abort the trial, and the RT of all preceding words and the abort trial button press.

    I have currently successfully set up the experiment to run as just the SPR design, using DashedSentence.

    Any help would be appreciated! Apologies for my inexperience.

    I will include my demonstration link here: https://farm.pcibex.net/r/FEXIqU/

    #10833
    Jeremy
    Keymaster

    Hello,

    Since you are using exclusively IBEX code, and no PennController code like the newKey you mention, it’s probably simpler to just edit the DashedSentence controller to add an abort key. Just edit the file DashedSentence.js from your project’s Modules folder:

    1. Insert a new line between line 203 (}) and line 204 (else {) and paste this:

                    else if (code == 81) {
                        t.sprResults[t.currentWord-1][0] = time;
                        t.sprResults[t.currentWord-1][1] = t.previousTime;
                        t.processSprResults(t.currentWord);
                        t.finishedCallback(t.resultsLines);
                    }

    2. Edit line 291 (previously line 285 before the aforementioned insertion) and change if from processSprResults: function () { to processSprResults: function (abortAt=-1) {

    3. Just a couple lines below, you have a block of 10 lines that start with for and end with }. Replace them with this:

            for (var i = 0; i < nonSpaceWords.length; ++i) {
                if (i==abortAt)
                    this.resultsLines.push([
                        ["Word number", i],
                        ["Word", "__ABORT__"],
                        ["Reading time", "NA"],
                        ["Newline?", false],
                        ["Sentence (or sentence MD5)", this.sentenceDesc]
                    ]);
                this.resultsLines.push([
                    ["Word number", i+1],
                    ["Word", csv_url_encode(nonSpaceWords[i])],
                    ["Reading time", abortAt>=0 && i>=abortAt ? "NA" : this.sprResults[i][0] - this.sprResults[i][1]],
                    ["Newline?", (! this.display == "in place") &&
                                 boolToInt(((i+1) < this.wordOSpans.length) &&
                                 (this.wordOSpans[i].offset().top != this.wordOSpans[i+1].offset().top))],
                    ["Sentence (or sentence MD5)", this.sentenceDesc]
                ]);
            }
            if (abortAt==nonSpaceWords.length)
                this.resultsLines.push([
                    ["Word number", nonSpaceWords.length],
                    ["Word", "__ABORT__"],
                    ["Reading time", "NA"],
                    ["Newline?", false],
                    ["Sentence (or sentence MD5)", this.sentenceDesc]
                ]);

    Now you can press Q to abort the self-paced reading instance. The results file will report a line that says “__ABORT__” for the last word shown on the screen, and the reaction times will be NA from there on (because the next words won’t have been displayed)

    If you want to use a different key from Q, you can look up the event.which column from this table and replace 81 in the bit from step 1 above with the value of your choice (for example, 27 if you’d rather use the Escape key)

    Jeremy

    #10847
    newebste
    Participant

    Hi Jeremy, thank you very much for the thorough response and assistance! I will give this a try and see how it works.

    #10848
    newebste
    Participant

    A small update: I edited DashedSentence.js in the modules folder as suggested, but I am now getting a new error that states:

    “[17:51:18] Invalid controller reference: ‘DashedSentence’—Did you mean to type FlashSentence? (newTrial: 0)”.

    Any thoughts on why this new error is happening/how I can circumvent it? Thank you so much again in advance.

    Demonstration link: https://farm.pcibex.net/r/FEXIqU/

    #10849
    newebste
    Participant

    A small update: I edited DashedSentence.js in the modules folder as suggested, but I am now getting a new error that states:

    “[17:51:18] Invalid controller reference: ‘DashedSentence’—Did you mean to type FlashSentence? (newTrial: 0)”.

    Any thoughts on why this new error is happening/how I can circumvent it? Thank you so much again in advance.

    Demonstration link: https://farm.pcibex.net/r/FEXIqU/

    #10857
    Jeremy
    Keymaster

    Sorry for the late reply. I see that the error no longer appears when running the experiment, so I imagine you have fixed the issue in the meantime

    Jeremy

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.