Millisecond Forums

## Randomizing position of stimuli

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

 By ***JayD*** - 10/25/2016 Hi,I'm attempting to write a task wherein participants are shown several coloured squares, followed by an inter-trial interval, followed by the presentation of only one of the previously shown squares (in its original position). Participants must respond with whether they think the square is the same or a different colour. The stimuli in the first instance should appear randomly, trial by trial. When the single stimulus is shown subsequently, it should be in the exact same position. There is a simple diagram here (http://www.scholarpedia.org/article/Visual_short_term_memory; Figure 1) of what I'm attempting to build (except in my task the "Test Array Until Response" only shows one of the previous squares - in this case, the yellow one).I've got some code written but am already receiving error messages and I don't think the way I've set up my trials will give the desired result.../ screencolor = (192, 192, 192)/ fontstyle = ("Arial", 28pt, false,false)/ txcolor = (0, 255, 0)/ pretrialpause = 0/ inputdevice = keyboard*******/ items = ("+")/ position = (50,50)/ txcolor = (255,255,255)/ txbgcolor = (transparent)/ fontstyle = ("Arial", 64pt, false,false)********/ 1 = "RED.bmp"/ 1 = "BLUE.bmp"ETC..../ items = Red_Square/ position = counter.Red_Square_pos.selectedvalue/ items = Blue_Square/ position = counter.Blue_Square_pos.selectedvalueETC..../ items = (1%, 2%, 3%, 4%, 5%, 6%, 7%, 8%, 9%, 10%, 11%, 12%, 13%, 14%, 15%, 16%, 17%, 18%, 19%, 20%, 21%, 22%, 23%, 24%, 25%, 26%, 27%, 28%, 29%, 30%, 31%, 32%, 33%, 34%, 35%, 36%, 37%, 38%, 39%, 61%, 62%, 63%, 64%, 65%, 66%, 67%, 68%, 69%, 70%, 71%, 72%, 73%, 74%, 75%, 76%, 77%, 78%, 79%, 80%, 81%, 82%, 83%, 84%, 85%, 86%, 87%, 88%, 89%, 90%, 91%, 92%, 93%, 94%, 95%, 96%, 97%, 98%, 99%, 100%)/ not = (Blue_Square_pos, Green_Square_pos, Yellow_Square_pos, Black_Square_pos, Brown_Square_pos, Orange_Square_pos, Purple_Square_pos)/ select = noreplace/ selectionrate = always/ items = (1%, 2%, 3%, 4%, 5%, 6%, 7%, 8%, 9%, 10%, 11%, 12%, 13%, 14%, 15%, 16%, 17%, 18%, 19%, 20%, 21%, 22%, 23%, 24%, 25%, 26%, 27%, 28%, 29%, 30%, 31%, 32%, 33%, 34%, 35%, 36%, 37%, 38%, 39%, 61%, 62%, 63%, 64%, 65%, 66%, 67%, 68%, 69%, 70%, 71%, 72%, 73%, 74%, 75%, 76%, 77%, 78%, 79%, 80%, 81%, 82%, 83%, 84%, 85%, 86%, 87%, 88%, 89%, 90%, 91%, 92%, 93%, 94%, 95%, 96%, 97%, 98%, 99%, 100%)/ not = (Red_Square_pos, Green_Square_pos, Yellow_Square_pos, Black_Square_pos, Brown_Square_pos, Orange_Square_pos, Purple_Square_pos)/ select = noreplace/ selectionrate = always***************** NOTE THAT I'VE REMOVED 40%-60% AS I DON'T WANT THE STIMULI AROUND THE CENTRE OF THE SCREEN / stimulustimes = [1 = fixation; 500 = Red_Square, Blue_Square; 600 = ; 1500 = Red_Square]/ inputdevice = keyboard/ correctresponse = ("z")/ validresponse = ("m", "z")/ trialduration = 2500/ responsetime = 1500/ responseinterrupt = immediate*******************I'm not sure whether - because of the counter - the second presentation of the 'Red_Square' will be randomized... I'm also unable to check as I keep getting error messages for the picture elements:  /position: Missing '('.Any help is greatly appreciated!Thanks,Jay By Dave - 10/26/2016 > I'm not sure whether - because of the counter - the second presentation of the 'Red_Square' will be randomized..No, it wont be because once the trial is running, the element cannot change position. It's not clear to me, however, why you set your s to / selectionrate = always. It seems to me you only want a single selection from the counter per trial, and thus / selectionrate = trial. Beyond that, I don't actually think you need separate s per square. Depending on how want to randomize the various stimuli's x and y positions, you should need at most than two counters (one for x, one for y).> I'm also unable to check as I keep getting error messages for the picture elements: > > > /position: Missing '('./ position = counter.Red_Square_pos.selectedvaluePosition is defined by *two* coordinates, horizontal and vertical, in parenthesis (), separated by a comma: You do not provide that, hence the error. To sum up, if I were you, I'd go for something like this:/ redx = 0%/ redy = 0%/ bluex = 0%/ bluey = 0%/ trials = [1-2 = red_same]/ ontrialbegin = [reset(counter.randpos); ]/ ontrialbegin = [values.redx=counter.randpos.selectedvalue; values.redy=counter.randpos.selectedvalue;    values.bluex=counter.randpos.selectedvalue; values.bluey=counter.randpos.selectedvalue;]/ stimulustimes = [1 = fixation; 500 = Red_Square, Blue_Square; 600 = blank; 1500 = Red_Square]/ validresponse = ("s", "d")/ correctresponse = ("d")/ color = red/ shape = rectangle/ size = (100px, 100px)/ hposition = values.redx/ vposition = values.redy/ color = blue/ shape = rectangle/ size = (100px, 100px)/ hposition = values.bluex/ vposition = values.bluey/ items = (1%, 2%, 3%, 4%, 5%, 6%, 7%, 8%, 9%, 10%,     11%, 12%, 13%, 14%, 15%, 16%, 17%, 18%, 19%, 20%,     21%, 22%, 23%, 24%, 25%, 26%, 27%, 28%, 29%, 30%,     31%, 32%, 33%, 34%, 35%, 36%, 37%, 38%, 39%,     61%, 62%, 63%, 64%, 65%, 66%, 67%, 68%, 69%, 70%,     71%, 72%, 73%, 74%, 75%, 76%, 77%, 78%, 79%, 80%,     81%, 82%, 83%, 84%, 85%, 86%, 87%, 88%, 89%, 90%,     91%, 92%, 93%, 94%, 95%, 96%, 97%, 98%, 99%, 100%)/ select = noreplace/ selectionrate = always/ items = ("+")/ color = white/ shape = rectangle/ size = (100%, 100%) By ***JayD*** - 10/31/2016 Hi Dave,Thanks a lot for your reply, it was really helpful. I just have two more questions regarding the script:1) Am I able to create trials in which the subsequent presentation of the single square (presented in the "Test Array Until Response" portion) is no longer the same colour, but is still in the same position? The trial you lay out gives: presentation of red & blue > blank > red OR blue (in same position AND same colour).However, I'm not sure how best to create: presentation of red & blue > blank > green (in same position as red, for example).2) Is there a way to ensure that the squares do not overlap, without creating a specific counter for each square (I've created separate one [see below] but it doesn't seem to work)?/ items = (11%, 12%, 13%, 14%, 15%, 16%, 17%, 18%, 19%, 20%,   21%, 22%, 23%, 24%, 25%, 26%, 27%, 28%, 29%, 30%,   31%, 32%, 33%, 34%, 35%, 36%, 37%, 38%, 39%,   61%, 62%, 63%, 64%, 65%, 66%, 67%, 68%, 69%, 70%,   71%, 72%, 73%, 74%, 75%, 76%, 77%, 78%, 79%, 80%,   81%, 82%, 83%, 84%, 85%, 86%, 87%, 88%, 89%, 90%)/ select = noreplace/ not = (randpos_blue, randpos_green)/ selectionrate = always/ items = (11%, 12%, 13%, 14%, 15%, 16%, 17%, 18%, 19%, 20%,   21%, 22%, 23%, 24%, 25%, 26%, 27%, 28%, 29%, 30%,   31%, 32%, 33%, 34%, 35%, 36%, 37%, 38%, 39%,   61%, 62%, 63%, 64%, 65%, 66%, 67%, 68%, 69%, 70%,   71%, 72%, 73%, 74%, 75%, 76%, 77%, 78%, 79%, 80%,   81%, 82%, 83%, 84%, 85%, 86%, 87%, 88%, 89%, 90%)/ select = noreplace/ not = (randpos_red, randpos_green)/ selectionrate = always/ items = (11%, 12%, 13%, 14%, 15%, 16%, 17%, 18%, 19%, 20%,   21%, 22%, 23%, 24%, 25%, 26%, 27%, 28%, 29%, 30%,   31%, 32%, 33%, 34%, 35%, 36%, 37%, 38%, 39%,   61%, 62%, 63%, 64%, 65%, 66%, 67%, 68%, 69%, 70%,   71%, 72%, 73%, 74%, 75%, 76%, 77%, 78%, 79%, 80%,   81%, 82%, 83%, 84%, 85%, 86%, 87%, 88%, 89%, 90%)/ select = noreplace/ not = (randpos_blue, randpos_red)/ selectionrate = alwaysThanks again,Jay By Dave - 10/31/2016 > 1) Am I able to create trials in which the subsequent presentation of the single square (presented in the "Test Array Until Response" > portion) is no longer the same colour, but is still in the same position? Yes, of course. Set the position of the differently colored square to the desired position (e.g. the one matching the red square) /ontrialbegin.> 2) Is there a way to ensure that the squares do not overlap, without creating a specific counter for each square (I've created separate one > [see below] but it doesn't seem to work)?As I've said in my previous response, I do not see why you even need a "specific counter for each square". You should need at most two counters. One for the x positions, one for the corresponding y positions. Then just sample all the positions from those counters, just like the example in my previous reply does (albeit it uses only a single for both x and y).