Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

158
Views
How do I encode a condition matching technique into my program?

I am new to programming and am currently trying to use jsPsych to create a browser-based behavior experiment.

In my experiment, participants first complete a "pre-trial" in which they rate various pictures:

var scale_1 = ["Do not enjoy", "Neutral", "Enjoy"];

var pre_trial = {
    timeline: [{
        type: 'survey-likert',
        preamble: jsPsych.timelineVariable('image'),
        questions: [{labels: scale_1, prompt: "The prompt"}]
    }],
    timeline_variables: [
       {image: 'image address'},
       {image: 'image address'},
       {image: 'image address'}
    ]
};

Then, I use the ratings to divide the images into two conditions, A and B. This division process uses matching such that, ultimately, the images that received a "Do not enjoy" rating are evenly distributed between Condition A and Condition B, as are the images rated "Neutral" and the ones rated "Enjoy."

Unfortunately, I cannot figure out how to perform this matching procedure. I have tried many different combinations of various JavaScript and jsPsych functionalities, such as pop( ), splice( ), concat( ), jspsych.data.get( ).select('response'), and many more. However, all of them have failed.

Does anyone here have experience with matched condition assignment in jsPsych, or any idea about how to do it? If so, would you please consider sharing your ideas here? I know that there is a GitHub forum dedicated to jsPsych, but I figured I would ask my question here as well since I am struggling so much to find the answer.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

I think maybe you can divide your whole experiment into four parts: pretrial, do-not-enjoy, neutral, enjoy.

In the pretrial, there are only pretrial and the function of jumping to the page depending on the answer participants give.

The last three parts are the same, they can distribute the participants into condition A or condition B randomly. (And depends on the platform you host, you can pass an url parameter to the second part to link the data)

// pre_trial is omitted here
jsPsych.init({
    timeline: [pre_trial],
on_finish: function(data) {
        var url;
        if (data.values()[0].response =="Neutral"){
          url = "http://...." // the url of neutral part
        }else if (data.values()[0].response =="Enjoy"){
          url = "http://...." // the url of Enjoy part
        }else if (data.values()[0].response =="Not Enjoy"){
          url = "http://...." // the url of Not Enjoy part
        }
        window.open(url)
    }
});
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!