Jeremy

Forum Replies Created

Viewing 15 posts - 1,201 through 1,215 (of 1,522 total)
  • Author
    Posts
  • in reply to: Arrow keys for response #5738
    Jeremy
    Keymaster

    Hi,

    You can use this interface to find the names of non-printable keys that you can use in the Key element: https://keycode.info/

    If you want your Key element to react to keypresses on the left or right arrow, you can do this:

    newKey("pressOnArrow", "ArrowLeft", "ArrowRight").wait()

    Jeremy

    in reply to: Timeout #5737
    Jeremy
    Keymaster

    Hi,

    You can use a timer which you end early if your participant presses a key:

    newKey("FJ").callback( getTimer("timeout").stop() ).log("all")
    ,
    newTimer("timeout", 5000).start().log().wait()
    ,
    getKey("FJ")
        .disable()
        .test.pressed().success( newText("Good job").print() )
        .failure( newText("Too slow").print() )

    Jeremy

    in reply to: Change background color #5732
    Jeremy
    Keymaster

    Hi,

    You can upload a file named global_z.css to the aesthetics folder and write this into it:

    body {
      background-color: lightyellow;
    }

    Jeremy

    in reply to: Audio won't play #5728
    Jeremy
    Keymaster

    Hi,

    Most browsers will block audio/video autoplay on page load, and will require an interaction with the page before the script can trigger playback. If this is the very first trial of your experiment, just add newButton("Start").print().wait(), immediately before newAudio and it should work (also, you probably want to add something after play() because as it is coded now your trial ends as soon as the audio starts playing).

    Jeremy

    in reply to: Randomization of Stimuli Across Blocks #5726
    Jeremy
    Keymaster

    Hi Andreas,

    Yes, the code should work across browsers (or at least, you won’t have to use a different code for Firefox vs Chrome)

    The new design you are describing has 4 conditions instead of 2, so you will need to adapt the code I gave you accordingly. So I worked on a slightly more general version of the code:

    AddTable("myTable", `leftRight_familiar,rightLeft_familiar,leftRight_unfamiliar,rightLeft_unfamiliar
    hello_familiar,olleh_familiar,hello_unfamiliar,olleh_unfamiliar
    world_familiar,dlrow_familiar,world_unfamiliar,dlrow_unfamiliar
    bye_familiar,eyb_familiar,bye_unfamiliar,eyb_unfamiliar
    mate_familiar,etam_familiar,mate_unfamiliar,etam_unfamiliar`)
    
    NITEMS = 4
    CONDITIONS = ['leftRight_familiar','rightLeft_familiar','leftRight_unfamiliar','rightLeft_unfamiliar']
    order = [...new Array(NITEMS)].map((v,i)=>i%CONDITIONS.length).sort(v=>Math.random()>=0.5)
    
    Sequence( 
        randomize("leftRight_familiar"),
        randomize("rightLeft_familiar"),
        randomize("leftRight_unfamiliar"),
        randomize("rightLeft_unfamiliar"),
    )
    
    Template( "myTable" , row =>
      newTrial( CONDITIONS[order[0]] ,
        newText( row[CONDITIONS[order.shift()]] ).print()
        ,
        newButton("Next").print().wait()
      )
    )

    Now if you update your design to use more or less conditions, you only have to change the content of Sequence and the value of CONDITIONS (and NITEMS if you have a different number of items). Notice that I took the liberty to replace 1 and 2 with familiar and unfamiliar for more transparency.

    Let me know if you have any questions

    Jeremy

    in reply to: Randomization of Stimuli Across Blocks #5721
    Jeremy
    Keymaster

    Hi Andreas,

    it always chooses ‘hello’ and ‘world’ for the first two trials (i.e. first block) and then ‘eyb’ and ‘etam’ for the third and fourth trial (i.e. second block)

    You’re probably using Chrome (which is fine) just replace

    order = [...new Array(NITEMS)].map((v,i)=>i<NITEMS/2).sort(v=>Math.random()>=0.5)

    with

    order = [...new Array(NITEMS)].map((v,i)=>i<NITEMS/2).sort(v=>1-2*(Math.random()>=0.5))

    I was also wondering what the order array does exactly.

    You got it right for the most part:

    • [...new Array(NITEMS)] indeed creates one array of NITEMS slots with the value undefined
    • map((v,i)=>i<NITEMS/2) loops through every slot, fills the v variable with its value (in this case, always undefined) and i with its index (from 0 to NITEMS-1) and replaces the value in the slot with i<NITEMS/2, which is true for the slots whose index is in the first half and false for the other half of the slots
    • sort(v=>1-2*(Math.random()>=0.5)) loops through every slot of the array returned from map (half true, half false) and depending on the value returned by the lambda function, it moves it forward (value > 0) or backward (value < 0) in the array. In this case, the value is a random number between 1 and -1 for each slot, so you end up with an array with half its slots true and half of them false in a totally random order

    The Template function will then look up the first value of the order array for each trial it generates, and remove it from the array at the same time (that’s the shift() method) so that the next generated trial will look up the next “first” value from order. Then, because of how we defined of order, half your trials will be generated from a true value (-> "leftRight") and the other half will be generated from a false value, in a random (ie. non linear) order.

    Not sure where to start with javascript, I never really followed a single method and the language is now more of a family of languages with many different uses. Ideally PennController lets you abstract away from javascript, but there are some cases (like this one) where it lacks some functionality that can only be implemented using some javascript

    Let me know whether changing the random bit fixed the issue

    Jeremy

    in reply to: Using if statements during a trial #5719
    Jeremy
    Keymaster

    Hello,

    Your problem must be coming from another part of your script, because I just tested what you posted and it works as expected, I don’t get any error message

    Did you make sure you properly defined dashed?

    Jeremy

    in reply to: How to switch back to the old VoiceRecorder #5718
    Jeremy
    Keymaster

    Hi,

    The simplest solution would be to downgrade to PennController 1.7. Follow these instructions but make sure to replace master with 1.7

    Jeremy

    in reply to: Reusing keys #5717
    Jeremy
    Keymaster

    Hi Angelica,

    Use disable on your Key element after you’re done with it, it should stop recording keypresses.

    To end a trial early, use the special command end

    Jeremy

    in reply to: send result files to a personal server #5712
    Jeremy
    Keymaster

    Hi Christy,

    By default the results are saved on the server that hosts the experiment, and there is no built-in option to redirect where they are sent. If you are developing your experiment on the Ibex Farm or the PCIbex Farm, the results will be saved there.

    If you have access to a personal server, you can host your experiment there as a standalone. To do so, you must first download a full standalone Ibex experiment: you can use the one here https://github.com/penncontroller/ibex
    Replace its content with your own experiment’s, notably your experiment’s script files in data_includes and your CSV tables in chunk_includes—note that with a standalone experiment, you need to place the images/audios/videos in www instead of chunk_includes

    Then follow the instructions from the Ibex documentation to set up a CGI experiment: https://github.com/addrummond/ibex/blob/master/docs/manual.md#step-by-step-cgi (the webspr directory refers to your full experiment’s folder structure that you downloaded and edited as mentioned just above)

    You results will be saved in the results subfolder of your experiment’s directory on your server

    Let me know if you have questions

    Jeremy

    in reply to: conditions in self-paced reading experiment #5708
    Jeremy
    Keymaster

    Hi,

    If you want to insert a linebreak after each period, then you’ll need to implement an alternative method, because DashedSentence does not support linebreaks. If you’re only concerned that the sentence is too wide though, you can easily control your element’s width using size, like this:

            newController("DashedSentence", {s: row.DS})
               .print()
               .size("30em")
               .wait()
               .remove()
               .log()

    Jeremy

    in reply to: Randomization of Stimuli Across Blocks #5706
    Jeremy
    Keymaster

    Hi Andreas,

    Here’s an example of what you can do. I use left-right vs right-left spelling to represent your design’s different accents, but in your case you probably want to point to different audio files. I’m also defining only 4 items, but set NITEMS to 24 if this is how many items you have (make sure you have 24 corresponding rows in your table—25 including the header)

    AddTable("myTable", `leftRight,rightLeft
    hello,olleh
    world,dlrow
    bye,eyb
    mate,etam`)
    
    NITEMS = 4
    order = [...new Array(NITEMS)].map((v,i)=>i<NITEMS/2).sort(v=>Math.random()>=0.5)
    
    Sequence( randomize("leftRight") , randomize("rightLeft") )
    
    Template( "myTable" , row =>
      newTrial( (order[0]?"leftRight":"rightLeft") ,
        newText( (order.shift()?row.leftRight:row.rightLeft) ).print()
        ,
        newButton("Next").print().wait()
      )
    )

    Let me know if you have any questions

    Jeremy

    in reply to: repository of example studies? #5702
    Jeremy
    Keymaster

    Hi,

    Thank you for the suggestion. It is something we have been wanting to do for quite some time now, but unfortunately we have never gotten around to doing it. When the new PCIbex Farm is ready, it will be possible to duplicate an experiment in one click, without requiring git-syncing, which will be ideal for experimenting with different models

    In the meantime, I am happy to write example experiments on demand

    Jeremy

    in reply to: DashedSentence in a PennController trial #5700
    Jeremy
    Keymaster

    Hello,

    You should probably write your sentences in your table using underscores (_) instead of spaces (or instead of wildcard * if this is what you’ve been using) inside chunks, and reserve space characters to delimit the chunks. For example: This_is_the_first_chunk and_this_is_the_second_chunk. Then just inject the native-Ibex DashedSentence controller, like this:

    //Introduction screen with button
    newTrial(
        newText("intro", "These are the instructions. Click to start.")
            .print()
            ,
        newButton("Start")
            .print()
            .wait()
            .remove()
    );
    
    //Experimental task with in place self-paced reading followed by a comprehension question. Sentence and question are pulled from the table. 
    Template(variable =>     
        newTrial(
            newText("test", "Press space bar to read the sentence.")
                .css("color", "red")
                .css("font-syle", "italic")
                .css("line-height", "1.5")
                .print()
            ,
            newText("test", "Press <b>A</b> for true. Press <b>L</b> for false.")
                .css("font-syle", "italic")
                .css("line-height", "1.5")
                .print()
            ,
            newController("DashedSentence", {s: variable.Sentence, display: "in place", hideUnderscores: true})
                .print()
                .log()
                .wait()
                .remove()
            ,
            newText("cq", variable.Question)
                .css("line-height", "2.5")
                .print()
            ,
            newKey("AL")
                .log()
                .wait()
        )
    );

    Jeremy

    in reply to: Checkbox/unselecting an option #5699
    Jeremy
    Keymaster

    Hi Daniela,

    Yes, this is a known bug which will be fixed in PennController 1.9. In the meantime, you can systematically hide the labels of any Scale element named rating by writing this in a file called global_z.css in your project’s aesthetics folder:

    .PennController-rating .option label {
        display: none;
    }

    Jeremy

Viewing 15 posts - 1,201 through 1,215 (of 1,522 total)