Millisecond Forums

Is it possible to add user-defined variables to the raw data file?

https://forums.millisecond.com/Topic41306.aspx

By EN - 7/5/2025

Hello:

I wonder if there is a way to add user-defined variables to the raw data file, which logs data at every trial?

When running the code attached below, I get the following columns in the raw data file:

date    time    group    subject    session    build    blockNum    trialNum    blockCode    trialCode    pretrialPause    posttrialPause    response    correct    latency    stimulusNumber1    stimulusItem1    stimulusOnset1    stimulusNumber2    stimulusItem2    stimulusOnset2    stimulusNumber3    stimulusItem3    stimulusOnset3

I would like to add variables such as values.box_clicking_boxesChecked, values.effortBoxes and values.effortCredits.

If that is not possible, would love to hear on alternative ways to implement that, if at all possible.

Thank you in advance!
With very best wishes,

EN

--

// Global variables -- some of these variables should be re-defined in emot_induction.iqx

<values>
//Thresholds specified by the procedure defined in calibration_time_boxcount.iqx
/ easyThresh50 = 8 //The number of boxes at the 50% level
/ mediumThresh65 = 10 //The number of boxes at the 65% level
/ mediumThresh80 = 13 //The number of boxes at the 80% level
/ hardThresh95 = 15 //The number of boxes at the 95% level

// From here -- may have to be specified globally to be used in other places
// Total number of boxes clicked in box_clicking
/ box_clicking_boxesChecked = 0
/ YOU_reward = 0
/ OTHER_reward = 0

// From here -- specific to social_effort_box_click_task.iqx
//Color of trial type -- in fact, red (YOU) or blue (OTHER)
/ c_colorname = black
//Stores the selected combination of effort and reward -- e.g., e1_r1 means the lowest effort and the lowest reward
/ eff_rew = "e0_r0" // for filling purposes, this condition DOES NOT EXIST

// Position of the two choices
/ effortX = 0%
/ restX = 0%

// Trial type
/ trialType = null

// Strings to be displayed at every trial
/ centerLabel = null // will be either YOU or OTHER
/ effortCredits = 0
/ effortBoxes = 0

</values>

<parameters> //
//These are the rewards (fixed for all participants)
/ low_pay = 2 //Low reward
/ medium_pay = 6 //Medium reward
/ high_pay = 10 //High reward

/ num_trials = 24 // total number of trials
</parameters>

// data to be saved in summary file -- CONSIDER ADDING ITEMS in the future
<summarydata>
/columns = (script.startdate, script.starttime, script.subjectid, script.groupid,
            script.elapsedtime, computer.platform,values.YOU_reward, values.OTHER_reward)
</summarydata>


// These checkboxes will also be defined in emot_induction.iqx -- must comment them when transferring!
<checkboxes row1>
/ caption=" "
/ options=("1", "2", "3", "4", "5", "6", "7", "8", "9", "10")
/ optionvalues = ("1", "2", "3", "4","5", "6", "7", "8", "9", "10")
/ required = true
/ orientation = horizontalequal
</checkboxes>

<checkboxes row2>
/ caption=" "
/ options=("11", "12", "13", "14", "15", "16", "17", "18", "19", "20")
/ optionvalues = ("11", "12", "13", "14","15", "16", "17", "18", "19", "20")
/ required = true
/ orientation = horizontalequal
</checkboxes>

<checkboxes row3>
/ caption=" "
/ options=("21", "22", "23", "24", "25", "26", "27", "28", "29", "30")
/ optionvalues = ("21", "22", "23", "24","25", "26", "27", "28", "29", "30")
/ required = true
/ orientation = horizontalequal
</checkboxes>

<checkboxes row4>
/ caption=" "
/ options=("31", "32", "33", "34", "35", "36", "37", "38", "39", "40")
/ optionvalues = ("31", "32", "33", "34","35", "36", "37", "38", "39", "40")
/ required = true
/ orientation = horizontalequal
</checkboxes>

<checkboxes row5>
/ caption=" "
/ options=("41", "42", "43", "44", "45", "46", "47", "48", "49", "50")
/ optionvalues = ("41", "42", "43", "44","45", "46", "47", "48", "49", "50")
/ required = true
/ orientation = horizontalequal
</checkboxes>

<surveypage box_clicking>
/ onTrialEnd = [
  values.box_clicking_boxesChecked = checkboxes.row1.selectedCount + checkboxes.row2.selectedCount + checkboxes.row3.selectedCount + checkboxes.row4.selectedCount + checkboxes.row5.selectedCount;
]
/caption = "<font color='green'>You must click at least <b><u><%values.effortBoxes%></u></b> boxes"
/questions = [1-5=sequence(row1, row2, row3, row4, row5)]
/ itemfontstyle = ("Arial", 2.00%, false, false, false, false, 5, 1)
/ itemspacing = 0.0%
/ showpagenumbers = false
/ showbackbutton = false
/ showquestionnumbers = false
/ responsefontstyle = ("Arial", 2.0%, false, false, false, false, 5, 1)
/ timeout = 10000 // 10 seconds
/ showNextButton = false
</surveypage>

<block SocialEffort_Block>
/ onBlockBegin = [
    // Randomized trial type order -- 24 trials
    list.trialTypeList.appendItem(list.trialType.nextValue); //1
    list.trialTypeList.appendItem(list.trialType.nextValue); //2
    list.trialTypeList.appendItem(list.trialType.nextValue); //3
    list.trialTypeList.appendItem(list.trialType.nextValue); //4
    list.trialTypeList.appendItem(list.trialType.nextValue); //5
    list.trialTypeList.appendItem(list.trialType.nextValue); //6
    list.trialTypeList.appendItem(list.trialType.nextValue); //7
    list.trialTypeList.appendItem(list.trialType.nextValue); //8
    list.trialTypeList.appendItem(list.trialType.nextValue); //9
    list.trialTypeList.appendItem(list.trialType.nextValue); //10
    list.trialTypeList.appendItem(list.trialType.nextValue); //11
    list.trialTypeList.appendItem(list.trialType.nextValue); //12
    list.trialTypeList.appendItem(list.trialType.nextValue); //13
    list.trialTypeList.appendItem(list.trialType.nextValue); //14
    list.trialTypeList.appendItem(list.trialType.nextValue); //15
    list.trialTypeList.appendItem(list.trialType.nextValue); //16
    list.trialTypeList.appendItem(list.trialType.nextValue); //17
    list.trialTypeList.appendItem(list.trialType.nextValue); //18
    list.trialTypeList.appendItem(list.trialType.nextValue); //19
    list.trialTypeList.appendItem(list.trialType.nextValue); //20
    list.trialTypeList.appendItem(list.trialType.nextValue); //21
    list.trialTypeList.appendItem(list.trialType.nextValue); //22
    list.trialTypeList.appendItem(list.trialType.nextValue); //23
    list.trialTypeList.appendItem(list.trialType.nextValue); //24
    // Randomized YOU effort-reward 12 pairs
    list.YOU_eff_rewList.appendItem(list.eff_rew_YOU.nextValue); //1
    list.YOU_eff_rewList.appendItem(list.eff_rew_YOU.nextValue); //2
    list.YOU_eff_rewList.appendItem(list.eff_rew_YOU.nextValue); //3
    list.YOU_eff_rewList.appendItem(list.eff_rew_YOU.nextValue); //4
    list.YOU_eff_rewList.appendItem(list.eff_rew_YOU.nextValue); //5
    list.YOU_eff_rewList.appendItem(list.eff_rew_YOU.nextValue); //6
    list.YOU_eff_rewList.appendItem(list.eff_rew_YOU.nextValue); //7
    list.YOU_eff_rewList.appendItem(list.eff_rew_YOU.nextValue); //8
    list.YOU_eff_rewList.appendItem(list.eff_rew_YOU.nextValue); //9
    list.YOU_eff_rewList.appendItem(list.eff_rew_YOU.nextValue); //10
    list.YOU_eff_rewList.appendItem(list.eff_rew_YOU.nextValue); //11
    list.YOU_eff_rewList.appendItem(list.eff_rew_YOU.nextValue); //12    
    // Randomized OTHER effort-reward 12 pairs
    list.OTHER_eff_rewList.appendItem(list.eff_rew_OTHER.nextValue); //1
    list.OTHER_eff_rewList.appendItem(list.eff_rew_OTHER.nextValue); //2
    list.OTHER_eff_rewList.appendItem(list.eff_rew_OTHER.nextValue); //3
    list.OTHER_eff_rewList.appendItem(list.eff_rew_OTHER.nextValue); //4
    list.OTHER_eff_rewList.appendItem(list.eff_rew_OTHER.nextValue); //5
    list.OTHER_eff_rewList.appendItem(list.eff_rew_OTHER.nextValue); //6
    list.OTHER_eff_rewList.appendItem(list.eff_rew_OTHER.nextValue); //7
    list.OTHER_eff_rewList.appendItem(list.eff_rew_OTHER.nextValue); //8
    list.OTHER_eff_rewList.appendItem(list.eff_rew_OTHER.nextValue); //9
    list.OTHER_eff_rewList.appendItem(list.eff_rew_OTHER.nextValue); //10
    list.OTHER_eff_rewList.appendItem(list.eff_rew_OTHER.nextValue); //11
    list.OTHER_eff_rewList.appendItem(list.eff_rew_OTHER.nextValue); //12
]
// trials = [1-parameters.num_trials = BoxClick_Trial]
/ trials = [1-24 = BoxClick_Trial] // ATTENTION: defining the number of trials manually....

</block>

<trial BoxClick_Trial>
/ onTrialBegin = [
  // pick random postion for effort_option
  values.effortX = list.x.nextValue;
  // pick position for rest_option
  values.restX = list.x.nextValue;
  // set trial type
  //values.trialType = list.trialType.nextValue;
    values.trialType = list.trialTypeList.nextValue;
  // set center label according to trial type
  if (values.trialType == "YOU") {
        values.c_colorname = red;
        //values.eff_rew = list.eff_rew_YOU.nextValue;
        values.eff_rew = list.YOU_eff_rewList.nextValue;
  } else { // OTHER
        values.c_colorname = blue;
        //values.eff_rew = list.eff_rew_OTHER.nextValue;
        values.eff_rew = list.OTHER_eff_rewList.nextValue;
  }    
    // set winnings and effort according to the value in eff_rew
    if (values.eff_rew == "e1_r1") {
        values.effortBoxes = values.easyThresh50;
        values.effortCredits = parameters.low_pay;
    } else if (values.eff_rew == "e1_r2") {
        values.effortBoxes = values.easyThresh50;
        values.effortCredits = parameters.medium_pay;
    } else if (values.eff_rew == "e1_r3") {
        values.effortBoxes = values.easyThresh50;
        values.effortCredits = parameters.high_pay;    
    } else if (values.eff_rew == "e2_r1") {
        values.effortBoxes = values.mediumThresh65;
        values.effortCredits = parameters.low_pay;    
    } else if (values.eff_rew == "e2_r2") {
        values.effortBoxes = values.mediumThresh65;
        values.effortCredits = parameters.medium_pay;
    } else if (values.eff_rew == "e2_r3") {
        values.effortBoxes = values.mediumThresh65;
        values.effortCredits = parameters.high_pay;
    } else if (values.eff_rew == "e3_r1") {
        values.effortBoxes = values.mediumThresh80;
        values.effortCredits = parameters.low_pay;
    } else if (values.eff_rew == "e3_r2") {
        values.effortBoxes = values.mediumThresh80;
        values.effortCredits = parameters.medium_pay;        
    } else if (values.eff_rew == "e3_r3") {
        values.effortBoxes = values.mediumThresh80;
        values.effortCredits = parameters.high_pay;
    } else if (values.eff_rew == "e4_r1") {
        values.effortBoxes = values.hardThresh95;
        values.effortCredits = parameters.low_pay;
    } else if (values.eff_rew == "e4_r2") {
        values.effortBoxes = values.hardThresh95;
        values.effortCredits = parameters.medium_pay;
    } else if (values.eff_rew == "e4_r3") {
        values.effortBoxes = values.hardThresh95;
        values.effortCredits = parameters.high_pay;
    }
]
/ stimulusframes = [1=effort_option, rest_option, center_label]
/ inputdevice = mouse
/ validresponse = (effort_option, rest_option)

/ branch = [
    if (trial.BoxClick_Trial.response=="effort_option") { // if subj chose the effortful option
        // run the clicking box survey
        return surveyPage.box_clicking;
    }
]
// update the rewards depending on the participant's choice and performance in the box clicking task
/ onTrialend = [
    if (trial.BoxClick_Trial.response=="effort_option") { // if subj chose the effortful option
        if (values.box_clicking_boxesChecked >= values.effortBoxes) { // succeeded in the box clicking task
            if (values.trialType == "YOU") { // add the reward to YOU_reward
                values.YOU_reward = values.YOU_reward + values.effortCredits;
            } else { // add the reward to OTHER_reward
                values.OTHER_reward = values.OTHER_reward + values.effortCredits;
            }
        }
    } else { // chose the rest option
        if (values.trialType == "YOU") {
            values.YOU_reward = values.YOU_reward + 1; // assuming that rest option's reward is 1
        } else {
            values.OTHER_reward = values.OTHER_reward + 1; // assuming that rest option's reward is 1
        }
    }
]
</trial>

// Stores the order of the 24 trial types -- YOU or OTHER
<list trialTypeList>
/ selectionMode = sequence
</list>

// Stores the order in which the effort/reward pairs will be presented in the 12 YOU trials
<list YOU_eff_rewList>
/ selectionMode = sequence
</list>

// Stores the order in which the effort/reward pairs will be presented in the 12 OTHER trials
<list OTHER_eff_rewList>
/ selectionMode = sequence
</list>

<text effort_option>
/ items = ("<%values.effortCredits%> credits for <%values.effortBoxes%> boxes")
/ hPosition = values.effortX
/ vPosition = 40%
/ fontStyle = ("arial", 12pt)
/ size = (15%, 10%)
/ vJustify = center
/ txBGColor = lightGray
</text>

<text rest_option>
/ items = ("1 credit for Rest")
/ hPosition = values.restX
/ vPosition = 40%
/ fontStyle = ("arial", 12pt)
/ size = (15%, 10%)
/ vJustify = center
/ txBGColor = lightGray
</text>

<text center_label>
/ items = ("<%values.trialType%>") // this is the label that should be used in the exp!
// items = ("<%values.eff_rew%>") // testing the list selection!
/ position = (50%, 30%)
/ txColor = values.c_colorname
/ fontStyle = ("arial", 16pt, true)
</text>

<list trialType>
/ items = ("YOU", "OTHER")
/ poolsize = parameters.num_trials
/ selectionmode = random
/ selectionrate = always
</list>

// This list contains all effort (4) x reward (3) = 12 combinations for the YOU trials
// It will be used to to sample --once-- all the 12 combinations
<list eff_rew_YOU>
/ items = ("e1_r1", "e1_r2", "e1_r3", "e2_r1", "e2_r2", "e2_r3", "e3_r1", "e3_r2", "e3_r3", "e4_r1", "e4_r2", "e4_r3")
/ poolsize = parameters.num_trials/2
/ replace = false
/ selectionmode = random
/ selectionrate = always
</list>

// Likewise for the OTHER trials
<list eff_rew_OTHER>
/ items = ("e1_r1", "e1_r2", "e1_r3", "e2_r1", "e2_r2", "e2_r3", "e3_r1", "e3_r2", "e3_r3", "e4_r1", "e4_r2", "e4_r3")
/ poolsize = parameters.num_trials/2
/ replace = false
/ selectionmode = random
/ selectionrate = always
</list>

<list x>
/ items = (35%, 65%)
/ selectionrate = always
</list>

By Dave - 7/5/2025

EN - 7/5/2025
Hello:

I wonder if there is a way to add user-defined variables to the raw data file, which logs data at every trial?

When running the code attached below, I get the following columns in the raw data file:

date    time    group    subject    session    build    blockNum    trialNum    blockCode    trialCode    pretrialPause    posttrialPause    response    correct    latency    stimulusNumber1    stimulusItem1    stimulusOnset1    stimulusNumber2    stimulusItem2    stimulusOnset2    stimulusNumber3    stimulusItem3    stimulusOnset3

I would like to add variables such as values.box_clicking_boxesChecked, values.effortBoxes and values.effortCredits.

If that is not possible, would love to hear on alternative ways to implement that, if at all possible.

Thank you in advance!
With very best wishes,

EN

--

// Global variables -- some of these variables should be re-defined in emot_induction.iqx

<values>
//Thresholds specified by the procedure defined in calibration_time_boxcount.iqx
/ easyThresh50 = 8 //The number of boxes at the 50% level
/ mediumThresh65 = 10 //The number of boxes at the 65% level
/ mediumThresh80 = 13 //The number of boxes at the 80% level
/ hardThresh95 = 15 //The number of boxes at the 95% level

// From here -- may have to be specified globally to be used in other places
// Total number of boxes clicked in box_clicking
/ box_clicking_boxesChecked = 0
/ YOU_reward = 0
/ OTHER_reward = 0

// From here -- specific to social_effort_box_click_task.iqx
//Color of trial type -- in fact, red (YOU) or blue (OTHER)
/ c_colorname = black
//Stores the selected combination of effort and reward -- e.g., e1_r1 means the lowest effort and the lowest reward
/ eff_rew = "e0_r0" // for filling purposes, this condition DOES NOT EXIST

// Position of the two choices
/ effortX = 0%
/ restX = 0%

// Trial type
/ trialType = null

// Strings to be displayed at every trial
/ centerLabel = null // will be either YOU or OTHER
/ effortCredits = 0
/ effortBoxes = 0

</values>

<parameters> //
//These are the rewards (fixed for all participants)
/ low_pay = 2 //Low reward
/ medium_pay = 6 //Medium reward
/ high_pay = 10 //High reward

/ num_trials = 24 // total number of trials
</parameters>

// data to be saved in summary file -- CONSIDER ADDING ITEMS in the future
<summarydata>
/columns = (script.startdate, script.starttime, script.subjectid, script.groupid,
            script.elapsedtime, computer.platform,values.YOU_reward, values.OTHER_reward)
</summarydata>


// These checkboxes will also be defined in emot_induction.iqx -- must comment them when transferring!
<checkboxes row1>
/ caption=" "
/ options=("1", "2", "3", "4", "5", "6", "7", "8", "9", "10")
/ optionvalues = ("1", "2", "3", "4","5", "6", "7", "8", "9", "10")
/ required = true
/ orientation = horizontalequal
</checkboxes>

<checkboxes row2>
/ caption=" "
/ options=("11", "12", "13", "14", "15", "16", "17", "18", "19", "20")
/ optionvalues = ("11", "12", "13", "14","15", "16", "17", "18", "19", "20")
/ required = true
/ orientation = horizontalequal
</checkboxes>

<checkboxes row3>
/ caption=" "
/ options=("21", "22", "23", "24", "25", "26", "27", "28", "29", "30")
/ optionvalues = ("21", "22", "23", "24","25", "26", "27", "28", "29", "30")
/ required = true
/ orientation = horizontalequal
</checkboxes>

<checkboxes row4>
/ caption=" "
/ options=("31", "32", "33", "34", "35", "36", "37", "38", "39", "40")
/ optionvalues = ("31", "32", "33", "34","35", "36", "37", "38", "39", "40")
/ required = true
/ orientation = horizontalequal
</checkboxes>

<checkboxes row5>
/ caption=" "
/ options=("41", "42", "43", "44", "45", "46", "47", "48", "49", "50")
/ optionvalues = ("41", "42", "43", "44","45", "46", "47", "48", "49", "50")
/ required = true
/ orientation = horizontalequal
</checkboxes>

<surveypage box_clicking>
/ onTrialEnd = [
  values.box_clicking_boxesChecked = checkboxes.row1.selectedCount + checkboxes.row2.selectedCount + checkboxes.row3.selectedCount + checkboxes.row4.selectedCount + checkboxes.row5.selectedCount;
]
/caption = "<font color='green'>You must click at least <b><u><%values.effortBoxes%></u></b> boxes"
/questions = [1-5=sequence(row1, row2, row3, row4, row5)]
/ itemfontstyle = ("Arial", 2.00%, false, false, false, false, 5, 1)
/ itemspacing = 0.0%
/ showpagenumbers = false
/ showbackbutton = false
/ showquestionnumbers = false
/ responsefontstyle = ("Arial", 2.0%, false, false, false, false, 5, 1)
/ timeout = 10000 // 10 seconds
/ showNextButton = false
</surveypage>

<block SocialEffort_Block>
/ onBlockBegin = [
    // Randomized trial type order -- 24 trials
    list.trialTypeList.appendItem(list.trialType.nextValue); //1
    list.trialTypeList.appendItem(list.trialType.nextValue); //2
    list.trialTypeList.appendItem(list.trialType.nextValue); //3
    list.trialTypeList.appendItem(list.trialType.nextValue); //4
    list.trialTypeList.appendItem(list.trialType.nextValue); //5
    list.trialTypeList.appendItem(list.trialType.nextValue); //6
    list.trialTypeList.appendItem(list.trialType.nextValue); //7
    list.trialTypeList.appendItem(list.trialType.nextValue); //8
    list.trialTypeList.appendItem(list.trialType.nextValue); //9
    list.trialTypeList.appendItem(list.trialType.nextValue); //10
    list.trialTypeList.appendItem(list.trialType.nextValue); //11
    list.trialTypeList.appendItem(list.trialType.nextValue); //12
    list.trialTypeList.appendItem(list.trialType.nextValue); //13
    list.trialTypeList.appendItem(list.trialType.nextValue); //14
    list.trialTypeList.appendItem(list.trialType.nextValue); //15
    list.trialTypeList.appendItem(list.trialType.nextValue); //16
    list.trialTypeList.appendItem(list.trialType.nextValue); //17
    list.trialTypeList.appendItem(list.trialType.nextValue); //18
    list.trialTypeList.appendItem(list.trialType.nextValue); //19
    list.trialTypeList.appendItem(list.trialType.nextValue); //20
    list.trialTypeList.appendItem(list.trialType.nextValue); //21
    list.trialTypeList.appendItem(list.trialType.nextValue); //22
    list.trialTypeList.appendItem(list.trialType.nextValue); //23
    list.trialTypeList.appendItem(list.trialType.nextValue); //24
    // Randomized YOU effort-reward 12 pairs
    list.YOU_eff_rewList.appendItem(list.eff_rew_YOU.nextValue); //1
    list.YOU_eff_rewList.appendItem(list.eff_rew_YOU.nextValue); //2
    list.YOU_eff_rewList.appendItem(list.eff_rew_YOU.nextValue); //3
    list.YOU_eff_rewList.appendItem(list.eff_rew_YOU.nextValue); //4
    list.YOU_eff_rewList.appendItem(list.eff_rew_YOU.nextValue); //5
    list.YOU_eff_rewList.appendItem(list.eff_rew_YOU.nextValue); //6
    list.YOU_eff_rewList.appendItem(list.eff_rew_YOU.nextValue); //7
    list.YOU_eff_rewList.appendItem(list.eff_rew_YOU.nextValue); //8
    list.YOU_eff_rewList.appendItem(list.eff_rew_YOU.nextValue); //9
    list.YOU_eff_rewList.appendItem(list.eff_rew_YOU.nextValue); //10
    list.YOU_eff_rewList.appendItem(list.eff_rew_YOU.nextValue); //11
    list.YOU_eff_rewList.appendItem(list.eff_rew_YOU.nextValue); //12    
    // Randomized OTHER effort-reward 12 pairs
    list.OTHER_eff_rewList.appendItem(list.eff_rew_OTHER.nextValue); //1
    list.OTHER_eff_rewList.appendItem(list.eff_rew_OTHER.nextValue); //2
    list.OTHER_eff_rewList.appendItem(list.eff_rew_OTHER.nextValue); //3
    list.OTHER_eff_rewList.appendItem(list.eff_rew_OTHER.nextValue); //4
    list.OTHER_eff_rewList.appendItem(list.eff_rew_OTHER.nextValue); //5
    list.OTHER_eff_rewList.appendItem(list.eff_rew_OTHER.nextValue); //6
    list.OTHER_eff_rewList.appendItem(list.eff_rew_OTHER.nextValue); //7
    list.OTHER_eff_rewList.appendItem(list.eff_rew_OTHER.nextValue); //8
    list.OTHER_eff_rewList.appendItem(list.eff_rew_OTHER.nextValue); //9
    list.OTHER_eff_rewList.appendItem(list.eff_rew_OTHER.nextValue); //10
    list.OTHER_eff_rewList.appendItem(list.eff_rew_OTHER.nextValue); //11
    list.OTHER_eff_rewList.appendItem(list.eff_rew_OTHER.nextValue); //12
]
// trials = [1-parameters.num_trials = BoxClick_Trial]
/ trials = [1-24 = BoxClick_Trial] // ATTENTION: defining the number of trials manually....

</block>

<trial BoxClick_Trial>
/ onTrialBegin = [
  // pick random postion for effort_option
  values.effortX = list.x.nextValue;
  // pick position for rest_option
  values.restX = list.x.nextValue;
  // set trial type
  //values.trialType = list.trialType.nextValue;
    values.trialType = list.trialTypeList.nextValue;
  // set center label according to trial type
  if (values.trialType == "YOU") {
        values.c_colorname = red;
        //values.eff_rew = list.eff_rew_YOU.nextValue;
        values.eff_rew = list.YOU_eff_rewList.nextValue;
  } else { // OTHER
        values.c_colorname = blue;
        //values.eff_rew = list.eff_rew_OTHER.nextValue;
        values.eff_rew = list.OTHER_eff_rewList.nextValue;
  }    
    // set winnings and effort according to the value in eff_rew
    if (values.eff_rew == "e1_r1") {
        values.effortBoxes = values.easyThresh50;
        values.effortCredits = parameters.low_pay;
    } else if (values.eff_rew == "e1_r2") {
        values.effortBoxes = values.easyThresh50;
        values.effortCredits = parameters.medium_pay;
    } else if (values.eff_rew == "e1_r3") {
        values.effortBoxes = values.easyThresh50;
        values.effortCredits = parameters.high_pay;    
    } else if (values.eff_rew == "e2_r1") {
        values.effortBoxes = values.mediumThresh65;
        values.effortCredits = parameters.low_pay;    
    } else if (values.eff_rew == "e2_r2") {
        values.effortBoxes = values.mediumThresh65;
        values.effortCredits = parameters.medium_pay;
    } else if (values.eff_rew == "e2_r3") {
        values.effortBoxes = values.mediumThresh65;
        values.effortCredits = parameters.high_pay;
    } else if (values.eff_rew == "e3_r1") {
        values.effortBoxes = values.mediumThresh80;
        values.effortCredits = parameters.low_pay;
    } else if (values.eff_rew == "e3_r2") {
        values.effortBoxes = values.mediumThresh80;
        values.effortCredits = parameters.medium_pay;        
    } else if (values.eff_rew == "e3_r3") {
        values.effortBoxes = values.mediumThresh80;
        values.effortCredits = parameters.high_pay;
    } else if (values.eff_rew == "e4_r1") {
        values.effortBoxes = values.hardThresh95;
        values.effortCredits = parameters.low_pay;
    } else if (values.eff_rew == "e4_r2") {
        values.effortBoxes = values.hardThresh95;
        values.effortCredits = parameters.medium_pay;
    } else if (values.eff_rew == "e4_r3") {
        values.effortBoxes = values.hardThresh95;
        values.effortCredits = parameters.high_pay;
    }
]
/ stimulusframes = [1=effort_option, rest_option, center_label]
/ inputdevice = mouse
/ validresponse = (effort_option, rest_option)

/ branch = [
    if (trial.BoxClick_Trial.response=="effort_option") { // if subj chose the effortful option
        // run the clicking box survey
        return surveyPage.box_clicking;
    }
]
// update the rewards depending on the participant's choice and performance in the box clicking task
/ onTrialend = [
    if (trial.BoxClick_Trial.response=="effort_option") { // if subj chose the effortful option
        if (values.box_clicking_boxesChecked >= values.effortBoxes) { // succeeded in the box clicking task
            if (values.trialType == "YOU") { // add the reward to YOU_reward
                values.YOU_reward = values.YOU_reward + values.effortCredits;
            } else { // add the reward to OTHER_reward
                values.OTHER_reward = values.OTHER_reward + values.effortCredits;
            }
        }
    } else { // chose the rest option
        if (values.trialType == "YOU") {
            values.YOU_reward = values.YOU_reward + 1; // assuming that rest option's reward is 1
        } else {
            values.OTHER_reward = values.OTHER_reward + 1; // assuming that rest option's reward is 1
        }
    }
]
</trial>

// Stores the order of the 24 trial types -- YOU or OTHER
<list trialTypeList>
/ selectionMode = sequence
</list>

// Stores the order in which the effort/reward pairs will be presented in the 12 YOU trials
<list YOU_eff_rewList>
/ selectionMode = sequence
</list>

// Stores the order in which the effort/reward pairs will be presented in the 12 OTHER trials
<list OTHER_eff_rewList>
/ selectionMode = sequence
</list>

<text effort_option>
/ items = ("<%values.effortCredits%> credits for <%values.effortBoxes%> boxes")
/ hPosition = values.effortX
/ vPosition = 40%
/ fontStyle = ("arial", 12pt)
/ size = (15%, 10%)
/ vJustify = center
/ txBGColor = lightGray
</text>

<text rest_option>
/ items = ("1 credit for Rest")
/ hPosition = values.restX
/ vPosition = 40%
/ fontStyle = ("arial", 12pt)
/ size = (15%, 10%)
/ vJustify = center
/ txBGColor = lightGray
</text>

<text center_label>
/ items = ("<%values.trialType%>") // this is the label that should be used in the exp!
// items = ("<%values.eff_rew%>") // testing the list selection!
/ position = (50%, 30%)
/ txColor = values.c_colorname
/ fontStyle = ("arial", 16pt, true)
</text>

<list trialType>
/ items = ("YOU", "OTHER")
/ poolsize = parameters.num_trials
/ selectionmode = random
/ selectionrate = always
</list>

// This list contains all effort (4) x reward (3) = 12 combinations for the YOU trials
// It will be used to to sample --once-- all the 12 combinations
<list eff_rew_YOU>
/ items = ("e1_r1", "e1_r2", "e1_r3", "e2_r1", "e2_r2", "e2_r3", "e3_r1", "e3_r2", "e3_r3", "e4_r1", "e4_r2", "e4_r3")
/ poolsize = parameters.num_trials/2
/ replace = false
/ selectionmode = random
/ selectionrate = always
</list>

// Likewise for the OTHER trials
<list eff_rew_OTHER>
/ items = ("e1_r1", "e1_r2", "e1_r3", "e2_r1", "e2_r2", "e2_r3", "e3_r1", "e3_r2", "e3_r3", "e4_r1", "e4_r2", "e4_r3")
/ poolsize = parameters.num_trials/2
/ replace = false
/ selectionmode = random
/ selectionrate = always
</list>

<list x>
/ items = (35%, 65%)
/ selectionrate = always
</list>


You need to create a <data> element and define all the things you want logged in its /columns attribute.

This is all covered in the documentation.
https://www.millisecond.com/support/docs/v6/html/language/attributes/columns.htm
By EN - 7/5/2025

Dave - 7/5/2025
EN - 7/5/2025
Hello:

I wonder if there is a way to add user-defined variables to the raw data file, which logs data at every trial?

When running the code attached below, I get the following columns in the raw data file:

date    time    group    subject    session    build    blockNum    trialNum    blockCode    trialCode    pretrialPause    posttrialPause    response    correct    latency    stimulusNumber1    stimulusItem1    stimulusOnset1    stimulusNumber2    stimulusItem2    stimulusOnset2    stimulusNumber3    stimulusItem3    stimulusOnset3

I would like to add variables such as values.box_clicking_boxesChecked, values.effortBoxes and values.effortCredits.

If that is not possible, would love to hear on alternative ways to implement that, if at all possible.

Thank you in advance!
With very best wishes,

EN

--

// Global variables -- some of these variables should be re-defined in emot_induction.iqx

<values>
//Thresholds specified by the procedure defined in calibration_time_boxcount.iqx
/ easyThresh50 = 8 //The number of boxes at the 50% level
/ mediumThresh65 = 10 //The number of boxes at the 65% level
/ mediumThresh80 = 13 //The number of boxes at the 80% level
/ hardThresh95 = 15 //The number of boxes at the 95% level

// From here -- may have to be specified globally to be used in other places
// Total number of boxes clicked in box_clicking
/ box_clicking_boxesChecked = 0
/ YOU_reward = 0
/ OTHER_reward = 0

// From here -- specific to social_effort_box_click_task.iqx
//Color of trial type -- in fact, red (YOU) or blue (OTHER)
/ c_colorname = black
//Stores the selected combination of effort and reward -- e.g., e1_r1 means the lowest effort and the lowest reward
/ eff_rew = "e0_r0" // for filling purposes, this condition DOES NOT EXIST

// Position of the two choices
/ effortX = 0%
/ restX = 0%

// Trial type
/ trialType = null

// Strings to be displayed at every trial
/ centerLabel = null // will be either YOU or OTHER
/ effortCredits = 0
/ effortBoxes = 0

</values>

<parameters> //
//These are the rewards (fixed for all participants)
/ low_pay = 2 //Low reward
/ medium_pay = 6 //Medium reward
/ high_pay = 10 //High reward

/ num_trials = 24 // total number of trials
</parameters>

// data to be saved in summary file -- CONSIDER ADDING ITEMS in the future
<summarydata>
/columns = (script.startdate, script.starttime, script.subjectid, script.groupid,
            script.elapsedtime, computer.platform,values.YOU_reward, values.OTHER_reward)
</summarydata>


// These checkboxes will also be defined in emot_induction.iqx -- must comment them when transferring!
<checkboxes row1>
/ caption=" "
/ options=("1", "2", "3", "4", "5", "6", "7", "8", "9", "10")
/ optionvalues = ("1", "2", "3", "4","5", "6", "7", "8", "9", "10")
/ required = true
/ orientation = horizontalequal
</checkboxes>

<checkboxes row2>
/ caption=" "
/ options=("11", "12", "13", "14", "15", "16", "17", "18", "19", "20")
/ optionvalues = ("11", "12", "13", "14","15", "16", "17", "18", "19", "20")
/ required = true
/ orientation = horizontalequal
</checkboxes>

<checkboxes row3>
/ caption=" "
/ options=("21", "22", "23", "24", "25", "26", "27", "28", "29", "30")
/ optionvalues = ("21", "22", "23", "24","25", "26", "27", "28", "29", "30")
/ required = true
/ orientation = horizontalequal
</checkboxes>

<checkboxes row4>
/ caption=" "
/ options=("31", "32", "33", "34", "35", "36", "37", "38", "39", "40")
/ optionvalues = ("31", "32", "33", "34","35", "36", "37", "38", "39", "40")
/ required = true
/ orientation = horizontalequal
</checkboxes>

<checkboxes row5>
/ caption=" "
/ options=("41", "42", "43", "44", "45", "46", "47", "48", "49", "50")
/ optionvalues = ("41", "42", "43", "44","45", "46", "47", "48", "49", "50")
/ required = true
/ orientation = horizontalequal
</checkboxes>

<surveypage box_clicking>
/ onTrialEnd = [
  values.box_clicking_boxesChecked = checkboxes.row1.selectedCount + checkboxes.row2.selectedCount + checkboxes.row3.selectedCount + checkboxes.row4.selectedCount + checkboxes.row5.selectedCount;
]
/caption = "<font color='green'>You must click at least <b><u><%values.effortBoxes%></u></b> boxes"
/questions = [1-5=sequence(row1, row2, row3, row4, row5)]
/ itemfontstyle = ("Arial", 2.00%, false, false, false, false, 5, 1)
/ itemspacing = 0.0%
/ showpagenumbers = false
/ showbackbutton = false
/ showquestionnumbers = false
/ responsefontstyle = ("Arial", 2.0%, false, false, false, false, 5, 1)
/ timeout = 10000 // 10 seconds
/ showNextButton = false
</surveypage>

<block SocialEffort_Block>
/ onBlockBegin = [
    // Randomized trial type order -- 24 trials
    list.trialTypeList.appendItem(list.trialType.nextValue); //1
    list.trialTypeList.appendItem(list.trialType.nextValue); //2
    list.trialTypeList.appendItem(list.trialType.nextValue); //3
    list.trialTypeList.appendItem(list.trialType.nextValue); //4
    list.trialTypeList.appendItem(list.trialType.nextValue); //5
    list.trialTypeList.appendItem(list.trialType.nextValue); //6
    list.trialTypeList.appendItem(list.trialType.nextValue); //7
    list.trialTypeList.appendItem(list.trialType.nextValue); //8
    list.trialTypeList.appendItem(list.trialType.nextValue); //9
    list.trialTypeList.appendItem(list.trialType.nextValue); //10
    list.trialTypeList.appendItem(list.trialType.nextValue); //11
    list.trialTypeList.appendItem(list.trialType.nextValue); //12
    list.trialTypeList.appendItem(list.trialType.nextValue); //13
    list.trialTypeList.appendItem(list.trialType.nextValue); //14
    list.trialTypeList.appendItem(list.trialType.nextValue); //15
    list.trialTypeList.appendItem(list.trialType.nextValue); //16
    list.trialTypeList.appendItem(list.trialType.nextValue); //17
    list.trialTypeList.appendItem(list.trialType.nextValue); //18
    list.trialTypeList.appendItem(list.trialType.nextValue); //19
    list.trialTypeList.appendItem(list.trialType.nextValue); //20
    list.trialTypeList.appendItem(list.trialType.nextValue); //21
    list.trialTypeList.appendItem(list.trialType.nextValue); //22
    list.trialTypeList.appendItem(list.trialType.nextValue); //23
    list.trialTypeList.appendItem(list.trialType.nextValue); //24
    // Randomized YOU effort-reward 12 pairs
    list.YOU_eff_rewList.appendItem(list.eff_rew_YOU.nextValue); //1
    list.YOU_eff_rewList.appendItem(list.eff_rew_YOU.nextValue); //2
    list.YOU_eff_rewList.appendItem(list.eff_rew_YOU.nextValue); //3
    list.YOU_eff_rewList.appendItem(list.eff_rew_YOU.nextValue); //4
    list.YOU_eff_rewList.appendItem(list.eff_rew_YOU.nextValue); //5
    list.YOU_eff_rewList.appendItem(list.eff_rew_YOU.nextValue); //6
    list.YOU_eff_rewList.appendItem(list.eff_rew_YOU.nextValue); //7
    list.YOU_eff_rewList.appendItem(list.eff_rew_YOU.nextValue); //8
    list.YOU_eff_rewList.appendItem(list.eff_rew_YOU.nextValue); //9
    list.YOU_eff_rewList.appendItem(list.eff_rew_YOU.nextValue); //10
    list.YOU_eff_rewList.appendItem(list.eff_rew_YOU.nextValue); //11
    list.YOU_eff_rewList.appendItem(list.eff_rew_YOU.nextValue); //12    
    // Randomized OTHER effort-reward 12 pairs
    list.OTHER_eff_rewList.appendItem(list.eff_rew_OTHER.nextValue); //1
    list.OTHER_eff_rewList.appendItem(list.eff_rew_OTHER.nextValue); //2
    list.OTHER_eff_rewList.appendItem(list.eff_rew_OTHER.nextValue); //3
    list.OTHER_eff_rewList.appendItem(list.eff_rew_OTHER.nextValue); //4
    list.OTHER_eff_rewList.appendItem(list.eff_rew_OTHER.nextValue); //5
    list.OTHER_eff_rewList.appendItem(list.eff_rew_OTHER.nextValue); //6
    list.OTHER_eff_rewList.appendItem(list.eff_rew_OTHER.nextValue); //7
    list.OTHER_eff_rewList.appendItem(list.eff_rew_OTHER.nextValue); //8
    list.OTHER_eff_rewList.appendItem(list.eff_rew_OTHER.nextValue); //9
    list.OTHER_eff_rewList.appendItem(list.eff_rew_OTHER.nextValue); //10
    list.OTHER_eff_rewList.appendItem(list.eff_rew_OTHER.nextValue); //11
    list.OTHER_eff_rewList.appendItem(list.eff_rew_OTHER.nextValue); //12
]
// trials = [1-parameters.num_trials = BoxClick_Trial]
/ trials = [1-24 = BoxClick_Trial] // ATTENTION: defining the number of trials manually....

</block>

<trial BoxClick_Trial>
/ onTrialBegin = [
  // pick random postion for effort_option
  values.effortX = list.x.nextValue;
  // pick position for rest_option
  values.restX = list.x.nextValue;
  // set trial type
  //values.trialType = list.trialType.nextValue;
    values.trialType = list.trialTypeList.nextValue;
  // set center label according to trial type
  if (values.trialType == "YOU") {
        values.c_colorname = red;
        //values.eff_rew = list.eff_rew_YOU.nextValue;
        values.eff_rew = list.YOU_eff_rewList.nextValue;
  } else { // OTHER
        values.c_colorname = blue;
        //values.eff_rew = list.eff_rew_OTHER.nextValue;
        values.eff_rew = list.OTHER_eff_rewList.nextValue;
  }    
    // set winnings and effort according to the value in eff_rew
    if (values.eff_rew == "e1_r1") {
        values.effortBoxes = values.easyThresh50;
        values.effortCredits = parameters.low_pay;
    } else if (values.eff_rew == "e1_r2") {
        values.effortBoxes = values.easyThresh50;
        values.effortCredits = parameters.medium_pay;
    } else if (values.eff_rew == "e1_r3") {
        values.effortBoxes = values.easyThresh50;
        values.effortCredits = parameters.high_pay;    
    } else if (values.eff_rew == "e2_r1") {
        values.effortBoxes = values.mediumThresh65;
        values.effortCredits = parameters.low_pay;    
    } else if (values.eff_rew == "e2_r2") {
        values.effortBoxes = values.mediumThresh65;
        values.effortCredits = parameters.medium_pay;
    } else if (values.eff_rew == "e2_r3") {
        values.effortBoxes = values.mediumThresh65;
        values.effortCredits = parameters.high_pay;
    } else if (values.eff_rew == "e3_r1") {
        values.effortBoxes = values.mediumThresh80;
        values.effortCredits = parameters.low_pay;
    } else if (values.eff_rew == "e3_r2") {
        values.effortBoxes = values.mediumThresh80;
        values.effortCredits = parameters.medium_pay;        
    } else if (values.eff_rew == "e3_r3") {
        values.effortBoxes = values.mediumThresh80;
        values.effortCredits = parameters.high_pay;
    } else if (values.eff_rew == "e4_r1") {
        values.effortBoxes = values.hardThresh95;
        values.effortCredits = parameters.low_pay;
    } else if (values.eff_rew == "e4_r2") {
        values.effortBoxes = values.hardThresh95;
        values.effortCredits = parameters.medium_pay;
    } else if (values.eff_rew == "e4_r3") {
        values.effortBoxes = values.hardThresh95;
        values.effortCredits = parameters.high_pay;
    }
]
/ stimulusframes = [1=effort_option, rest_option, center_label]
/ inputdevice = mouse
/ validresponse = (effort_option, rest_option)

/ branch = [
    if (trial.BoxClick_Trial.response=="effort_option") { // if subj chose the effortful option
        // run the clicking box survey
        return surveyPage.box_clicking;
    }
]
// update the rewards depending on the participant's choice and performance in the box clicking task
/ onTrialend = [
    if (trial.BoxClick_Trial.response=="effort_option") { // if subj chose the effortful option
        if (values.box_clicking_boxesChecked >= values.effortBoxes) { // succeeded in the box clicking task
            if (values.trialType == "YOU") { // add the reward to YOU_reward
                values.YOU_reward = values.YOU_reward + values.effortCredits;
            } else { // add the reward to OTHER_reward
                values.OTHER_reward = values.OTHER_reward + values.effortCredits;
            }
        }
    } else { // chose the rest option
        if (values.trialType == "YOU") {
            values.YOU_reward = values.YOU_reward + 1; // assuming that rest option's reward is 1
        } else {
            values.OTHER_reward = values.OTHER_reward + 1; // assuming that rest option's reward is 1
        }
    }
]
</trial>

// Stores the order of the 24 trial types -- YOU or OTHER
<list trialTypeList>
/ selectionMode = sequence
</list>

// Stores the order in which the effort/reward pairs will be presented in the 12 YOU trials
<list YOU_eff_rewList>
/ selectionMode = sequence
</list>

// Stores the order in which the effort/reward pairs will be presented in the 12 OTHER trials
<list OTHER_eff_rewList>
/ selectionMode = sequence
</list>

<text effort_option>
/ items = ("<%values.effortCredits%> credits for <%values.effortBoxes%> boxes")
/ hPosition = values.effortX
/ vPosition = 40%
/ fontStyle = ("arial", 12pt)
/ size = (15%, 10%)
/ vJustify = center
/ txBGColor = lightGray
</text>

<text rest_option>
/ items = ("1 credit for Rest")
/ hPosition = values.restX
/ vPosition = 40%
/ fontStyle = ("arial", 12pt)
/ size = (15%, 10%)
/ vJustify = center
/ txBGColor = lightGray
</text>

<text center_label>
/ items = ("<%values.trialType%>") // this is the label that should be used in the exp!
// items = ("<%values.eff_rew%>") // testing the list selection!
/ position = (50%, 30%)
/ txColor = values.c_colorname
/ fontStyle = ("arial", 16pt, true)
</text>

<list trialType>
/ items = ("YOU", "OTHER")
/ poolsize = parameters.num_trials
/ selectionmode = random
/ selectionrate = always
</list>

// This list contains all effort (4) x reward (3) = 12 combinations for the YOU trials
// It will be used to to sample --once-- all the 12 combinations
<list eff_rew_YOU>
/ items = ("e1_r1", "e1_r2", "e1_r3", "e2_r1", "e2_r2", "e2_r3", "e3_r1", "e3_r2", "e3_r3", "e4_r1", "e4_r2", "e4_r3")
/ poolsize = parameters.num_trials/2
/ replace = false
/ selectionmode = random
/ selectionrate = always
</list>

// Likewise for the OTHER trials
<list eff_rew_OTHER>
/ items = ("e1_r1", "e1_r2", "e1_r3", "e2_r1", "e2_r2", "e2_r3", "e3_r1", "e3_r2", "e3_r3", "e4_r1", "e4_r2", "e4_r3")
/ poolsize = parameters.num_trials/2
/ replace = false
/ selectionmode = random
/ selectionrate = always
</list>

<list x>
/ items = (35%, 65%)
/ selectionrate = always
</list>


You need to create a <data> element and define all the things you want logged in its /columns attribute.

This is all covered in the documentation.
https://www.millisecond.com/support/docs/v6/html/language/attributes/columns.htm

Thanks, Dave!

Adding the <data> element below accomplished what I wanted but I wonder how to add the stimulus-numbered columns  (e.g., stimulusNumber1, stimulusItem1, stimulusOnset1, etc.) as before?
Best wishes,

EN

--
<data>
/columns = (date, time, group, subject, session, build, blockNum, trialNum, blockCode, trialCode,
            pretrialPause, posttrialPause, response, correct, latency, values.box_clicking_boxesChecked,
            values.effortBoxes, values.effortCredits)
</data>

By Dave - 7/5/2025

EN - 7/5/2025
Dave - 7/5/2025
EN - 7/5/2025
Hello:

I wonder if there is a way to add user-defined variables to the raw data file, which logs data at every trial?

When running the code attached below, I get the following columns in the raw data file:

date    time    group    subject    session    build    blockNum    trialNum    blockCode    trialCode    pretrialPause    posttrialPause    response    correct    latency    stimulusNumber1    stimulusItem1    stimulusOnset1    stimulusNumber2    stimulusItem2    stimulusOnset2    stimulusNumber3    stimulusItem3    stimulusOnset3

I would like to add variables such as values.box_clicking_boxesChecked, values.effortBoxes and values.effortCredits.

If that is not possible, would love to hear on alternative ways to implement that, if at all possible.

Thank you in advance!
With very best wishes,

EN

--

// Global variables -- some of these variables should be re-defined in emot_induction.iqx

<values>
//Thresholds specified by the procedure defined in calibration_time_boxcount.iqx
/ easyThresh50 = 8 //The number of boxes at the 50% level
/ mediumThresh65 = 10 //The number of boxes at the 65% level
/ mediumThresh80 = 13 //The number of boxes at the 80% level
/ hardThresh95 = 15 //The number of boxes at the 95% level

// From here -- may have to be specified globally to be used in other places
// Total number of boxes clicked in box_clicking
/ box_clicking_boxesChecked = 0
/ YOU_reward = 0
/ OTHER_reward = 0

// From here -- specific to social_effort_box_click_task.iqx
//Color of trial type -- in fact, red (YOU) or blue (OTHER)
/ c_colorname = black
//Stores the selected combination of effort and reward -- e.g., e1_r1 means the lowest effort and the lowest reward
/ eff_rew = "e0_r0" // for filling purposes, this condition DOES NOT EXIST

// Position of the two choices
/ effortX = 0%
/ restX = 0%

// Trial type
/ trialType = null

// Strings to be displayed at every trial
/ centerLabel = null // will be either YOU or OTHER
/ effortCredits = 0
/ effortBoxes = 0

</values>

<parameters> //
//These are the rewards (fixed for all participants)
/ low_pay = 2 //Low reward
/ medium_pay = 6 //Medium reward
/ high_pay = 10 //High reward

/ num_trials = 24 // total number of trials
</parameters>

// data to be saved in summary file -- CONSIDER ADDING ITEMS in the future
<summarydata>
/columns = (script.startdate, script.starttime, script.subjectid, script.groupid,
            script.elapsedtime, computer.platform,values.YOU_reward, values.OTHER_reward)
</summarydata>


// These checkboxes will also be defined in emot_induction.iqx -- must comment them when transferring!
<checkboxes row1>
/ caption=" "
/ options=("1", "2", "3", "4", "5", "6", "7", "8", "9", "10")
/ optionvalues = ("1", "2", "3", "4","5", "6", "7", "8", "9", "10")
/ required = true
/ orientation = horizontalequal
</checkboxes>

<checkboxes row2>
/ caption=" "
/ options=("11", "12", "13", "14", "15", "16", "17", "18", "19", "20")
/ optionvalues = ("11", "12", "13", "14","15", "16", "17", "18", "19", "20")
/ required = true
/ orientation = horizontalequal
</checkboxes>

<checkboxes row3>
/ caption=" "
/ options=("21", "22", "23", "24", "25", "26", "27", "28", "29", "30")
/ optionvalues = ("21", "22", "23", "24","25", "26", "27", "28", "29", "30")
/ required = true
/ orientation = horizontalequal
</checkboxes>

<checkboxes row4>
/ caption=" "
/ options=("31", "32", "33", "34", "35", "36", "37", "38", "39", "40")
/ optionvalues = ("31", "32", "33", "34","35", "36", "37", "38", "39", "40")
/ required = true
/ orientation = horizontalequal
</checkboxes>

<checkboxes row5>
/ caption=" "
/ options=("41", "42", "43", "44", "45", "46", "47", "48", "49", "50")
/ optionvalues = ("41", "42", "43", "44","45", "46", "47", "48", "49", "50")
/ required = true
/ orientation = horizontalequal
</checkboxes>

<surveypage box_clicking>
/ onTrialEnd = [
  values.box_clicking_boxesChecked = checkboxes.row1.selectedCount + checkboxes.row2.selectedCount + checkboxes.row3.selectedCount + checkboxes.row4.selectedCount + checkboxes.row5.selectedCount;
]
/caption = "<font color='green'>You must click at least <b><u><%values.effortBoxes%></u></b> boxes"
/questions = [1-5=sequence(row1, row2, row3, row4, row5)]
/ itemfontstyle = ("Arial", 2.00%, false, false, false, false, 5, 1)
/ itemspacing = 0.0%
/ showpagenumbers = false
/ showbackbutton = false
/ showquestionnumbers = false
/ responsefontstyle = ("Arial", 2.0%, false, false, false, false, 5, 1)
/ timeout = 10000 // 10 seconds
/ showNextButton = false
</surveypage>

<block SocialEffort_Block>
/ onBlockBegin = [
    // Randomized trial type order -- 24 trials
    list.trialTypeList.appendItem(list.trialType.nextValue); //1
    list.trialTypeList.appendItem(list.trialType.nextValue); //2
    list.trialTypeList.appendItem(list.trialType.nextValue); //3
    list.trialTypeList.appendItem(list.trialType.nextValue); //4
    list.trialTypeList.appendItem(list.trialType.nextValue); //5
    list.trialTypeList.appendItem(list.trialType.nextValue); //6
    list.trialTypeList.appendItem(list.trialType.nextValue); //7
    list.trialTypeList.appendItem(list.trialType.nextValue); //8
    list.trialTypeList.appendItem(list.trialType.nextValue); //9
    list.trialTypeList.appendItem(list.trialType.nextValue); //10
    list.trialTypeList.appendItem(list.trialType.nextValue); //11
    list.trialTypeList.appendItem(list.trialType.nextValue); //12
    list.trialTypeList.appendItem(list.trialType.nextValue); //13
    list.trialTypeList.appendItem(list.trialType.nextValue); //14
    list.trialTypeList.appendItem(list.trialType.nextValue); //15
    list.trialTypeList.appendItem(list.trialType.nextValue); //16
    list.trialTypeList.appendItem(list.trialType.nextValue); //17
    list.trialTypeList.appendItem(list.trialType.nextValue); //18
    list.trialTypeList.appendItem(list.trialType.nextValue); //19
    list.trialTypeList.appendItem(list.trialType.nextValue); //20
    list.trialTypeList.appendItem(list.trialType.nextValue); //21
    list.trialTypeList.appendItem(list.trialType.nextValue); //22
    list.trialTypeList.appendItem(list.trialType.nextValue); //23
    list.trialTypeList.appendItem(list.trialType.nextValue); //24
    // Randomized YOU effort-reward 12 pairs
    list.YOU_eff_rewList.appendItem(list.eff_rew_YOU.nextValue); //1
    list.YOU_eff_rewList.appendItem(list.eff_rew_YOU.nextValue); //2
    list.YOU_eff_rewList.appendItem(list.eff_rew_YOU.nextValue); //3
    list.YOU_eff_rewList.appendItem(list.eff_rew_YOU.nextValue); //4
    list.YOU_eff_rewList.appendItem(list.eff_rew_YOU.nextValue); //5
    list.YOU_eff_rewList.appendItem(list.eff_rew_YOU.nextValue); //6
    list.YOU_eff_rewList.appendItem(list.eff_rew_YOU.nextValue); //7
    list.YOU_eff_rewList.appendItem(list.eff_rew_YOU.nextValue); //8
    list.YOU_eff_rewList.appendItem(list.eff_rew_YOU.nextValue); //9
    list.YOU_eff_rewList.appendItem(list.eff_rew_YOU.nextValue); //10
    list.YOU_eff_rewList.appendItem(list.eff_rew_YOU.nextValue); //11
    list.YOU_eff_rewList.appendItem(list.eff_rew_YOU.nextValue); //12    
    // Randomized OTHER effort-reward 12 pairs
    list.OTHER_eff_rewList.appendItem(list.eff_rew_OTHER.nextValue); //1
    list.OTHER_eff_rewList.appendItem(list.eff_rew_OTHER.nextValue); //2
    list.OTHER_eff_rewList.appendItem(list.eff_rew_OTHER.nextValue); //3
    list.OTHER_eff_rewList.appendItem(list.eff_rew_OTHER.nextValue); //4
    list.OTHER_eff_rewList.appendItem(list.eff_rew_OTHER.nextValue); //5
    list.OTHER_eff_rewList.appendItem(list.eff_rew_OTHER.nextValue); //6
    list.OTHER_eff_rewList.appendItem(list.eff_rew_OTHER.nextValue); //7
    list.OTHER_eff_rewList.appendItem(list.eff_rew_OTHER.nextValue); //8
    list.OTHER_eff_rewList.appendItem(list.eff_rew_OTHER.nextValue); //9
    list.OTHER_eff_rewList.appendItem(list.eff_rew_OTHER.nextValue); //10
    list.OTHER_eff_rewList.appendItem(list.eff_rew_OTHER.nextValue); //11
    list.OTHER_eff_rewList.appendItem(list.eff_rew_OTHER.nextValue); //12
]
// trials = [1-parameters.num_trials = BoxClick_Trial]
/ trials = [1-24 = BoxClick_Trial] // ATTENTION: defining the number of trials manually....

</block>

<trial BoxClick_Trial>
/ onTrialBegin = [
  // pick random postion for effort_option
  values.effortX = list.x.nextValue;
  // pick position for rest_option
  values.restX = list.x.nextValue;
  // set trial type
  //values.trialType = list.trialType.nextValue;
    values.trialType = list.trialTypeList.nextValue;
  // set center label according to trial type
  if (values.trialType == "YOU") {
        values.c_colorname = red;
        //values.eff_rew = list.eff_rew_YOU.nextValue;
        values.eff_rew = list.YOU_eff_rewList.nextValue;
  } else { // OTHER
        values.c_colorname = blue;
        //values.eff_rew = list.eff_rew_OTHER.nextValue;
        values.eff_rew = list.OTHER_eff_rewList.nextValue;
  }    
    // set winnings and effort according to the value in eff_rew
    if (values.eff_rew == "e1_r1") {
        values.effortBoxes = values.easyThresh50;
        values.effortCredits = parameters.low_pay;
    } else if (values.eff_rew == "e1_r2") {
        values.effortBoxes = values.easyThresh50;
        values.effortCredits = parameters.medium_pay;
    } else if (values.eff_rew == "e1_r3") {
        values.effortBoxes = values.easyThresh50;
        values.effortCredits = parameters.high_pay;    
    } else if (values.eff_rew == "e2_r1") {
        values.effortBoxes = values.mediumThresh65;
        values.effortCredits = parameters.low_pay;    
    } else if (values.eff_rew == "e2_r2") {
        values.effortBoxes = values.mediumThresh65;
        values.effortCredits = parameters.medium_pay;
    } else if (values.eff_rew == "e2_r3") {
        values.effortBoxes = values.mediumThresh65;
        values.effortCredits = parameters.high_pay;
    } else if (values.eff_rew == "e3_r1") {
        values.effortBoxes = values.mediumThresh80;
        values.effortCredits = parameters.low_pay;
    } else if (values.eff_rew == "e3_r2") {
        values.effortBoxes = values.mediumThresh80;
        values.effortCredits = parameters.medium_pay;        
    } else if (values.eff_rew == "e3_r3") {
        values.effortBoxes = values.mediumThresh80;
        values.effortCredits = parameters.high_pay;
    } else if (values.eff_rew == "e4_r1") {
        values.effortBoxes = values.hardThresh95;
        values.effortCredits = parameters.low_pay;
    } else if (values.eff_rew == "e4_r2") {
        values.effortBoxes = values.hardThresh95;
        values.effortCredits = parameters.medium_pay;
    } else if (values.eff_rew == "e4_r3") {
        values.effortBoxes = values.hardThresh95;
        values.effortCredits = parameters.high_pay;
    }
]
/ stimulusframes = [1=effort_option, rest_option, center_label]
/ inputdevice = mouse
/ validresponse = (effort_option, rest_option)

/ branch = [
    if (trial.BoxClick_Trial.response=="effort_option") { // if subj chose the effortful option
        // run the clicking box survey
        return surveyPage.box_clicking;
    }
]
// update the rewards depending on the participant's choice and performance in the box clicking task
/ onTrialend = [
    if (trial.BoxClick_Trial.response=="effort_option") { // if subj chose the effortful option
        if (values.box_clicking_boxesChecked >= values.effortBoxes) { // succeeded in the box clicking task
            if (values.trialType == "YOU") { // add the reward to YOU_reward
                values.YOU_reward = values.YOU_reward + values.effortCredits;
            } else { // add the reward to OTHER_reward
                values.OTHER_reward = values.OTHER_reward + values.effortCredits;
            }
        }
    } else { // chose the rest option
        if (values.trialType == "YOU") {
            values.YOU_reward = values.YOU_reward + 1; // assuming that rest option's reward is 1
        } else {
            values.OTHER_reward = values.OTHER_reward + 1; // assuming that rest option's reward is 1
        }
    }
]
</trial>

// Stores the order of the 24 trial types -- YOU or OTHER
<list trialTypeList>
/ selectionMode = sequence
</list>

// Stores the order in which the effort/reward pairs will be presented in the 12 YOU trials
<list YOU_eff_rewList>
/ selectionMode = sequence
</list>

// Stores the order in which the effort/reward pairs will be presented in the 12 OTHER trials
<list OTHER_eff_rewList>
/ selectionMode = sequence
</list>

<text effort_option>
/ items = ("<%values.effortCredits%> credits for <%values.effortBoxes%> boxes")
/ hPosition = values.effortX
/ vPosition = 40%
/ fontStyle = ("arial", 12pt)
/ size = (15%, 10%)
/ vJustify = center
/ txBGColor = lightGray
</text>

<text rest_option>
/ items = ("1 credit for Rest")
/ hPosition = values.restX
/ vPosition = 40%
/ fontStyle = ("arial", 12pt)
/ size = (15%, 10%)
/ vJustify = center
/ txBGColor = lightGray
</text>

<text center_label>
/ items = ("<%values.trialType%>") // this is the label that should be used in the exp!
// items = ("<%values.eff_rew%>") // testing the list selection!
/ position = (50%, 30%)
/ txColor = values.c_colorname
/ fontStyle = ("arial", 16pt, true)
</text>

<list trialType>
/ items = ("YOU", "OTHER")
/ poolsize = parameters.num_trials
/ selectionmode = random
/ selectionrate = always
</list>

// This list contains all effort (4) x reward (3) = 12 combinations for the YOU trials
// It will be used to to sample --once-- all the 12 combinations
<list eff_rew_YOU>
/ items = ("e1_r1", "e1_r2", "e1_r3", "e2_r1", "e2_r2", "e2_r3", "e3_r1", "e3_r2", "e3_r3", "e4_r1", "e4_r2", "e4_r3")
/ poolsize = parameters.num_trials/2
/ replace = false
/ selectionmode = random
/ selectionrate = always
</list>

// Likewise for the OTHER trials
<list eff_rew_OTHER>
/ items = ("e1_r1", "e1_r2", "e1_r3", "e2_r1", "e2_r2", "e2_r3", "e3_r1", "e3_r2", "e3_r3", "e4_r1", "e4_r2", "e4_r3")
/ poolsize = parameters.num_trials/2
/ replace = false
/ selectionmode = random
/ selectionrate = always
</list>

<list x>
/ items = (35%, 65%)
/ selectionrate = always
</list>


You need to create a <data> element and define all the things you want logged in its /columns attribute.

This is all covered in the documentation.
https://www.millisecond.com/support/docs/v6/html/language/attributes/columns.htm

Thanks, Dave!

Adding the <data> element below accomplished what I wanted but I wonder how to add the stimulus-numbered columns  (e.g., stimulusNumber1, stimulusItem1, stimulusOnset1, etc.) as before?
Best wishes,

EN

--
<data>
/columns = (date, time, group, subject, session, build, blockNum, trialNum, blockCode, trialCode,
            pretrialPause, posttrialPause, response, correct, latency, values.box_clicking_boxesChecked,
            values.effortBoxes, values.effortCredits)
</data>


That is explained in the Remarks section at the link.

By EN - 7/5/2025

EN - 7/5/2025
Dave - 7/5/2025
EN - 7/5/2025
Hello:

I wonder if there is a way to add user-defined variables to the raw data file, which logs data at every trial?

When running the code attached below, I get the following columns in the raw data file:

date    time    group    subject    session    build    blockNum    trialNum    blockCode    trialCode    pretrialPause    posttrialPause    response    correct    latency    stimulusNumber1    stimulusItem1    stimulusOnset1    stimulusNumber2    stimulusItem2    stimulusOnset2    stimulusNumber3    stimulusItem3    stimulusOnset3

I would like to add variables such as values.box_clicking_boxesChecked, values.effortBoxes and values.effortCredits.

If that is not possible, would love to hear on alternative ways to implement that, if at all possible.

Thank you in advance!
With very best wishes,

EN

--

// Global variables -- some of these variables should be re-defined in emot_induction.iqx

<values>
//Thresholds specified by the procedure defined in calibration_time_boxcount.iqx
/ easyThresh50 = 8 //The number of boxes at the 50% level
/ mediumThresh65 = 10 //The number of boxes at the 65% level
/ mediumThresh80 = 13 //The number of boxes at the 80% level
/ hardThresh95 = 15 //The number of boxes at the 95% level

// From here -- may have to be specified globally to be used in other places
// Total number of boxes clicked in box_clicking
/ box_clicking_boxesChecked = 0
/ YOU_reward = 0
/ OTHER_reward = 0

// From here -- specific to social_effort_box_click_task.iqx
//Color of trial type -- in fact, red (YOU) or blue (OTHER)
/ c_colorname = black
//Stores the selected combination of effort and reward -- e.g., e1_r1 means the lowest effort and the lowest reward
/ eff_rew = "e0_r0" // for filling purposes, this condition DOES NOT EXIST

// Position of the two choices
/ effortX = 0%
/ restX = 0%

// Trial type
/ trialType = null

// Strings to be displayed at every trial
/ centerLabel = null // will be either YOU or OTHER
/ effortCredits = 0
/ effortBoxes = 0

</values>

<parameters> //
//These are the rewards (fixed for all participants)
/ low_pay = 2 //Low reward
/ medium_pay = 6 //Medium reward
/ high_pay = 10 //High reward

/ num_trials = 24 // total number of trials
</parameters>

// data to be saved in summary file -- CONSIDER ADDING ITEMS in the future
<summarydata>
/columns = (script.startdate, script.starttime, script.subjectid, script.groupid,
            script.elapsedtime, computer.platform,values.YOU_reward, values.OTHER_reward)
</summarydata>


// These checkboxes will also be defined in emot_induction.iqx -- must comment them when transferring!
<checkboxes row1>
/ caption=" "
/ options=("1", "2", "3", "4", "5", "6", "7", "8", "9", "10")
/ optionvalues = ("1", "2", "3", "4","5", "6", "7", "8", "9", "10")
/ required = true
/ orientation = horizontalequal
</checkboxes>

<checkboxes row2>
/ caption=" "
/ options=("11", "12", "13", "14", "15", "16", "17", "18", "19", "20")
/ optionvalues = ("11", "12", "13", "14","15", "16", "17", "18", "19", "20")
/ required = true
/ orientation = horizontalequal
</checkboxes>

<checkboxes row3>
/ caption=" "
/ options=("21", "22", "23", "24", "25", "26", "27", "28", "29", "30")
/ optionvalues = ("21", "22", "23", "24","25", "26", "27", "28", "29", "30")
/ required = true
/ orientation = horizontalequal
</checkboxes>

<checkboxes row4>
/ caption=" "
/ options=("31", "32", "33", "34", "35", "36", "37", "38", "39", "40")
/ optionvalues = ("31", "32", "33", "34","35", "36", "37", "38", "39", "40")
/ required = true
/ orientation = horizontalequal
</checkboxes>

<checkboxes row5>
/ caption=" "
/ options=("41", "42", "43", "44", "45", "46", "47", "48", "49", "50")
/ optionvalues = ("41", "42", "43", "44","45", "46", "47", "48", "49", "50")
/ required = true
/ orientation = horizontalequal
</checkboxes>

<surveypage box_clicking>
/ onTrialEnd = [
  values.box_clicking_boxesChecked = checkboxes.row1.selectedCount + checkboxes.row2.selectedCount + checkboxes.row3.selectedCount + checkboxes.row4.selectedCount + checkboxes.row5.selectedCount;
]
/caption = "<font color='green'>You must click at least <b><u><%values.effortBoxes%></u></b> boxes"
/questions = [1-5=sequence(row1, row2, row3, row4, row5)]
/ itemfontstyle = ("Arial", 2.00%, false, false, false, false, 5, 1)
/ itemspacing = 0.0%
/ showpagenumbers = false
/ showbackbutton = false
/ showquestionnumbers = false
/ responsefontstyle = ("Arial", 2.0%, false, false, false, false, 5, 1)
/ timeout = 10000 // 10 seconds
/ showNextButton = false
</surveypage>

<block SocialEffort_Block>
/ onBlockBegin = [
    // Randomized trial type order -- 24 trials
    list.trialTypeList.appendItem(list.trialType.nextValue); //1
    list.trialTypeList.appendItem(list.trialType.nextValue); //2
    list.trialTypeList.appendItem(list.trialType.nextValue); //3
    list.trialTypeList.appendItem(list.trialType.nextValue); //4
    list.trialTypeList.appendItem(list.trialType.nextValue); //5
    list.trialTypeList.appendItem(list.trialType.nextValue); //6
    list.trialTypeList.appendItem(list.trialType.nextValue); //7
    list.trialTypeList.appendItem(list.trialType.nextValue); //8
    list.trialTypeList.appendItem(list.trialType.nextValue); //9
    list.trialTypeList.appendItem(list.trialType.nextValue); //10
    list.trialTypeList.appendItem(list.trialType.nextValue); //11
    list.trialTypeList.appendItem(list.trialType.nextValue); //12
    list.trialTypeList.appendItem(list.trialType.nextValue); //13
    list.trialTypeList.appendItem(list.trialType.nextValue); //14
    list.trialTypeList.appendItem(list.trialType.nextValue); //15
    list.trialTypeList.appendItem(list.trialType.nextValue); //16
    list.trialTypeList.appendItem(list.trialType.nextValue); //17
    list.trialTypeList.appendItem(list.trialType.nextValue); //18
    list.trialTypeList.appendItem(list.trialType.nextValue); //19
    list.trialTypeList.appendItem(list.trialType.nextValue); //20
    list.trialTypeList.appendItem(list.trialType.nextValue); //21
    list.trialTypeList.appendItem(list.trialType.nextValue); //22
    list.trialTypeList.appendItem(list.trialType.nextValue); //23
    list.trialTypeList.appendItem(list.trialType.nextValue); //24
    // Randomized YOU effort-reward 12 pairs
    list.YOU_eff_rewList.appendItem(list.eff_rew_YOU.nextValue); //1
    list.YOU_eff_rewList.appendItem(list.eff_rew_YOU.nextValue); //2
    list.YOU_eff_rewList.appendItem(list.eff_rew_YOU.nextValue); //3
    list.YOU_eff_rewList.appendItem(list.eff_rew_YOU.nextValue); //4
    list.YOU_eff_rewList.appendItem(list.eff_rew_YOU.nextValue); //5
    list.YOU_eff_rewList.appendItem(list.eff_rew_YOU.nextValue); //6
    list.YOU_eff_rewList.appendItem(list.eff_rew_YOU.nextValue); //7
    list.YOU_eff_rewList.appendItem(list.eff_rew_YOU.nextValue); //8
    list.YOU_eff_rewList.appendItem(list.eff_rew_YOU.nextValue); //9
    list.YOU_eff_rewList.appendItem(list.eff_rew_YOU.nextValue); //10
    list.YOU_eff_rewList.appendItem(list.eff_rew_YOU.nextValue); //11
    list.YOU_eff_rewList.appendItem(list.eff_rew_YOU.nextValue); //12    
    // Randomized OTHER effort-reward 12 pairs
    list.OTHER_eff_rewList.appendItem(list.eff_rew_OTHER.nextValue); //1
    list.OTHER_eff_rewList.appendItem(list.eff_rew_OTHER.nextValue); //2
    list.OTHER_eff_rewList.appendItem(list.eff_rew_OTHER.nextValue); //3
    list.OTHER_eff_rewList.appendItem(list.eff_rew_OTHER.nextValue); //4
    list.OTHER_eff_rewList.appendItem(list.eff_rew_OTHER.nextValue); //5
    list.OTHER_eff_rewList.appendItem(list.eff_rew_OTHER.nextValue); //6
    list.OTHER_eff_rewList.appendItem(list.eff_rew_OTHER.nextValue); //7
    list.OTHER_eff_rewList.appendItem(list.eff_rew_OTHER.nextValue); //8
    list.OTHER_eff_rewList.appendItem(list.eff_rew_OTHER.nextValue); //9
    list.OTHER_eff_rewList.appendItem(list.eff_rew_OTHER.nextValue); //10
    list.OTHER_eff_rewList.appendItem(list.eff_rew_OTHER.nextValue); //11
    list.OTHER_eff_rewList.appendItem(list.eff_rew_OTHER.nextValue); //12
]
// trials = [1-parameters.num_trials = BoxClick_Trial]
/ trials = [1-24 = BoxClick_Trial] // ATTENTION: defining the number of trials manually....

</block>

<trial BoxClick_Trial>
/ onTrialBegin = [
  // pick random postion for effort_option
  values.effortX = list.x.nextValue;
  // pick position for rest_option
  values.restX = list.x.nextValue;
  // set trial type
  //values.trialType = list.trialType.nextValue;
    values.trialType = list.trialTypeList.nextValue;
  // set center label according to trial type
  if (values.trialType == "YOU") {
        values.c_colorname = red;
        //values.eff_rew = list.eff_rew_YOU.nextValue;
        values.eff_rew = list.YOU_eff_rewList.nextValue;
  } else { // OTHER
        values.c_colorname = blue;
        //values.eff_rew = list.eff_rew_OTHER.nextValue;
        values.eff_rew = list.OTHER_eff_rewList.nextValue;
  }    
    // set winnings and effort according to the value in eff_rew
    if (values.eff_rew == "e1_r1") {
        values.effortBoxes = values.easyThresh50;
        values.effortCredits = parameters.low_pay;
    } else if (values.eff_rew == "e1_r2") {
        values.effortBoxes = values.easyThresh50;
        values.effortCredits = parameters.medium_pay;
    } else if (values.eff_rew == "e1_r3") {
        values.effortBoxes = values.easyThresh50;
        values.effortCredits = parameters.high_pay;    
    } else if (values.eff_rew == "e2_r1") {
        values.effortBoxes = values.mediumThresh65;
        values.effortCredits = parameters.low_pay;    
    } else if (values.eff_rew == "e2_r2") {
        values.effortBoxes = values.mediumThresh65;
        values.effortCredits = parameters.medium_pay;
    } else if (values.eff_rew == "e2_r3") {
        values.effortBoxes = values.mediumThresh65;
        values.effortCredits = parameters.high_pay;
    } else if (values.eff_rew == "e3_r1") {
        values.effortBoxes = values.mediumThresh80;
        values.effortCredits = parameters.low_pay;
    } else if (values.eff_rew == "e3_r2") {
        values.effortBoxes = values.mediumThresh80;
        values.effortCredits = parameters.medium_pay;        
    } else if (values.eff_rew == "e3_r3") {
        values.effortBoxes = values.mediumThresh80;
        values.effortCredits = parameters.high_pay;
    } else if (values.eff_rew == "e4_r1") {
        values.effortBoxes = values.hardThresh95;
        values.effortCredits = parameters.low_pay;
    } else if (values.eff_rew == "e4_r2") {
        values.effortBoxes = values.hardThresh95;
        values.effortCredits = parameters.medium_pay;
    } else if (values.eff_rew == "e4_r3") {
        values.effortBoxes = values.hardThresh95;
        values.effortCredits = parameters.high_pay;
    }
]
/ stimulusframes = [1=effort_option, rest_option, center_label]
/ inputdevice = mouse
/ validresponse = (effort_option, rest_option)

/ branch = [
    if (trial.BoxClick_Trial.response=="effort_option") { // if subj chose the effortful option
        // run the clicking box survey
        return surveyPage.box_clicking;
    }
]
// update the rewards depending on the participant's choice and performance in the box clicking task
/ onTrialend = [
    if (trial.BoxClick_Trial.response=="effort_option") { // if subj chose the effortful option
        if (values.box_clicking_boxesChecked >= values.effortBoxes) { // succeeded in the box clicking task
            if (values.trialType == "YOU") { // add the reward to YOU_reward
                values.YOU_reward = values.YOU_reward + values.effortCredits;
            } else { // add the reward to OTHER_reward
                values.OTHER_reward = values.OTHER_reward + values.effortCredits;
            }
        }
    } else { // chose the rest option
        if (values.trialType == "YOU") {
            values.YOU_reward = values.YOU_reward + 1; // assuming that rest option's reward is 1
        } else {
            values.OTHER_reward = values.OTHER_reward + 1; // assuming that rest option's reward is 1
        }
    }
]
</trial>

// Stores the order of the 24 trial types -- YOU or OTHER
<list trialTypeList>
/ selectionMode = sequence
</list>

// Stores the order in which the effort/reward pairs will be presented in the 12 YOU trials
<list YOU_eff_rewList>
/ selectionMode = sequence
</list>

// Stores the order in which the effort/reward pairs will be presented in the 12 OTHER trials
<list OTHER_eff_rewList>
/ selectionMode = sequence
</list>

<text effort_option>
/ items = ("<%values.effortCredits%> credits for <%values.effortBoxes%> boxes")
/ hPosition = values.effortX
/ vPosition = 40%
/ fontStyle = ("arial", 12pt)
/ size = (15%, 10%)
/ vJustify = center
/ txBGColor = lightGray
</text>

<text rest_option>
/ items = ("1 credit for Rest")
/ hPosition = values.restX
/ vPosition = 40%
/ fontStyle = ("arial", 12pt)
/ size = (15%, 10%)
/ vJustify = center
/ txBGColor = lightGray
</text>

<text center_label>
/ items = ("<%values.trialType%>") // this is the label that should be used in the exp!
// items = ("<%values.eff_rew%>") // testing the list selection!
/ position = (50%, 30%)
/ txColor = values.c_colorname
/ fontStyle = ("arial", 16pt, true)
</text>

<list trialType>
/ items = ("YOU", "OTHER")
/ poolsize = parameters.num_trials
/ selectionmode = random
/ selectionrate = always
</list>

// This list contains all effort (4) x reward (3) = 12 combinations for the YOU trials
// It will be used to to sample --once-- all the 12 combinations
<list eff_rew_YOU>
/ items = ("e1_r1", "e1_r2", "e1_r3", "e2_r1", "e2_r2", "e2_r3", "e3_r1", "e3_r2", "e3_r3", "e4_r1", "e4_r2", "e4_r3")
/ poolsize = parameters.num_trials/2
/ replace = false
/ selectionmode = random
/ selectionrate = always
</list>

// Likewise for the OTHER trials
<list eff_rew_OTHER>
/ items = ("e1_r1", "e1_r2", "e1_r3", "e2_r1", "e2_r2", "e2_r3", "e3_r1", "e3_r2", "e3_r3", "e4_r1", "e4_r2", "e4_r3")
/ poolsize = parameters.num_trials/2
/ replace = false
/ selectionmode = random
/ selectionrate = always
</list>

<list x>
/ items = (35%, 65%)
/ selectionrate = always
</list>


You need to create a <data> element and define all the things you want logged in its /columns attribute.

This is all covered in the documentation.
https://www.millisecond.com/support/docs/v6/html/language/attributes/columns.htm

Thanks, Dave!

Adding the <data> element below accomplished what I wanted but I wonder how to add the stimulus-numbered columns  (e.g., stimulusNumber1, stimulusItem1, stimulusOnset1, etc.) as before?
Best wishes,

EN

--
<data>
/columns = (date, time, group, subject, session, build, blockNum, trialNum, blockCode, trialCode,
            pretrialPause, posttrialPause, response, correct, latency, values.box_clicking_boxesChecked,
            values.effortBoxes, values.effortCredits)
</data>


Sorry! This does it:

<data>
/columns = (date, time, group, subject, session, build, blockNum, trialNum, blockCode, trialCode,
            pretrialPause, posttrialPause, response, correct, latency, stimulusitem, stimulusnumber, stimulusonset, stimulusitem, stimulusnumber, stimulusonset, stimulusitem, stimulusnumber, stimulusonset, values.box_clicking_boxesChecked,
            values.effortBoxes, values.effortCredits)
</data>