PennController for IBEX › Forums › Support › Issue Importing Images After Test.Is()
- This topic has 2 replies, 2 voices, and was last updated 5 years ago by
JCroteau.
-
AuthorPosts
-
June 15, 2020 at 3:20 pm #5644
JCroteau
ParticipantI’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.
June 16, 2020 at 9:24 pm #5656Jeremy
KeymasterWe 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
June 17, 2020 at 8:26 am #5658JCroteau
ParticipantThank you for your help! This resolved the issue.
-
AuthorPosts
- You must be logged in to reply to this topic.