Matching up delay and immediate blocks?


Author
Message
sandy_d
sandy_d
Expert (1.3K reputation)Expert (1.3K reputation)Expert (1.3K reputation)Expert (1.3K reputation)Expert (1.3K reputation)Expert (1.3K reputation)Expert (1.3K reputation)Expert (1.3K reputation)Expert (1.3K reputation)
Group: Forum Members
Posts: 13, Visits: 58
Hello,

I'm trying to run a series of sequences within a delay block in the DDT Food and Money so that the left hand and right hand choice will have the same starting value at the right hand side at the beginning of each block time.  (ie: so the left hand side will display " 4 servings of grapes right now" and the right hand side will display "4 servings of grapes in 30 minutes").

My question is, how do I do it so that at the start of each of the delay blocks, the starting value of food is the same for the immediate (left) and for the delayed (right hand side).
Of the 3 possible food blocks I have, this is working correctly for the first two (which goes through the block of 4 servings of food followed with 7 time delays) .

My code so far is:

<data>
/ columns = (build, computer.platform, date,time,subject, group,
    values.blockcount,blocknum,blockcode,values.blocktype,values.order,
    values.trialcount,trialnum,trialcode,response,latency,
    values.delay,parameters.delayedreward_4, parameters.delayedreward_8, parameters.delayedreward_12,values.immediatereward,
    values.delayedresponsestreak,values.immediateresponsestreak,
    values.ip_desc,values.ip_asc,values.ip)
/ separatefiles = true
</data>


****************************
summary data file
****************************

<summarydata>
/ columns = (script.startdate, script.starttime, script.subjectid, script.groupid, script.elapsedtime, computer.platform, values.completed, parameters.delayedreward,
values.ip_delay1_F4, values.ip_delay2_F4, values.ip_delay3_F4, values.ip_delay4_F4, values.ip_delay5_F4, values.ip_delay6_F4, values.ip_delay7_F4,
values.ip_delay1_F8, values.ip_delay2_F8, values.ip_delay3_F8, values.ip_delay4_F8, values.ip_delay5_F8, values.ip_delay6_F8, values.ip_delay7_F8
values.ip_delay1_FF12, values.ip_delay2_F12, values.ip_delay3_F12, values.ip_delay4_F12, values.ip_delay5_F12, values.ip_delay6_F12, values.ip_delay7_F12)
/ separatefiles = true
</summarydata>


*****************************************************************************************************************
*****************************************************************************************************************
    Values: updated automatically on runtime of script
*****************************************************************************************************************
*****************************************************************************************************************
/ completed:                        0 = script was not completed; 1 = script was completed (all conditions run)
/ immediatereward:                    stores the current reward for the immediate response
/ order:                            stores direction of current reward adjustment ("ascending" or "descending")
/ delay:                            stores the current temporal delay
/ object:                            stores the object option of the block (1-4: selected food options)
/ foodchoice:                        stores the selected food option
/ ip_found:                            helper variable to determine indifference point (changes value if ip is found)
/ ip_asc:                            stores ip value for ascending blocks
/ ip_desc:                            stores ip value for descending blocks
/ ip:                                stores final ip value
/ blockcount:                        counts the blocks
/ trialcount:                        counts the trials
/ blocktype:                        stores the type of block "money" or "food"
/ previousresponse:                    stores the previous response
/ immediateresponsestreak:            counts the numbers of consecutive choices of immediate reward
/ delayedresponsestreak:            counts the numbers of consecutive choices of delayed reward

summary variables:
/ip_delay1_F4-
/ip_delay7_F12:                        the IPs for the 7 different delays for all food (F) blocks

<values>
/ completed = 0
/ immediatereward = 0.00
/ order = ""
/ delay = 0
/ object = 0
/ foodchoice = 0
/ ip_found = 0
/ ip_asc = 0.00
/ ip_desc = 0.00
/ ip = 0.00
/ blockcount = 0
/ trialcount = 0
/ blocktype = ""
/ previousresponse = ""
/ immediateresponsestreak = 0
/ delayedresponsestreak = 0

/ ip_delay1_F4 = 0
/ ip_delay2_F4 = 0
/ ip_delay3_F4 = 0
/ ip_delay4_F4 = 0
/ ip_delay5_F4 = 0
/ ip_delay6_F4 = 0
/ ip_delay7_F4 = 0


/ ip_delay1_F8 = 0
/ ip_delay2_F8 = 0
/ ip_delay3_F8 = 0
/ ip_delay4_F8 = 0
/ ip_delay5_F8 = 0
/ ip_delay6_F8 = 0
/ ip_delay7_F8 = 0


/ ip_delay1_F12 = 0
/ ip_delay2_F12 = 0
/ ip_delay3_F12 = 0
/ ip_delay4_F12 = 0
/ ip_delay5_F12 = 0
/ ip_delay6_F12 = 0
/ ip_delay7_F12 = 0
</values>

*****************************************************************************************************************
*****************************************************************************************************************
    Expressions
*****************************************************************************************************************
*****************************************************************************************************************
<expressions>
/ immediatereward = format("%.2f", values.immediatereward)
/ delayedreward_4 = format("%.2f", parameters.delayedreward_4)
/ immediatereward = format("%.2f", values.immediatereward)
/ delayedreward_8 = format("%.2f", parameters.delayedreward_8)
/ immediatereward = format("%.2f", values.immediatereward)
/ delayedreward_12 = format("%.2f", parameters.delayedreward_12)
/ ip_asc = format("%.2f", values.ip_asc)
/ ip_desc = format("%.2f", values.ip_desc)
/ ip = format("%.2f", values.ip)
/ objectdescription = getitem(item.objectdescriptions, values.object)
</expressions>

*****************************************************************************************************************
*****************************************************************************************************************
    List Elements
*****************************************************************************************************************
*****************************************************************************************************************
    Delay Periods (7)
*****************************************************************************************************************
*****************************************************************************************************************
<list delays>
/ items = (parameters.delay1, parameters.delay2, parameters.delay3, parameters.delay4, parameters.delay5, parameters.delay6, parameters.delay7) 
/ selectionmode = sequence
/ selectionrate = block
/ resetinterval = 0
</list>

*****************************************************************************************************************
*****************************************************************************************************************
    Immediate Rewards (9 -- Descending Order)
*****************************************************************************************************************
*****************************************************************************************************************
<list immediaterewards4_desc>
/ items = (4.0, 3.5, 3.0, 2.5, 2.0, 1.5, 1.0, 0.5, 0.0)
/ selectionmode = sequence
/ selectionmode = sequence
/ selectionrate = trial
</list>

<list immediaterewards8_desc>
/ items = (8.0, 7.0, 6.0, 5.0, 4.0, 3.0, 2.0, 1.0, 0.0)
/ selectionmode = sequence
/ selectionmode = sequence
/ selectionrate = trial
</list>

<list immediaterewards12_desc>
/ items = (12.0, 10.0, 8.0, 7.0, 6.0, 4.0, 2.0, 1.0, 0.0)
/ selectionmode = sequence
/ selectionmode = sequence
/ selectionrate = trial
</list>

*****************************************************************************************************************
*****************************************************************************************************************
    Immediate Rewards (9 -- Ascending Order)
*****************************************************************************************************************
*****************************************************************************************************************
<list immediaterewards4_asc>
/ items = (0.0, 0.5, 1.0, 1.5, 2.0, 2.5, 3.0, 3.5, 4.0)
/ selectionmode = sequence
/ selectionrate = trial
</list>

<list immediaterewards8_asc>
/ items = (0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0)
/ selectionmode = sequence
/ selectionrate = trial
</list>

<list immediaterewards12_asc>
/ items = (0.0, 1.0, 2.0, 4.0, 6.0, 7.0, 8.0, 10.0, 12.0)
/ selectionmode = sequence
/ selectionrate = trial
</list>


*****************************************************************************************************************
*****************************************************************************************************************
    Stimulus Elements
*****************************************************************************************************************
*****************************************************************************************************************
    For DDT Trial
*****************************************************************************************************************
*****************************************************************************************************************
<text question_4>
/ items = question_4
/ select = 1
/ erase = false
/ position = (50%, 50%)
</text>


<text or>
/ items = question_4
/ select = 3
/ erase = false
/ position = (50%, 65%)
</text>

<text immediate>
/ items = question_4
/ select = 2
/ txbgcolor = grey
/ vjustify = center
/ size = (20%, 20%)
/ position = (30%, 65%)
</text>

<text delayed_4>
/ items = question_4
/ select = 4
/ txbgcolor = grey
/ vjustify = center
/ size = (20%, 20%)
/ position = (70%, 65%)
</text>

<text question_8>
/ items = question_8
/ select = 1
/ erase = false
/ position = (50%, 50%)
</text>


<text delayed_8>
/ items = question_8
/ select = 4
/ txbgcolor = grey
/ vjustify = center
/ size = (20%, 20%)
/ position = (70%, 65%)
</text>

<text question_12>
/ items = question_12
/ select = 1
/ erase = false
/ position = (50%, 50%)
</text>

<text delayed_12>
/ items = question_12
/ select = 4
/ txbgcolor = grey
/ vjustify = center
/ size = (20%, 20%)
/ position = (70%, 65%)
</text>

<picture objectpic>
/ items = objectpicitems
/ select = values.object
/ position = (50%, 25%)
/ erase = false
</picture>


**************************************************************************************************************
**************************************************************************************************************
    Debug Stuff
**************************************************************************************************************
**************************************************************************************************************
<text debug>
/ items = ("Block = <%values.blockcount%> | Blocktype = <%values.blocktype%> | Order = <%values.order%> | IP_Desc = <%expressions.ip_desc%> | IP_Asc = <%expressions.ip_asc%> | IP = <%expressions.ip%>
Delayedstreak = <%values.delayedresponsestreak%> | Immediatestreak = <%values.immediateresponsestreak%>")
/ fontstyle = ("Arial", 2.00%)
/ erase = false
/ position = (50%, 5%)
/ size = (90%, 5%)
</text>

*****************************************************************************************************************
*****************************************************************************************************************
    For Food Pick Trial
*****************************************************************************************************************
*****************************************************************************************************************
<text foodcaption>
/ items = foodcaptions
/ select = 1
/ position = (50%, 10%)
</text>

<picture foodapic>
/ items = foodpics
/ select = 1
/ position = (30%, 30%)
</picture>

<picture foodbpic>
/ items = foodpics
/ select = 2
/ position = (70%, 30%)
</picture>

<picture foodcpic>
/ items = foodpics
/ select = 3
/ position = (30%, 70%)
</picture>

<picture fooddpic>
/ items = foodpics
/ select = 4
/ position = (70%, 70%)
</picture>

<text foodatxt>
/ items = foodcaptions
/ select = 2
/ position = (30%, 50%)
</text>

<text foodbtxt>
/ items = foodcaptions
/ select = 3
/ position = (70%, 50%)
</text>

<text foodctxt>
/ items = foodcaptions
/ select = 4
/ position = (30%, 90%)
</text>

<text fooddtxt>
/ items = foodcaptions
/ select = 5
/ position = (70%, 90%)
</text>
**************************************************************************************************************
**************************************************************************************************************
    Trial Elements
**************************************************************************************************************
**************************************************************************************************************
    DDT Choice Trial
**************************************************************************************************************
**************************************************************************************************************
<trial discounttrial4>
/ pretrialpause = parameters.pretrialdelay
/ posttrialpause = parameters.posttrialdelay
/ ontrialbegin = [values.trialcount+=1]
/ ontrialbegin = [if (values.trialcount==1)
        values.previousresponse="" else
        values.previousresponse=trial.discounttrial4.response]
/ ontrialbegin = [if (values.order=="descending")
        values.immediatereward=list.immediaterewards4_desc.nextvalue]
/ ontrialbegin = [if (values.order=="ascending")
        values.immediatereward=list.immediaterewards4_asc.nextvalue]

/ stimulusframes = [1=objectpic, question_4, or, immediate, delayed_4]
/ validresponse = (immediate, delayed_4)

/ ontrialend = [if (values.previousresponse=="immediate" && trial.discounttrial4.response=="immediate")
        values.immediateresponsestreak+=1 else
        values.immediateresponsestreak=0]
/ ontrialend = [if (values.previousresponse=="delayed" && trial.discounttrial4.response=="delayed")
        values.delayedresponsestreak+=1 else
        values.delayedresponsestreak=0]
/ ontrialend = [if (values.order=="descending" && values.ip_found==0 && values.delayedresponsestreak==1) {
        values.ip_desc=values.immediatereward; values.ip_found=1}]
/ ontrialend = [
    if (values.order=="ascending" && values.ip_found==0 && values.immediateresponsestreak==1) {
        values.ip_asc=values.immediatereward; values.ip_found=1}]

</trial>

<trial discounttrial8>
/ pretrialpause = parameters.pretrialdelay
/ posttrialpause = parameters.posttrialdelay
/ ontrialbegin = [values.trialcount+=1]
/ ontrialbegin = [if (values.trialcount==1)
        values.previousresponse="" else
        values.previousresponse=trial.discounttrial8.response]
/ ontrialbegin = [if (values.order=="descending")
        values.immediatereward=list.immediaterewards8_desc.nextvalue]
/ ontrialbegin = [if (values.order=="ascending")
        values.immediatereward=list.immediaterewards8_asc.nextvalue]

/ stimulusframes = [1=objectpic, question_8, or, immediate, delayed_8]
/ validresponse = (immediate, delayed_8)

/ ontrialend = [if (values.previousresponse=="immediate" && trial.discounttrial8.response=="immediate")
        values.immediateresponsestreak+=1 else
        values.immediateresponsestreak=0]
/ ontrialend = [if (values.previousresponse=="delayed" && trial.discounttrial8.response=="delayed")
        values.delayedresponsestreak+=1 else
        values.delayedresponsestreak=0]
/ ontrialend = [if (values.order=="descending" && values.ip_found==0 && values.delayedresponsestreak==1) {
        values.ip_desc=values.immediatereward; values.ip_found=1}]
/ ontrialend = [
    if (values.order=="ascending" && values.ip_found==0 && values.immediateresponsestreak==1) {
        values.ip_asc=values.immediatereward; values.ip_found=1}]

</trial>

<trial discounttrial12>
/ pretrialpause = parameters.pretrialdelay
/ posttrialpause = parameters.posttrialdelay
/ ontrialbegin = [values.trialcount+=1]
/ ontrialbegin = [if (values.trialcount==1)
        values.previousresponse="" else
        values.previousresponse=trial.discounttrial12.response]
/ ontrialbegin = [if (values.order=="descending")
        values.immediatereward=list.immediaterewards12_desc.nextvalue]
/ ontrialbegin = [if (values.order=="ascending")
        values.immediatereward=list.immediaterewards12_asc.nextvalue]

/ stimulusframes = [1=objectpic, question_12, or, immediate, delayed_12]
/ validresponse = (immediate, delayed_12)

/ ontrialend = [if (values.previousresponse=="immediate" && trial.discounttrial12.response=="immediate")
        values.immediateresponsestreak+=1 else
        values.immediateresponsestreak=0]
/ ontrialend = [if (values.previousresponse=="delayed" && trial.discounttrial12.response=="delayed")
        values.delayedresponsestreak+=1 else
        values.delayedresponsestreak=0]
/ ontrialend = [if (values.order=="descending" && values.ip_found==0 && values.delayedresponsestreak==1) {
        values.ip_desc=values.immediatereward; values.ip_found=1}]
/ ontrialend = [
    if (values.order=="ascending" && values.ip_found==0 && values.immediateresponsestreak==1) {
        values.ip_asc=values.immediatereward; values.ip_found=1}]

</trial>


**************************************************************************************************************
**************************************************************************************************************
    Compute Indifference Point
**************************************************************************************************************
**************************************************************************************************************
<trial compute_ip4>
/ ontrialbegin = [
    if (values.order=="descending" && values.ip_found==0)
        values.ip_desc=values.immediatereward
]
/ ontrialbegin = [
    if (values.order=="ascending" && values.ip_found==0)
        values.ip_asc=parameters.delayedreward_4
]
/ ontrialbegin = [
    if (values.ip_desc!=0.00 && values.ip_asc!=0.00)
        values.ip=(values.ip_desc+values.ip_asc)*0.5
]
   
/ ontrialbegin = [
    if (values.ip != 0 && values.blocktype == "food4" && values.delay == parameters.delay1) {
        values.ip_delay1_F4 = values.ip
    }
]
/ ontrialbegin = [
    if (values.ip != 0 && values.blocktype == "food4" && values.delay == parameters.delay2) {
        values.ip_delay2_F4 = values.ip
    }
]
/ ontrialbegin = [
    if (values.ip != 0 && values.blocktype == "food4" && values.delay == parameters.delay3) {
        values.ip_delay3_F4 = values.ip
    }
]
/ ontrialbegin = [
    if (values.ip != 0 && values.blocktype == "food4" && values.delay == parameters.delay4) {
        values.ip_delay4_F4 = values.ip
    }
]
/ ontrialbegin = [
    if (values.ip != 0 && values.blocktype == "food4" && values.delay == parameters.delay5) {
        values.ip_delay5_F4 = values.ip
    }
]
/ ontrialbegin = [
    if (values.ip != 0 && values.blocktype == "food4" && values.delay == parameters.delay6) {
        values.ip_delay6_F4 = values.ip
    }
]
/ ontrialbegin = [
    if (values.ip != 0 && values.blocktype == "food4" && values.delay == parameters.delay7) {
        values.ip_delay7_F4 = values.ip
    }
]



/ validresponse = (noresponse)
/ trialduration = 0
</trial>

<trial compute_ip8>
/ ontrialbegin = [
    if (values.order=="descending" && values.ip_found==0)
        values.ip_desc=values.immediatereward
]
/ ontrialbegin = [
    if (values.order=="ascending" && values.ip_found==0)
        values.ip_asc=parameters.delayedreward_8
]
/ ontrialbegin = [
    if (values.ip_desc!=0.00 && values.ip_asc!=0.00)
        values.ip=(values.ip_desc+values.ip_asc)*0.5
]
   
/ ontrialbegin = [
    if (values.ip != 0 && values.blocktype == "food8" && values.delay == parameters.delay1) {
        values.ip_delay1_F8 = values.ip
    }
]
/ ontrialbegin = [
    if (values.ip != 0 && values.blocktype == "food8" && values.delay == parameters.delay2) {
        values.ip_delay2_F8 = values.ip
    }
]
/ ontrialbegin = [
    if (values.ip != 0 && values.blocktype == "food8" && values.delay == parameters.delay3) {
        values.ip_delay3_F8 = values.ip
    }
]
/ ontrialbegin = [
    if (values.ip != 0 && values.blocktype == "food8" && values.delay == parameters.delay4) {
        values.ip_delay4_F8 = values.ip
    }
]
/ ontrialbegin = [
    if (values.ip != 0 && values.blocktype == "food8" && values.delay == parameters.delay5) {
        values.ip_delay5_F8 = values.ip
    }
]
/ ontrialbegin = [
    if (values.ip != 0 && values.blocktype == "food8" && values.delay == parameters.delay6) {
        values.ip_delay6_F8 = values.ip
    }
]
/ ontrialbegin = [
    if (values.ip != 0 && values.blocktype == "food8" && values.delay == parameters.delay7) {
        values.ip_delay7_F8 = values.ip
    }
]

/ validresponse = (noresponse)
/ trialduration = 0
</trial>       

<trial compute_ip12>
/ ontrialbegin = [
    if (values.order=="descending" && values.ip_found==0)
        values.ip_desc=values.immediatereward
]
/ ontrialbegin = [
    if (values.order=="ascending" && values.ip_found==0)
        values.ip_asc=parameters.delayedreward_12
]
/ ontrialbegin = [
    if (values.ip_desc!=0.00 && values.ip_asc!=0.00)
        values.ip=(values.ip_desc+values.ip_asc)*0.5
]
   
/ ontrialbegin = [
    if (values.ip != 0 && values.blocktype == "food12" && values.delay == parameters.delay1) {
        values.ip_delay1_F12 = values.ip
    }
]
/ ontrialbegin = [
    if (values.ip != 0 && values.blocktype == "food12" && values.delay == parameters.delay2) {
        values.ip_delay2_F12 = values.ip
    }
]
/ ontrialbegin = [
    if (values.ip != 0 && values.blocktype == "food12" && values.delay == parameters.delay3) {
        values.ip_delay3_F12 = values.ip
    }
]
/ ontrialbegin = [
    if (values.ip != 0 && values.blocktype == "food12" && values.delay == parameters.delay4) {
        values.ip_delay4_F12 = values.ip
    }
]
/ ontrialbegin = [
    if (values.ip != 0 && values.blocktype == "food12" && values.delay == parameters.delay5) {
        values.ip_delay5_F12 = values.ip
    }
]
/ ontrialbegin = [
    if (values.ip != 0 && values.blocktype == "food12" && values.delay == parameters.delay6) {
        values.ip_delay6_F12 = values.ip
    }
]
/ ontrialbegin = [
    if (values.ip != 0 && values.blocktype == "food12" && values.delay == parameters.delay7) {
        values.ip_delay7_F12 = values.ip
    }
]

/ validresponse = (noresponse)
/ trialduration = 0
</trial>
**************************************************************************************************************
**************************************************************************************************************
    Preferred Food Trial
**************************************************************************************************************
**************************************************************************************************************
<trial foodchoice>
/ stimulusframes = [1=foodcaption, foodapic, foodbpic, foodcpic, fooddpic, foodatxt, foodbtxt, foodctxt, fooddtxt]
/ validresponse = (foodapic, foodbpic, foodcpic, fooddpic)
/ ontrialend = [
    if (trial.foodchoice.response=="foodapic")
        values.foodchoice=1
]
/ ontrialend = [
    if (trial.foodchoice.response=="foodbpic")
        values.foodchoice=2
]
/ ontrialend = [
    if (trial.foodchoice.response=="foodcpic")
        values.foodchoice=3
]
/ ontrialend = [
    if (trial.foodchoice.response=="fooddpic")
        values.foodchoice=4
]
</trial>

**************************************************************************************************************
**************************************************************************************************************
    Block Elements
**************************************************************************************************************
**************************************************************************************************************
    Food Preference Block
**************************************************************************************************************
**************************************************************************************************************
<block foodchoice>
/ preinstructions = (foodintro)
/ postinstructions = (foodoutro)
/ trials = [1=foodchoice]
</block>

**************************************************************************************************************
**************************************************************************************************************
    DDT Blocks
**************************************************************************************************************
**************************************************************************************************************
    Food 4 Discounting (Descending)
**************************************************************************************************************
**************************************************************************************************************
<block food4_desc>
/ onblockbegin = [
    values.object=values.foodchoice;
    values.blocktype="food4";
    values.ip_found=0
]
/ onblockbegin = [
    values.immediateresponsestreak=0;
    values.delayedresponsestreak=0
]
/ onblockbegin = [values.previousresponse=""]
/ onblockbegin = [
    values.blockcount+=1;
    values.trialcount=0
]
/ onblockbegin = [
    values.order="descending";
    values.ip_desc=0.00;
    values.ip=0.00
]
/ onblockbegin = [
    if (mod(values.blockcount,4)==1 || mod(values.blockcount,4)==3)
        values.ip_asc=0.00
]
/ onblockbegin = [
    if (mod(values.blockcount,4)==1)
        values.delay=list.delays.nextvalue
]
/ trials = [1-9=discounttrial4; 10=compute_ip4]
</block>


**************************************************************************************************************
**************************************************************************************************************
    Food 4 Discounting (Ascending)
**************************************************************************************************************
**************************************************************************************************************
<block food4_asc>
/ onblockbegin = [
    values.object=values.foodchoice;
    values.blocktype="food4";
    values.ip_found=0
]
/ onblockbegin = [
    values.immediateresponsestreak=0;
    values.delayedresponsestreak=0
]
/ onblockbegin = [values.previousresponse=""]
/ onblockbegin = [
    values.blockcount+=1;
    values.trialcount=0
]
/ onblockbegin = [
    values.order="ascending";
    values.ip_asc=0.00;
    values.ip=0.00
]
/ onblockbegin = [
    if (mod(values.blockcount,4)==1 || mod(values.blockcount,4)==3)
        values.ip_desc=0.00
]
/ onblockbegin = [
    if (mod(values.blockcount,4)==1)
        values.delay=list.delays.nextvalue
]
/ trials = [1-9=discounttrial4; 10=compute_ip4]
</block>
**************************************************************************************************************
**************************************************************************************************************
    Food 8 Discounting (Descending)
**************************************************************************************************************
**************************************************************************************************************
<block food8_desc>
/ onblockbegin = [
    values.object=values.foodchoice;
    values.blocktype="food8";
    values.ip_found=0
]
/ onblockbegin = [
    values.immediateresponsestreak=0;
    values.delayedresponsestreak=0
]
/ onblockbegin = [values.previousresponse=""]
/ onblockbegin = [
    values.blockcount+=1;
    values.trialcount=0
]
/ onblockbegin = [
    values.order="descending";
    values.ip_desc=0.00;
    values.ip=0.00
]
/ onblockbegin = [
    if (mod(values.blockcount,4)==1 || mod(values.blockcount,4)==3)
        values.ip_asc=0.00
]
/ onblockbegin = [
    if (mod(values.blockcount,4)==1)
        values.delay=list.delays.nextvalue
]
/ trials = [1-9=discounttrial8; 10=compute_ip8]
</block>


**************************************************************************************************************
**************************************************************************************************************
    Food 8 Discounting (Ascending)
**************************************************************************************************************
**************************************************************************************************************
<block food8_asc>
/ onblockbegin = [
    values.object=values.foodchoice;
    values.blocktype="food8";
    values.ip_found=0
]
/ onblockbegin = [
    values.immediateresponsestreak=0;
    values.delayedresponsestreak=0
]
/ onblockbegin = [values.previousresponse=""]
/ onblockbegin = [
    values.blockcount+=1;
    values.trialcount=0
]
/ onblockbegin = [
    values.order="ascending";
    values.ip_asc=0.00;
    values.ip=0.00
]
/ onblockbegin = [
    if (mod(values.blockcount,4)==1 || mod(values.blockcount,4)==3)
        values.ip_desc=0.00
]
/ onblockbegin = [
    if (mod(values.blockcount,4)==1)
        values.delay=list.delays.nextvalue
]
/ trials = [1-9=discounttrial8; 10=compute_ip8]
</block>

**************************************************************************************************************
**************************************************************************************************************
    Food 12 Discounting (Descending)
**************************************************************************************************************
**************************************************************************************************************
<block food12_desc>
/ onblockbegin = [
    values.object=values.foodchoice;
    values.blocktype="food12";
    values.ip_found=0
]
/ onblockbegin = [
    values.immediateresponsestreak=0;
    values.delayedresponsestreak=0
]
/ onblockbegin = [values.previousresponse=""]
/ onblockbegin = [
    values.blockcount+=1;
    values.trialcount=0
]
/ onblockbegin = [
    values.order="descending";
    values.ip_asc=0.00;
    values.ip=0.00
]
/ onblockbegin = [
    if (mod(values.blockcount,4)==1 || mod(values.blockcount,4)==3)
        values.ip_asc=0.00
]
/ onblockbegin = [
    if (mod(values.blockcount,4)==1)
        values.delay=list.delays.nextvalue
]
/ trials = [1-9=discounttrial12; 10=compute_ip12]
</block>


**************************************************************************************************************
**************************************************************************************************************
    Food 12 Discounting (Ascending)
**************************************************************************************************************
**************************************************************************************************************
<block food12_asc>
/ onblockbegin = [
    values.object=values.foodchoice;
    values.blocktype="food12";
    values.ip_found=0
]
/ onblockbegin = [
    values.immediateresponsestreak=0;
    values.delayedresponsestreak=0
]
/ onblockbegin = [values.previousresponse=""]
/ onblockbegin = [
    values.blockcount+=1;
    values.trialcount=0
]
/ onblockbegin = [
    values.order="ascending";
    values.ip_asc=0.00;
    values.ip=0.00
]
/ onblockbegin = [
    if (mod(values.blockcount,4)==1 || mod(values.blockcount,4)==3)
        values.ip_desc=0.00
]
/ onblockbegin = [
    if (mod(values.blockcount,4)==1)
        values.delay=list.delays.nextvalue
]
/ trials = [1-9=discounttrial12; 10=compute_ip12]
</block>

**************************************************************************************************************
**************************************************************************************************************
    Expt Elements
**************************************************************************************************************
**************************************************************************************************************
    Order: Food4(Descending), Food4(Ascending), Food8(Descending), Food8(Ascending), Food12(Descending), Food12(Ascending)
**************************************************************************************************************
**************************************************************************************************************
<expt>
/ preinstructions = (generalintro)
/ postinstructions = (generaloutro)
/ blocks = [1=foodchoice; 2-7=sequence(food4_desc, food4_asc, food8_desc, food8_asc, food12_desc, food12_asc)]
/ subjects = (1 of 6)
/ groupassignment = groupnumber
/ onexptend = [values.completed = 1]
</expt>

**************************************************************************************************************
**************************************************************************************************************
    Order: Food8(Descending), Food8(Ascending), Food4(Descending), Food4(Ascending), Food12(Descending), Food12(Ascending)
**************************************************************************************************************
**************************************************************************************************************
<expt>
/ preinstructions = (generalintro)
/ postinstructions = (generaloutro)
/ blocks = [1=foodchoice; 2-7=sequence(food8_desc, food8_asc, food4_desc, food4_asc, food12_desc, food12_asc)]
/ subjects = (2 of 6)
/ groupassignment = groupnumber
/ onexptend = [values.completed = 1]
</expt>

**************************************************************************************************************
**************************************************************************************************************
    Order: Food8(Descending), Food8(Ascending), Food12(Descending), Food12(Ascending), Food4(Descending), Food4(Ascending)
**************************************************************************************************************
**************************************************************************************************************
<expt>
/ preinstructions = (generalintro)
/ postinstructions = (generaloutro)
/ blocks = [1=foodchoice; 2-7=sequence(food8_desc, food8_asc, food12_desc, food12_asc, food4_desc, food4_asc)]
/ subjects = (3 of 6)
/ groupassignment = groupnumber
/ onexptend = [values.completed = 1]
</expt>

**************************************************************************************************************
**************************************************************************************************************
    Order: Food12(Descending), Food12(Ascending), Food8(Descending), Food8(Ascending), Food4(Descending), Food4(Ascending)
**************************************************************************************************************
**************************************************************************************************************
<expt>
/ preinstructions = (generalintro)
/ postinstructions = (generaloutro)
/ blocks = [1=foodchoice; 2-7=sequence(food12_desc, food12_asc, food8_desc, food8_asc, food4_desc, food4_asc)]
/ subjects = (4 of 6)
/ groupassignment = groupnumber
/ onexptend = [values.completed = 1]
</expt>

**************************************************************************************************************
**************************************************************************************************************
    Order: Food12(Descending), Food12(Ascending), Food4(Descending), Food4(Ascending), Food8(Descending), Food8(Ascending)
**************************************************************************************************************
**************************************************************************************************************
<expt>
/ preinstructions = (generalintro)
/ postinstructions = (generaloutro)
/ blocks = [1=foodchoice; 2-7=sequence(food12_desc, food12_asc, food4_desc, food4_asc, food8_desc, food8_asc)]
/ subjects = (5 of 6)
/ groupassignment = groupnumber
/ onexptend = [values.completed = 1]
</expt>


**************************************************************************************************************
**************************************************************************************************************
    Order: Food4(Descending), Food4(Ascending), Food12(Descending), Food12(Ascending), Food8(Descending), Food8(Ascending)
**************************************************************************************************************
**************************************************************************************************************
<expt>
/ preinstructions = (generalintro)
/ postinstructions = (generaloutro)
/ blocks = [1=foodchoice; 2-7=sequence(food4_desc, food4_asc, food12_desc, food12_asc, food8_desc, food8_asc)]
/ subjects = (6 of 6)
/ groupassignment = groupnumber
/ onexptend = [values.completed = 1]
</expt>



Any insight is appreciated! Thanks.

Dave
Dave
Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)
Group: Administrators
Posts: 13K, Visits: 105K
sandy_d - Thursday, November 17, 2016
Hello,

I'm trying to run a series of sequences within a delay block in the DDT Food and Money so that the left hand and right hand choice will have the same starting value at the right hand side at the beginning of each block time.  (ie: so the left hand side will display " 4 servings of grapes right now" and the right hand side will display "4 servings of grapes in 30 minutes").

My question is, how do I do it so that at the start of each of the delay blocks, the starting value of food is the same for the immediate (left) and for the delayed (right hand side).
Of the 3 possible food blocks I have, this is working correctly for the first two (which goes through the block of 4 servings of food followed with 7 time delays) .

My code so far is:

<data>
/ columns = (build, computer.platform, date,time,subject, group,
    values.blockcount,blocknum,blockcode,values.blocktype,values.order,
    values.trialcount,trialnum,trialcode,response,latency,
    values.delay,parameters.delayedreward_4, parameters.delayedreward_8, parameters.delayedreward_12,values.immediatereward,
    values.delayedresponsestreak,values.immediateresponsestreak,
    values.ip_desc,values.ip_asc,values.ip)
/ separatefiles = true
</data>


****************************
summary data file
****************************

<summarydata>
/ columns = (script.startdate, script.starttime, script.subjectid, script.groupid, script.elapsedtime, computer.platform, values.completed, parameters.delayedreward,
values.ip_delay1_F4, values.ip_delay2_F4, values.ip_delay3_F4, values.ip_delay4_F4, values.ip_delay5_F4, values.ip_delay6_F4, values.ip_delay7_F4,
values.ip_delay1_F8, values.ip_delay2_F8, values.ip_delay3_F8, values.ip_delay4_F8, values.ip_delay5_F8, values.ip_delay6_F8, values.ip_delay7_F8
values.ip_delay1_FF12, values.ip_delay2_F12, values.ip_delay3_F12, values.ip_delay4_F12, values.ip_delay5_F12, values.ip_delay6_F12, values.ip_delay7_F12)
/ separatefiles = true
</summarydata>


*****************************************************************************************************************
*****************************************************************************************************************
    Values: updated automatically on runtime of script
*****************************************************************************************************************
*****************************************************************************************************************
/ completed:                        0 = script was not completed; 1 = script was completed (all conditions run)
/ immediatereward:                    stores the current reward for the immediate response
/ order:                            stores direction of current reward adjustment ("ascending" or "descending")
/ delay:                            stores the current temporal delay
/ object:                            stores the object option of the block (1-4: selected food options)
/ foodchoice:                        stores the selected food option
/ ip_found:                            helper variable to determine indifference point (changes value if ip is found)
/ ip_asc:                            stores ip value for ascending blocks
/ ip_desc:                            stores ip value for descending blocks
/ ip:                                stores final ip value
/ blockcount:                        counts the blocks
/ trialcount:                        counts the trials
/ blocktype:                        stores the type of block "money" or "food"
/ previousresponse:                    stores the previous response
/ immediateresponsestreak:            counts the numbers of consecutive choices of immediate reward
/ delayedresponsestreak:            counts the numbers of consecutive choices of delayed reward

summary variables:
/ip_delay1_F4-
/ip_delay7_F12:                        the IPs for the 7 different delays for all food (F) blocks

<values>
/ completed = 0
/ immediatereward = 0.00
/ order = ""
/ delay = 0
/ object = 0
/ foodchoice = 0
/ ip_found = 0
/ ip_asc = 0.00
/ ip_desc = 0.00
/ ip = 0.00
/ blockcount = 0
/ trialcount = 0
/ blocktype = ""
/ previousresponse = ""
/ immediateresponsestreak = 0
/ delayedresponsestreak = 0

/ ip_delay1_F4 = 0
/ ip_delay2_F4 = 0
/ ip_delay3_F4 = 0
/ ip_delay4_F4 = 0
/ ip_delay5_F4 = 0
/ ip_delay6_F4 = 0
/ ip_delay7_F4 = 0


/ ip_delay1_F8 = 0
/ ip_delay2_F8 = 0
/ ip_delay3_F8 = 0
/ ip_delay4_F8 = 0
/ ip_delay5_F8 = 0
/ ip_delay6_F8 = 0
/ ip_delay7_F8 = 0


/ ip_delay1_F12 = 0
/ ip_delay2_F12 = 0
/ ip_delay3_F12 = 0
/ ip_delay4_F12 = 0
/ ip_delay5_F12 = 0
/ ip_delay6_F12 = 0
/ ip_delay7_F12 = 0
</values>

*****************************************************************************************************************
*****************************************************************************************************************
    Expressions
*****************************************************************************************************************
*****************************************************************************************************************
<expressions>
/ immediatereward = format("%.2f", values.immediatereward)
/ delayedreward_4 = format("%.2f", parameters.delayedreward_4)
/ immediatereward = format("%.2f", values.immediatereward)
/ delayedreward_8 = format("%.2f", parameters.delayedreward_8)
/ immediatereward = format("%.2f", values.immediatereward)
/ delayedreward_12 = format("%.2f", parameters.delayedreward_12)
/ ip_asc = format("%.2f", values.ip_asc)
/ ip_desc = format("%.2f", values.ip_desc)
/ ip = format("%.2f", values.ip)
/ objectdescription = getitem(item.objectdescriptions, values.object)
</expressions>

*****************************************************************************************************************
*****************************************************************************************************************
    List Elements
*****************************************************************************************************************
*****************************************************************************************************************
    Delay Periods (7)
*****************************************************************************************************************
*****************************************************************************************************************
<list delays>
/ items = (parameters.delay1, parameters.delay2, parameters.delay3, parameters.delay4, parameters.delay5, parameters.delay6, parameters.delay7) 
/ selectionmode = sequence
/ selectionrate = block
/ resetinterval = 0
</list>

*****************************************************************************************************************
*****************************************************************************************************************
    Immediate Rewards (9 -- Descending Order)
*****************************************************************************************************************
*****************************************************************************************************************
<list immediaterewards4_desc>
/ items = (4.0, 3.5, 3.0, 2.5, 2.0, 1.5, 1.0, 0.5, 0.0)
/ selectionmode = sequence
/ selectionmode = sequence
/ selectionrate = trial
</list>

<list immediaterewards8_desc>
/ items = (8.0, 7.0, 6.0, 5.0, 4.0, 3.0, 2.0, 1.0, 0.0)
/ selectionmode = sequence
/ selectionmode = sequence
/ selectionrate = trial
</list>

<list immediaterewards12_desc>
/ items = (12.0, 10.0, 8.0, 7.0, 6.0, 4.0, 2.0, 1.0, 0.0)
/ selectionmode = sequence
/ selectionmode = sequence
/ selectionrate = trial
</list>

*****************************************************************************************************************
*****************************************************************************************************************
    Immediate Rewards (9 -- Ascending Order)
*****************************************************************************************************************
*****************************************************************************************************************
<list immediaterewards4_asc>
/ items = (0.0, 0.5, 1.0, 1.5, 2.0, 2.5, 3.0, 3.5, 4.0)
/ selectionmode = sequence
/ selectionrate = trial
</list>

<list immediaterewards8_asc>
/ items = (0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0)
/ selectionmode = sequence
/ selectionrate = trial
</list>

<list immediaterewards12_asc>
/ items = (0.0, 1.0, 2.0, 4.0, 6.0, 7.0, 8.0, 10.0, 12.0)
/ selectionmode = sequence
/ selectionrate = trial
</list>


*****************************************************************************************************************
*****************************************************************************************************************
    Stimulus Elements
*****************************************************************************************************************
*****************************************************************************************************************
    For DDT Trial
*****************************************************************************************************************
*****************************************************************************************************************
<text question_4>
/ items = question_4
/ select = 1
/ erase = false
/ position = (50%, 50%)
</text>


<text or>
/ items = question_4
/ select = 3
/ erase = false
/ position = (50%, 65%)
</text>

<text immediate>
/ items = question_4
/ select = 2
/ txbgcolor = grey
/ vjustify = center
/ size = (20%, 20%)
/ position = (30%, 65%)
</text>

<text delayed_4>
/ items = question_4
/ select = 4
/ txbgcolor = grey
/ vjustify = center
/ size = (20%, 20%)
/ position = (70%, 65%)
</text>

<text question_8>
/ items = question_8
/ select = 1
/ erase = false
/ position = (50%, 50%)
</text>


<text delayed_8>
/ items = question_8
/ select = 4
/ txbgcolor = grey
/ vjustify = center
/ size = (20%, 20%)
/ position = (70%, 65%)
</text>

<text question_12>
/ items = question_12
/ select = 1
/ erase = false
/ position = (50%, 50%)
</text>

<text delayed_12>
/ items = question_12
/ select = 4
/ txbgcolor = grey
/ vjustify = center
/ size = (20%, 20%)
/ position = (70%, 65%)
</text>

<picture objectpic>
/ items = objectpicitems
/ select = values.object
/ position = (50%, 25%)
/ erase = false
</picture>


**************************************************************************************************************
**************************************************************************************************************
    Debug Stuff
**************************************************************************************************************
**************************************************************************************************************
<text debug>
/ items = ("Block = <%values.blockcount%> | Blocktype = <%values.blocktype%> | Order = <%values.order%> | IP_Desc = <%expressions.ip_desc%> | IP_Asc = <%expressions.ip_asc%> | IP = <%expressions.ip%>
Delayedstreak = <%values.delayedresponsestreak%> | Immediatestreak = <%values.immediateresponsestreak%>")
/ fontstyle = ("Arial", 2.00%)
/ erase = false
/ position = (50%, 5%)
/ size = (90%, 5%)
</text>

*****************************************************************************************************************
*****************************************************************************************************************
    For Food Pick Trial
*****************************************************************************************************************
*****************************************************************************************************************
<text foodcaption>
/ items = foodcaptions
/ select = 1
/ position = (50%, 10%)
</text>

<picture foodapic>
/ items = foodpics
/ select = 1
/ position = (30%, 30%)
</picture>

<picture foodbpic>
/ items = foodpics
/ select = 2
/ position = (70%, 30%)
</picture>

<picture foodcpic>
/ items = foodpics
/ select = 3
/ position = (30%, 70%)
</picture>

<picture fooddpic>
/ items = foodpics
/ select = 4
/ position = (70%, 70%)
</picture>

<text foodatxt>
/ items = foodcaptions
/ select = 2
/ position = (30%, 50%)
</text>

<text foodbtxt>
/ items = foodcaptions
/ select = 3
/ position = (70%, 50%)
</text>

<text foodctxt>
/ items = foodcaptions
/ select = 4
/ position = (30%, 90%)
</text>

<text fooddtxt>
/ items = foodcaptions
/ select = 5
/ position = (70%, 90%)
</text>
**************************************************************************************************************
**************************************************************************************************************
    Trial Elements
**************************************************************************************************************
**************************************************************************************************************
    DDT Choice Trial
**************************************************************************************************************
**************************************************************************************************************
<trial discounttrial4>
/ pretrialpause = parameters.pretrialdelay
/ posttrialpause = parameters.posttrialdelay
/ ontrialbegin = [values.trialcount+=1]
/ ontrialbegin = [if (values.trialcount==1)
        values.previousresponse="" else
        values.previousresponse=trial.discounttrial4.response]
/ ontrialbegin = [if (values.order=="descending")
        values.immediatereward=list.immediaterewards4_desc.nextvalue]
/ ontrialbegin = [if (values.order=="ascending")
        values.immediatereward=list.immediaterewards4_asc.nextvalue]

/ stimulusframes = [1=objectpic, question_4, or, immediate, delayed_4]
/ validresponse = (immediate, delayed_4)

/ ontrialend = [if (values.previousresponse=="immediate" && trial.discounttrial4.response=="immediate")
        values.immediateresponsestreak+=1 else
        values.immediateresponsestreak=0]
/ ontrialend = [if (values.previousresponse=="delayed" && trial.discounttrial4.response=="delayed")
        values.delayedresponsestreak+=1 else
        values.delayedresponsestreak=0]
/ ontrialend = [if (values.order=="descending" && values.ip_found==0 && values.delayedresponsestreak==1) {
        values.ip_desc=values.immediatereward; values.ip_found=1}]
/ ontrialend = [
    if (values.order=="ascending" && values.ip_found==0 && values.immediateresponsestreak==1) {
        values.ip_asc=values.immediatereward; values.ip_found=1}]

</trial>

<trial discounttrial8>
/ pretrialpause = parameters.pretrialdelay
/ posttrialpause = parameters.posttrialdelay
/ ontrialbegin = [values.trialcount+=1]
/ ontrialbegin = [if (values.trialcount==1)
        values.previousresponse="" else
        values.previousresponse=trial.discounttrial8.response]
/ ontrialbegin = [if (values.order=="descending")
        values.immediatereward=list.immediaterewards8_desc.nextvalue]
/ ontrialbegin = [if (values.order=="ascending")
        values.immediatereward=list.immediaterewards8_asc.nextvalue]

/ stimulusframes = [1=objectpic, question_8, or, immediate, delayed_8]
/ validresponse = (immediate, delayed_8)

/ ontrialend = [if (values.previousresponse=="immediate" && trial.discounttrial8.response=="immediate")
        values.immediateresponsestreak+=1 else
        values.immediateresponsestreak=0]
/ ontrialend = [if (values.previousresponse=="delayed" && trial.discounttrial8.response=="delayed")
        values.delayedresponsestreak+=1 else
        values.delayedresponsestreak=0]
/ ontrialend = [if (values.order=="descending" && values.ip_found==0 && values.delayedresponsestreak==1) {
        values.ip_desc=values.immediatereward; values.ip_found=1}]
/ ontrialend = [
    if (values.order=="ascending" && values.ip_found==0 && values.immediateresponsestreak==1) {
        values.ip_asc=values.immediatereward; values.ip_found=1}]

</trial>

<trial discounttrial12>
/ pretrialpause = parameters.pretrialdelay
/ posttrialpause = parameters.posttrialdelay
/ ontrialbegin = [values.trialcount+=1]
/ ontrialbegin = [if (values.trialcount==1)
        values.previousresponse="" else
        values.previousresponse=trial.discounttrial12.response]
/ ontrialbegin = [if (values.order=="descending")
        values.immediatereward=list.immediaterewards12_desc.nextvalue]
/ ontrialbegin = [if (values.order=="ascending")
        values.immediatereward=list.immediaterewards12_asc.nextvalue]

/ stimulusframes = [1=objectpic, question_12, or, immediate, delayed_12]
/ validresponse = (immediate, delayed_12)

/ ontrialend = [if (values.previousresponse=="immediate" && trial.discounttrial12.response=="immediate")
        values.immediateresponsestreak+=1 else
        values.immediateresponsestreak=0]
/ ontrialend = [if (values.previousresponse=="delayed" && trial.discounttrial12.response=="delayed")
        values.delayedresponsestreak+=1 else
        values.delayedresponsestreak=0]
/ ontrialend = [if (values.order=="descending" && values.ip_found==0 && values.delayedresponsestreak==1) {
        values.ip_desc=values.immediatereward; values.ip_found=1}]
/ ontrialend = [
    if (values.order=="ascending" && values.ip_found==0 && values.immediateresponsestreak==1) {
        values.ip_asc=values.immediatereward; values.ip_found=1}]

</trial>


**************************************************************************************************************
**************************************************************************************************************
    Compute Indifference Point
**************************************************************************************************************
**************************************************************************************************************
<trial compute_ip4>
/ ontrialbegin = [
    if (values.order=="descending" && values.ip_found==0)
        values.ip_desc=values.immediatereward
]
/ ontrialbegin = [
    if (values.order=="ascending" && values.ip_found==0)
        values.ip_asc=parameters.delayedreward_4
]
/ ontrialbegin = [
    if (values.ip_desc!=0.00 && values.ip_asc!=0.00)
        values.ip=(values.ip_desc+values.ip_asc)*0.5
]
   
/ ontrialbegin = [
    if (values.ip != 0 && values.blocktype == "food4" && values.delay == parameters.delay1) {
        values.ip_delay1_F4 = values.ip
    }
]
/ ontrialbegin = [
    if (values.ip != 0 && values.blocktype == "food4" && values.delay == parameters.delay2) {
        values.ip_delay2_F4 = values.ip
    }
]
/ ontrialbegin = [
    if (values.ip != 0 && values.blocktype == "food4" && values.delay == parameters.delay3) {
        values.ip_delay3_F4 = values.ip
    }
]
/ ontrialbegin = [
    if (values.ip != 0 && values.blocktype == "food4" && values.delay == parameters.delay4) {
        values.ip_delay4_F4 = values.ip
    }
]
/ ontrialbegin = [
    if (values.ip != 0 && values.blocktype == "food4" && values.delay == parameters.delay5) {
        values.ip_delay5_F4 = values.ip
    }
]
/ ontrialbegin = [
    if (values.ip != 0 && values.blocktype == "food4" && values.delay == parameters.delay6) {
        values.ip_delay6_F4 = values.ip
    }
]
/ ontrialbegin = [
    if (values.ip != 0 && values.blocktype == "food4" && values.delay == parameters.delay7) {
        values.ip_delay7_F4 = values.ip
    }
]



/ validresponse = (noresponse)
/ trialduration = 0
</trial>

<trial compute_ip8>
/ ontrialbegin = [
    if (values.order=="descending" && values.ip_found==0)
        values.ip_desc=values.immediatereward
]
/ ontrialbegin = [
    if (values.order=="ascending" && values.ip_found==0)
        values.ip_asc=parameters.delayedreward_8
]
/ ontrialbegin = [
    if (values.ip_desc!=0.00 && values.ip_asc!=0.00)
        values.ip=(values.ip_desc+values.ip_asc)*0.5
]
   
/ ontrialbegin = [
    if (values.ip != 0 && values.blocktype == "food8" && values.delay == parameters.delay1) {
        values.ip_delay1_F8 = values.ip
    }
]
/ ontrialbegin = [
    if (values.ip != 0 && values.blocktype == "food8" && values.delay == parameters.delay2) {
        values.ip_delay2_F8 = values.ip
    }
]
/ ontrialbegin = [
    if (values.ip != 0 && values.blocktype == "food8" && values.delay == parameters.delay3) {
        values.ip_delay3_F8 = values.ip
    }
]
/ ontrialbegin = [
    if (values.ip != 0 && values.blocktype == "food8" && values.delay == parameters.delay4) {
        values.ip_delay4_F8 = values.ip
    }
]
/ ontrialbegin = [
    if (values.ip != 0 && values.blocktype == "food8" && values.delay == parameters.delay5) {
        values.ip_delay5_F8 = values.ip
    }
]
/ ontrialbegin = [
    if (values.ip != 0 && values.blocktype == "food8" && values.delay == parameters.delay6) {
        values.ip_delay6_F8 = values.ip
    }
]
/ ontrialbegin = [
    if (values.ip != 0 && values.blocktype == "food8" && values.delay == parameters.delay7) {
        values.ip_delay7_F8 = values.ip
    }
]

/ validresponse = (noresponse)
/ trialduration = 0
</trial>       

<trial compute_ip12>
/ ontrialbegin = [
    if (values.order=="descending" && values.ip_found==0)
        values.ip_desc=values.immediatereward
]
/ ontrialbegin = [
    if (values.order=="ascending" && values.ip_found==0)
        values.ip_asc=parameters.delayedreward_12
]
/ ontrialbegin = [
    if (values.ip_desc!=0.00 && values.ip_asc!=0.00)
        values.ip=(values.ip_desc+values.ip_asc)*0.5
]
   
/ ontrialbegin = [
    if (values.ip != 0 && values.blocktype == "food12" && values.delay == parameters.delay1) {
        values.ip_delay1_F12 = values.ip
    }
]
/ ontrialbegin = [
    if (values.ip != 0 && values.blocktype == "food12" && values.delay == parameters.delay2) {
        values.ip_delay2_F12 = values.ip
    }
]
/ ontrialbegin = [
    if (values.ip != 0 && values.blocktype == "food12" && values.delay == parameters.delay3) {
        values.ip_delay3_F12 = values.ip
    }
]
/ ontrialbegin = [
    if (values.ip != 0 && values.blocktype == "food12" && values.delay == parameters.delay4) {
        values.ip_delay4_F12 = values.ip
    }
]
/ ontrialbegin = [
    if (values.ip != 0 && values.blocktype == "food12" && values.delay == parameters.delay5) {
        values.ip_delay5_F12 = values.ip
    }
]
/ ontrialbegin = [
    if (values.ip != 0 && values.blocktype == "food12" && values.delay == parameters.delay6) {
        values.ip_delay6_F12 = values.ip
    }
]
/ ontrialbegin = [
    if (values.ip != 0 && values.blocktype == "food12" && values.delay == parameters.delay7) {
        values.ip_delay7_F12 = values.ip
    }
]

/ validresponse = (noresponse)
/ trialduration = 0
</trial>
**************************************************************************************************************
**************************************************************************************************************
    Preferred Food Trial
**************************************************************************************************************
**************************************************************************************************************
<trial foodchoice>
/ stimulusframes = [1=foodcaption, foodapic, foodbpic, foodcpic, fooddpic, foodatxt, foodbtxt, foodctxt, fooddtxt]
/ validresponse = (foodapic, foodbpic, foodcpic, fooddpic)
/ ontrialend = [
    if (trial.foodchoice.response=="foodapic")
        values.foodchoice=1
]
/ ontrialend = [
    if (trial.foodchoice.response=="foodbpic")
        values.foodchoice=2
]
/ ontrialend = [
    if (trial.foodchoice.response=="foodcpic")
        values.foodchoice=3
]
/ ontrialend = [
    if (trial.foodchoice.response=="fooddpic")
        values.foodchoice=4
]
</trial>

**************************************************************************************************************
**************************************************************************************************************
    Block Elements
**************************************************************************************************************
**************************************************************************************************************
    Food Preference Block
**************************************************************************************************************
**************************************************************************************************************
<block foodchoice>
/ preinstructions = (foodintro)
/ postinstructions = (foodoutro)
/ trials = [1=foodchoice]
</block>

**************************************************************************************************************
**************************************************************************************************************
    DDT Blocks
**************************************************************************************************************
**************************************************************************************************************
    Food 4 Discounting (Descending)
**************************************************************************************************************
**************************************************************************************************************
<block food4_desc>
/ onblockbegin = [
    values.object=values.foodchoice;
    values.blocktype="food4";
    values.ip_found=0
]
/ onblockbegin = [
    values.immediateresponsestreak=0;
    values.delayedresponsestreak=0
]
/ onblockbegin = [values.previousresponse=""]
/ onblockbegin = [
    values.blockcount+=1;
    values.trialcount=0
]
/ onblockbegin = [
    values.order="descending";
    values.ip_desc=0.00;
    values.ip=0.00
]
/ onblockbegin = [
    if (mod(values.blockcount,4)==1 || mod(values.blockcount,4)==3)
        values.ip_asc=0.00
]
/ onblockbegin = [
    if (mod(values.blockcount,4)==1)
        values.delay=list.delays.nextvalue
]
/ trials = [1-9=discounttrial4; 10=compute_ip4]
</block>


**************************************************************************************************************
**************************************************************************************************************
    Food 4 Discounting (Ascending)
**************************************************************************************************************
**************************************************************************************************************
<block food4_asc>
/ onblockbegin = [
    values.object=values.foodchoice;
    values.blocktype="food4";
    values.ip_found=0
]
/ onblockbegin = [
    values.immediateresponsestreak=0;
    values.delayedresponsestreak=0
]
/ onblockbegin = [values.previousresponse=""]
/ onblockbegin = [
    values.blockcount+=1;
    values.trialcount=0
]
/ onblockbegin = [
    values.order="ascending";
    values.ip_asc=0.00;
    values.ip=0.00
]
/ onblockbegin = [
    if (mod(values.blockcount,4)==1 || mod(values.blockcount,4)==3)
        values.ip_desc=0.00
]
/ onblockbegin = [
    if (mod(values.blockcount,4)==1)
        values.delay=list.delays.nextvalue
]
/ trials = [1-9=discounttrial4; 10=compute_ip4]
</block>
**************************************************************************************************************
**************************************************************************************************************
    Food 8 Discounting (Descending)
**************************************************************************************************************
**************************************************************************************************************
<block food8_desc>
/ onblockbegin = [
    values.object=values.foodchoice;
    values.blocktype="food8";
    values.ip_found=0
]
/ onblockbegin = [
    values.immediateresponsestreak=0;
    values.delayedresponsestreak=0
]
/ onblockbegin = [values.previousresponse=""]
/ onblockbegin = [
    values.blockcount+=1;
    values.trialcount=0
]
/ onblockbegin = [
    values.order="descending";
    values.ip_desc=0.00;
    values.ip=0.00
]
/ onblockbegin = [
    if (mod(values.blockcount,4)==1 || mod(values.blockcount,4)==3)
        values.ip_asc=0.00
]
/ onblockbegin = [
    if (mod(values.blockcount,4)==1)
        values.delay=list.delays.nextvalue
]
/ trials = [1-9=discounttrial8; 10=compute_ip8]
</block>


**************************************************************************************************************
**************************************************************************************************************
    Food 8 Discounting (Ascending)
**************************************************************************************************************
**************************************************************************************************************
<block food8_asc>
/ onblockbegin = [
    values.object=values.foodchoice;
    values.blocktype="food8";
    values.ip_found=0
]
/ onblockbegin = [
    values.immediateresponsestreak=0;
    values.delayedresponsestreak=0
]
/ onblockbegin = [values.previousresponse=""]
/ onblockbegin = [
    values.blockcount+=1;
    values.trialcount=0
]
/ onblockbegin = [
    values.order="ascending";
    values.ip_asc=0.00;
    values.ip=0.00
]
/ onblockbegin = [
    if (mod(values.blockcount,4)==1 || mod(values.blockcount,4)==3)
        values.ip_desc=0.00
]
/ onblockbegin = [
    if (mod(values.blockcount,4)==1)
        values.delay=list.delays.nextvalue
]
/ trials = [1-9=discounttrial8; 10=compute_ip8]
</block>

**************************************************************************************************************
**************************************************************************************************************
    Food 12 Discounting (Descending)
**************************************************************************************************************
**************************************************************************************************************
<block food12_desc>
/ onblockbegin = [
    values.object=values.foodchoice;
    values.blocktype="food12";
    values.ip_found=0
]
/ onblockbegin = [
    values.immediateresponsestreak=0;
    values.delayedresponsestreak=0
]
/ onblockbegin = [values.previousresponse=""]
/ onblockbegin = [
    values.blockcount+=1;
    values.trialcount=0
]
/ onblockbegin = [
    values.order="descending";
    values.ip_asc=0.00;
    values.ip=0.00
]
/ onblockbegin = [
    if (mod(values.blockcount,4)==1 || mod(values.blockcount,4)==3)
        values.ip_asc=0.00
]
/ onblockbegin = [
    if (mod(values.blockcount,4)==1)
        values.delay=list.delays.nextvalue
]
/ trials = [1-9=discounttrial12; 10=compute_ip12]
</block>


**************************************************************************************************************
**************************************************************************************************************
    Food 12 Discounting (Ascending)
**************************************************************************************************************
**************************************************************************************************************
<block food12_asc>
/ onblockbegin = [
    values.object=values.foodchoice;
    values.blocktype="food12";
    values.ip_found=0
]
/ onblockbegin = [
    values.immediateresponsestreak=0;
    values.delayedresponsestreak=0
]
/ onblockbegin = [values.previousresponse=""]
/ onblockbegin = [
    values.blockcount+=1;
    values.trialcount=0
]
/ onblockbegin = [
    values.order="ascending";
    values.ip_asc=0.00;
    values.ip=0.00
]
/ onblockbegin = [
    if (mod(values.blockcount,4)==1 || mod(values.blockcount,4)==3)
        values.ip_desc=0.00
]
/ onblockbegin = [
    if (mod(values.blockcount,4)==1)
        values.delay=list.delays.nextvalue
]
/ trials = [1-9=discounttrial12; 10=compute_ip12]
</block>

**************************************************************************************************************
**************************************************************************************************************
    Expt Elements
**************************************************************************************************************
**************************************************************************************************************
    Order: Food4(Descending), Food4(Ascending), Food8(Descending), Food8(Ascending), Food12(Descending), Food12(Ascending)
**************************************************************************************************************
**************************************************************************************************************
<expt>
/ preinstructions = (generalintro)
/ postinstructions = (generaloutro)
/ blocks = [1=foodchoice; 2-7=sequence(food4_desc, food4_asc, food8_desc, food8_asc, food12_desc, food12_asc)]
/ subjects = (1 of 6)
/ groupassignment = groupnumber
/ onexptend = [values.completed = 1]
</expt>

**************************************************************************************************************
**************************************************************************************************************
    Order: Food8(Descending), Food8(Ascending), Food4(Descending), Food4(Ascending), Food12(Descending), Food12(Ascending)
**************************************************************************************************************
**************************************************************************************************************
<expt>
/ preinstructions = (generalintro)
/ postinstructions = (generaloutro)
/ blocks = [1=foodchoice; 2-7=sequence(food8_desc, food8_asc, food4_desc, food4_asc, food12_desc, food12_asc)]
/ subjects = (2 of 6)
/ groupassignment = groupnumber
/ onexptend = [values.completed = 1]
</expt>

**************************************************************************************************************
**************************************************************************************************************
    Order: Food8(Descending), Food8(Ascending), Food12(Descending), Food12(Ascending), Food4(Descending), Food4(Ascending)
**************************************************************************************************************
**************************************************************************************************************
<expt>
/ preinstructions = (generalintro)
/ postinstructions = (generaloutro)
/ blocks = [1=foodchoice; 2-7=sequence(food8_desc, food8_asc, food12_desc, food12_asc, food4_desc, food4_asc)]
/ subjects = (3 of 6)
/ groupassignment = groupnumber
/ onexptend = [values.completed = 1]
</expt>

**************************************************************************************************************
**************************************************************************************************************
    Order: Food12(Descending), Food12(Ascending), Food8(Descending), Food8(Ascending), Food4(Descending), Food4(Ascending)
**************************************************************************************************************
**************************************************************************************************************
<expt>
/ preinstructions = (generalintro)
/ postinstructions = (generaloutro)
/ blocks = [1=foodchoice; 2-7=sequence(food12_desc, food12_asc, food8_desc, food8_asc, food4_desc, food4_asc)]
/ subjects = (4 of 6)
/ groupassignment = groupnumber
/ onexptend = [values.completed = 1]
</expt>

**************************************************************************************************************
**************************************************************************************************************
    Order: Food12(Descending), Food12(Ascending), Food4(Descending), Food4(Ascending), Food8(Descending), Food8(Ascending)
**************************************************************************************************************
**************************************************************************************************************
<expt>
/ preinstructions = (generalintro)
/ postinstructions = (generaloutro)
/ blocks = [1=foodchoice; 2-7=sequence(food12_desc, food12_asc, food4_desc, food4_asc, food8_desc, food8_asc)]
/ subjects = (5 of 6)
/ groupassignment = groupnumber
/ onexptend = [values.completed = 1]
</expt>


**************************************************************************************************************
**************************************************************************************************************
    Order: Food4(Descending), Food4(Ascending), Food12(Descending), Food12(Ascending), Food8(Descending), Food8(Ascending)
**************************************************************************************************************
**************************************************************************************************************
<expt>
/ preinstructions = (generalintro)
/ postinstructions = (generaloutro)
/ blocks = [1=foodchoice; 2-7=sequence(food4_desc, food4_asc, food12_desc, food12_asc, food8_desc, food8_asc)]
/ subjects = (6 of 6)
/ groupassignment = groupnumber
/ onexptend = [values.completed = 1]
</expt>



Any insight is appreciated! Thanks.

The code is incomplete and broken as a consequence. There are various references to <parameters> throughout it, yet no <parameters> element is present. This makes it impossible to answer your question adequately.

You can attach files to a post via +Insert -> Add file. It is generally not necessary to paste entire scripts encompassing hundreds or thousands of lines of code into a message's body. Apart from being error-prone, it makes posts hard to read and the code hard to work with. If you have questions about particular parts of the code, it is better to include only those parts in the message body to direct the reader's focus to what's important. Thanks.

sandy_d
sandy_d
Expert (1.3K reputation)Expert (1.3K reputation)Expert (1.3K reputation)Expert (1.3K reputation)Expert (1.3K reputation)Expert (1.3K reputation)Expert (1.3K reputation)Expert (1.3K reputation)Expert (1.3K reputation)
Group: Forum Members
Posts: 13, Visits: 58
Dave - Thursday, November 17, 2016
sandy_d - Thursday, November 17, 2016
Hello,

I'm trying to run a series of sequences within a delay block in the DDT Food and Money so that the left hand and right hand choice will have the same starting value at the right hand side at the beginning of each block time.  (ie: so the left hand side will display " 4 servings of grapes right now" and the right hand side will display "4 servings of grapes in 30 minutes").

My question is, how do I do it so that at the start of each of the delay blocks, the starting value of food is the same for the immediate (left) and for the delayed (right hand side).
Of the 3 possible food blocks I have, this is working correctly for the first two (which goes through the block of 4 servings of food followed with 7 time delays) .

My code so far is:

<data>
/ columns = (build, computer.platform, date,time,subject, group,
    values.blockcount,blocknum,blockcode,values.blocktype,values.order,
    values.trialcount,trialnum,trialcode,response,latency,
    values.delay,parameters.delayedreward_4, parameters.delayedreward_8, parameters.delayedreward_12,values.immediatereward,
    values.delayedresponsestreak,values.immediateresponsestreak,
    values.ip_desc,values.ip_asc,values.ip)
/ separatefiles = true
</data>


****************************
summary data file
****************************

<summarydata>
/ columns = (script.startdate, script.starttime, script.subjectid, script.groupid, script.elapsedtime, computer.platform, values.completed, parameters.delayedreward,
values.ip_delay1_F4, values.ip_delay2_F4, values.ip_delay3_F4, values.ip_delay4_F4, values.ip_delay5_F4, values.ip_delay6_F4, values.ip_delay7_F4,
values.ip_delay1_F8, values.ip_delay2_F8, values.ip_delay3_F8, values.ip_delay4_F8, values.ip_delay5_F8, values.ip_delay6_F8, values.ip_delay7_F8
values.ip_delay1_FF12, values.ip_delay2_F12, values.ip_delay3_F12, values.ip_delay4_F12, values.ip_delay5_F12, values.ip_delay6_F12, values.ip_delay7_F12)
/ separatefiles = true
</summarydata>


*****************************************************************************************************************
*****************************************************************************************************************
    Values: updated automatically on runtime of script
*****************************************************************************************************************
*****************************************************************************************************************
/ completed:                        0 = script was not completed; 1 = script was completed (all conditions run)
/ immediatereward:                    stores the current reward for the immediate response
/ order:                            stores direction of current reward adjustment ("ascending" or "descending")
/ delay:                            stores the current temporal delay
/ object:                            stores the object option of the block (1-4: selected food options)
/ foodchoice:                        stores the selected food option
/ ip_found:                            helper variable to determine indifference point (changes value if ip is found)
/ ip_asc:                            stores ip value for ascending blocks
/ ip_desc:                            stores ip value for descending blocks
/ ip:                                stores final ip value
/ blockcount:                        counts the blocks
/ trialcount:                        counts the trials
/ blocktype:                        stores the type of block "money" or "food"
/ previousresponse:                    stores the previous response
/ immediateresponsestreak:            counts the numbers of consecutive choices of immediate reward
/ delayedresponsestreak:            counts the numbers of consecutive choices of delayed reward

summary variables:
/ip_delay1_F4-
/ip_delay7_F12:                        the IPs for the 7 different delays for all food (F) blocks

<values>
/ completed = 0
/ immediatereward = 0.00
/ order = ""
/ delay = 0
/ object = 0
/ foodchoice = 0
/ ip_found = 0
/ ip_asc = 0.00
/ ip_desc = 0.00
/ ip = 0.00
/ blockcount = 0
/ trialcount = 0
/ blocktype = ""
/ previousresponse = ""
/ immediateresponsestreak = 0
/ delayedresponsestreak = 0

/ ip_delay1_F4 = 0
/ ip_delay2_F4 = 0
/ ip_delay3_F4 = 0
/ ip_delay4_F4 = 0
/ ip_delay5_F4 = 0
/ ip_delay6_F4 = 0
/ ip_delay7_F4 = 0


/ ip_delay1_F8 = 0
/ ip_delay2_F8 = 0
/ ip_delay3_F8 = 0
/ ip_delay4_F8 = 0
/ ip_delay5_F8 = 0
/ ip_delay6_F8 = 0
/ ip_delay7_F8 = 0


/ ip_delay1_F12 = 0
/ ip_delay2_F12 = 0
/ ip_delay3_F12 = 0
/ ip_delay4_F12 = 0
/ ip_delay5_F12 = 0
/ ip_delay6_F12 = 0
/ ip_delay7_F12 = 0
</values>

*****************************************************************************************************************
*****************************************************************************************************************
    Expressions
*****************************************************************************************************************
*****************************************************************************************************************
<expressions>
/ immediatereward = format("%.2f", values.immediatereward)
/ delayedreward_4 = format("%.2f", parameters.delayedreward_4)
/ immediatereward = format("%.2f", values.immediatereward)
/ delayedreward_8 = format("%.2f", parameters.delayedreward_8)
/ immediatereward = format("%.2f", values.immediatereward)
/ delayedreward_12 = format("%.2f", parameters.delayedreward_12)
/ ip_asc = format("%.2f", values.ip_asc)
/ ip_desc = format("%.2f", values.ip_desc)
/ ip = format("%.2f", values.ip)
/ objectdescription = getitem(item.objectdescriptions, values.object)
</expressions>

*****************************************************************************************************************
*****************************************************************************************************************
    List Elements
*****************************************************************************************************************
*****************************************************************************************************************
    Delay Periods (7)
*****************************************************************************************************************
*****************************************************************************************************************
<list delays>
/ items = (parameters.delay1, parameters.delay2, parameters.delay3, parameters.delay4, parameters.delay5, parameters.delay6, parameters.delay7) 
/ selectionmode = sequence
/ selectionrate = block
/ resetinterval = 0
</list>

*****************************************************************************************************************
*****************************************************************************************************************
    Immediate Rewards (9 -- Descending Order)
*****************************************************************************************************************
*****************************************************************************************************************
<list immediaterewards4_desc>
/ items = (4.0, 3.5, 3.0, 2.5, 2.0, 1.5, 1.0, 0.5, 0.0)
/ selectionmode = sequence
/ selectionmode = sequence
/ selectionrate = trial
</list>

<list immediaterewards8_desc>
/ items = (8.0, 7.0, 6.0, 5.0, 4.0, 3.0, 2.0, 1.0, 0.0)
/ selectionmode = sequence
/ selectionmode = sequence
/ selectionrate = trial
</list>

<list immediaterewards12_desc>
/ items = (12.0, 10.0, 8.0, 7.0, 6.0, 4.0, 2.0, 1.0, 0.0)
/ selectionmode = sequence
/ selectionmode = sequence
/ selectionrate = trial
</list>

*****************************************************************************************************************
*****************************************************************************************************************
    Immediate Rewards (9 -- Ascending Order)
*****************************************************************************************************************
*****************************************************************************************************************
<list immediaterewards4_asc>
/ items = (0.0, 0.5, 1.0, 1.5, 2.0, 2.5, 3.0, 3.5, 4.0)
/ selectionmode = sequence
/ selectionrate = trial
</list>

<list immediaterewards8_asc>
/ items = (0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0)
/ selectionmode = sequence
/ selectionrate = trial
</list>

<list immediaterewards12_asc>
/ items = (0.0, 1.0, 2.0, 4.0, 6.0, 7.0, 8.0, 10.0, 12.0)
/ selectionmode = sequence
/ selectionrate = trial
</list>


*****************************************************************************************************************
*****************************************************************************************************************
    Stimulus Elements
*****************************************************************************************************************
*****************************************************************************************************************
    For DDT Trial
*****************************************************************************************************************
*****************************************************************************************************************
<text question_4>
/ items = question_4
/ select = 1
/ erase = false
/ position = (50%, 50%)
</text>


<text or>
/ items = question_4
/ select = 3
/ erase = false
/ position = (50%, 65%)
</text>

<text immediate>
/ items = question_4
/ select = 2
/ txbgcolor = grey
/ vjustify = center
/ size = (20%, 20%)
/ position = (30%, 65%)
</text>

<text delayed_4>
/ items = question_4
/ select = 4
/ txbgcolor = grey
/ vjustify = center
/ size = (20%, 20%)
/ position = (70%, 65%)
</text>

<text question_8>
/ items = question_8
/ select = 1
/ erase = false
/ position = (50%, 50%)
</text>


<text delayed_8>
/ items = question_8
/ select = 4
/ txbgcolor = grey
/ vjustify = center
/ size = (20%, 20%)
/ position = (70%, 65%)
</text>

<text question_12>
/ items = question_12
/ select = 1
/ erase = false
/ position = (50%, 50%)
</text>

<text delayed_12>
/ items = question_12
/ select = 4
/ txbgcolor = grey
/ vjustify = center
/ size = (20%, 20%)
/ position = (70%, 65%)
</text>

<picture objectpic>
/ items = objectpicitems
/ select = values.object
/ position = (50%, 25%)
/ erase = false
</picture>


**************************************************************************************************************
**************************************************************************************************************
    Debug Stuff
**************************************************************************************************************
**************************************************************************************************************
<text debug>
/ items = ("Block = <%values.blockcount%> | Blocktype = <%values.blocktype%> | Order = <%values.order%> | IP_Desc = <%expressions.ip_desc%> | IP_Asc = <%expressions.ip_asc%> | IP = <%expressions.ip%>
Delayedstreak = <%values.delayedresponsestreak%> | Immediatestreak = <%values.immediateresponsestreak%>")
/ fontstyle = ("Arial", 2.00%)
/ erase = false
/ position = (50%, 5%)
/ size = (90%, 5%)
</text>

*****************************************************************************************************************
*****************************************************************************************************************
    For Food Pick Trial
*****************************************************************************************************************
*****************************************************************************************************************
<text foodcaption>
/ items = foodcaptions
/ select = 1
/ position = (50%, 10%)
</text>

<picture foodapic>
/ items = foodpics
/ select = 1
/ position = (30%, 30%)
</picture>

<picture foodbpic>
/ items = foodpics
/ select = 2
/ position = (70%, 30%)
</picture>

<picture foodcpic>
/ items = foodpics
/ select = 3
/ position = (30%, 70%)
</picture>

<picture fooddpic>
/ items = foodpics
/ select = 4
/ position = (70%, 70%)
</picture>

<text foodatxt>
/ items = foodcaptions
/ select = 2
/ position = (30%, 50%)
</text>

<text foodbtxt>
/ items = foodcaptions
/ select = 3
/ position = (70%, 50%)
</text>

<text foodctxt>
/ items = foodcaptions
/ select = 4
/ position = (30%, 90%)
</text>

<text fooddtxt>
/ items = foodcaptions
/ select = 5
/ position = (70%, 90%)
</text>
**************************************************************************************************************
**************************************************************************************************************
    Trial Elements
**************************************************************************************************************
**************************************************************************************************************
    DDT Choice Trial
**************************************************************************************************************
**************************************************************************************************************
<trial discounttrial4>
/ pretrialpause = parameters.pretrialdelay
/ posttrialpause = parameters.posttrialdelay
/ ontrialbegin = [values.trialcount+=1]
/ ontrialbegin = [if (values.trialcount==1)
        values.previousresponse="" else
        values.previousresponse=trial.discounttrial4.response]
/ ontrialbegin = [if (values.order=="descending")
        values.immediatereward=list.immediaterewards4_desc.nextvalue]
/ ontrialbegin = [if (values.order=="ascending")
        values.immediatereward=list.immediaterewards4_asc.nextvalue]

/ stimulusframes = [1=objectpic, question_4, or, immediate, delayed_4]
/ validresponse = (immediate, delayed_4)

/ ontrialend = [if (values.previousresponse=="immediate" && trial.discounttrial4.response=="immediate")
        values.immediateresponsestreak+=1 else
        values.immediateresponsestreak=0]
/ ontrialend = [if (values.previousresponse=="delayed" && trial.discounttrial4.response=="delayed")
        values.delayedresponsestreak+=1 else
        values.delayedresponsestreak=0]
/ ontrialend = [if (values.order=="descending" && values.ip_found==0 && values.delayedresponsestreak==1) {
        values.ip_desc=values.immediatereward; values.ip_found=1}]
/ ontrialend = [
    if (values.order=="ascending" && values.ip_found==0 && values.immediateresponsestreak==1) {
        values.ip_asc=values.immediatereward; values.ip_found=1}]

</trial>

<trial discounttrial8>
/ pretrialpause = parameters.pretrialdelay
/ posttrialpause = parameters.posttrialdelay
/ ontrialbegin = [values.trialcount+=1]
/ ontrialbegin = [if (values.trialcount==1)
        values.previousresponse="" else
        values.previousresponse=trial.discounttrial8.response]
/ ontrialbegin = [if (values.order=="descending")
        values.immediatereward=list.immediaterewards8_desc.nextvalue]
/ ontrialbegin = [if (values.order=="ascending")
        values.immediatereward=list.immediaterewards8_asc.nextvalue]

/ stimulusframes = [1=objectpic, question_8, or, immediate, delayed_8]
/ validresponse = (immediate, delayed_8)

/ ontrialend = [if (values.previousresponse=="immediate" && trial.discounttrial8.response=="immediate")
        values.immediateresponsestreak+=1 else
        values.immediateresponsestreak=0]
/ ontrialend = [if (values.previousresponse=="delayed" && trial.discounttrial8.response=="delayed")
        values.delayedresponsestreak+=1 else
        values.delayedresponsestreak=0]
/ ontrialend = [if (values.order=="descending" && values.ip_found==0 && values.delayedresponsestreak==1) {
        values.ip_desc=values.immediatereward; values.ip_found=1}]
/ ontrialend = [
    if (values.order=="ascending" && values.ip_found==0 && values.immediateresponsestreak==1) {
        values.ip_asc=values.immediatereward; values.ip_found=1}]

</trial>

<trial discounttrial12>
/ pretrialpause = parameters.pretrialdelay
/ posttrialpause = parameters.posttrialdelay
/ ontrialbegin = [values.trialcount+=1]
/ ontrialbegin = [if (values.trialcount==1)
        values.previousresponse="" else
        values.previousresponse=trial.discounttrial12.response]
/ ontrialbegin = [if (values.order=="descending")
        values.immediatereward=list.immediaterewards12_desc.nextvalue]
/ ontrialbegin = [if (values.order=="ascending")
        values.immediatereward=list.immediaterewards12_asc.nextvalue]

/ stimulusframes = [1=objectpic, question_12, or, immediate, delayed_12]
/ validresponse = (immediate, delayed_12)

/ ontrialend = [if (values.previousresponse=="immediate" && trial.discounttrial12.response=="immediate")
        values.immediateresponsestreak+=1 else
        values.immediateresponsestreak=0]
/ ontrialend = [if (values.previousresponse=="delayed" && trial.discounttrial12.response=="delayed")
        values.delayedresponsestreak+=1 else
        values.delayedresponsestreak=0]
/ ontrialend = [if (values.order=="descending" && values.ip_found==0 && values.delayedresponsestreak==1) {
        values.ip_desc=values.immediatereward; values.ip_found=1}]
/ ontrialend = [
    if (values.order=="ascending" && values.ip_found==0 && values.immediateresponsestreak==1) {
        values.ip_asc=values.immediatereward; values.ip_found=1}]

</trial>


**************************************************************************************************************
**************************************************************************************************************
    Compute Indifference Point
**************************************************************************************************************
**************************************************************************************************************
<trial compute_ip4>
/ ontrialbegin = [
    if (values.order=="descending" && values.ip_found==0)
        values.ip_desc=values.immediatereward
]
/ ontrialbegin = [
    if (values.order=="ascending" && values.ip_found==0)
        values.ip_asc=parameters.delayedreward_4
]
/ ontrialbegin = [
    if (values.ip_desc!=0.00 && values.ip_asc!=0.00)
        values.ip=(values.ip_desc+values.ip_asc)*0.5
]
   
/ ontrialbegin = [
    if (values.ip != 0 && values.blocktype == "food4" && values.delay == parameters.delay1) {
        values.ip_delay1_F4 = values.ip
    }
]
/ ontrialbegin = [
    if (values.ip != 0 && values.blocktype == "food4" && values.delay == parameters.delay2) {
        values.ip_delay2_F4 = values.ip
    }
]
/ ontrialbegin = [
    if (values.ip != 0 && values.blocktype == "food4" && values.delay == parameters.delay3) {
        values.ip_delay3_F4 = values.ip
    }
]
/ ontrialbegin = [
    if (values.ip != 0 && values.blocktype == "food4" && values.delay == parameters.delay4) {
        values.ip_delay4_F4 = values.ip
    }
]
/ ontrialbegin = [
    if (values.ip != 0 && values.blocktype == "food4" && values.delay == parameters.delay5) {
        values.ip_delay5_F4 = values.ip
    }
]
/ ontrialbegin = [
    if (values.ip != 0 && values.blocktype == "food4" && values.delay == parameters.delay6) {
        values.ip_delay6_F4 = values.ip
    }
]
/ ontrialbegin = [
    if (values.ip != 0 && values.blocktype == "food4" && values.delay == parameters.delay7) {
        values.ip_delay7_F4 = values.ip
    }
]



/ validresponse = (noresponse)
/ trialduration = 0
</trial>

<trial compute_ip8>
/ ontrialbegin = [
    if (values.order=="descending" && values.ip_found==0)
        values.ip_desc=values.immediatereward
]
/ ontrialbegin = [
    if (values.order=="ascending" && values.ip_found==0)
        values.ip_asc=parameters.delayedreward_8
]
/ ontrialbegin = [
    if (values.ip_desc!=0.00 && values.ip_asc!=0.00)
        values.ip=(values.ip_desc+values.ip_asc)*0.5
]
   
/ ontrialbegin = [
    if (values.ip != 0 && values.blocktype == "food8" && values.delay == parameters.delay1) {
        values.ip_delay1_F8 = values.ip
    }
]
/ ontrialbegin = [
    if (values.ip != 0 && values.blocktype == "food8" && values.delay == parameters.delay2) {
        values.ip_delay2_F8 = values.ip
    }
]
/ ontrialbegin = [
    if (values.ip != 0 && values.blocktype == "food8" && values.delay == parameters.delay3) {
        values.ip_delay3_F8 = values.ip
    }
]
/ ontrialbegin = [
    if (values.ip != 0 && values.blocktype == "food8" && values.delay == parameters.delay4) {
        values.ip_delay4_F8 = values.ip
    }
]
/ ontrialbegin = [
    if (values.ip != 0 && values.blocktype == "food8" && values.delay == parameters.delay5) {
        values.ip_delay5_F8 = values.ip
    }
]
/ ontrialbegin = [
    if (values.ip != 0 && values.blocktype == "food8" && values.delay == parameters.delay6) {
        values.ip_delay6_F8 = values.ip
    }
]
/ ontrialbegin = [
    if (values.ip != 0 && values.blocktype == "food8" && values.delay == parameters.delay7) {
        values.ip_delay7_F8 = values.ip
    }
]

/ validresponse = (noresponse)
/ trialduration = 0
</trial>       

<trial compute_ip12>
/ ontrialbegin = [
    if (values.order=="descending" && values.ip_found==0)
        values.ip_desc=values.immediatereward
]
/ ontrialbegin = [
    if (values.order=="ascending" && values.ip_found==0)
        values.ip_asc=parameters.delayedreward_12
]
/ ontrialbegin = [
    if (values.ip_desc!=0.00 && values.ip_asc!=0.00)
        values.ip=(values.ip_desc+values.ip_asc)*0.5
]
   
/ ontrialbegin = [
    if (values.ip != 0 && values.blocktype == "food12" && values.delay == parameters.delay1) {
        values.ip_delay1_F12 = values.ip
    }
]
/ ontrialbegin = [
    if (values.ip != 0 && values.blocktype == "food12" && values.delay == parameters.delay2) {
        values.ip_delay2_F12 = values.ip
    }
]
/ ontrialbegin = [
    if (values.ip != 0 && values.blocktype == "food12" && values.delay == parameters.delay3) {
        values.ip_delay3_F12 = values.ip
    }
]
/ ontrialbegin = [
    if (values.ip != 0 && values.blocktype == "food12" && values.delay == parameters.delay4) {
        values.ip_delay4_F12 = values.ip
    }
]
/ ontrialbegin = [
    if (values.ip != 0 && values.blocktype == "food12" && values.delay == parameters.delay5) {
        values.ip_delay5_F12 = values.ip
    }
]
/ ontrialbegin = [
    if (values.ip != 0 && values.blocktype == "food12" && values.delay == parameters.delay6) {
        values.ip_delay6_F12 = values.ip
    }
]
/ ontrialbegin = [
    if (values.ip != 0 && values.blocktype == "food12" && values.delay == parameters.delay7) {
        values.ip_delay7_F12 = values.ip
    }
]

/ validresponse = (noresponse)
/ trialduration = 0
</trial>
**************************************************************************************************************
**************************************************************************************************************
    Preferred Food Trial
**************************************************************************************************************
**************************************************************************************************************
<trial foodchoice>
/ stimulusframes = [1=foodcaption, foodapic, foodbpic, foodcpic, fooddpic, foodatxt, foodbtxt, foodctxt, fooddtxt]
/ validresponse = (foodapic, foodbpic, foodcpic, fooddpic)
/ ontrialend = [
    if (trial.foodchoice.response=="foodapic")
        values.foodchoice=1
]
/ ontrialend = [
    if (trial.foodchoice.response=="foodbpic")
        values.foodchoice=2
]
/ ontrialend = [
    if (trial.foodchoice.response=="foodcpic")
        values.foodchoice=3
]
/ ontrialend = [
    if (trial.foodchoice.response=="fooddpic")
        values.foodchoice=4
]
</trial>

**************************************************************************************************************
**************************************************************************************************************
    Block Elements
**************************************************************************************************************
**************************************************************************************************************
    Food Preference Block
**************************************************************************************************************
**************************************************************************************************************
<block foodchoice>
/ preinstructions = (foodintro)
/ postinstructions = (foodoutro)
/ trials = [1=foodchoice]
</block>

**************************************************************************************************************
**************************************************************************************************************
    DDT Blocks
**************************************************************************************************************
**************************************************************************************************************
    Food 4 Discounting (Descending)
**************************************************************************************************************
**************************************************************************************************************
<block food4_desc>
/ onblockbegin = [
    values.object=values.foodchoice;
    values.blocktype="food4";
    values.ip_found=0
]
/ onblockbegin = [
    values.immediateresponsestreak=0;
    values.delayedresponsestreak=0
]
/ onblockbegin = [values.previousresponse=""]
/ onblockbegin = [
    values.blockcount+=1;
    values.trialcount=0
]
/ onblockbegin = [
    values.order="descending";
    values.ip_desc=0.00;
    values.ip=0.00
]
/ onblockbegin = [
    if (mod(values.blockcount,4)==1 || mod(values.blockcount,4)==3)
        values.ip_asc=0.00
]
/ onblockbegin = [
    if (mod(values.blockcount,4)==1)
        values.delay=list.delays.nextvalue
]
/ trials = [1-9=discounttrial4; 10=compute_ip4]
</block>


**************************************************************************************************************
**************************************************************************************************************
    Food 4 Discounting (Ascending)
**************************************************************************************************************
**************************************************************************************************************
<block food4_asc>
/ onblockbegin = [
    values.object=values.foodchoice;
    values.blocktype="food4";
    values.ip_found=0
]
/ onblockbegin = [
    values.immediateresponsestreak=0;
    values.delayedresponsestreak=0
]
/ onblockbegin = [values.previousresponse=""]
/ onblockbegin = [
    values.blockcount+=1;
    values.trialcount=0
]
/ onblockbegin = [
    values.order="ascending";
    values.ip_asc=0.00;
    values.ip=0.00
]
/ onblockbegin = [
    if (mod(values.blockcount,4)==1 || mod(values.blockcount,4)==3)
        values.ip_desc=0.00
]
/ onblockbegin = [
    if (mod(values.blockcount,4)==1)
        values.delay=list.delays.nextvalue
]
/ trials = [1-9=discounttrial4; 10=compute_ip4]
</block>
**************************************************************************************************************
**************************************************************************************************************
    Food 8 Discounting (Descending)
**************************************************************************************************************
**************************************************************************************************************
<block food8_desc>
/ onblockbegin = [
    values.object=values.foodchoice;
    values.blocktype="food8";
    values.ip_found=0
]
/ onblockbegin = [
    values.immediateresponsestreak=0;
    values.delayedresponsestreak=0
]
/ onblockbegin = [values.previousresponse=""]
/ onblockbegin = [
    values.blockcount+=1;
    values.trialcount=0
]
/ onblockbegin = [
    values.order="descending";
    values.ip_desc=0.00;
    values.ip=0.00
]
/ onblockbegin = [
    if (mod(values.blockcount,4)==1 || mod(values.blockcount,4)==3)
        values.ip_asc=0.00
]
/ onblockbegin = [
    if (mod(values.blockcount,4)==1)
        values.delay=list.delays.nextvalue
]
/ trials = [1-9=discounttrial8; 10=compute_ip8]
</block>


**************************************************************************************************************
**************************************************************************************************************
    Food 8 Discounting (Ascending)
**************************************************************************************************************
**************************************************************************************************************
<block food8_asc>
/ onblockbegin = [
    values.object=values.foodchoice;
    values.blocktype="food8";
    values.ip_found=0
]
/ onblockbegin = [
    values.immediateresponsestreak=0;
    values.delayedresponsestreak=0
]
/ onblockbegin = [values.previousresponse=""]
/ onblockbegin = [
    values.blockcount+=1;
    values.trialcount=0
]
/ onblockbegin = [
    values.order="ascending";
    values.ip_asc=0.00;
    values.ip=0.00
]
/ onblockbegin = [
    if (mod(values.blockcount,4)==1 || mod(values.blockcount,4)==3)
        values.ip_desc=0.00
]
/ onblockbegin = [
    if (mod(values.blockcount,4)==1)
        values.delay=list.delays.nextvalue
]
/ trials = [1-9=discounttrial8; 10=compute_ip8]
</block>

**************************************************************************************************************
**************************************************************************************************************
    Food 12 Discounting (Descending)
**************************************************************************************************************
**************************************************************************************************************
<block food12_desc>
/ onblockbegin = [
    values.object=values.foodchoice;
    values.blocktype="food12";
    values.ip_found=0
]
/ onblockbegin = [
    values.immediateresponsestreak=0;
    values.delayedresponsestreak=0
]
/ onblockbegin = [values.previousresponse=""]
/ onblockbegin = [
    values.blockcount+=1;
    values.trialcount=0
]
/ onblockbegin = [
    values.order="descending";
    values.ip_asc=0.00;
    values.ip=0.00
]
/ onblockbegin = [
    if (mod(values.blockcount,4)==1 || mod(values.blockcount,4)==3)
        values.ip_asc=0.00
]
/ onblockbegin = [
    if (mod(values.blockcount,4)==1)
        values.delay=list.delays.nextvalue
]
/ trials = [1-9=discounttrial12; 10=compute_ip12]
</block>


**************************************************************************************************************
**************************************************************************************************************
    Food 12 Discounting (Ascending)
**************************************************************************************************************
**************************************************************************************************************
<block food12_asc>
/ onblockbegin = [
    values.object=values.foodchoice;
    values.blocktype="food12";
    values.ip_found=0
]
/ onblockbegin = [
    values.immediateresponsestreak=0;
    values.delayedresponsestreak=0
]
/ onblockbegin = [values.previousresponse=""]
/ onblockbegin = [
    values.blockcount+=1;
    values.trialcount=0
]
/ onblockbegin = [
    values.order="ascending";
    values.ip_asc=0.00;
    values.ip=0.00
]
/ onblockbegin = [
    if (mod(values.blockcount,4)==1 || mod(values.blockcount,4)==3)
        values.ip_desc=0.00
]
/ onblockbegin = [
    if (mod(values.blockcount,4)==1)
        values.delay=list.delays.nextvalue
]
/ trials = [1-9=discounttrial12; 10=compute_ip12]
</block>

**************************************************************************************************************
**************************************************************************************************************
    Expt Elements
**************************************************************************************************************
**************************************************************************************************************
    Order: Food4(Descending), Food4(Ascending), Food8(Descending), Food8(Ascending), Food12(Descending), Food12(Ascending)
**************************************************************************************************************
**************************************************************************************************************
<expt>
/ preinstructions = (generalintro)
/ postinstructions = (generaloutro)
/ blocks = [1=foodchoice; 2-7=sequence(food4_desc, food4_asc, food8_desc, food8_asc, food12_desc, food12_asc)]
/ subjects = (1 of 6)
/ groupassignment = groupnumber
/ onexptend = [values.completed = 1]
</expt>

**************************************************************************************************************
**************************************************************************************************************
    Order: Food8(Descending), Food8(Ascending), Food4(Descending), Food4(Ascending), Food12(Descending), Food12(Ascending)
**************************************************************************************************************
**************************************************************************************************************
<expt>
/ preinstructions = (generalintro)
/ postinstructions = (generaloutro)
/ blocks = [1=foodchoice; 2-7=sequence(food8_desc, food8_asc, food4_desc, food4_asc, food12_desc, food12_asc)]
/ subjects = (2 of 6)
/ groupassignment = groupnumber
/ onexptend = [values.completed = 1]
</expt>

**************************************************************************************************************
**************************************************************************************************************
    Order: Food8(Descending), Food8(Ascending), Food12(Descending), Food12(Ascending), Food4(Descending), Food4(Ascending)
**************************************************************************************************************
**************************************************************************************************************
<expt>
/ preinstructions = (generalintro)
/ postinstructions = (generaloutro)
/ blocks = [1=foodchoice; 2-7=sequence(food8_desc, food8_asc, food12_desc, food12_asc, food4_desc, food4_asc)]
/ subjects = (3 of 6)
/ groupassignment = groupnumber
/ onexptend = [values.completed = 1]
</expt>

**************************************************************************************************************
**************************************************************************************************************
    Order: Food12(Descending), Food12(Ascending), Food8(Descending), Food8(Ascending), Food4(Descending), Food4(Ascending)
**************************************************************************************************************
**************************************************************************************************************
<expt>
/ preinstructions = (generalintro)
/ postinstructions = (generaloutro)
/ blocks = [1=foodchoice; 2-7=sequence(food12_desc, food12_asc, food8_desc, food8_asc, food4_desc, food4_asc)]
/ subjects = (4 of 6)
/ groupassignment = groupnumber
/ onexptend = [values.completed = 1]
</expt>

**************************************************************************************************************
**************************************************************************************************************
    Order: Food12(Descending), Food12(Ascending), Food4(Descending), Food4(Ascending), Food8(Descending), Food8(Ascending)
**************************************************************************************************************
**************************************************************************************************************
<expt>
/ preinstructions = (generalintro)
/ postinstructions = (generaloutro)
/ blocks = [1=foodchoice; 2-7=sequence(food12_desc, food12_asc, food4_desc, food4_asc, food8_desc, food8_asc)]
/ subjects = (5 of 6)
/ groupassignment = groupnumber
/ onexptend = [values.completed = 1]
</expt>


**************************************************************************************************************
**************************************************************************************************************
    Order: Food4(Descending), Food4(Ascending), Food12(Descending), Food12(Ascending), Food8(Descending), Food8(Ascending)
**************************************************************************************************************
**************************************************************************************************************
<expt>
/ preinstructions = (generalintro)
/ postinstructions = (generaloutro)
/ blocks = [1=foodchoice; 2-7=sequence(food4_desc, food4_asc, food12_desc, food12_asc, food8_desc, food8_asc)]
/ subjects = (6 of 6)
/ groupassignment = groupnumber
/ onexptend = [values.completed = 1]
</expt>



Any insight is appreciated! Thanks.

The code is incomplete and broken as a consequence. There are various references to <parameters> throughout it, yet no <parameters> element is present. This makes it impossible to answer your question adequately.

You can attach files to a post via +Insert -> Add file. It is generally not necessary to paste entire scripts encompassing hundreds or thousands of lines of code into a message's body. Apart from being error-prone, it makes posts hard to read and the code hard to work with. If you have questions about particular parts of the code, it is better to include only those parts in the message body to direct the reader's focus to what's important. Thanks.


Would the attached file provide more clarification?



Attachments
Dave
Dave
Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)
Group: Administrators
Posts: 13K, Visits: 105K
sandy_d - Thursday, November 17, 2016
Dave - Thursday, November 17, 2016
sandy_d - Thursday, November 17, 2016
Hello,

I'm trying to run a series of sequences within a delay block in the DDT Food and Money so that the left hand and right hand choice will have the same starting value at the right hand side at the beginning of each block time.  (ie: so the left hand side will display " 4 servings of grapes right now" and the right hand side will display "4 servings of grapes in 30 minutes").

My question is, how do I do it so that at the start of each of the delay blocks, the starting value of food is the same for the immediate (left) and for the delayed (right hand side).
Of the 3 possible food blocks I have, this is working correctly for the first two (which goes through the block of 4 servings of food followed with 7 time delays) .

My code so far is:

<data>
/ columns = (build, computer.platform, date,time,subject, group,
    values.blockcount,blocknum,blockcode,values.blocktype,values.order,
    values.trialcount,trialnum,trialcode,response,latency,
    values.delay,parameters.delayedreward_4, parameters.delayedreward_8, parameters.delayedreward_12,values.immediatereward,
    values.delayedresponsestreak,values.immediateresponsestreak,
    values.ip_desc,values.ip_asc,values.ip)
/ separatefiles = true
</data>


****************************
summary data file
****************************

<summarydata>
/ columns = (script.startdate, script.starttime, script.subjectid, script.groupid, script.elapsedtime, computer.platform, values.completed, parameters.delayedreward,
values.ip_delay1_F4, values.ip_delay2_F4, values.ip_delay3_F4, values.ip_delay4_F4, values.ip_delay5_F4, values.ip_delay6_F4, values.ip_delay7_F4,
values.ip_delay1_F8, values.ip_delay2_F8, values.ip_delay3_F8, values.ip_delay4_F8, values.ip_delay5_F8, values.ip_delay6_F8, values.ip_delay7_F8
values.ip_delay1_FF12, values.ip_delay2_F12, values.ip_delay3_F12, values.ip_delay4_F12, values.ip_delay5_F12, values.ip_delay6_F12, values.ip_delay7_F12)
/ separatefiles = true
</summarydata>


*****************************************************************************************************************
*****************************************************************************************************************
    Values: updated automatically on runtime of script
*****************************************************************************************************************
*****************************************************************************************************************
/ completed:                        0 = script was not completed; 1 = script was completed (all conditions run)
/ immediatereward:                    stores the current reward for the immediate response
/ order:                            stores direction of current reward adjustment ("ascending" or "descending")
/ delay:                            stores the current temporal delay
/ object:                            stores the object option of the block (1-4: selected food options)
/ foodchoice:                        stores the selected food option
/ ip_found:                            helper variable to determine indifference point (changes value if ip is found)
/ ip_asc:                            stores ip value for ascending blocks
/ ip_desc:                            stores ip value for descending blocks
/ ip:                                stores final ip value
/ blockcount:                        counts the blocks
/ trialcount:                        counts the trials
/ blocktype:                        stores the type of block "money" or "food"
/ previousresponse:                    stores the previous response
/ immediateresponsestreak:            counts the numbers of consecutive choices of immediate reward
/ delayedresponsestreak:            counts the numbers of consecutive choices of delayed reward

summary variables:
/ip_delay1_F4-
/ip_delay7_F12:                        the IPs for the 7 different delays for all food (F) blocks

<values>
/ completed = 0
/ immediatereward = 0.00
/ order = ""
/ delay = 0
/ object = 0
/ foodchoice = 0
/ ip_found = 0
/ ip_asc = 0.00
/ ip_desc = 0.00
/ ip = 0.00
/ blockcount = 0
/ trialcount = 0
/ blocktype = ""
/ previousresponse = ""
/ immediateresponsestreak = 0
/ delayedresponsestreak = 0

/ ip_delay1_F4 = 0
/ ip_delay2_F4 = 0
/ ip_delay3_F4 = 0
/ ip_delay4_F4 = 0
/ ip_delay5_F4 = 0
/ ip_delay6_F4 = 0
/ ip_delay7_F4 = 0


/ ip_delay1_F8 = 0
/ ip_delay2_F8 = 0
/ ip_delay3_F8 = 0
/ ip_delay4_F8 = 0
/ ip_delay5_F8 = 0
/ ip_delay6_F8 = 0
/ ip_delay7_F8 = 0


/ ip_delay1_F12 = 0
/ ip_delay2_F12 = 0
/ ip_delay3_F12 = 0
/ ip_delay4_F12 = 0
/ ip_delay5_F12 = 0
/ ip_delay6_F12 = 0
/ ip_delay7_F12 = 0
</values>

*****************************************************************************************************************
*****************************************************************************************************************
    Expressions
*****************************************************************************************************************
*****************************************************************************************************************
<expressions>
/ immediatereward = format("%.2f", values.immediatereward)
/ delayedreward_4 = format("%.2f", parameters.delayedreward_4)
/ immediatereward = format("%.2f", values.immediatereward)
/ delayedreward_8 = format("%.2f", parameters.delayedreward_8)
/ immediatereward = format("%.2f", values.immediatereward)
/ delayedreward_12 = format("%.2f", parameters.delayedreward_12)
/ ip_asc = format("%.2f", values.ip_asc)
/ ip_desc = format("%.2f", values.ip_desc)
/ ip = format("%.2f", values.ip)
/ objectdescription = getitem(item.objectdescriptions, values.object)
</expressions>

*****************************************************************************************************************
*****************************************************************************************************************
    List Elements
*****************************************************************************************************************
*****************************************************************************************************************
    Delay Periods (7)
*****************************************************************************************************************
*****************************************************************************************************************
<list delays>
/ items = (parameters.delay1, parameters.delay2, parameters.delay3, parameters.delay4, parameters.delay5, parameters.delay6, parameters.delay7) 
/ selectionmode = sequence
/ selectionrate = block
/ resetinterval = 0
</list>

*****************************************************************************************************************
*****************************************************************************************************************
    Immediate Rewards (9 -- Descending Order)
*****************************************************************************************************************
*****************************************************************************************************************
<list immediaterewards4_desc>
/ items = (4.0, 3.5, 3.0, 2.5, 2.0, 1.5, 1.0, 0.5, 0.0)
/ selectionmode = sequence
/ selectionmode = sequence
/ selectionrate = trial
</list>

<list immediaterewards8_desc>
/ items = (8.0, 7.0, 6.0, 5.0, 4.0, 3.0, 2.0, 1.0, 0.0)
/ selectionmode = sequence
/ selectionmode = sequence
/ selectionrate = trial
</list>

<list immediaterewards12_desc>
/ items = (12.0, 10.0, 8.0, 7.0, 6.0, 4.0, 2.0, 1.0, 0.0)
/ selectionmode = sequence
/ selectionmode = sequence
/ selectionrate = trial
</list>

*****************************************************************************************************************
*****************************************************************************************************************
    Immediate Rewards (9 -- Ascending Order)
*****************************************************************************************************************
*****************************************************************************************************************
<list immediaterewards4_asc>
/ items = (0.0, 0.5, 1.0, 1.5, 2.0, 2.5, 3.0, 3.5, 4.0)
/ selectionmode = sequence
/ selectionrate = trial
</list>

<list immediaterewards8_asc>
/ items = (0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0)
/ selectionmode = sequence
/ selectionrate = trial
</list>

<list immediaterewards12_asc>
/ items = (0.0, 1.0, 2.0, 4.0, 6.0, 7.0, 8.0, 10.0, 12.0)
/ selectionmode = sequence
/ selectionrate = trial
</list>


*****************************************************************************************************************
*****************************************************************************************************************
    Stimulus Elements
*****************************************************************************************************************
*****************************************************************************************************************
    For DDT Trial
*****************************************************************************************************************
*****************************************************************************************************************
<text question_4>
/ items = question_4
/ select = 1
/ erase = false
/ position = (50%, 50%)
</text>


<text or>
/ items = question_4
/ select = 3
/ erase = false
/ position = (50%, 65%)
</text>

<text immediate>
/ items = question_4
/ select = 2
/ txbgcolor = grey
/ vjustify = center
/ size = (20%, 20%)
/ position = (30%, 65%)
</text>

<text delayed_4>
/ items = question_4
/ select = 4
/ txbgcolor = grey
/ vjustify = center
/ size = (20%, 20%)
/ position = (70%, 65%)
</text>

<text question_8>
/ items = question_8
/ select = 1
/ erase = false
/ position = (50%, 50%)
</text>


<text delayed_8>
/ items = question_8
/ select = 4
/ txbgcolor = grey
/ vjustify = center
/ size = (20%, 20%)
/ position = (70%, 65%)
</text>

<text question_12>
/ items = question_12
/ select = 1
/ erase = false
/ position = (50%, 50%)
</text>

<text delayed_12>
/ items = question_12
/ select = 4
/ txbgcolor = grey
/ vjustify = center
/ size = (20%, 20%)
/ position = (70%, 65%)
</text>

<picture objectpic>
/ items = objectpicitems
/ select = values.object
/ position = (50%, 25%)
/ erase = false
</picture>


**************************************************************************************************************
**************************************************************************************************************
    Debug Stuff
**************************************************************************************************************
**************************************************************************************************************
<text debug>
/ items = ("Block = <%values.blockcount%> | Blocktype = <%values.blocktype%> | Order = <%values.order%> | IP_Desc = <%expressions.ip_desc%> | IP_Asc = <%expressions.ip_asc%> | IP = <%expressions.ip%>
Delayedstreak = <%values.delayedresponsestreak%> | Immediatestreak = <%values.immediateresponsestreak%>")
/ fontstyle = ("Arial", 2.00%)
/ erase = false
/ position = (50%, 5%)
/ size = (90%, 5%)
</text>

*****************************************************************************************************************
*****************************************************************************************************************
    For Food Pick Trial
*****************************************************************************************************************
*****************************************************************************************************************
<text foodcaption>
/ items = foodcaptions
/ select = 1
/ position = (50%, 10%)
</text>

<picture foodapic>
/ items = foodpics
/ select = 1
/ position = (30%, 30%)
</picture>

<picture foodbpic>
/ items = foodpics
/ select = 2
/ position = (70%, 30%)
</picture>

<picture foodcpic>
/ items = foodpics
/ select = 3
/ position = (30%, 70%)
</picture>

<picture fooddpic>
/ items = foodpics
/ select = 4
/ position = (70%, 70%)
</picture>

<text foodatxt>
/ items = foodcaptions
/ select = 2
/ position = (30%, 50%)
</text>

<text foodbtxt>
/ items = foodcaptions
/ select = 3
/ position = (70%, 50%)
</text>

<text foodctxt>
/ items = foodcaptions
/ select = 4
/ position = (30%, 90%)
</text>

<text fooddtxt>
/ items = foodcaptions
/ select = 5
/ position = (70%, 90%)
</text>
**************************************************************************************************************
**************************************************************************************************************
    Trial Elements
**************************************************************************************************************
**************************************************************************************************************
    DDT Choice Trial
**************************************************************************************************************
**************************************************************************************************************
<trial discounttrial4>
/ pretrialpause = parameters.pretrialdelay
/ posttrialpause = parameters.posttrialdelay
/ ontrialbegin = [values.trialcount+=1]
/ ontrialbegin = [if (values.trialcount==1)
        values.previousresponse="" else
        values.previousresponse=trial.discounttrial4.response]
/ ontrialbegin = [if (values.order=="descending")
        values.immediatereward=list.immediaterewards4_desc.nextvalue]
/ ontrialbegin = [if (values.order=="ascending")
        values.immediatereward=list.immediaterewards4_asc.nextvalue]

/ stimulusframes = [1=objectpic, question_4, or, immediate, delayed_4]
/ validresponse = (immediate, delayed_4)

/ ontrialend = [if (values.previousresponse=="immediate" && trial.discounttrial4.response=="immediate")
        values.immediateresponsestreak+=1 else
        values.immediateresponsestreak=0]
/ ontrialend = [if (values.previousresponse=="delayed" && trial.discounttrial4.response=="delayed")
        values.delayedresponsestreak+=1 else
        values.delayedresponsestreak=0]
/ ontrialend = [if (values.order=="descending" && values.ip_found==0 && values.delayedresponsestreak==1) {
        values.ip_desc=values.immediatereward; values.ip_found=1}]
/ ontrialend = [
    if (values.order=="ascending" && values.ip_found==0 && values.immediateresponsestreak==1) {
        values.ip_asc=values.immediatereward; values.ip_found=1}]

</trial>

<trial discounttrial8>
/ pretrialpause = parameters.pretrialdelay
/ posttrialpause = parameters.posttrialdelay
/ ontrialbegin = [values.trialcount+=1]
/ ontrialbegin = [if (values.trialcount==1)
        values.previousresponse="" else
        values.previousresponse=trial.discounttrial8.response]
/ ontrialbegin = [if (values.order=="descending")
        values.immediatereward=list.immediaterewards8_desc.nextvalue]
/ ontrialbegin = [if (values.order=="ascending")
        values.immediatereward=list.immediaterewards8_asc.nextvalue]

/ stimulusframes = [1=objectpic, question_8, or, immediate, delayed_8]
/ validresponse = (immediate, delayed_8)

/ ontrialend = [if (values.previousresponse=="immediate" && trial.discounttrial8.response=="immediate")
        values.immediateresponsestreak+=1 else
        values.immediateresponsestreak=0]
/ ontrialend = [if (values.previousresponse=="delayed" && trial.discounttrial8.response=="delayed")
        values.delayedresponsestreak+=1 else
        values.delayedresponsestreak=0]
/ ontrialend = [if (values.order=="descending" && values.ip_found==0 && values.delayedresponsestreak==1) {
        values.ip_desc=values.immediatereward; values.ip_found=1}]
/ ontrialend = [
    if (values.order=="ascending" && values.ip_found==0 && values.immediateresponsestreak==1) {
        values.ip_asc=values.immediatereward; values.ip_found=1}]

</trial>

<trial discounttrial12>
/ pretrialpause = parameters.pretrialdelay
/ posttrialpause = parameters.posttrialdelay
/ ontrialbegin = [values.trialcount+=1]
/ ontrialbegin = [if (values.trialcount==1)
        values.previousresponse="" else
        values.previousresponse=trial.discounttrial12.response]
/ ontrialbegin = [if (values.order=="descending")
        values.immediatereward=list.immediaterewards12_desc.nextvalue]
/ ontrialbegin = [if (values.order=="ascending")
        values.immediatereward=list.immediaterewards12_asc.nextvalue]

/ stimulusframes = [1=objectpic, question_12, or, immediate, delayed_12]
/ validresponse = (immediate, delayed_12)

/ ontrialend = [if (values.previousresponse=="immediate" && trial.discounttrial12.response=="immediate")
        values.immediateresponsestreak+=1 else
        values.immediateresponsestreak=0]
/ ontrialend = [if (values.previousresponse=="delayed" && trial.discounttrial12.response=="delayed")
        values.delayedresponsestreak+=1 else
        values.delayedresponsestreak=0]
/ ontrialend = [if (values.order=="descending" && values.ip_found==0 && values.delayedresponsestreak==1) {
        values.ip_desc=values.immediatereward; values.ip_found=1}]
/ ontrialend = [
    if (values.order=="ascending" && values.ip_found==0 && values.immediateresponsestreak==1) {
        values.ip_asc=values.immediatereward; values.ip_found=1}]

</trial>


**************************************************************************************************************
**************************************************************************************************************
    Compute Indifference Point
**************************************************************************************************************
**************************************************************************************************************
<trial compute_ip4>
/ ontrialbegin = [
    if (values.order=="descending" && values.ip_found==0)
        values.ip_desc=values.immediatereward
]
/ ontrialbegin = [
    if (values.order=="ascending" && values.ip_found==0)
        values.ip_asc=parameters.delayedreward_4
]
/ ontrialbegin = [
    if (values.ip_desc!=0.00 && values.ip_asc!=0.00)
        values.ip=(values.ip_desc+values.ip_asc)*0.5
]
   
/ ontrialbegin = [
    if (values.ip != 0 && values.blocktype == "food4" && values.delay == parameters.delay1) {
        values.ip_delay1_F4 = values.ip
    }
]
/ ontrialbegin = [
    if (values.ip != 0 && values.blocktype == "food4" && values.delay == parameters.delay2) {
        values.ip_delay2_F4 = values.ip
    }
]
/ ontrialbegin = [
    if (values.ip != 0 && values.blocktype == "food4" && values.delay == parameters.delay3) {
        values.ip_delay3_F4 = values.ip
    }
]
/ ontrialbegin = [
    if (values.ip != 0 && values.blocktype == "food4" && values.delay == parameters.delay4) {
        values.ip_delay4_F4 = values.ip
    }
]
/ ontrialbegin = [
    if (values.ip != 0 && values.blocktype == "food4" && values.delay == parameters.delay5) {
        values.ip_delay5_F4 = values.ip
    }
]
/ ontrialbegin = [
    if (values.ip != 0 && values.blocktype == "food4" && values.delay == parameters.delay6) {
        values.ip_delay6_F4 = values.ip
    }
]
/ ontrialbegin = [
    if (values.ip != 0 && values.blocktype == "food4" && values.delay == parameters.delay7) {
        values.ip_delay7_F4 = values.ip
    }
]



/ validresponse = (noresponse)
/ trialduration = 0
</trial>

<trial compute_ip8>
/ ontrialbegin = [
    if (values.order=="descending" && values.ip_found==0)
        values.ip_desc=values.immediatereward
]
/ ontrialbegin = [
    if (values.order=="ascending" && values.ip_found==0)
        values.ip_asc=parameters.delayedreward_8
]
/ ontrialbegin = [
    if (values.ip_desc!=0.00 && values.ip_asc!=0.00)
        values.ip=(values.ip_desc+values.ip_asc)*0.5
]
   
/ ontrialbegin = [
    if (values.ip != 0 && values.blocktype == "food8" && values.delay == parameters.delay1) {
        values.ip_delay1_F8 = values.ip
    }
]
/ ontrialbegin = [
    if (values.ip != 0 && values.blocktype == "food8" && values.delay == parameters.delay2) {
        values.ip_delay2_F8 = values.ip
    }
]
/ ontrialbegin = [
    if (values.ip != 0 && values.blocktype == "food8" && values.delay == parameters.delay3) {
        values.ip_delay3_F8 = values.ip
    }
]
/ ontrialbegin = [
    if (values.ip != 0 && values.blocktype == "food8" && values.delay == parameters.delay4) {
        values.ip_delay4_F8 = values.ip
    }
]
/ ontrialbegin = [
    if (values.ip != 0 && values.blocktype == "food8" && values.delay == parameters.delay5) {
        values.ip_delay5_F8 = values.ip
    }
]
/ ontrialbegin = [
    if (values.ip != 0 && values.blocktype == "food8" && values.delay == parameters.delay6) {
        values.ip_delay6_F8 = values.ip
    }
]
/ ontrialbegin = [
    if (values.ip != 0 && values.blocktype == "food8" && values.delay == parameters.delay7) {
        values.ip_delay7_F8 = values.ip
    }
]

/ validresponse = (noresponse)
/ trialduration = 0
</trial>       

<trial compute_ip12>
/ ontrialbegin = [
    if (values.order=="descending" && values.ip_found==0)
        values.ip_desc=values.immediatereward
]
/ ontrialbegin = [
    if (values.order=="ascending" && values.ip_found==0)
        values.ip_asc=parameters.delayedreward_12
]
/ ontrialbegin = [
    if (values.ip_desc!=0.00 && values.ip_asc!=0.00)
        values.ip=(values.ip_desc+values.ip_asc)*0.5
]
   
/ ontrialbegin = [
    if (values.ip != 0 && values.blocktype == "food12" && values.delay == parameters.delay1) {
        values.ip_delay1_F12 = values.ip
    }
]
/ ontrialbegin = [
    if (values.ip != 0 && values.blocktype == "food12" && values.delay == parameters.delay2) {
        values.ip_delay2_F12 = values.ip
    }
]
/ ontrialbegin = [
    if (values.ip != 0 && values.blocktype == "food12" && values.delay == parameters.delay3) {
        values.ip_delay3_F12 = values.ip
    }
]
/ ontrialbegin = [
    if (values.ip != 0 && values.blocktype == "food12" && values.delay == parameters.delay4) {
        values.ip_delay4_F12 = values.ip
    }
]
/ ontrialbegin = [
    if (values.ip != 0 && values.blocktype == "food12" && values.delay == parameters.delay5) {
        values.ip_delay5_F12 = values.ip
    }
]
/ ontrialbegin = [
    if (values.ip != 0 && values.blocktype == "food12" && values.delay == parameters.delay6) {
        values.ip_delay6_F12 = values.ip
    }
]
/ ontrialbegin = [
    if (values.ip != 0 && values.blocktype == "food12" && values.delay == parameters.delay7) {
        values.ip_delay7_F12 = values.ip
    }
]

/ validresponse = (noresponse)
/ trialduration = 0
</trial>
**************************************************************************************************************
**************************************************************************************************************
    Preferred Food Trial
**************************************************************************************************************
**************************************************************************************************************
<trial foodchoice>
/ stimulusframes = [1=foodcaption, foodapic, foodbpic, foodcpic, fooddpic, foodatxt, foodbtxt, foodctxt, fooddtxt]
/ validresponse = (foodapic, foodbpic, foodcpic, fooddpic)
/ ontrialend = [
    if (trial.foodchoice.response=="foodapic")
        values.foodchoice=1
]
/ ontrialend = [
    if (trial.foodchoice.response=="foodbpic")
        values.foodchoice=2
]
/ ontrialend = [
    if (trial.foodchoice.response=="foodcpic")
        values.foodchoice=3
]
/ ontrialend = [
    if (trial.foodchoice.response=="fooddpic")
        values.foodchoice=4
]
</trial>

**************************************************************************************************************
**************************************************************************************************************
    Block Elements
**************************************************************************************************************
**************************************************************************************************************
    Food Preference Block
**************************************************************************************************************
**************************************************************************************************************
<block foodchoice>
/ preinstructions = (foodintro)
/ postinstructions = (foodoutro)
/ trials = [1=foodchoice]
</block>

**************************************************************************************************************
**************************************************************************************************************
    DDT Blocks
**************************************************************************************************************
**************************************************************************************************************
    Food 4 Discounting (Descending)
**************************************************************************************************************
**************************************************************************************************************
<block food4_desc>
/ onblockbegin = [
    values.object=values.foodchoice;
    values.blocktype="food4";
    values.ip_found=0
]
/ onblockbegin = [
    values.immediateresponsestreak=0;
    values.delayedresponsestreak=0
]
/ onblockbegin = [values.previousresponse=""]
/ onblockbegin = [
    values.blockcount+=1;
    values.trialcount=0
]
/ onblockbegin = [
    values.order="descending";
    values.ip_desc=0.00;
    values.ip=0.00
]
/ onblockbegin = [
    if (mod(values.blockcount,4)==1 || mod(values.blockcount,4)==3)
        values.ip_asc=0.00
]
/ onblockbegin = [
    if (mod(values.blockcount,4)==1)
        values.delay=list.delays.nextvalue
]
/ trials = [1-9=discounttrial4; 10=compute_ip4]
</block>


**************************************************************************************************************
**************************************************************************************************************
    Food 4 Discounting (Ascending)
**************************************************************************************************************
**************************************************************************************************************
<block food4_asc>
/ onblockbegin = [
    values.object=values.foodchoice;
    values.blocktype="food4";
    values.ip_found=0
]
/ onblockbegin = [
    values.immediateresponsestreak=0;
    values.delayedresponsestreak=0
]
/ onblockbegin = [values.previousresponse=""]
/ onblockbegin = [
    values.blockcount+=1;
    values.trialcount=0
]
/ onblockbegin = [
    values.order="ascending";
    values.ip_asc=0.00;
    values.ip=0.00
]
/ onblockbegin = [
    if (mod(values.blockcount,4)==1 || mod(values.blockcount,4)==3)
        values.ip_desc=0.00
]
/ onblockbegin = [
    if (mod(values.blockcount,4)==1)
        values.delay=list.delays.nextvalue
]
/ trials = [1-9=discounttrial4; 10=compute_ip4]
</block>
**************************************************************************************************************
**************************************************************************************************************
    Food 8 Discounting (Descending)
**************************************************************************************************************
**************************************************************************************************************
<block food8_desc>
/ onblockbegin = [
    values.object=values.foodchoice;
    values.blocktype="food8";
    values.ip_found=0
]
/ onblockbegin = [
    values.immediateresponsestreak=0;
    values.delayedresponsestreak=0
]
/ onblockbegin = [values.previousresponse=""]
/ onblockbegin = [
    values.blockcount+=1;
    values.trialcount=0
]
/ onblockbegin = [
    values.order="descending";
    values.ip_desc=0.00;
    values.ip=0.00
]
/ onblockbegin = [
    if (mod(values.blockcount,4)==1 || mod(values.blockcount,4)==3)
        values.ip_asc=0.00
]
/ onblockbegin = [
    if (mod(values.blockcount,4)==1)
        values.delay=list.delays.nextvalue
]
/ trials = [1-9=discounttrial8; 10=compute_ip8]
</block>


**************************************************************************************************************
**************************************************************************************************************
    Food 8 Discounting (Ascending)
**************************************************************************************************************
**************************************************************************************************************
<block food8_asc>
/ onblockbegin = [
    values.object=values.foodchoice;
    values.blocktype="food8";
    values.ip_found=0
]
/ onblockbegin = [
    values.immediateresponsestreak=0;
    values.delayedresponsestreak=0
]
/ onblockbegin = [values.previousresponse=""]
/ onblockbegin = [
    values.blockcount+=1;
    values.trialcount=0
]
/ onblockbegin = [
    values.order="ascending";
    values.ip_asc=0.00;
    values.ip=0.00
]
/ onblockbegin = [
    if (mod(values.blockcount,4)==1 || mod(values.blockcount,4)==3)
        values.ip_desc=0.00
]
/ onblockbegin = [
    if (mod(values.blockcount,4)==1)
        values.delay=list.delays.nextvalue
]
/ trials = [1-9=discounttrial8; 10=compute_ip8]
</block>

**************************************************************************************************************
**************************************************************************************************************
    Food 12 Discounting (Descending)
**************************************************************************************************************
**************************************************************************************************************
<block food12_desc>
/ onblockbegin = [
    values.object=values.foodchoice;
    values.blocktype="food12";
    values.ip_found=0
]
/ onblockbegin = [
    values.immediateresponsestreak=0;
    values.delayedresponsestreak=0
]
/ onblockbegin = [values.previousresponse=""]
/ onblockbegin = [
    values.blockcount+=1;
    values.trialcount=0
]
/ onblockbegin = [
    values.order="descending";
    values.ip_asc=0.00;
    values.ip=0.00
]
/ onblockbegin = [
    if (mod(values.blockcount,4)==1 || mod(values.blockcount,4)==3)
        values.ip_asc=0.00
]
/ onblockbegin = [
    if (mod(values.blockcount,4)==1)
        values.delay=list.delays.nextvalue
]
/ trials = [1-9=discounttrial12; 10=compute_ip12]
</block>


**************************************************************************************************************
**************************************************************************************************************
    Food 12 Discounting (Ascending)
**************************************************************************************************************
**************************************************************************************************************
<block food12_asc>
/ onblockbegin = [
    values.object=values.foodchoice;
    values.blocktype="food12";
    values.ip_found=0
]
/ onblockbegin = [
    values.immediateresponsestreak=0;
    values.delayedresponsestreak=0
]
/ onblockbegin = [values.previousresponse=""]
/ onblockbegin = [
    values.blockcount+=1;
    values.trialcount=0
]
/ onblockbegin = [
    values.order="ascending";
    values.ip_asc=0.00;
    values.ip=0.00
]
/ onblockbegin = [
    if (mod(values.blockcount,4)==1 || mod(values.blockcount,4)==3)
        values.ip_desc=0.00
]
/ onblockbegin = [
    if (mod(values.blockcount,4)==1)
        values.delay=list.delays.nextvalue
]
/ trials = [1-9=discounttrial12; 10=compute_ip12]
</block>

**************************************************************************************************************
**************************************************************************************************************
    Expt Elements
**************************************************************************************************************
**************************************************************************************************************
    Order: Food4(Descending), Food4(Ascending), Food8(Descending), Food8(Ascending), Food12(Descending), Food12(Ascending)
**************************************************************************************************************
**************************************************************************************************************
<expt>
/ preinstructions = (generalintro)
/ postinstructions = (generaloutro)
/ blocks = [1=foodchoice; 2-7=sequence(food4_desc, food4_asc, food8_desc, food8_asc, food12_desc, food12_asc)]
/ subjects = (1 of 6)
/ groupassignment = groupnumber
/ onexptend = [values.completed = 1]
</expt>

**************************************************************************************************************
**************************************************************************************************************
    Order: Food8(Descending), Food8(Ascending), Food4(Descending), Food4(Ascending), Food12(Descending), Food12(Ascending)
**************************************************************************************************************
**************************************************************************************************************
<expt>
/ preinstructions = (generalintro)
/ postinstructions = (generaloutro)
/ blocks = [1=foodchoice; 2-7=sequence(food8_desc, food8_asc, food4_desc, food4_asc, food12_desc, food12_asc)]
/ subjects = (2 of 6)
/ groupassignment = groupnumber
/ onexptend = [values.completed = 1]
</expt>

**************************************************************************************************************
**************************************************************************************************************
    Order: Food8(Descending), Food8(Ascending), Food12(Descending), Food12(Ascending), Food4(Descending), Food4(Ascending)
**************************************************************************************************************
**************************************************************************************************************
<expt>
/ preinstructions = (generalintro)
/ postinstructions = (generaloutro)
/ blocks = [1=foodchoice; 2-7=sequence(food8_desc, food8_asc, food12_desc, food12_asc, food4_desc, food4_asc)]
/ subjects = (3 of 6)
/ groupassignment = groupnumber
/ onexptend = [values.completed = 1]
</expt>

**************************************************************************************************************
**************************************************************************************************************
    Order: Food12(Descending), Food12(Ascending), Food8(Descending), Food8(Ascending), Food4(Descending), Food4(Ascending)
**************************************************************************************************************
**************************************************************************************************************
<expt>
/ preinstructions = (generalintro)
/ postinstructions = (generaloutro)
/ blocks = [1=foodchoice; 2-7=sequence(food12_desc, food12_asc, food8_desc, food8_asc, food4_desc, food4_asc)]
/ subjects = (4 of 6)
/ groupassignment = groupnumber
/ onexptend = [values.completed = 1]
</expt>

**************************************************************************************************************
**************************************************************************************************************
    Order: Food12(Descending), Food12(Ascending), Food4(Descending), Food4(Ascending), Food8(Descending), Food8(Ascending)
**************************************************************************************************************
**************************************************************************************************************
<expt>
/ preinstructions = (generalintro)
/ postinstructions = (generaloutro)
/ blocks = [1=foodchoice; 2-7=sequence(food12_desc, food12_asc, food4_desc, food4_asc, food8_desc, food8_asc)]
/ subjects = (5 of 6)
/ groupassignment = groupnumber
/ onexptend = [values.completed = 1]
</expt>


**************************************************************************************************************
**************************************************************************************************************
    Order: Food4(Descending), Food4(Ascending), Food12(Descending), Food12(Ascending), Food8(Descending), Food8(Ascending)
**************************************************************************************************************
**************************************************************************************************************
<expt>
/ preinstructions = (generalintro)
/ postinstructions = (generaloutro)
/ blocks = [1=foodchoice; 2-7=sequence(food4_desc, food4_asc, food12_desc, food12_asc, food8_desc, food8_asc)]
/ subjects = (6 of 6)
/ groupassignment = groupnumber
/ onexptend = [values.completed = 1]
</expt>



Any insight is appreciated! Thanks.

The code is incomplete and broken as a consequence. There are various references to <parameters> throughout it, yet no <parameters> element is present. This makes it impossible to answer your question adequately.

You can attach files to a post via +Insert -> Add file. It is generally not necessary to paste entire scripts encompassing hundreds or thousands of lines of code into a message's body. Apart from being error-prone, it makes posts hard to read and the code hard to work with. If you have questions about particular parts of the code, it is better to include only those parts in the message body to direct the reader's focus to what's important. Thanks.


Would the attached file provide more clarification?



Not really. Recall what I tried to explain in previous threads, such as https://www.millisecond.com/forums/Topic20125.aspx#bm20147

On that basis, you need to clarify the following: Do you want

Delay 1
food4_desc -> food4_asc
Delay 2
food4_desc -> food4_asc
Delay 3
food4_desc -> food4_asc
...
Delay 1
food8_desc -> food8_asc
Delay 2
food8_desc -> food8_asc
Delay 3
food8_desc -> food8_asc
...
Delay 1
food12_desc -> food12_asc
Delay 2
food12_desc -> food12_asc
Delay 3
food12_desc -> food12_asc
...

i.e., run through all the delay levels for 4 servings, then through all delay levels for 8 servings, then through all delay levels for 12 servings

OR

do you want

Delay 1
food4_desc -> food4_asc
food8_desc -> food8_asc
food12_desc -> food12_asc
Delay 2
food4_desc -> food4_asc
food8_desc -> food8_asc
food12_desc -> food12_asc
....

i.e., complete delay level 1 (30 minutes) for 4 servings, followed by delay level 1 for 8 servings, followed by delay level 1 for 12 servings
and then
delay level 2 for 4 servings, followed by delay level 2 for 8 servings, delay level 2 for 12 servings,
and so forth.

This difference is important.

Edited 9 Years Ago by Dave
sandy_d
sandy_d
Expert (1.3K reputation)Expert (1.3K reputation)Expert (1.3K reputation)Expert (1.3K reputation)Expert (1.3K reputation)Expert (1.3K reputation)Expert (1.3K reputation)Expert (1.3K reputation)Expert (1.3K reputation)
Group: Forum Members
Posts: 13, Visits: 58
Dave - Thursday, November 17, 2016
sandy_d - Thursday, November 17, 2016
Dave - Thursday, November 17, 2016
sandy_d - Thursday, November 17, 2016
Hello,

I'm trying to run a series of sequences within a delay block in the DDT Food and Money so that the left hand and right hand choice will have the same starting value at the right hand side at the beginning of each block time.  (ie: so the left hand side will display " 4 servings of grapes right now" and the right hand side will display "4 servings of grapes in 30 minutes").

My question is, how do I do it so that at the start of each of the delay blocks, the starting value of food is the same for the immediate (left) and for the delayed (right hand side).
Of the 3 possible food blocks I have, this is working correctly for the first two (which goes through the block of 4 servings of food followed with 7 time delays) .

My code so far is:

<data>
/ columns = (build, computer.platform, date,time,subject, group,
    values.blockcount,blocknum,blockcode,values.blocktype,values.order,
    values.trialcount,trialnum,trialcode,response,latency,
    values.delay,parameters.delayedreward_4, parameters.delayedreward_8, parameters.delayedreward_12,values.immediatereward,
    values.delayedresponsestreak,values.immediateresponsestreak,
    values.ip_desc,values.ip_asc,values.ip)
/ separatefiles = true
</data>


****************************
summary data file
****************************

<summarydata>
/ columns = (script.startdate, script.starttime, script.subjectid, script.groupid, script.elapsedtime, computer.platform, values.completed, parameters.delayedreward,
values.ip_delay1_F4, values.ip_delay2_F4, values.ip_delay3_F4, values.ip_delay4_F4, values.ip_delay5_F4, values.ip_delay6_F4, values.ip_delay7_F4,
values.ip_delay1_F8, values.ip_delay2_F8, values.ip_delay3_F8, values.ip_delay4_F8, values.ip_delay5_F8, values.ip_delay6_F8, values.ip_delay7_F8
values.ip_delay1_FF12, values.ip_delay2_F12, values.ip_delay3_F12, values.ip_delay4_F12, values.ip_delay5_F12, values.ip_delay6_F12, values.ip_delay7_F12)
/ separatefiles = true
</summarydata>


*****************************************************************************************************************
*****************************************************************************************************************
    Values: updated automatically on runtime of script
*****************************************************************************************************************
*****************************************************************************************************************
/ completed:                        0 = script was not completed; 1 = script was completed (all conditions run)
/ immediatereward:                    stores the current reward for the immediate response
/ order:                            stores direction of current reward adjustment ("ascending" or "descending")
/ delay:                            stores the current temporal delay
/ object:                            stores the object option of the block (1-4: selected food options)
/ foodchoice:                        stores the selected food option
/ ip_found:                            helper variable to determine indifference point (changes value if ip is found)
/ ip_asc:                            stores ip value for ascending blocks
/ ip_desc:                            stores ip value for descending blocks
/ ip:                                stores final ip value
/ blockcount:                        counts the blocks
/ trialcount:                        counts the trials
/ blocktype:                        stores the type of block "money" or "food"
/ previousresponse:                    stores the previous response
/ immediateresponsestreak:            counts the numbers of consecutive choices of immediate reward
/ delayedresponsestreak:            counts the numbers of consecutive choices of delayed reward

summary variables:
/ip_delay1_F4-
/ip_delay7_F12:                        the IPs for the 7 different delays for all food (F) blocks

<values>
/ completed = 0
/ immediatereward = 0.00
/ order = ""
/ delay = 0
/ object = 0
/ foodchoice = 0
/ ip_found = 0
/ ip_asc = 0.00
/ ip_desc = 0.00
/ ip = 0.00
/ blockcount = 0
/ trialcount = 0
/ blocktype = ""
/ previousresponse = ""
/ immediateresponsestreak = 0
/ delayedresponsestreak = 0

/ ip_delay1_F4 = 0
/ ip_delay2_F4 = 0
/ ip_delay3_F4 = 0
/ ip_delay4_F4 = 0
/ ip_delay5_F4 = 0
/ ip_delay6_F4 = 0
/ ip_delay7_F4 = 0


/ ip_delay1_F8 = 0
/ ip_delay2_F8 = 0
/ ip_delay3_F8 = 0
/ ip_delay4_F8 = 0
/ ip_delay5_F8 = 0
/ ip_delay6_F8 = 0
/ ip_delay7_F8 = 0


/ ip_delay1_F12 = 0
/ ip_delay2_F12 = 0
/ ip_delay3_F12 = 0
/ ip_delay4_F12 = 0
/ ip_delay5_F12 = 0
/ ip_delay6_F12 = 0
/ ip_delay7_F12 = 0
</values>

*****************************************************************************************************************
*****************************************************************************************************************
    Expressions
*****************************************************************************************************************
*****************************************************************************************************************
<expressions>
/ immediatereward = format("%.2f", values.immediatereward)
/ delayedreward_4 = format("%.2f", parameters.delayedreward_4)
/ immediatereward = format("%.2f", values.immediatereward)
/ delayedreward_8 = format("%.2f", parameters.delayedreward_8)
/ immediatereward = format("%.2f", values.immediatereward)
/ delayedreward_12 = format("%.2f", parameters.delayedreward_12)
/ ip_asc = format("%.2f", values.ip_asc)
/ ip_desc = format("%.2f", values.ip_desc)
/ ip = format("%.2f", values.ip)
/ objectdescription = getitem(item.objectdescriptions, values.object)
</expressions>

*****************************************************************************************************************
*****************************************************************************************************************
    List Elements
*****************************************************************************************************************
*****************************************************************************************************************
    Delay Periods (7)
*****************************************************************************************************************
*****************************************************************************************************************
<list delays>
/ items = (parameters.delay1, parameters.delay2, parameters.delay3, parameters.delay4, parameters.delay5, parameters.delay6, parameters.delay7) 
/ selectionmode = sequence
/ selectionrate = block
/ resetinterval = 0
</list>

*****************************************************************************************************************
*****************************************************************************************************************
    Immediate Rewards (9 -- Descending Order)
*****************************************************************************************************************
*****************************************************************************************************************
<list immediaterewards4_desc>
/ items = (4.0, 3.5, 3.0, 2.5, 2.0, 1.5, 1.0, 0.5, 0.0)
/ selectionmode = sequence
/ selectionmode = sequence
/ selectionrate = trial
</list>

<list immediaterewards8_desc>
/ items = (8.0, 7.0, 6.0, 5.0, 4.0, 3.0, 2.0, 1.0, 0.0)
/ selectionmode = sequence
/ selectionmode = sequence
/ selectionrate = trial
</list>

<list immediaterewards12_desc>
/ items = (12.0, 10.0, 8.0, 7.0, 6.0, 4.0, 2.0, 1.0, 0.0)
/ selectionmode = sequence
/ selectionmode = sequence
/ selectionrate = trial
</list>

*****************************************************************************************************************
*****************************************************************************************************************
    Immediate Rewards (9 -- Ascending Order)
*****************************************************************************************************************
*****************************************************************************************************************
<list immediaterewards4_asc>
/ items = (0.0, 0.5, 1.0, 1.5, 2.0, 2.5, 3.0, 3.5, 4.0)
/ selectionmode = sequence
/ selectionrate = trial
</list>

<list immediaterewards8_asc>
/ items = (0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0)
/ selectionmode = sequence
/ selectionrate = trial
</list>

<list immediaterewards12_asc>
/ items = (0.0, 1.0, 2.0, 4.0, 6.0, 7.0, 8.0, 10.0, 12.0)
/ selectionmode = sequence
/ selectionrate = trial
</list>


*****************************************************************************************************************
*****************************************************************************************************************
    Stimulus Elements
*****************************************************************************************************************
*****************************************************************************************************************
    For DDT Trial
*****************************************************************************************************************
*****************************************************************************************************************
<text question_4>
/ items = question_4
/ select = 1
/ erase = false
/ position = (50%, 50%)
</text>


<text or>
/ items = question_4
/ select = 3
/ erase = false
/ position = (50%, 65%)
</text>

<text immediate>
/ items = question_4
/ select = 2
/ txbgcolor = grey
/ vjustify = center
/ size = (20%, 20%)
/ position = (30%, 65%)
</text>

<text delayed_4>
/ items = question_4
/ select = 4
/ txbgcolor = grey
/ vjustify = center
/ size = (20%, 20%)
/ position = (70%, 65%)
</text>

<text question_8>
/ items = question_8
/ select = 1
/ erase = false
/ position = (50%, 50%)
</text>


<text delayed_8>
/ items = question_8
/ select = 4
/ txbgcolor = grey
/ vjustify = center
/ size = (20%, 20%)
/ position = (70%, 65%)
</text>

<text question_12>
/ items = question_12
/ select = 1
/ erase = false
/ position = (50%, 50%)
</text>

<text delayed_12>
/ items = question_12
/ select = 4
/ txbgcolor = grey
/ vjustify = center
/ size = (20%, 20%)
/ position = (70%, 65%)
</text>

<picture objectpic>
/ items = objectpicitems
/ select = values.object
/ position = (50%, 25%)
/ erase = false
</picture>


**************************************************************************************************************
**************************************************************************************************************
    Debug Stuff
**************************************************************************************************************
**************************************************************************************************************
<text debug>
/ items = ("Block = <%values.blockcount%> | Blocktype = <%values.blocktype%> | Order = <%values.order%> | IP_Desc = <%expressions.ip_desc%> | IP_Asc = <%expressions.ip_asc%> | IP = <%expressions.ip%>
Delayedstreak = <%values.delayedresponsestreak%> | Immediatestreak = <%values.immediateresponsestreak%>")
/ fontstyle = ("Arial", 2.00%)
/ erase = false
/ position = (50%, 5%)
/ size = (90%, 5%)
</text>

*****************************************************************************************************************
*****************************************************************************************************************
    For Food Pick Trial
*****************************************************************************************************************
*****************************************************************************************************************
<text foodcaption>
/ items = foodcaptions
/ select = 1
/ position = (50%, 10%)
</text>

<picture foodapic>
/ items = foodpics
/ select = 1
/ position = (30%, 30%)
</picture>

<picture foodbpic>
/ items = foodpics
/ select = 2
/ position = (70%, 30%)
</picture>

<picture foodcpic>
/ items = foodpics
/ select = 3
/ position = (30%, 70%)
</picture>

<picture fooddpic>
/ items = foodpics
/ select = 4
/ position = (70%, 70%)
</picture>

<text foodatxt>
/ items = foodcaptions
/ select = 2
/ position = (30%, 50%)
</text>

<text foodbtxt>
/ items = foodcaptions
/ select = 3
/ position = (70%, 50%)
</text>

<text foodctxt>
/ items = foodcaptions
/ select = 4
/ position = (30%, 90%)
</text>

<text fooddtxt>
/ items = foodcaptions
/ select = 5
/ position = (70%, 90%)
</text>
**************************************************************************************************************
**************************************************************************************************************
    Trial Elements
**************************************************************************************************************
**************************************************************************************************************
    DDT Choice Trial
**************************************************************************************************************
**************************************************************************************************************
<trial discounttrial4>
/ pretrialpause = parameters.pretrialdelay
/ posttrialpause = parameters.posttrialdelay
/ ontrialbegin = [values.trialcount+=1]
/ ontrialbegin = [if (values.trialcount==1)
        values.previousresponse="" else
        values.previousresponse=trial.discounttrial4.response]
/ ontrialbegin = [if (values.order=="descending")
        values.immediatereward=list.immediaterewards4_desc.nextvalue]
/ ontrialbegin = [if (values.order=="ascending")
        values.immediatereward=list.immediaterewards4_asc.nextvalue]

/ stimulusframes = [1=objectpic, question_4, or, immediate, delayed_4]
/ validresponse = (immediate, delayed_4)

/ ontrialend = [if (values.previousresponse=="immediate" && trial.discounttrial4.response=="immediate")
        values.immediateresponsestreak+=1 else
        values.immediateresponsestreak=0]
/ ontrialend = [if (values.previousresponse=="delayed" && trial.discounttrial4.response=="delayed")
        values.delayedresponsestreak+=1 else
        values.delayedresponsestreak=0]
/ ontrialend = [if (values.order=="descending" && values.ip_found==0 && values.delayedresponsestreak==1) {
        values.ip_desc=values.immediatereward; values.ip_found=1}]
/ ontrialend = [
    if (values.order=="ascending" && values.ip_found==0 && values.immediateresponsestreak==1) {
        values.ip_asc=values.immediatereward; values.ip_found=1}]

</trial>

<trial discounttrial8>
/ pretrialpause = parameters.pretrialdelay
/ posttrialpause = parameters.posttrialdelay
/ ontrialbegin = [values.trialcount+=1]
/ ontrialbegin = [if (values.trialcount==1)
        values.previousresponse="" else
        values.previousresponse=trial.discounttrial8.response]
/ ontrialbegin = [if (values.order=="descending")
        values.immediatereward=list.immediaterewards8_desc.nextvalue]
/ ontrialbegin = [if (values.order=="ascending")
        values.immediatereward=list.immediaterewards8_asc.nextvalue]

/ stimulusframes = [1=objectpic, question_8, or, immediate, delayed_8]
/ validresponse = (immediate, delayed_8)

/ ontrialend = [if (values.previousresponse=="immediate" && trial.discounttrial8.response=="immediate")
        values.immediateresponsestreak+=1 else
        values.immediateresponsestreak=0]
/ ontrialend = [if (values.previousresponse=="delayed" && trial.discounttrial8.response=="delayed")
        values.delayedresponsestreak+=1 else
        values.delayedresponsestreak=0]
/ ontrialend = [if (values.order=="descending" && values.ip_found==0 && values.delayedresponsestreak==1) {
        values.ip_desc=values.immediatereward; values.ip_found=1}]
/ ontrialend = [
    if (values.order=="ascending" && values.ip_found==0 && values.immediateresponsestreak==1) {
        values.ip_asc=values.immediatereward; values.ip_found=1}]

</trial>

<trial discounttrial12>
/ pretrialpause = parameters.pretrialdelay
/ posttrialpause = parameters.posttrialdelay
/ ontrialbegin = [values.trialcount+=1]
/ ontrialbegin = [if (values.trialcount==1)
        values.previousresponse="" else
        values.previousresponse=trial.discounttrial12.response]
/ ontrialbegin = [if (values.order=="descending")
        values.immediatereward=list.immediaterewards12_desc.nextvalue]
/ ontrialbegin = [if (values.order=="ascending")
        values.immediatereward=list.immediaterewards12_asc.nextvalue]

/ stimulusframes = [1=objectpic, question_12, or, immediate, delayed_12]
/ validresponse = (immediate, delayed_12)

/ ontrialend = [if (values.previousresponse=="immediate" && trial.discounttrial12.response=="immediate")
        values.immediateresponsestreak+=1 else
        values.immediateresponsestreak=0]
/ ontrialend = [if (values.previousresponse=="delayed" && trial.discounttrial12.response=="delayed")
        values.delayedresponsestreak+=1 else
        values.delayedresponsestreak=0]
/ ontrialend = [if (values.order=="descending" && values.ip_found==0 && values.delayedresponsestreak==1) {
        values.ip_desc=values.immediatereward; values.ip_found=1}]
/ ontrialend = [
    if (values.order=="ascending" && values.ip_found==0 && values.immediateresponsestreak==1) {
        values.ip_asc=values.immediatereward; values.ip_found=1}]

</trial>


**************************************************************************************************************
**************************************************************************************************************
    Compute Indifference Point
**************************************************************************************************************
**************************************************************************************************************
<trial compute_ip4>
/ ontrialbegin = [
    if (values.order=="descending" && values.ip_found==0)
        values.ip_desc=values.immediatereward
]
/ ontrialbegin = [
    if (values.order=="ascending" && values.ip_found==0)
        values.ip_asc=parameters.delayedreward_4
]
/ ontrialbegin = [
    if (values.ip_desc!=0.00 && values.ip_asc!=0.00)
        values.ip=(values.ip_desc+values.ip_asc)*0.5
]
   
/ ontrialbegin = [
    if (values.ip != 0 && values.blocktype == "food4" && values.delay == parameters.delay1) {
        values.ip_delay1_F4 = values.ip
    }
]
/ ontrialbegin = [
    if (values.ip != 0 && values.blocktype == "food4" && values.delay == parameters.delay2) {
        values.ip_delay2_F4 = values.ip
    }
]
/ ontrialbegin = [
    if (values.ip != 0 && values.blocktype == "food4" && values.delay == parameters.delay3) {
        values.ip_delay3_F4 = values.ip
    }
]
/ ontrialbegin = [
    if (values.ip != 0 && values.blocktype == "food4" && values.delay == parameters.delay4) {
        values.ip_delay4_F4 = values.ip
    }
]
/ ontrialbegin = [
    if (values.ip != 0 && values.blocktype == "food4" && values.delay == parameters.delay5) {
        values.ip_delay5_F4 = values.ip
    }
]
/ ontrialbegin = [
    if (values.ip != 0 && values.blocktype == "food4" && values.delay == parameters.delay6) {
        values.ip_delay6_F4 = values.ip
    }
]
/ ontrialbegin = [
    if (values.ip != 0 && values.blocktype == "food4" && values.delay == parameters.delay7) {
        values.ip_delay7_F4 = values.ip
    }
]



/ validresponse = (noresponse)
/ trialduration = 0
</trial>

<trial compute_ip8>
/ ontrialbegin = [
    if (values.order=="descending" && values.ip_found==0)
        values.ip_desc=values.immediatereward
]
/ ontrialbegin = [
    if (values.order=="ascending" && values.ip_found==0)
        values.ip_asc=parameters.delayedreward_8
]
/ ontrialbegin = [
    if (values.ip_desc!=0.00 && values.ip_asc!=0.00)
        values.ip=(values.ip_desc+values.ip_asc)*0.5
]
   
/ ontrialbegin = [
    if (values.ip != 0 && values.blocktype == "food8" && values.delay == parameters.delay1) {
        values.ip_delay1_F8 = values.ip
    }
]
/ ontrialbegin = [
    if (values.ip != 0 && values.blocktype == "food8" && values.delay == parameters.delay2) {
        values.ip_delay2_F8 = values.ip
    }
]
/ ontrialbegin = [
    if (values.ip != 0 && values.blocktype == "food8" && values.delay == parameters.delay3) {
        values.ip_delay3_F8 = values.ip
    }
]
/ ontrialbegin = [
    if (values.ip != 0 && values.blocktype == "food8" && values.delay == parameters.delay4) {
        values.ip_delay4_F8 = values.ip
    }
]
/ ontrialbegin = [
    if (values.ip != 0 && values.blocktype == "food8" && values.delay == parameters.delay5) {
        values.ip_delay5_F8 = values.ip
    }
]
/ ontrialbegin = [
    if (values.ip != 0 && values.blocktype == "food8" && values.delay == parameters.delay6) {
        values.ip_delay6_F8 = values.ip
    }
]
/ ontrialbegin = [
    if (values.ip != 0 && values.blocktype == "food8" && values.delay == parameters.delay7) {
        values.ip_delay7_F8 = values.ip
    }
]

/ validresponse = (noresponse)
/ trialduration = 0
</trial>       

<trial compute_ip12>
/ ontrialbegin = [
    if (values.order=="descending" && values.ip_found==0)
        values.ip_desc=values.immediatereward
]
/ ontrialbegin = [
    if (values.order=="ascending" && values.ip_found==0)
        values.ip_asc=parameters.delayedreward_12
]
/ ontrialbegin = [
    if (values.ip_desc!=0.00 && values.ip_asc!=0.00)
        values.ip=(values.ip_desc+values.ip_asc)*0.5
]
   
/ ontrialbegin = [
    if (values.ip != 0 && values.blocktype == "food12" && values.delay == parameters.delay1) {
        values.ip_delay1_F12 = values.ip
    }
]
/ ontrialbegin = [
    if (values.ip != 0 && values.blocktype == "food12" && values.delay == parameters.delay2) {
        values.ip_delay2_F12 = values.ip
    }
]
/ ontrialbegin = [
    if (values.ip != 0 && values.blocktype == "food12" && values.delay == parameters.delay3) {
        values.ip_delay3_F12 = values.ip
    }
]
/ ontrialbegin = [
    if (values.ip != 0 && values.blocktype == "food12" && values.delay == parameters.delay4) {
        values.ip_delay4_F12 = values.ip
    }
]
/ ontrialbegin = [
    if (values.ip != 0 && values.blocktype == "food12" && values.delay == parameters.delay5) {
        values.ip_delay5_F12 = values.ip
    }
]
/ ontrialbegin = [
    if (values.ip != 0 && values.blocktype == "food12" && values.delay == parameters.delay6) {
        values.ip_delay6_F12 = values.ip
    }
]
/ ontrialbegin = [
    if (values.ip != 0 && values.blocktype == "food12" && values.delay == parameters.delay7) {
        values.ip_delay7_F12 = values.ip
    }
]

/ validresponse = (noresponse)
/ trialduration = 0
</trial>
**************************************************************************************************************
**************************************************************************************************************
    Preferred Food Trial
**************************************************************************************************************
**************************************************************************************************************
<trial foodchoice>
/ stimulusframes = [1=foodcaption, foodapic, foodbpic, foodcpic, fooddpic, foodatxt, foodbtxt, foodctxt, fooddtxt]
/ validresponse = (foodapic, foodbpic, foodcpic, fooddpic)
/ ontrialend = [
    if (trial.foodchoice.response=="foodapic")
        values.foodchoice=1
]
/ ontrialend = [
    if (trial.foodchoice.response=="foodbpic")
        values.foodchoice=2
]
/ ontrialend = [
    if (trial.foodchoice.response=="foodcpic")
        values.foodchoice=3
]
/ ontrialend = [
    if (trial.foodchoice.response=="fooddpic")
        values.foodchoice=4
]
</trial>

**************************************************************************************************************
**************************************************************************************************************
    Block Elements
**************************************************************************************************************
**************************************************************************************************************
    Food Preference Block
**************************************************************************************************************
**************************************************************************************************************
<block foodchoice>
/ preinstructions = (foodintro)
/ postinstructions = (foodoutro)
/ trials = [1=foodchoice]
</block>

**************************************************************************************************************
**************************************************************************************************************
    DDT Blocks
**************************************************************************************************************
**************************************************************************************************************
    Food 4 Discounting (Descending)
**************************************************************************************************************
**************************************************************************************************************
<block food4_desc>
/ onblockbegin = [
    values.object=values.foodchoice;
    values.blocktype="food4";
    values.ip_found=0
]
/ onblockbegin = [
    values.immediateresponsestreak=0;
    values.delayedresponsestreak=0
]
/ onblockbegin = [values.previousresponse=""]
/ onblockbegin = [
    values.blockcount+=1;
    values.trialcount=0
]
/ onblockbegin = [
    values.order="descending";
    values.ip_desc=0.00;
    values.ip=0.00
]
/ onblockbegin = [
    if (mod(values.blockcount,4)==1 || mod(values.blockcount,4)==3)
        values.ip_asc=0.00
]
/ onblockbegin = [
    if (mod(values.blockcount,4)==1)
        values.delay=list.delays.nextvalue
]
/ trials = [1-9=discounttrial4; 10=compute_ip4]
</block>


**************************************************************************************************************
**************************************************************************************************************
    Food 4 Discounting (Ascending)
**************************************************************************************************************
**************************************************************************************************************
<block food4_asc>
/ onblockbegin = [
    values.object=values.foodchoice;
    values.blocktype="food4";
    values.ip_found=0
]
/ onblockbegin = [
    values.immediateresponsestreak=0;
    values.delayedresponsestreak=0
]
/ onblockbegin = [values.previousresponse=""]
/ onblockbegin = [
    values.blockcount+=1;
    values.trialcount=0
]
/ onblockbegin = [
    values.order="ascending";
    values.ip_asc=0.00;
    values.ip=0.00
]
/ onblockbegin = [
    if (mod(values.blockcount,4)==1 || mod(values.blockcount,4)==3)
        values.ip_desc=0.00
]
/ onblockbegin = [
    if (mod(values.blockcount,4)==1)
        values.delay=list.delays.nextvalue
]
/ trials = [1-9=discounttrial4; 10=compute_ip4]
</block>
**************************************************************************************************************
**************************************************************************************************************
    Food 8 Discounting (Descending)
**************************************************************************************************************
**************************************************************************************************************
<block food8_desc>
/ onblockbegin = [
    values.object=values.foodchoice;
    values.blocktype="food8";
    values.ip_found=0
]
/ onblockbegin = [
    values.immediateresponsestreak=0;
    values.delayedresponsestreak=0
]
/ onblockbegin = [values.previousresponse=""]
/ onblockbegin = [
    values.blockcount+=1;
    values.trialcount=0
]
/ onblockbegin = [
    values.order="descending";
    values.ip_desc=0.00;
    values.ip=0.00
]
/ onblockbegin = [
    if (mod(values.blockcount,4)==1 || mod(values.blockcount,4)==3)
        values.ip_asc=0.00
]
/ onblockbegin = [
    if (mod(values.blockcount,4)==1)
        values.delay=list.delays.nextvalue
]
/ trials = [1-9=discounttrial8; 10=compute_ip8]
</block>


**************************************************************************************************************
**************************************************************************************************************
    Food 8 Discounting (Ascending)
**************************************************************************************************************
**************************************************************************************************************
<block food8_asc>
/ onblockbegin = [
    values.object=values.foodchoice;
    values.blocktype="food8";
    values.ip_found=0
]
/ onblockbegin = [
    values.immediateresponsestreak=0;
    values.delayedresponsestreak=0
]
/ onblockbegin = [values.previousresponse=""]
/ onblockbegin = [
    values.blockcount+=1;
    values.trialcount=0
]
/ onblockbegin = [
    values.order="ascending";
    values.ip_asc=0.00;
    values.ip=0.00
]
/ onblockbegin = [
    if (mod(values.blockcount,4)==1 || mod(values.blockcount,4)==3)
        values.ip_desc=0.00
]
/ onblockbegin = [
    if (mod(values.blockcount,4)==1)
        values.delay=list.delays.nextvalue
]
/ trials = [1-9=discounttrial8; 10=compute_ip8]
</block>

**************************************************************************************************************
**************************************************************************************************************
    Food 12 Discounting (Descending)
**************************************************************************************************************
**************************************************************************************************************
<block food12_desc>
/ onblockbegin = [
    values.object=values.foodchoice;
    values.blocktype="food12";
    values.ip_found=0
]
/ onblockbegin = [
    values.immediateresponsestreak=0;
    values.delayedresponsestreak=0
]
/ onblockbegin = [values.previousresponse=""]
/ onblockbegin = [
    values.blockcount+=1;
    values.trialcount=0
]
/ onblockbegin = [
    values.order="descending";
    values.ip_asc=0.00;
    values.ip=0.00
]
/ onblockbegin = [
    if (mod(values.blockcount,4)==1 || mod(values.blockcount,4)==3)
        values.ip_asc=0.00
]
/ onblockbegin = [
    if (mod(values.blockcount,4)==1)
        values.delay=list.delays.nextvalue
]
/ trials = [1-9=discounttrial12; 10=compute_ip12]
</block>


**************************************************************************************************************
**************************************************************************************************************
    Food 12 Discounting (Ascending)
**************************************************************************************************************
**************************************************************************************************************
<block food12_asc>
/ onblockbegin = [
    values.object=values.foodchoice;
    values.blocktype="food12";
    values.ip_found=0
]
/ onblockbegin = [
    values.immediateresponsestreak=0;
    values.delayedresponsestreak=0
]
/ onblockbegin = [values.previousresponse=""]
/ onblockbegin = [
    values.blockcount+=1;
    values.trialcount=0
]
/ onblockbegin = [
    values.order="ascending";
    values.ip_asc=0.00;
    values.ip=0.00
]
/ onblockbegin = [
    if (mod(values.blockcount,4)==1 || mod(values.blockcount,4)==3)
        values.ip_desc=0.00
]
/ onblockbegin = [
    if (mod(values.blockcount,4)==1)
        values.delay=list.delays.nextvalue
]
/ trials = [1-9=discounttrial12; 10=compute_ip12]
</block>

**************************************************************************************************************
**************************************************************************************************************
    Expt Elements
**************************************************************************************************************
**************************************************************************************************************
    Order: Food4(Descending), Food4(Ascending), Food8(Descending), Food8(Ascending), Food12(Descending), Food12(Ascending)
**************************************************************************************************************
**************************************************************************************************************
<expt>
/ preinstructions = (generalintro)
/ postinstructions = (generaloutro)
/ blocks = [1=foodchoice; 2-7=sequence(food4_desc, food4_asc, food8_desc, food8_asc, food12_desc, food12_asc)]
/ subjects = (1 of 6)
/ groupassignment = groupnumber
/ onexptend = [values.completed = 1]
</expt>

**************************************************************************************************************
**************************************************************************************************************
    Order: Food8(Descending), Food8(Ascending), Food4(Descending), Food4(Ascending), Food12(Descending), Food12(Ascending)
**************************************************************************************************************
**************************************************************************************************************
<expt>
/ preinstructions = (generalintro)
/ postinstructions = (generaloutro)
/ blocks = [1=foodchoice; 2-7=sequence(food8_desc, food8_asc, food4_desc, food4_asc, food12_desc, food12_asc)]
/ subjects = (2 of 6)
/ groupassignment = groupnumber
/ onexptend = [values.completed = 1]
</expt>

**************************************************************************************************************
**************************************************************************************************************
    Order: Food8(Descending), Food8(Ascending), Food12(Descending), Food12(Ascending), Food4(Descending), Food4(Ascending)
**************************************************************************************************************
**************************************************************************************************************
<expt>
/ preinstructions = (generalintro)
/ postinstructions = (generaloutro)
/ blocks = [1=foodchoice; 2-7=sequence(food8_desc, food8_asc, food12_desc, food12_asc, food4_desc, food4_asc)]
/ subjects = (3 of 6)
/ groupassignment = groupnumber
/ onexptend = [values.completed = 1]
</expt>

**************************************************************************************************************
**************************************************************************************************************
    Order: Food12(Descending), Food12(Ascending), Food8(Descending), Food8(Ascending), Food4(Descending), Food4(Ascending)
**************************************************************************************************************
**************************************************************************************************************
<expt>
/ preinstructions = (generalintro)
/ postinstructions = (generaloutro)
/ blocks = [1=foodchoice; 2-7=sequence(food12_desc, food12_asc, food8_desc, food8_asc, food4_desc, food4_asc)]
/ subjects = (4 of 6)
/ groupassignment = groupnumber
/ onexptend = [values.completed = 1]
</expt>

**************************************************************************************************************
**************************************************************************************************************
    Order: Food12(Descending), Food12(Ascending), Food4(Descending), Food4(Ascending), Food8(Descending), Food8(Ascending)
**************************************************************************************************************
**************************************************************************************************************
<expt>
/ preinstructions = (generalintro)
/ postinstructions = (generaloutro)
/ blocks = [1=foodchoice; 2-7=sequence(food12_desc, food12_asc, food4_desc, food4_asc, food8_desc, food8_asc)]
/ subjects = (5 of 6)
/ groupassignment = groupnumber
/ onexptend = [values.completed = 1]
</expt>


**************************************************************************************************************
**************************************************************************************************************
    Order: Food4(Descending), Food4(Ascending), Food12(Descending), Food12(Ascending), Food8(Descending), Food8(Ascending)
**************************************************************************************************************
**************************************************************************************************************
<expt>
/ preinstructions = (generalintro)
/ postinstructions = (generaloutro)
/ blocks = [1=foodchoice; 2-7=sequence(food4_desc, food4_asc, food12_desc, food12_asc, food8_desc, food8_asc)]
/ subjects = (6 of 6)
/ groupassignment = groupnumber
/ onexptend = [values.completed = 1]
</expt>



Any insight is appreciated! Thanks.

The code is incomplete and broken as a consequence. There are various references to <parameters> throughout it, yet no <parameters> element is present. This makes it impossible to answer your question adequately.

You can attach files to a post via +Insert -> Add file. It is generally not necessary to paste entire scripts encompassing hundreds or thousands of lines of code into a message's body. Apart from being error-prone, it makes posts hard to read and the code hard to work with. If you have questions about particular parts of the code, it is better to include only those parts in the message body to direct the reader's focus to what's important. Thanks.


Would the attached file provide more clarification?



Not really. Recall what I tried to explain in previous threads, such as https://www.millisecond.com/forums/Topic20125.aspx#bm20147

On that basis, you need to clarify the following: Do you want

Delay 1
food4_desc -> food4_asc
Delay 2
food4_desc -> food4_asc
Delay 3
food4_desc -> food4_asc
...
Delay 1
food8_desc -> food8_asc
Delay 2
food8_desc -> food8_asc
Delay 3
food8_desc -> food8_asc
...
Delay 1
food12_desc -> food12_asc
Delay 2
food12_desc -> food12_asc
Delay 3
food12_desc -> food12_asc
...

i.e., run through all the delay levels for 4 servings, then through all delay levels for 8 servings, then through all delay levels for 12 servings

OR

do you want

Delay 1
food4_desc -> food4_asc
food8_desc -> food8_asc
food12_desc -> food12_asc
Delay 2
food4_desc -> food4_asc
food8_desc -> food8_asc
food12_desc -> food12_asc
....

i.e., complete delay level 1 (30 minutes) for 4 servings, followed by delay level 1 for 8 servings, followed by delay level 1 for 12 servings
and then
delay level 2 for 4 servings, followed by delay level 2 for 8 servings, delay level 2 for 12 servings,
and so forth.

This difference is important.

I'm trying to have it so that  all the delays for the 4 servings run, then all the delays for the 8 servings, then all the delays for the 12 servings.


Dave
Dave
Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)
Group: Administrators
Posts: 13K, Visits: 105K
sandy_d - Thursday, November 17, 2016
Dave - Thursday, November 17, 2016
sandy_d - Thursday, November 17, 2016
Dave - Thursday, November 17, 2016
sandy_d - Thursday, November 17, 2016
Hello,

I'm trying to run a series of sequences within a delay block in the DDT Food and Money so that the left hand and right hand choice will have the same starting value at the right hand side at the beginning of each block time.  (ie: so the left hand side will display " 4 servings of grapes right now" and the right hand side will display "4 servings of grapes in 30 minutes").

My question is, how do I do it so that at the start of each of the delay blocks, the starting value of food is the same for the immediate (left) and for the delayed (right hand side).
Of the 3 possible food blocks I have, this is working correctly for the first two (which goes through the block of 4 servings of food followed with 7 time delays) .

My code so far is:

<data>
/ columns = (build, computer.platform, date,time,subject, group,
    values.blockcount,blocknum,blockcode,values.blocktype,values.order,
    values.trialcount,trialnum,trialcode,response,latency,
    values.delay,parameters.delayedreward_4, parameters.delayedreward_8, parameters.delayedreward_12,values.immediatereward,
    values.delayedresponsestreak,values.immediateresponsestreak,
    values.ip_desc,values.ip_asc,values.ip)
/ separatefiles = true
</data>


****************************
summary data file
****************************

<summarydata>
/ columns = (script.startdate, script.starttime, script.subjectid, script.groupid, script.elapsedtime, computer.platform, values.completed, parameters.delayedreward,
values.ip_delay1_F4, values.ip_delay2_F4, values.ip_delay3_F4, values.ip_delay4_F4, values.ip_delay5_F4, values.ip_delay6_F4, values.ip_delay7_F4,
values.ip_delay1_F8, values.ip_delay2_F8, values.ip_delay3_F8, values.ip_delay4_F8, values.ip_delay5_F8, values.ip_delay6_F8, values.ip_delay7_F8
values.ip_delay1_FF12, values.ip_delay2_F12, values.ip_delay3_F12, values.ip_delay4_F12, values.ip_delay5_F12, values.ip_delay6_F12, values.ip_delay7_F12)
/ separatefiles = true
</summarydata>


*****************************************************************************************************************
*****************************************************************************************************************
    Values: updated automatically on runtime of script
*****************************************************************************************************************
*****************************************************************************************************************
/ completed:                        0 = script was not completed; 1 = script was completed (all conditions run)
/ immediatereward:                    stores the current reward for the immediate response
/ order:                            stores direction of current reward adjustment ("ascending" or "descending")
/ delay:                            stores the current temporal delay
/ object:                            stores the object option of the block (1-4: selected food options)
/ foodchoice:                        stores the selected food option
/ ip_found:                            helper variable to determine indifference point (changes value if ip is found)
/ ip_asc:                            stores ip value for ascending blocks
/ ip_desc:                            stores ip value for descending blocks
/ ip:                                stores final ip value
/ blockcount:                        counts the blocks
/ trialcount:                        counts the trials
/ blocktype:                        stores the type of block "money" or "food"
/ previousresponse:                    stores the previous response
/ immediateresponsestreak:            counts the numbers of consecutive choices of immediate reward
/ delayedresponsestreak:            counts the numbers of consecutive choices of delayed reward

summary variables:
/ip_delay1_F4-
/ip_delay7_F12:                        the IPs for the 7 different delays for all food (F) blocks

<values>
/ completed = 0
/ immediatereward = 0.00
/ order = ""
/ delay = 0
/ object = 0
/ foodchoice = 0
/ ip_found = 0
/ ip_asc = 0.00
/ ip_desc = 0.00
/ ip = 0.00
/ blockcount = 0
/ trialcount = 0
/ blocktype = ""
/ previousresponse = ""
/ immediateresponsestreak = 0
/ delayedresponsestreak = 0

/ ip_delay1_F4 = 0
/ ip_delay2_F4 = 0
/ ip_delay3_F4 = 0
/ ip_delay4_F4 = 0
/ ip_delay5_F4 = 0
/ ip_delay6_F4 = 0
/ ip_delay7_F4 = 0


/ ip_delay1_F8 = 0
/ ip_delay2_F8 = 0
/ ip_delay3_F8 = 0
/ ip_delay4_F8 = 0
/ ip_delay5_F8 = 0
/ ip_delay6_F8 = 0
/ ip_delay7_F8 = 0


/ ip_delay1_F12 = 0
/ ip_delay2_F12 = 0
/ ip_delay3_F12 = 0
/ ip_delay4_F12 = 0
/ ip_delay5_F12 = 0
/ ip_delay6_F12 = 0
/ ip_delay7_F12 = 0
</values>

*****************************************************************************************************************
*****************************************************************************************************************
    Expressions
*****************************************************************************************************************
*****************************************************************************************************************
<expressions>
/ immediatereward = format("%.2f", values.immediatereward)
/ delayedreward_4 = format("%.2f", parameters.delayedreward_4)
/ immediatereward = format("%.2f", values.immediatereward)
/ delayedreward_8 = format("%.2f", parameters.delayedreward_8)
/ immediatereward = format("%.2f", values.immediatereward)
/ delayedreward_12 = format("%.2f", parameters.delayedreward_12)
/ ip_asc = format("%.2f", values.ip_asc)
/ ip_desc = format("%.2f", values.ip_desc)
/ ip = format("%.2f", values.ip)
/ objectdescription = getitem(item.objectdescriptions, values.object)
</expressions>

*****************************************************************************************************************
*****************************************************************************************************************
    List Elements
*****************************************************************************************************************
*****************************************************************************************************************
    Delay Periods (7)
*****************************************************************************************************************
*****************************************************************************************************************
<list delays>
/ items = (parameters.delay1, parameters.delay2, parameters.delay3, parameters.delay4, parameters.delay5, parameters.delay6, parameters.delay7) 
/ selectionmode = sequence
/ selectionrate = block
/ resetinterval = 0
</list>

*****************************************************************************************************************
*****************************************************************************************************************
    Immediate Rewards (9 -- Descending Order)
*****************************************************************************************************************
*****************************************************************************************************************
<list immediaterewards4_desc>
/ items = (4.0, 3.5, 3.0, 2.5, 2.0, 1.5, 1.0, 0.5, 0.0)
/ selectionmode = sequence
/ selectionmode = sequence
/ selectionrate = trial
</list>

<list immediaterewards8_desc>
/ items = (8.0, 7.0, 6.0, 5.0, 4.0, 3.0, 2.0, 1.0, 0.0)
/ selectionmode = sequence
/ selectionmode = sequence
/ selectionrate = trial
</list>

<list immediaterewards12_desc>
/ items = (12.0, 10.0, 8.0, 7.0, 6.0, 4.0, 2.0, 1.0, 0.0)
/ selectionmode = sequence
/ selectionmode = sequence
/ selectionrate = trial
</list>

*****************************************************************************************************************
*****************************************************************************************************************
    Immediate Rewards (9 -- Ascending Order)
*****************************************************************************************************************
*****************************************************************************************************************
<list immediaterewards4_asc>
/ items = (0.0, 0.5, 1.0, 1.5, 2.0, 2.5, 3.0, 3.5, 4.0)
/ selectionmode = sequence
/ selectionrate = trial
</list>

<list immediaterewards8_asc>
/ items = (0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0)
/ selectionmode = sequence
/ selectionrate = trial
</list>

<list immediaterewards12_asc>
/ items = (0.0, 1.0, 2.0, 4.0, 6.0, 7.0, 8.0, 10.0, 12.0)
/ selectionmode = sequence
/ selectionrate = trial
</list>


*****************************************************************************************************************
*****************************************************************************************************************
    Stimulus Elements
*****************************************************************************************************************
*****************************************************************************************************************
    For DDT Trial
*****************************************************************************************************************
*****************************************************************************************************************
<text question_4>
/ items = question_4
/ select = 1
/ erase = false
/ position = (50%, 50%)
</text>


<text or>
/ items = question_4
/ select = 3
/ erase = false
/ position = (50%, 65%)
</text>

<text immediate>
/ items = question_4
/ select = 2
/ txbgcolor = grey
/ vjustify = center
/ size = (20%, 20%)
/ position = (30%, 65%)
</text>

<text delayed_4>
/ items = question_4
/ select = 4
/ txbgcolor = grey
/ vjustify = center
/ size = (20%, 20%)
/ position = (70%, 65%)
</text>

<text question_8>
/ items = question_8
/ select = 1
/ erase = false
/ position = (50%, 50%)
</text>


<text delayed_8>
/ items = question_8
/ select = 4
/ txbgcolor = grey
/ vjustify = center
/ size = (20%, 20%)
/ position = (70%, 65%)
</text>

<text question_12>
/ items = question_12
/ select = 1
/ erase = false
/ position = (50%, 50%)
</text>

<text delayed_12>
/ items = question_12
/ select = 4
/ txbgcolor = grey
/ vjustify = center
/ size = (20%, 20%)
/ position = (70%, 65%)
</text>

<picture objectpic>
/ items = objectpicitems
/ select = values.object
/ position = (50%, 25%)
/ erase = false
</picture>


**************************************************************************************************************
**************************************************************************************************************
    Debug Stuff
**************************************************************************************************************
**************************************************************************************************************
<text debug>
/ items = ("Block = <%values.blockcount%> | Blocktype = <%values.blocktype%> | Order = <%values.order%> | IP_Desc = <%expressions.ip_desc%> | IP_Asc = <%expressions.ip_asc%> | IP = <%expressions.ip%>
Delayedstreak = <%values.delayedresponsestreak%> | Immediatestreak = <%values.immediateresponsestreak%>")
/ fontstyle = ("Arial", 2.00%)
/ erase = false
/ position = (50%, 5%)
/ size = (90%, 5%)
</text>

*****************************************************************************************************************
*****************************************************************************************************************
    For Food Pick Trial
*****************************************************************************************************************
*****************************************************************************************************************
<text foodcaption>
/ items = foodcaptions
/ select = 1
/ position = (50%, 10%)
</text>

<picture foodapic>
/ items = foodpics
/ select = 1
/ position = (30%, 30%)
</picture>

<picture foodbpic>
/ items = foodpics
/ select = 2
/ position = (70%, 30%)
</picture>

<picture foodcpic>
/ items = foodpics
/ select = 3
/ position = (30%, 70%)
</picture>

<picture fooddpic>
/ items = foodpics
/ select = 4
/ position = (70%, 70%)
</picture>

<text foodatxt>
/ items = foodcaptions
/ select = 2
/ position = (30%, 50%)
</text>

<text foodbtxt>
/ items = foodcaptions
/ select = 3
/ position = (70%, 50%)
</text>

<text foodctxt>
/ items = foodcaptions
/ select = 4
/ position = (30%, 90%)
</text>

<text fooddtxt>
/ items = foodcaptions
/ select = 5
/ position = (70%, 90%)
</text>
**************************************************************************************************************
**************************************************************************************************************
    Trial Elements
**************************************************************************************************************
**************************************************************************************************************
    DDT Choice Trial
**************************************************************************************************************
**************************************************************************************************************
<trial discounttrial4>
/ pretrialpause = parameters.pretrialdelay
/ posttrialpause = parameters.posttrialdelay
/ ontrialbegin = [values.trialcount+=1]
/ ontrialbegin = [if (values.trialcount==1)
        values.previousresponse="" else
        values.previousresponse=trial.discounttrial4.response]
/ ontrialbegin = [if (values.order=="descending")
        values.immediatereward=list.immediaterewards4_desc.nextvalue]
/ ontrialbegin = [if (values.order=="ascending")
        values.immediatereward=list.immediaterewards4_asc.nextvalue]

/ stimulusframes = [1=objectpic, question_4, or, immediate, delayed_4]
/ validresponse = (immediate, delayed_4)

/ ontrialend = [if (values.previousresponse=="immediate" && trial.discounttrial4.response=="immediate")
        values.immediateresponsestreak+=1 else
        values.immediateresponsestreak=0]
/ ontrialend = [if (values.previousresponse=="delayed" && trial.discounttrial4.response=="delayed")
        values.delayedresponsestreak+=1 else
        values.delayedresponsestreak=0]
/ ontrialend = [if (values.order=="descending" && values.ip_found==0 && values.delayedresponsestreak==1) {
        values.ip_desc=values.immediatereward; values.ip_found=1}]
/ ontrialend = [
    if (values.order=="ascending" && values.ip_found==0 && values.immediateresponsestreak==1) {
        values.ip_asc=values.immediatereward; values.ip_found=1}]

</trial>

<trial discounttrial8>
/ pretrialpause = parameters.pretrialdelay
/ posttrialpause = parameters.posttrialdelay
/ ontrialbegin = [values.trialcount+=1]
/ ontrialbegin = [if (values.trialcount==1)
        values.previousresponse="" else
        values.previousresponse=trial.discounttrial8.response]
/ ontrialbegin = [if (values.order=="descending")
        values.immediatereward=list.immediaterewards8_desc.nextvalue]
/ ontrialbegin = [if (values.order=="ascending")
        values.immediatereward=list.immediaterewards8_asc.nextvalue]

/ stimulusframes = [1=objectpic, question_8, or, immediate, delayed_8]
/ validresponse = (immediate, delayed_8)

/ ontrialend = [if (values.previousresponse=="immediate" && trial.discounttrial8.response=="immediate")
        values.immediateresponsestreak+=1 else
        values.immediateresponsestreak=0]
/ ontrialend = [if (values.previousresponse=="delayed" && trial.discounttrial8.response=="delayed")
        values.delayedresponsestreak+=1 else
        values.delayedresponsestreak=0]
/ ontrialend = [if (values.order=="descending" && values.ip_found==0 && values.delayedresponsestreak==1) {
        values.ip_desc=values.immediatereward; values.ip_found=1}]
/ ontrialend = [
    if (values.order=="ascending" && values.ip_found==0 && values.immediateresponsestreak==1) {
        values.ip_asc=values.immediatereward; values.ip_found=1}]

</trial>

<trial discounttrial12>
/ pretrialpause = parameters.pretrialdelay
/ posttrialpause = parameters.posttrialdelay
/ ontrialbegin = [values.trialcount+=1]
/ ontrialbegin = [if (values.trialcount==1)
        values.previousresponse="" else
        values.previousresponse=trial.discounttrial12.response]
/ ontrialbegin = [if (values.order=="descending")
        values.immediatereward=list.immediaterewards12_desc.nextvalue]
/ ontrialbegin = [if (values.order=="ascending")
        values.immediatereward=list.immediaterewards12_asc.nextvalue]

/ stimulusframes = [1=objectpic, question_12, or, immediate, delayed_12]
/ validresponse = (immediate, delayed_12)

/ ontrialend = [if (values.previousresponse=="immediate" && trial.discounttrial12.response=="immediate")
        values.immediateresponsestreak+=1 else
        values.immediateresponsestreak=0]
/ ontrialend = [if (values.previousresponse=="delayed" && trial.discounttrial12.response=="delayed")
        values.delayedresponsestreak+=1 else
        values.delayedresponsestreak=0]
/ ontrialend = [if (values.order=="descending" && values.ip_found==0 && values.delayedresponsestreak==1) {
        values.ip_desc=values.immediatereward; values.ip_found=1}]
/ ontrialend = [
    if (values.order=="ascending" && values.ip_found==0 && values.immediateresponsestreak==1) {
        values.ip_asc=values.immediatereward; values.ip_found=1}]

</trial>


**************************************************************************************************************
**************************************************************************************************************
    Compute Indifference Point
**************************************************************************************************************
**************************************************************************************************************
<trial compute_ip4>
/ ontrialbegin = [
    if (values.order=="descending" && values.ip_found==0)
        values.ip_desc=values.immediatereward
]
/ ontrialbegin = [
    if (values.order=="ascending" && values.ip_found==0)
        values.ip_asc=parameters.delayedreward_4
]
/ ontrialbegin = [
    if (values.ip_desc!=0.00 && values.ip_asc!=0.00)
        values.ip=(values.ip_desc+values.ip_asc)*0.5
]
   
/ ontrialbegin = [
    if (values.ip != 0 && values.blocktype == "food4" && values.delay == parameters.delay1) {
        values.ip_delay1_F4 = values.ip
    }
]
/ ontrialbegin = [
    if (values.ip != 0 && values.blocktype == "food4" && values.delay == parameters.delay2) {
        values.ip_delay2_F4 = values.ip
    }
]
/ ontrialbegin = [
    if (values.ip != 0 && values.blocktype == "food4" && values.delay == parameters.delay3) {
        values.ip_delay3_F4 = values.ip
    }
]
/ ontrialbegin = [
    if (values.ip != 0 && values.blocktype == "food4" && values.delay == parameters.delay4) {
        values.ip_delay4_F4 = values.ip
    }
]
/ ontrialbegin = [
    if (values.ip != 0 && values.blocktype == "food4" && values.delay == parameters.delay5) {
        values.ip_delay5_F4 = values.ip
    }
]
/ ontrialbegin = [
    if (values.ip != 0 && values.blocktype == "food4" && values.delay == parameters.delay6) {
        values.ip_delay6_F4 = values.ip
    }
]
/ ontrialbegin = [
    if (values.ip != 0 && values.blocktype == "food4" && values.delay == parameters.delay7) {
        values.ip_delay7_F4 = values.ip
    }
]



/ validresponse = (noresponse)
/ trialduration = 0
</trial>

<trial compute_ip8>
/ ontrialbegin = [
    if (values.order=="descending" && values.ip_found==0)
        values.ip_desc=values.immediatereward
]
/ ontrialbegin = [
    if (values.order=="ascending" && values.ip_found==0)
        values.ip_asc=parameters.delayedreward_8
]
/ ontrialbegin = [
    if (values.ip_desc!=0.00 && values.ip_asc!=0.00)
        values.ip=(values.ip_desc+values.ip_asc)*0.5
]
   
/ ontrialbegin = [
    if (values.ip != 0 && values.blocktype == "food8" && values.delay == parameters.delay1) {
        values.ip_delay1_F8 = values.ip
    }
]
/ ontrialbegin = [
    if (values.ip != 0 && values.blocktype == "food8" && values.delay == parameters.delay2) {
        values.ip_delay2_F8 = values.ip
    }
]
/ ontrialbegin = [
    if (values.ip != 0 && values.blocktype == "food8" && values.delay == parameters.delay3) {
        values.ip_delay3_F8 = values.ip
    }
]
/ ontrialbegin = [
    if (values.ip != 0 && values.blocktype == "food8" && values.delay == parameters.delay4) {
        values.ip_delay4_F8 = values.ip
    }
]
/ ontrialbegin = [
    if (values.ip != 0 && values.blocktype == "food8" && values.delay == parameters.delay5) {
        values.ip_delay5_F8 = values.ip
    }
]
/ ontrialbegin = [
    if (values.ip != 0 && values.blocktype == "food8" && values.delay == parameters.delay6) {
        values.ip_delay6_F8 = values.ip
    }
]
/ ontrialbegin = [
    if (values.ip != 0 && values.blocktype == "food8" && values.delay == parameters.delay7) {
        values.ip_delay7_F8 = values.ip
    }
]

/ validresponse = (noresponse)
/ trialduration = 0
</trial>       

<trial compute_ip12>
/ ontrialbegin = [
    if (values.order=="descending" && values.ip_found==0)
        values.ip_desc=values.immediatereward
]
/ ontrialbegin = [
    if (values.order=="ascending" && values.ip_found==0)
        values.ip_asc=parameters.delayedreward_12
]
/ ontrialbegin = [
    if (values.ip_desc!=0.00 && values.ip_asc!=0.00)
        values.ip=(values.ip_desc+values.ip_asc)*0.5
]
   
/ ontrialbegin = [
    if (values.ip != 0 && values.blocktype == "food12" && values.delay == parameters.delay1) {
        values.ip_delay1_F12 = values.ip
    }
]
/ ontrialbegin = [
    if (values.ip != 0 && values.blocktype == "food12" && values.delay == parameters.delay2) {
        values.ip_delay2_F12 = values.ip
    }
]
/ ontrialbegin = [
    if (values.ip != 0 && values.blocktype == "food12" && values.delay == parameters.delay3) {
        values.ip_delay3_F12 = values.ip
    }
]
/ ontrialbegin = [
    if (values.ip != 0 && values.blocktype == "food12" && values.delay == parameters.delay4) {
        values.ip_delay4_F12 = values.ip
    }
]
/ ontrialbegin = [
    if (values.ip != 0 && values.blocktype == "food12" && values.delay == parameters.delay5) {
        values.ip_delay5_F12 = values.ip
    }
]
/ ontrialbegin = [
    if (values.ip != 0 && values.blocktype == "food12" && values.delay == parameters.delay6) {
        values.ip_delay6_F12 = values.ip
    }
]
/ ontrialbegin = [
    if (values.ip != 0 && values.blocktype == "food12" && values.delay == parameters.delay7) {
        values.ip_delay7_F12 = values.ip
    }
]

/ validresponse = (noresponse)
/ trialduration = 0
</trial>
**************************************************************************************************************
**************************************************************************************************************
    Preferred Food Trial
**************************************************************************************************************
**************************************************************************************************************
<trial foodchoice>
/ stimulusframes = [1=foodcaption, foodapic, foodbpic, foodcpic, fooddpic, foodatxt, foodbtxt, foodctxt, fooddtxt]
/ validresponse = (foodapic, foodbpic, foodcpic, fooddpic)
/ ontrialend = [
    if (trial.foodchoice.response=="foodapic")
        values.foodchoice=1
]
/ ontrialend = [
    if (trial.foodchoice.response=="foodbpic")
        values.foodchoice=2
]
/ ontrialend = [
    if (trial.foodchoice.response=="foodcpic")
        values.foodchoice=3
]
/ ontrialend = [
    if (trial.foodchoice.response=="fooddpic")
        values.foodchoice=4
]
</trial>

**************************************************************************************************************
**************************************************************************************************************
    Block Elements
**************************************************************************************************************
**************************************************************************************************************
    Food Preference Block
**************************************************************************************************************
**************************************************************************************************************
<block foodchoice>
/ preinstructions = (foodintro)
/ postinstructions = (foodoutro)
/ trials = [1=foodchoice]
</block>

**************************************************************************************************************
**************************************************************************************************************
    DDT Blocks
**************************************************************************************************************
**************************************************************************************************************
    Food 4 Discounting (Descending)
**************************************************************************************************************
**************************************************************************************************************
<block food4_desc>
/ onblockbegin = [
    values.object=values.foodchoice;
    values.blocktype="food4";
    values.ip_found=0
]
/ onblockbegin = [
    values.immediateresponsestreak=0;
    values.delayedresponsestreak=0
]
/ onblockbegin = [values.previousresponse=""]
/ onblockbegin = [
    values.blockcount+=1;
    values.trialcount=0
]
/ onblockbegin = [
    values.order="descending";
    values.ip_desc=0.00;
    values.ip=0.00
]
/ onblockbegin = [
    if (mod(values.blockcount,4)==1 || mod(values.blockcount,4)==3)
        values.ip_asc=0.00
]
/ onblockbegin = [
    if (mod(values.blockcount,4)==1)
        values.delay=list.delays.nextvalue
]
/ trials = [1-9=discounttrial4; 10=compute_ip4]
</block>


**************************************************************************************************************
**************************************************************************************************************
    Food 4 Discounting (Ascending)
**************************************************************************************************************
**************************************************************************************************************
<block food4_asc>
/ onblockbegin = [
    values.object=values.foodchoice;
    values.blocktype="food4";
    values.ip_found=0
]
/ onblockbegin = [
    values.immediateresponsestreak=0;
    values.delayedresponsestreak=0
]
/ onblockbegin = [values.previousresponse=""]
/ onblockbegin = [
    values.blockcount+=1;
    values.trialcount=0
]
/ onblockbegin = [
    values.order="ascending";
    values.ip_asc=0.00;
    values.ip=0.00
]
/ onblockbegin = [
    if (mod(values.blockcount,4)==1 || mod(values.blockcount,4)==3)
        values.ip_desc=0.00
]
/ onblockbegin = [
    if (mod(values.blockcount,4)==1)
        values.delay=list.delays.nextvalue
]
/ trials = [1-9=discounttrial4; 10=compute_ip4]
</block>
**************************************************************************************************************
**************************************************************************************************************
    Food 8 Discounting (Descending)
**************************************************************************************************************
**************************************************************************************************************
<block food8_desc>
/ onblockbegin = [
    values.object=values.foodchoice;
    values.blocktype="food8";
    values.ip_found=0
]
/ onblockbegin = [
    values.immediateresponsestreak=0;
    values.delayedresponsestreak=0
]
/ onblockbegin = [values.previousresponse=""]
/ onblockbegin = [
    values.blockcount+=1;
    values.trialcount=0
]
/ onblockbegin = [
    values.order="descending";
    values.ip_desc=0.00;
    values.ip=0.00
]
/ onblockbegin = [
    if (mod(values.blockcount,4)==1 || mod(values.blockcount,4)==3)
        values.ip_asc=0.00
]
/ onblockbegin = [
    if (mod(values.blockcount,4)==1)
        values.delay=list.delays.nextvalue
]
/ trials = [1-9=discounttrial8; 10=compute_ip8]
</block>


**************************************************************************************************************
**************************************************************************************************************
    Food 8 Discounting (Ascending)
**************************************************************************************************************
**************************************************************************************************************
<block food8_asc>
/ onblockbegin = [
    values.object=values.foodchoice;
    values.blocktype="food8";
    values.ip_found=0
]
/ onblockbegin = [
    values.immediateresponsestreak=0;
    values.delayedresponsestreak=0
]
/ onblockbegin = [values.previousresponse=""]
/ onblockbegin = [
    values.blockcount+=1;
    values.trialcount=0
]
/ onblockbegin = [
    values.order="ascending";
    values.ip_asc=0.00;
    values.ip=0.00
]
/ onblockbegin = [
    if (mod(values.blockcount,4)==1 || mod(values.blockcount,4)==3)
        values.ip_desc=0.00
]
/ onblockbegin = [
    if (mod(values.blockcount,4)==1)
        values.delay=list.delays.nextvalue
]
/ trials = [1-9=discounttrial8; 10=compute_ip8]
</block>

**************************************************************************************************************
**************************************************************************************************************
    Food 12 Discounting (Descending)
**************************************************************************************************************
**************************************************************************************************************
<block food12_desc>
/ onblockbegin = [
    values.object=values.foodchoice;
    values.blocktype="food12";
    values.ip_found=0
]
/ onblockbegin = [
    values.immediateresponsestreak=0;
    values.delayedresponsestreak=0
]
/ onblockbegin = [values.previousresponse=""]
/ onblockbegin = [
    values.blockcount+=1;
    values.trialcount=0
]
/ onblockbegin = [
    values.order="descending";
    values.ip_asc=0.00;
    values.ip=0.00
]
/ onblockbegin = [
    if (mod(values.blockcount,4)==1 || mod(values.blockcount,4)==3)
        values.ip_asc=0.00
]
/ onblockbegin = [
    if (mod(values.blockcount,4)==1)
        values.delay=list.delays.nextvalue
]
/ trials = [1-9=discounttrial12; 10=compute_ip12]
</block>


**************************************************************************************************************
**************************************************************************************************************
    Food 12 Discounting (Ascending)
**************************************************************************************************************
**************************************************************************************************************
<block food12_asc>
/ onblockbegin = [
    values.object=values.foodchoice;
    values.blocktype="food12";
    values.ip_found=0
]
/ onblockbegin = [
    values.immediateresponsestreak=0;
    values.delayedresponsestreak=0
]
/ onblockbegin = [values.previousresponse=""]
/ onblockbegin = [
    values.blockcount+=1;
    values.trialcount=0
]
/ onblockbegin = [
    values.order="ascending";
    values.ip_asc=0.00;
    values.ip=0.00
]
/ onblockbegin = [
    if (mod(values.blockcount,4)==1 || mod(values.blockcount,4)==3)
        values.ip_desc=0.00
]
/ onblockbegin = [
    if (mod(values.blockcount,4)==1)
        values.delay=list.delays.nextvalue
]
/ trials = [1-9=discounttrial12; 10=compute_ip12]
</block>

**************************************************************************************************************
**************************************************************************************************************
    Expt Elements
**************************************************************************************************************
**************************************************************************************************************
    Order: Food4(Descending), Food4(Ascending), Food8(Descending), Food8(Ascending), Food12(Descending), Food12(Ascending)
**************************************************************************************************************
**************************************************************************************************************
<expt>
/ preinstructions = (generalintro)
/ postinstructions = (generaloutro)
/ blocks = [1=foodchoice; 2-7=sequence(food4_desc, food4_asc, food8_desc, food8_asc, food12_desc, food12_asc)]
/ subjects = (1 of 6)
/ groupassignment = groupnumber
/ onexptend = [values.completed = 1]
</expt>

**************************************************************************************************************
**************************************************************************************************************
    Order: Food8(Descending), Food8(Ascending), Food4(Descending), Food4(Ascending), Food12(Descending), Food12(Ascending)
**************************************************************************************************************
**************************************************************************************************************
<expt>
/ preinstructions = (generalintro)
/ postinstructions = (generaloutro)
/ blocks = [1=foodchoice; 2-7=sequence(food8_desc, food8_asc, food4_desc, food4_asc, food12_desc, food12_asc)]
/ subjects = (2 of 6)
/ groupassignment = groupnumber
/ onexptend = [values.completed = 1]
</expt>

**************************************************************************************************************
**************************************************************************************************************
    Order: Food8(Descending), Food8(Ascending), Food12(Descending), Food12(Ascending), Food4(Descending), Food4(Ascending)
**************************************************************************************************************
**************************************************************************************************************
<expt>
/ preinstructions = (generalintro)
/ postinstructions = (generaloutro)
/ blocks = [1=foodchoice; 2-7=sequence(food8_desc, food8_asc, food12_desc, food12_asc, food4_desc, food4_asc)]
/ subjects = (3 of 6)
/ groupassignment = groupnumber
/ onexptend = [values.completed = 1]
</expt>

**************************************************************************************************************
**************************************************************************************************************
    Order: Food12(Descending), Food12(Ascending), Food8(Descending), Food8(Ascending), Food4(Descending), Food4(Ascending)
**************************************************************************************************************
**************************************************************************************************************
<expt>
/ preinstructions = (generalintro)
/ postinstructions = (generaloutro)
/ blocks = [1=foodchoice; 2-7=sequence(food12_desc, food12_asc, food8_desc, food8_asc, food4_desc, food4_asc)]
/ subjects = (4 of 6)
/ groupassignment = groupnumber
/ onexptend = [values.completed = 1]
</expt>

**************************************************************************************************************
**************************************************************************************************************
    Order: Food12(Descending), Food12(Ascending), Food4(Descending), Food4(Ascending), Food8(Descending), Food8(Ascending)
**************************************************************************************************************
**************************************************************************************************************
<expt>
/ preinstructions = (generalintro)
/ postinstructions = (generaloutro)
/ blocks = [1=foodchoice; 2-7=sequence(food12_desc, food12_asc, food4_desc, food4_asc, food8_desc, food8_asc)]
/ subjects = (5 of 6)
/ groupassignment = groupnumber
/ onexptend = [values.completed = 1]
</expt>


**************************************************************************************************************
**************************************************************************************************************
    Order: Food4(Descending), Food4(Ascending), Food12(Descending), Food12(Ascending), Food8(Descending), Food8(Ascending)
**************************************************************************************************************
**************************************************************************************************************
<expt>
/ preinstructions = (generalintro)
/ postinstructions = (generaloutro)
/ blocks = [1=foodchoice; 2-7=sequence(food4_desc, food4_asc, food12_desc, food12_asc, food8_desc, food8_asc)]
/ subjects = (6 of 6)
/ groupassignment = groupnumber
/ onexptend = [values.completed = 1]
</expt>



Any insight is appreciated! Thanks.

The code is incomplete and broken as a consequence. There are various references to <parameters> throughout it, yet no <parameters> element is present. This makes it impossible to answer your question adequately.

You can attach files to a post via +Insert -> Add file. It is generally not necessary to paste entire scripts encompassing hundreds or thousands of lines of code into a message's body. Apart from being error-prone, it makes posts hard to read and the code hard to work with. If you have questions about particular parts of the code, it is better to include only those parts in the message body to direct the reader's focus to what's important. Thanks.


Would the attached file provide more clarification?



Not really. Recall what I tried to explain in previous threads, such as https://www.millisecond.com/forums/Topic20125.aspx#bm20147

On that basis, you need to clarify the following: Do you want

Delay 1
food4_desc -> food4_asc
Delay 2
food4_desc -> food4_asc
Delay 3
food4_desc -> food4_asc
...
Delay 1
food8_desc -> food8_asc
Delay 2
food8_desc -> food8_asc
Delay 3
food8_desc -> food8_asc
...
Delay 1
food12_desc -> food12_asc
Delay 2
food12_desc -> food12_asc
Delay 3
food12_desc -> food12_asc
...

i.e., run through all the delay levels for 4 servings, then through all delay levels for 8 servings, then through all delay levels for 12 servings

OR

do you want

Delay 1
food4_desc -> food4_asc
food8_desc -> food8_asc
food12_desc -> food12_asc
Delay 2
food4_desc -> food4_asc
food8_desc -> food8_asc
food12_desc -> food12_asc
....

i.e., complete delay level 1 (30 minutes) for 4 servings, followed by delay level 1 for 8 servings, followed by delay level 1 for 12 servings
and then
delay level 2 for 4 servings, followed by delay level 2 for 8 servings, delay level 2 for 12 servings,
and so forth.

This difference is important.

I'm trying to have it so that  all the delays for the 4 servings run, then all the delays for the 8 servings, then all the delays for the 12 servings.


Okay, then this is wrong:

/ blocks = [1=foodchoice; 2-7=sequence(food4_desc, food4_asc, food8_desc, food8_asc, food12_desc, food12_asc)]

You have 7 delay levels. If you want to run through them grouped by number of servings, you need to run
- 7 times the sequence(food4_desc, food4_asc), followed by
- 7 times the sequence(food8_desc, food8_asc), followed by
- 7 times the sequence(food12_desc, food12_asc)

i.e.,

/ blocks = [1=foodchoice;
    2-8=sequence(food4_desc, food4_asc);
    9-15=sequence(food8_desc, food8_asc);
    16-22=sequence(food12_desc, food12_asc)]

As also noted previously, you then also need to sample a new delay-level from <list delays> after *each chunk of TWO blocks*, not after each chunk of FOUR blocks as your script (still) does currently:

/ onblockbegin = [
    if (mod(values.blockcount,4)==1)
        values.delay=list.delays.nextvalue
]

needs to read

/ onblockbegin = [
    if (mod(values.blockcount,2)==1)
        values.delay=list.delays.nextvalue
]


Attachments
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Reading This Topic

Explore
Messages
Mentions
Search