Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Supported by

Resuming within a component (jsPsych and JATOS)

Hello! I'm helping a professor set up an annotation task, in which his research assistants will read a series of text-based prompts and categorize them (first with a multiple-choice question, then by typing descriptive text). I have the actual task inelegantly but functionally coded in jsPsych, and now I'd like to improve the task flow, but I'm not sure how to implement the ideal version of this (other than a vague impression that using batches might be helpful).

There are 100 prompts in the list as it is now, and I imagine the professor will add to this list. It's long, so the RA's won't be doing the whole task in one session. Right now I've split the existing prompts into blocks of 10, and saved each block of 10 as its own component; there's also an initial component that allows RA's to say which block they have next, and then skips to the relevant set. It works, but it relies on the RA's to remember their block, it uses a lot of unneccessarily duplicated information in each component, and it means extra data processing in order to make the results files manageable.

Does JATOS have a built-in functionality that would let this all be one big component, and save progress to let RA's leave and come back at will?

Thanks in advance for your advice!

Comments

  • edited July 2021

    Hi,

    There's no built-in functionality but in your case it seems like it will be rather straightforward.

    You're right that the batch session is the way to go, because it's a data structure that outlives any study run. And given that your participants are RAs, and not real volunteers, I'm guessing that you don't need to keep the data anonymous. In that case, you can ask the RAs to input their name, and in the batch session store their name along with the last prompt they completed.

    This is what you will probably need:

    • A first component where people (the RAs) provide their name, random ID, or whatever you like. This ID will need to be the same for all sessions, but it sounds like it's doable in your case, as it should be ok for the to remember their ID. In the JS for that component, you'll have to check: Is there an entry in the batch session data for this ID? [you can find the functions to query the batch data in the docs] If not, go directly to prompt 1. If yes, skip to the appropriate prompt
    • A second component with all 100 prompts together.
    • To allow the first component to communicate with the second component, and tell the second component which prompt to start from, the best is to use the Study Session Data

    Hope this helps (sorry for the first preliminary answer, I clicked Save before I was done)

    Elisa

  • ekmekm
    edited August 2021

    Hi Elisa,

    Thanks for your response! I'm sorry to say that I've gotten pretty confused about how to implement it, though it was clearly laid out. I have the two components (A: where RA's select their ID from a jsPsych html-button-response list, and B: the actual task, now with 1000 rows of data), but I don't know how to appropriately query/set the data I need.

    Right now in component A I have the following in the jatos.onLoad() chunk at the end:

    on_finish: function(data){
    //get the trial data from the RA:
      var ra_choice = jsPsych.data.getLastTimelineData().last(1).values()[0];         //add 1 to their response, since the buttons are numbered 0, 1, etc. and I don't want to assign any RA's as 0
      ra_num = ra_choice['response']+1;
      var studySessionData = {"ra_num": ra_num};
      jatos.setStudySessionData(studySessionData);
      //jatos.batchSession.get("ra_num");
      jatos.startNextComponent();
    }
    

    which sets the RA ID appropriately, I think. (?)

    That brings us to component B. Right now I have the following in the jatos.onLoad() chunk:

    on_data_update: function(data){
      //identifier for where in the task they've gotten to:
      var record_id = jsPsych.data.getLastTrialData().values()[0].record;
      jatos.batchSession.set("record", record_id)
        .then(() => console.log("Batch Session successfully updated"))
        .catch(() => console.log("Batch Session synch failed"));
     
     //save data after each trial, send to JATOS
        var studyID = jatos.studyResultId;
        jsPsych.data.addProperties({study_ID : studyID});
        var relevantData = jsPsych.data.get().filter({trial_type: 'survey-text'}).ignore('internal_node_id');
        jatos.submitResultData(relevantData.csv());
    },
    

    But I don't really trust that I'm saving the prompt/record info in a way where it's associated with a specific RA. More importantly, I'm not really sure how to use the study session data to tell the second component which prompt/record to start from. Does it go in an on_start function? My list of records is just saved as jsPsych.timelineVariables, is that accessible from this part of the code?

    Thanks again for your help!

    -Elise

  • Hi Elise,

    I'm a little bit lost in your code because I don't see where you use the ra_num value in component B. I'll respond to a few different points, they won't be a fully worked out solution but I think it will help you get closer at least.

    First, in component A you use jatos.setStudySessionData . That's not actually what you need, you should be doing:

    jatos.studySessionData.ra_num = ra.num;
    

    See the docs here: https://www.jatos.org/jatos.js-Reference.html#jatossetstudysessiondata


    Second point: I think you should have something along these lines in component B.

    // within the jatos.onLoad callback get the information you had stored in component A
    ra_num = jatos.studySessionData.ra_num; 
    
    
    // then use it to access the correct field in the batch session
    on_data_update: function(data){
      //identifier for where in the task they've gotten to:
      var record_id = jsPsych.data.getLastTrialData().values()[0].record;
    
      // add this to the batch session
      var deferred = jatos.batchSession.add("/RAs/" + ra_num, record_id); //this way you add the last trial completed tothe specific RA name
      deferred.done(() => {
        console.log("Batch Session successfully updated"))
      });
    
     
     //save data after each trial, send to JATOS
        var studyID = jatos.studyResultId;
        jsPsych.data.addProperties({study_ID : studyID});
        var relevantData = jsPsych.data.get().filter({trial_type: 'survey-text'}).ignore('internal_node_id');
        jatos.submitResultData(relevantData.csv());
    },
    
    

    (But I'm guessing a bit, maybe @kri can double-check)

    On to your last question, how to make jsPsych start from a given point: I don't know, that's something you'd have to ask in the jsPsych forum. But maybe the way to go is to create the timeline based on the number of remaining trials.

    Hope this helps

    Elisa

  • Hi again, one thing I just noticed:

    jatos.submitResultData will replace (overwrite) any existing data on the component. You probably should be using jatos.appendResultData instead.

  • ekmekm
    edited August 2021

    Hi Elisa,

    Thanks again for your help with this. The code you've provided gave me a good start! Quick question--for batch data, is it sufficient to be testing it on my local JATOS or will it work differently on my public-facing server?

    I'm just asking because I've been doing all my work locally, but it's not working as I expected it to--that said, I haven't worked with batches before so my expectations may be the issue! Specifically, jatos.batchSession.add doesn't seem to do anything at all; I've been running it in the console as well as in my code, but if I print it using jatos.batchSession.getAll, the only value that shows up is the ID number for the second record in the list. There's no ra_num, and it doesn't update to be the record I'm actually on if I move past the 2nd record.

    ETA: this is the code in my jatos.onload chunk of component B:

    jatos.onload(function() {
        ra_num = jatos.studySessionData.ra_num;
        jsPsych.init({
            timeline: [RA_ID, node],
            on_data_update: function(data){
                //identifier for where in the task they've gotten to
                var record_id = jsPsych.data.getLastTrialData().values()[0].record;
                //adding associating that with the relevant RA
                var deferred = jatos.batchSession.add("/RAs/" + ra_num, record_id);
                deferred.done(() => {
                    console.log("Batch Session successfully updated");
    //this never actually prints in the console, so I assume it never successfully updates
                });
    
                //save data after each trial, send to JATOS
                var studyID = jatos.studyResultId;
                jsPsych.data.addProperties({study_ID : studyID});
                var relevantData = jsPsych.data.get().filter({trial_type: '/survey-text'}).ignore('internal_node_id').ignore('question_order').ignore('response').ignore('trial_type').ignore('time_elapsed');
                jatos.submitResultData(relevantData.csv());
    //left as submitResultData because otherwise I ended up with duplicates of every line preceding the current one (Trial 1 --> saves header and 1 row; Trial 2 --> saves everything from Trial 1, plus header and first 2 rows; Trial 3 --> saves everything from Trial 2, plus header and first 3 rows.
            },
            on_finish: function(){
                var relevantData = jsPsych.data.get().filter({trial_type: '/survey-text'}).ignore('internal_node_id').ignore('question_order').ignore('response').ignore('trial_type').ignore('time_elapsed');
                jatos.submitResultData(relevantData.csv(), jatos.endStudy);
            }
        });
    });
    


  • Hi, yes, the batch should behave exactly in the same way locally as in the server. You've got a typo though:

    it's jatos.onLoad , not .onload . Maybe this already explains why your code chunk doesn't run?

    Best

  • Hi Elisa,

    Thanks for catching that, and for the speedy answer! I think it actually was running, though--in the period since I sent that message, I tried a very stupid solution which actually does seem to have worked. There's something about the the batchSession.add() function that isn't working, but batchSession.set() is indeed working (which was how I had that persistent "ID for the second record in the list" mentioned above), so I just threw a bunch of if/else statements in there.

    Here's what it looks like now, which actually does seem to be doing the trick:

            on_data_update: function(data){
                //identifier for where in the task they've gotten to
                var record_id = jsPsych.data.getLastTrialData().values()[0].record;
                //associating that with the relevant RA (STUPID WAY)
                if(ra_num == 1){
                    jatos.batchSession.set("RA1_record", record_id)
                        .then(() => console.log("Batch Session successfully updated"))
                        .catch(() => console.log("Batch Session synch failed"));
                }else if(ra_num == 2){
                    jatos.batchSession.set("RA2_record", record_id)
                        .then(() => console.log("Batch Session successfully updated"))
                        .catch(() => console.log("Batch Session synch failed"));
                }else if(ra_num==3){
                    jatos.batchSession.set("RA3_record", record_id)
                        .then(() => console.log("Batch Session successfully updated"))
                        .catch(() => console.log("Batch Session synch failed"));
                }else {
                    jatos.batchSession.set("RA4_record", record_id)
                        .then(() => console.log("Batch Session successfully updated"))
                        .catch(() => console.log("Batch Session synch failed"));
                }
                //associating that with the relevant RA (SMARTER WAY 1), not working
                /*
                jatos.batchSession.add("/RAs/", ra_num, record_id)
                    .then(() => console.log("Batch Session successfully updated"))
                    .catch(() => console.log("Batch Session synch failed")); //always prints this
                */
                //associating that with the relevant RA (SMARTER WAY 2), not working
                /*var deferred = jatos.batchSession.add("/RAs/" + ra_num, record_id);
                deferred.done(() => {
                    console.log("Batch Session successfully updated");
                });*/
                
                //save data after each trial, send to JATOS
                var studyID = jatos.studyResultId;
                jsPsych.data.addProperties({study_ID : studyID});
                var relevantData = jsPsych.data.get().filter({trial_type: 'survey-text'}).ignore('internal_node_id').ignore('question_order').ignore('response').ignore('trial_type').ignore('time_elapsed');
                jatos.submitResultData(relevantData.csv());
            },
    

    Since this is basically working, I'm focusing on the problem of editing the timeline_variables in the jsPsych forum now, but if you have suggestions for why jatos.batchSession.add() is being strange, please let me know! Thanks again for all your advice. :)

Sign In or Register to comment.

agen judi bola , sportbook, casino, togel, number game, singapore, tangkas, basket, slot, poker, dominoqq, agen bola. Semua permainan bisa dimainkan hanya dengan 1 ID. minimal deposit 50.000 ,- bonus cashback hingga 10% , diskon togel hingga 66% bisa bermain di android dan IOS kapanpun dan dimana pun. poker , bandarq , aduq, domino qq , dominobet. Semua permainan bisa dimainkan hanya dengan 1 ID. minimal deposit 10.000 ,- bonus turnover 0.5% dan bonus referral 20%. Bonus - bonus yang dihadirkan bisa terbilang cukup tinggi dan memuaskan, anda hanya perlu memasang pada situs yang memberikan bursa pasaran terbaik yaitu http://45.77.173.118/ Bola168. Situs penyedia segala jenis permainan poker online kini semakin banyak ditemukan di Internet, salah satunya TahunQQ merupakan situs Agen Judi Domino66 Dan BandarQ Terpercaya yang mampu memberikan banyak provit bagi bettornya. Permainan Yang Di Sediakan Dewi365 Juga sangat banyak Dan menarik dan Peluang untuk memenangkan Taruhan Judi online ini juga sangat mudah . Mainkan Segera Taruhan Sportbook anda bersama Agen Judi Bola Bersama Dewi365 Kemenangan Anda Berapa pun akan Terbayarkan. Tersedia 9 macam permainan seru yang bisa kamu mainkan hanya di dalam 1 ID saja. Permainan seru yang tersedia seperti Poker, Domino QQ Dan juga BandarQ Online. Semuanya tersedia lengkap hanya di ABGQQ. Situs ABGQQ sangat mudah dimenangkan, kamu juga akan mendapatkan mega bonus dan setiap pemain berhak mendapatkan cashback mingguan. ABGQQ juga telah diakui sebagai Bandar Domino Online yang menjamin sistem FAIR PLAY disetiap permainan yang bisa dimainkan dengan deposit minimal hanya Rp.25.000. DEWI365 adalah Bandar Judi Bola Terpercaya & resmi dan terpercaya di indonesia. Situs judi bola ini menyediakan fasilitas bagi anda untuk dapat bermain memainkan permainan judi bola. Didalam situs ini memiliki berbagai permainan taruhan bola terlengkap seperti Sbobet, yang membuat DEWI365 menjadi situs judi bola terbaik dan terpercaya di Indonesia. Tentunya sebagai situs yang bertugas sebagai Bandar Poker Online pastinya akan berusaha untuk menjaga semua informasi dan keamanan yang terdapat di POKERQQ13. Kotakqq adalah situs Judi Poker Online Terpercayayang menyediakan 9 jenis permainan sakong online, dominoqq, domino99, bandarq, bandar ceme, aduq, poker online, bandar poker, balak66, perang baccarat, dan capsa susun. Dengan minimal deposit withdraw 15.000 Anda sudah bisa memainkan semua permaina pkv games di situs kami. Jackpot besar,Win rate tinggi, Fair play, PKV Games