Hello, Happy New Year 2024.
I have two trials "plus" and "minus" where each trial consists of two different attributes (say trialtype): "same" and "distinct" and each attribute has two different sub-attributes (such as odd/even, low/high). I would like to have equal number of each attribute and it's sub-attributes. That is, in a block of 64 trials (as in the script below), I want to have 32 plus trials (with 16 "same": 8 even/8 odd) and 32 minus trials (with 16 "same": 8 low/8 high). How can I achieve this?
Thanks to Mr. Dave for his kind help earlier in this scripts.
Output of the script is in the attached excel file (where I have highlighted the issues).
Would appreciate your help - Thank you.
Here is the script:
<values>
/ lftimg = ""
/ rgtimg = ""
/ lftitemnumber = 0
/ rgtitemnumber = 0
/ aitem = 0
/ bitem = 0
/ citem = 0
/ ditem = 0
/ eitem = 0
/ fitem = 0
/ gitem = 0
/ hitem = 0
/ trialtype = ""
/ rightlist = 1
/ lfttype = ""
/ rgttype = ""
</values>
<text A>
/items = ("A1.jpg","A2.jpg","A3.jpg","A4.jpg","A5.jpg","A6.jpg","A7.jpg","A8.jpg")
/size = (20%,20%)
/fontstyle = ("Arial", 50pt, true)
/ vposition = 50%
/ hposition = 0%
/ select = values.aitem
</text>
<text B>
/items = ("B1.jpg","B2.jpg","B3.jpg","B4.jpg","B5.jpg","B6.jpg","B7.jpg","B8.jpg")
/size = (20%,20%)
/fontstyle = ("Arial", 50pt, true)
/ vposition = 50%
/ hposition = 0%
/ select = values.bitem
</text>
<text C>
/items = ("C1.jpg","C2.jpg","C3.jpg","C4.jpg","C5.jpg","C6.jpg","C7.jpg","C8.jpg")
/size = (20%,20%)
/fontstyle = ("Arial", 50pt, true)
/ vposition = 50%
/ hposition = 0%
/ select = values.citem
</text>
<text D>
/items = ("D1.jpg","D2.jpg","D3.jpg","D4.jpg","D5.jpg","D6.jpg","D7.jpg","D8.jpg")
/size = (20%,20%)
/fontstyle = ("Arial", 50pt, true)
/ vposition = 50%
/ hposition = 0%
/ select = values.ditem
</text>
<text E>
/items = ("E1.jpg","E2.jpg","E3.jpg","E4.jpg","E5.jpg","E6.jpg","E7.jpg","E8.jpg")
/size = (20%,20%)
/fontstyle = ("Arial", 50pt, true)
/ vposition = 50%
/ hposition = 0%
/ select = values.aitem
</text>
<text F>
/items = ("F1.jpg","F2.jpg","F3.jpg","F4.jpg","F5.jpg","F6.jpg","F7.jpg","F8.jpg")
/size = (20%,20%)
/fontstyle = ("Arial", 50pt, true)
/ vposition = 50%
/ hposition = 0%
/ select = values.bitem
</text>
<text G>
/items = ("G1.jpg","G2.jpg","G3.jpg","G4.jpg","G5.jpg","G6.jpg","G7.jpg","G8.jpg")
/size = (20%,20%)
/fontstyle = ("Arial", 50pt, true)
/ vposition = 50%
/ hposition = 0%
/ select = values.citem
</text>
<text H>
/items = ("H1.jpg","H2.jpg","H3.jpg","H4.jpg","H5.jpg","H6.jpg","H7.jpg","H8.jpg")
/size = (20%,20%)
/fontstyle = ("Arial", 50pt, true)
/ vposition = 50%
/ hposition = 0%
/ select = values.ditem
</text>
<text plus>
/ items = ("Positive")
/ size = (20%, 20%)
/ position = (50%, 50%)
/ fontstyle = ("Arial", 30pt, true)
</text>
<text minus>
/ items = ("Minus")
/ size = (20%, 20%)
/ position = (50%, 50%)
/ fontstyle = ("Arial", 30pt, true)
</text>
<list image>
/ items = (text.A, text.B, text.C, text.D, text.E, text.F, text.G, text.H)
/ selectionmode = random
/ replace = false
/ selectionrate = always
</list>
<list itemnumbers>
/ poolsize = 8
/ selectionrate = always
</list>
<list odditemnumbers>
/ items = (1,3,5,7)
/ not = (values.lftitemnumber)
/ selectionrate = always
/ replace = true
</list>
<list evenitemnumbers>
/ items = (2,4,6,8)
/ not = (values.lftitemnumber)
/ selectionrate = always
/ replace = true
</list>
<list rightevenodditemnumber>
/ items = (list.odditemnumbers.nextvalue, list.evenitemnumbers.nextvalue)
/ selectionmode = values.rightlist
</list>
<list lowitemnumbers>
/ items = (1,2,3,4)
/ not = (values.lftitemnumber)
/ selectionrate = always
/ replace = true
</list>
<list highitemnumbers>
/ items = (5,6,7,8)
/ not = (values.lftitemnumber)
/ selectionrate = always
/ replace = true
</list>
<list righthighlowitemnumber>
/ items = (list.lowitemnumbers.nextvalue, list.highitemnumbers.nextvalue)
/ selectionmode = values.rightlist
</list>
<list trialytype>
/ items = ("same", "same", "distinct", "distinct")
</list>
<trial plus>
/ ontrialbegin = [
values.trialtype = list.trialytype.nextvalue; // determine trial type
trial.plus.resetstimulusframes();
list.image.reset();
trial.plus.insertstimulusframe(list.image.nextvalue, 1);
values.lftimg = list.image.currentvalue; // image type -- A, B, C, or D -- displayed on left side
trial.plus.insertstimulusframe(list.image.nextvalue, 1);
values.rgtimg = list.image.currentvalue; // image type -- A, B, C, or D -- displayed on right side
if (values.lftimg == text.A) {
text.A.hposition = 30%;
values.aitem = list.itemnumbers.nextindex;
values.lftitemnumber = values.aitem;
} else if (values.lftimg == text.B) {
text.B.hposition = 30%;
values.bitem = list.itemnumbers.nextindex;
values.lftitemnumber = values.bitem;
} else if (values.lftimg == text.C) {
text.C.hposition = 30%;
values.citem = list.itemnumbers.nextindex;
values.lftitemnumber = values.citem;
} else if (values.lftimg == text.D) {
text.D.hposition = 30%;
values.ditem = list.itemnumbers.nextindex;
values.lftitemnumber = values.ditem;
} else if (values.lftimg == text.E) {
text.E.hposition = 30%;
values.eitem = list.itemnumbers.nextindex;
values.lftitemnumber = values.eitem;
} else if (values.lftimg == text.F) {
text.F.hposition = 30%;
values.fitem = list.itemnumbers.nextindex;
values.lftitemnumber = values.fitem;
} else if (values.lftimg == text.G) {
text.G.hposition = 30%;
values.gitem = list.itemnumbers.nextindex;
values.lftitemnumber = values.gitem;
} else if (values.lftimg == text.H) {
text.H.hposition = 30%;
values.hitem = list.itemnumbers.nextindex;
values.lftitemnumber = values.hitem;
};
if (mod(values.lftitemnumber, 2) == 1) { // left item is odd
values.lfttype = "odd";
if (values.trialtype == "same") { // if trial type is same
values.rgttype = "odd";
values.rightlist = 1; // we use odd item numbers for the right image
} else { // otherwise
values.rgttype = "even";
values.rightlist = 2; // we use even item numbers for the right image
}
} else if (mod(values.lftitemnumber, 2) == 0) { // left item is even
values.lfttype = "even";
if (values.trialtype == "same") { // if trial type is same
values.rgttype = "even";
values.rightlist = 2; // we use even item numbers for the right image
} else { // otherwise
values.rgttype = "odd";
values.rightlist = 1; // we use odd item numbers for the right image
}
};
if (values.rgtimg == text.A) {
text.A.hposition = 70%;
values.aitem = list.rightevenodditemnumber.nextvalue;
values.rgtitemnumber = values.aitem;
} else if (values.rgtimg == text.B) {
text.B.hposition = 70%;
values.bitem = list.rightevenodditemnumber.nextvalue;
values.rgtitemnumber = values.bitem;
} else if (values.rgtimg == text.C) {
text.C.hposition = 70%;
values.citem = list.rightevenodditemnumber.nextvalue;
values.rgtitemnumber = values.citem;
} else if (values.rgtimg == text.D) {
text.D.hposition = 70%;
values.ditem = list.rightevenodditemnumber.nextvalue;
values.rgtitemnumber = values.ditem;
} else if (values.rgtimg == text.E) {
text.E.hposition = 70%;
values.eitem = list.rightevenodditemnumber.nextvalue;
values.rgtitemnumber = values.eitem;
} else if (values.rgtimg == text.F) {
text.F.hposition = 70%;
values.fitem = list.rightevenodditemnumber.nextvalue;
values.rgtitemnumber = values.fitem;
} else if (values.rgtimg == text.G) {
text.G.hposition = 70%;
values.gitem = list.rightevenodditemnumber.nextvalue;
values.rgtitemnumber = values.gitem;
} else if (values.rgtimg == text.H) {
text.H.hposition = 70%;
values.hitem = list.rightevenodditemnumber.nextvalue;
values.rgtitemnumber = values.hitem;
};
]
/ stimulusframes = [1=clearScreen, text.plus]
/ validresponse = ("s", "d")
</trial>
<trial minus>
/ ontrialbegin = [
values.trialtype = list.trialytype.nextvalue; // determine trial type
trial.minus.resetstimulusframes();
list.image.reset();
trial.minus.insertstimulusframe(list.image.nextvalue, 1);
values.lftimg = list.image.currentvalue; // image type -- A, B, C, or D -- displayed on left side
trial.minus.insertstimulusframe(list.image.nextvalue, 1);
values.rgtimg = list.image.currentvalue; // image type -- A, B, C, or D -- displayed on right side
if (values.lftimg == text.A) {
text.A.hposition = 30%;
values.aitem = list.itemnumbers.nextindex;
values.lftitemnumber = values.aitem;
} else if (values.lftimg == text.B) {
text.B.hposition = 30%;
values.bitem = list.itemnumbers.nextindex;
values.lftitemnumber = values.bitem;
} else if (values.lftimg == text.C) {
text.C.hposition = 30%;
values.citem = list.itemnumbers.nextindex;
values.lftitemnumber = values.citem;
} else if (values.lftimg == text.D) {
text.D.hposition = 30%;
values.ditem = list.itemnumbers.nextindex;
values.lftitemnumber = values.ditem;
} else if (values.lftimg == text.E) {
text.E.hposition = 30%;
values.eitem = list.itemnumbers.nextindex;
values.lftitemnumber = values.eitem;
} else if (values.lftimg == text.F) {
text.F.hposition = 30%;
values.fitem = list.itemnumbers.nextindex;
values.lftitemnumber = values.fitem;
} else if (values.lftimg == text.G) {
text.G.hposition = 30%;
values.gitem = list.itemnumbers.nextindex;
values.lftitemnumber = values.gitem;
} else if (values.lftimg == text.H) {
text.H.hposition = 30%;
values.hitem = list.itemnumbers.nextindex;
values.lftitemnumber = values.hitem;
};
if (values.lftitemnumber < 5) { // left item is odd
values.lfttype = "low";
if (values.trialtype == "same") { // if trial type is same
values.rgttype = "low";
values.rightlist = 1; // we use odd item numbers for the right image
} else { // otherwise
values.rgttype = "high";
values.rightlist = 2; // we use even item numbers for the right image
}
} else if (values.lftitemnumber >= 5) { // left item is even
values.lfttype = "high";
if (values.trialtype == "same") { // if trial type is same
values.rgttype = "high";
values.rightlist = 2; // we use even item numbers for the right image
} else { // otherwise
values.rgttype = "low";
values.rightlist = 1; // we use odd item numbers for the right image
}
};
if (values.rgtimg == text.A) {
text.A.hposition = 70%;
values.aitem = list.righthighlowitemnumber.nextvalue;
values.rgtitemnumber = values.aitem;
} else if (values.rgtimg == text.B) {
text.B.hposition = 70%;
values.bitem = list.righthighlowitemnumber.nextvalue;
values.rgtitemnumber = values.bitem;
} else if (values.rgtimg == text.C) {
text.C.hposition = 70%;
values.citem = list.righthighlowitemnumber.nextvalue;
values.rgtitemnumber = values.citem;
} else if (values.rgtimg == text.D) {
text.D.hposition = 70%;
values.ditem = list.righthighlowitemnumber.nextvalue;
values.rgtitemnumber = values.ditem;
} else if (values.rgtimg == text.E) {
text.E.hposition = 70%;
values.eitem = list.righthighlowitemnumber.nextvalue;
values.rgtitemnumber = values.eitem;
} else if (values.rgtimg == text.F) {
text.F.hposition = 70%;
values.fitem = list.righthighlowitemnumber.nextvalue;
values.rgtitemnumber = values.fitem;
} else if (values.rgtimg == text.G) {
text.G.hposition = 70%;
values.gitem = list.righthighlowitemnumber.nextvalue;
values.rgtitemnumber = values.gitem;
} else if (values.rgtimg == text.H) {
text.H.hposition = 70%;
values.hitem = list.righthighlowitemnumber.nextvalue;
values.rgtitemnumber = values.hitem;
};
]
/ stimulusframes = [1=clearScreen, text.minus]
/ validresponse = ("s", "d")
</trial>
<block tryblock>
/ trials = [1-64 = noreplace(trial.PLUS, trial.minus)]
/ recorddata = true
</block>
<data>
/ columns = (date time subject group session blocknum blockcode trialnum trialcode response latency correct
values.lftimg values.rgtimg values.lftitemnumber values.rgtitemnumber values.trialtype values.lfttype values.rgttype)
</data>