Issue Importing Images After Test.Is()

PennController for IBEX Forums Support Issue Importing Images After Test.Is()

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #5644
    JCroteau
    Participant

    I’m having some issues importing images from the experiment CSV file. The experiment runs by pointing to each row in the .csv and pulling files out of each column in that row so that the proper stimulus for each trial is displayed to participants. I’m using branching logic to check whether a trial requires a file print from a particular column (.test.is()). Some trials have yes/no questions and some trials have multiple choice. Participants are making their selections by clicking images in the Selector element.

    In the .success(…) and .failure(…) portions of the code the program malfunctions. If I hardcode the files into the program it runs fine. When I use variable.ColumnName to grab the file name I need, the entire program refuses to load after the welcome page (it says resources preloading but when I check the Log all the resources have preloaded). If I skip with the debugger to the trials where I’m using the variable.ColumnName command it loads those trials fine (and selects the right files). I’ve tried filling the .csv so there are no empty boxes but that didn’t solve the issue. I’ve triple-checked the spelling in the .csv vs my file names as well.

    #5656
    Jeremy
    Keymaster

    We resolved this issue by email

    The problem was coming from the assumption that newImage commands embedded in the success would only be evaluated in case of a successful test, but all new* commands are evaluated at the beginning of the experiment, even if they are embedded in a test command that will be evaluated upon runtime. One reason for this behavior is to let PennController preload the resources as soon as possible.

    In this case, the solution was to carry out the same tests using javascript’s ternary conditional, which will effectively include the PennController commands in Template only if the test is successful, like this:

    Template( "myTable.csv" , row => 
      newTrial( "trial"
        ( row.Image.match(/png$/) ?
          newImage( row.Image ).print()
        :
          newText( row.Text ).print()
        )
        ,
        newButton("Next").print().wait()
      )
    )

    Jeremy

    #5658
    JCroteau
    Participant

    Thank you for your help! This resolved the issue.

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