Millisecond Forums

Stimuli not erasing after trial

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

By kev_dent - 12/20/2022

I'm currently setting up a new experiment but I'm having an issue where my stimuli are not erased after each trial.
If I run the trial twice by enumerating two instances of the same trial it is fine.
However when called inside a block the stimuli persist.
Is this a bug or am I misunderstanding something?

Here is the code I am playing with:

<picture face>
/items =("Faces/Face1.jpg","Faces/Face2.jpg","Faces/Face3.jpg","Faces/Face4.jpg","Faces/Face5.jpg","Faces/Face6.jpg","Faces/Face7.jpg","Faces/Face8.jpg")
/scale = 0.25
/ position = (poslistx, poslisty)
/erase = true(white)
</picture>

<picture plants>
/items =("HousePlants/Plant1.bmp","HousePlants/Plant2.bmp","HousePlants/Plant3.bmp","HousePlants/Plant4.bmp","HousePlants/Plant6.bmp","HousePlants/Plant7.bmp","HousePlants/Plant8.bmp")
/scale = 0.25
/ position = (poslistx, poslisty)
/erase = true(white)
</picture>

<picture fruits>
/items = ("Fruit/Apple1.bmp","Fruit/Banana1.bmp","Fruit/Grapes1.bmp","Fruit/Lemon1.bmp","Fruit/Melon1.bmp","Fruit/Orange1.bmp","Fruit/Pear1.bmp","Fruit/Pineapple1.bmp")
/scale = 0.25
/ position = (poslistx, poslisty)
/erase = true(white)
</picture>

<picture flowers>
/items = ("Flowers/Amarylis.bmp","Flowers/Chrysan.bmp","Flowers/Clematis.bmp","Flowers/Echinace.bmp","Flowers/Mallow.bmp","Flowers/Marigold.bmp","Flowers/Sunflower.bmp","Flowers/Zinnia.bmp")
/scale = 0.25
/ position = (poslistx, poslisty)
/erase = true(white)
</picture>

<picture leafs>
/items = ("Leaves/Leaf1.bmp","Leaves/Leaf2.bmp","Leaves/Leaf3.bmp","Leaves/Leaf4.bmp","Leaves/Leaf5.bmp","Leaves/Leaf6.bmp","Leaves/Leaf7.bmp","Leaves/Leaf8.bmp")
/scale = 0.25
/ position = (poslistx, poslisty)
/erase = true(white)
</picture>

<picture trees>
/items = ("Trees/Tree1.bmp","Trees/Tree2.bmp","Trees/Tree3.bmp","Trees/Tree4.bmp","Trees/Tree5.bmp","Trees/Tree6.bmp","Trees/Tree7.bmp","Trees/Tree8.bmp")
/scale = 0.25
/ position = (poslistx, poslisty)
/erase = true(white)
</picture>

<picture butterflies>
/items = ("Butterflies/Butterfly1.bmp","Butterflies/Butterfly2.bmp","Butterflies/Butterfly3.bmp","Butterflies/Butterfly4.bmp","Butterflies/Butterfly5.bmp","Butterflies/Butterfly6.bmp","Butterflies/Butterfly7.bmp","Butterflies/Butterfly8.bmp")
/scale = 0.25
/ position = (poslistx, poslisty)
/erase = true(white)
</picture>

<list poslisty>
/items =(16*sin(0.33*m_pi)+50, 16*sin(0.66*m_pi)+50 , 16*sin(0.99*m_pi)+50, 16*sin(1.33*m_pi)+50, 16*sin(1.66*m_pi)+50, 16*sin(1.99*m_pi)+50)
/select=list.poslistx.currentindex
/ selectionrate = always
</list>

<list poslistx>
/items =(10*cos(0.33*m_pi)+50, 10*cos(0.66*m_pi)+50, 10*cos(0.99*m_pi)+50, 10*cos(1.33*m_pi)+50, 10*cos(1.66*m_pi)+50, 10*cos(1.99*m_pi)+50)

/ selectionrate = always
</list>


<trial search>
/stimulustimes = [0=butterflies plants flowers trees leafs fruits]
/ inputdevice = keyboard
/ validresponse = ("z" "n")
</trial>



<block main>
/trials = [
    1-10=search
]
</block>

<expt>

/blocks=[1=main]
</expt>
By Dave - 12/20/2022

kev_dent - 12/20/2022
I'm currently setting up a new experiment but I'm having an issue where my stimuli are not erased after each trial.
If I run the trial twice by enumerating two instances of the same trial it is fine.
However when called inside a block the stimuli persist.
Is this a bug or am I misunderstanding something?

Here is the code I am playing with:

<picture face>
/items =("Faces/Face1.jpg","Faces/Face2.jpg","Faces/Face3.jpg","Faces/Face4.jpg","Faces/Face5.jpg","Faces/Face6.jpg","Faces/Face7.jpg","Faces/Face8.jpg")
/scale = 0.25
/ position = (poslistx, poslisty)
/erase = true(white)
</picture>

<picture plants>
/items =("HousePlants/Plant1.bmp","HousePlants/Plant2.bmp","HousePlants/Plant3.bmp","HousePlants/Plant4.bmp","HousePlants/Plant6.bmp","HousePlants/Plant7.bmp","HousePlants/Plant8.bmp")
/scale = 0.25
/ position = (poslistx, poslisty)
/erase = true(white)
</picture>

<picture fruits>
/items = ("Fruit/Apple1.bmp","Fruit/Banana1.bmp","Fruit/Grapes1.bmp","Fruit/Lemon1.bmp","Fruit/Melon1.bmp","Fruit/Orange1.bmp","Fruit/Pear1.bmp","Fruit/Pineapple1.bmp")
/scale = 0.25
/ position = (poslistx, poslisty)
/erase = true(white)
</picture>

<picture flowers>
/items = ("Flowers/Amarylis.bmp","Flowers/Chrysan.bmp","Flowers/Clematis.bmp","Flowers/Echinace.bmp","Flowers/Mallow.bmp","Flowers/Marigold.bmp","Flowers/Sunflower.bmp","Flowers/Zinnia.bmp")
/scale = 0.25
/ position = (poslistx, poslisty)
/erase = true(white)
</picture>

<picture leafs>
/items = ("Leaves/Leaf1.bmp","Leaves/Leaf2.bmp","Leaves/Leaf3.bmp","Leaves/Leaf4.bmp","Leaves/Leaf5.bmp","Leaves/Leaf6.bmp","Leaves/Leaf7.bmp","Leaves/Leaf8.bmp")
/scale = 0.25
/ position = (poslistx, poslisty)
/erase = true(white)
</picture>

<picture trees>
/items = ("Trees/Tree1.bmp","Trees/Tree2.bmp","Trees/Tree3.bmp","Trees/Tree4.bmp","Trees/Tree5.bmp","Trees/Tree6.bmp","Trees/Tree7.bmp","Trees/Tree8.bmp")
/scale = 0.25
/ position = (poslistx, poslisty)
/erase = true(white)
</picture>

<picture butterflies>
/items = ("Butterflies/Butterfly1.bmp","Butterflies/Butterfly2.bmp","Butterflies/Butterfly3.bmp","Butterflies/Butterfly4.bmp","Butterflies/Butterfly5.bmp","Butterflies/Butterfly6.bmp","Butterflies/Butterfly7.bmp","Butterflies/Butterfly8.bmp")
/scale = 0.25
/ position = (poslistx, poslisty)
/erase = true(white)
</picture>

<list poslisty>
/items =(16*sin(0.33*m_pi)+50, 16*sin(0.66*m_pi)+50 , 16*sin(0.99*m_pi)+50, 16*sin(1.33*m_pi)+50, 16*sin(1.66*m_pi)+50, 16*sin(1.99*m_pi)+50)
/select=list.poslistx.currentindex
/ selectionrate = always
</list>

<list poslistx>
/items =(10*cos(0.33*m_pi)+50, 10*cos(0.66*m_pi)+50, 10*cos(0.99*m_pi)+50, 10*cos(1.33*m_pi)+50, 10*cos(1.66*m_pi)+50, 10*cos(1.99*m_pi)+50)

/ selectionrate = always
</list>


<trial search>
/stimulustimes = [0=butterflies plants flowers trees leafs fruits]
/ inputdevice = keyboard
/ validresponse = ("z" "n")
</trial>



<block main>
/trials = [
    1-10=search
]
</block>

<expt>

/blocks=[1=main]
</expt>

When you need to share code that requires external files (here: various images), please provide any and all files the code requires to run. Otherwise nobody can run it or reproduce any supposed issue.
By kev_dent - 12/20/2022

Ok sure I will upload the code / stims when I am back at my computer, tomorrow.

But it seems from your reply that there is nothing obviously wrong with the code?
By Dave - 12/20/2022

kev_dent - 12/20/2022
Ok sure I will upload the code / stims when I am back at my computer, tomorrow.But it seems from your reply that there is nothing obviously wrong with the code?

Not obviously, but I have a suspicion: I think the /scale attribute throws off the positioning of the erasing rectangle, because the erase routing mistakenly assumes the entire display is scaled by that factor, not just the individual stimulus.

There should, however, be an easy fix if all you care about is stimuli from the previous trial being cleared before the current trial draws to the screen. Simply add a clearscreen as the 1st stimulus in the trial, i.e.

<trial search>
/stimulustimes = [0=clearscreen, butterflies, plants, flowers, trees. leaf, fruits]
/ inputdevice = keyboard
/ validresponse = ("z", "n")
</trial>


and that should take care of everything
By kev_dent - 12/21/2022

Dave - 12/20/2022
kev_dent - 12/20/2022
I'm currently setting up a new experiment but I'm having an issue where my stimuli are not erased after each trial.
If I run the trial twice by enumerating two instances of the same trial it is fine.
However when called inside a block the stimuli persist.
Is this a bug or am I misunderstanding something?

Here is the code I am playing with:

<picture face>
/items =("Faces/Face1.jpg","Faces/Face2.jpg","Faces/Face3.jpg","Faces/Face4.jpg","Faces/Face5.jpg","Faces/Face6.jpg","Faces/Face7.jpg","Faces/Face8.jpg")
/scale = 0.25
/ position = (poslistx, poslisty)
/erase = true(white)
</picture>

<picture plants>
/items =("HousePlants/Plant1.bmp","HousePlants/Plant2.bmp","HousePlants/Plant3.bmp","HousePlants/Plant4.bmp","HousePlants/Plant6.bmp","HousePlants/Plant7.bmp","HousePlants/Plant8.bmp")
/scale = 0.25
/ position = (poslistx, poslisty)
/erase = true(white)
</picture>

<picture fruits>
/items = ("Fruit/Apple1.bmp","Fruit/Banana1.bmp","Fruit/Grapes1.bmp","Fruit/Lemon1.bmp","Fruit/Melon1.bmp","Fruit/Orange1.bmp","Fruit/Pear1.bmp","Fruit/Pineapple1.bmp")
/scale = 0.25
/ position = (poslistx, poslisty)
/erase = true(white)
</picture>

<picture flowers>
/items = ("Flowers/Amarylis.bmp","Flowers/Chrysan.bmp","Flowers/Clematis.bmp","Flowers/Echinace.bmp","Flowers/Mallow.bmp","Flowers/Marigold.bmp","Flowers/Sunflower.bmp","Flowers/Zinnia.bmp")
/scale = 0.25
/ position = (poslistx, poslisty)
/erase = true(white)
</picture>

<picture leafs>
/items = ("Leaves/Leaf1.bmp","Leaves/Leaf2.bmp","Leaves/Leaf3.bmp","Leaves/Leaf4.bmp","Leaves/Leaf5.bmp","Leaves/Leaf6.bmp","Leaves/Leaf7.bmp","Leaves/Leaf8.bmp")
/scale = 0.25
/ position = (poslistx, poslisty)
/erase = true(white)
</picture>

<picture trees>
/items = ("Trees/Tree1.bmp","Trees/Tree2.bmp","Trees/Tree3.bmp","Trees/Tree4.bmp","Trees/Tree5.bmp","Trees/Tree6.bmp","Trees/Tree7.bmp","Trees/Tree8.bmp")
/scale = 0.25
/ position = (poslistx, poslisty)
/erase = true(white)
</picture>

<picture butterflies>
/items = ("Butterflies/Butterfly1.bmp","Butterflies/Butterfly2.bmp","Butterflies/Butterfly3.bmp","Butterflies/Butterfly4.bmp","Butterflies/Butterfly5.bmp","Butterflies/Butterfly6.bmp","Butterflies/Butterfly7.bmp","Butterflies/Butterfly8.bmp")
/scale = 0.25
/ position = (poslistx, poslisty)
/erase = true(white)
</picture>

<list poslisty>
/items =(16*sin(0.33*m_pi)+50, 16*sin(0.66*m_pi)+50 , 16*sin(0.99*m_pi)+50, 16*sin(1.33*m_pi)+50, 16*sin(1.66*m_pi)+50, 16*sin(1.99*m_pi)+50)
/select=list.poslistx.currentindex
/ selectionrate = always
</list>

<list poslistx>
/items =(10*cos(0.33*m_pi)+50, 10*cos(0.66*m_pi)+50, 10*cos(0.99*m_pi)+50, 10*cos(1.33*m_pi)+50, 10*cos(1.66*m_pi)+50, 10*cos(1.99*m_pi)+50)

/ selectionrate = always
</list>


<trial search>
/stimulustimes = [0=butterflies plants flowers trees leafs fruits]
/ inputdevice = keyboard
/ validresponse = ("z" "n")
</trial>



<block main>
/trials = [
    1-10=search
]
</block>

<expt>

/blocks=[1=main]
</expt>

When you need to share code that requires external files (here: various images), please provide any and all files the code requires to run. Otherwise nobody can run it or reproduce any supposed issue.

Hi Dave, Please find a simplified version of the experiment attached (insufficient space for the original). 
I tried your clearscreen suggestion and it did solve the issue, do you know where "clearscreen" is documented I did not know about this possibility.
It would be good to know if the issue is due to the scaling I used, since I can of course resize the images that are used.
Thanks
Kevin
By Dave - 12/21/2022

kev_dent - 12/21/2022
Dave - 12/20/2022
kev_dent - 12/20/2022
I'm currently setting up a new experiment but I'm having an issue where my stimuli are not erased after each trial.
If I run the trial twice by enumerating two instances of the same trial it is fine.
However when called inside a block the stimuli persist.
Is this a bug or am I misunderstanding something?

Here is the code I am playing with:

<picture face>
/items =("Faces/Face1.jpg","Faces/Face2.jpg","Faces/Face3.jpg","Faces/Face4.jpg","Faces/Face5.jpg","Faces/Face6.jpg","Faces/Face7.jpg","Faces/Face8.jpg")
/scale = 0.25
/ position = (poslistx, poslisty)
/erase = true(white)
</picture>

<picture plants>
/items =("HousePlants/Plant1.bmp","HousePlants/Plant2.bmp","HousePlants/Plant3.bmp","HousePlants/Plant4.bmp","HousePlants/Plant6.bmp","HousePlants/Plant7.bmp","HousePlants/Plant8.bmp")
/scale = 0.25
/ position = (poslistx, poslisty)
/erase = true(white)
</picture>

<picture fruits>
/items = ("Fruit/Apple1.bmp","Fruit/Banana1.bmp","Fruit/Grapes1.bmp","Fruit/Lemon1.bmp","Fruit/Melon1.bmp","Fruit/Orange1.bmp","Fruit/Pear1.bmp","Fruit/Pineapple1.bmp")
/scale = 0.25
/ position = (poslistx, poslisty)
/erase = true(white)
</picture>

<picture flowers>
/items = ("Flowers/Amarylis.bmp","Flowers/Chrysan.bmp","Flowers/Clematis.bmp","Flowers/Echinace.bmp","Flowers/Mallow.bmp","Flowers/Marigold.bmp","Flowers/Sunflower.bmp","Flowers/Zinnia.bmp")
/scale = 0.25
/ position = (poslistx, poslisty)
/erase = true(white)
</picture>

<picture leafs>
/items = ("Leaves/Leaf1.bmp","Leaves/Leaf2.bmp","Leaves/Leaf3.bmp","Leaves/Leaf4.bmp","Leaves/Leaf5.bmp","Leaves/Leaf6.bmp","Leaves/Leaf7.bmp","Leaves/Leaf8.bmp")
/scale = 0.25
/ position = (poslistx, poslisty)
/erase = true(white)
</picture>

<picture trees>
/items = ("Trees/Tree1.bmp","Trees/Tree2.bmp","Trees/Tree3.bmp","Trees/Tree4.bmp","Trees/Tree5.bmp","Trees/Tree6.bmp","Trees/Tree7.bmp","Trees/Tree8.bmp")
/scale = 0.25
/ position = (poslistx, poslisty)
/erase = true(white)
</picture>

<picture butterflies>
/items = ("Butterflies/Butterfly1.bmp","Butterflies/Butterfly2.bmp","Butterflies/Butterfly3.bmp","Butterflies/Butterfly4.bmp","Butterflies/Butterfly5.bmp","Butterflies/Butterfly6.bmp","Butterflies/Butterfly7.bmp","Butterflies/Butterfly8.bmp")
/scale = 0.25
/ position = (poslistx, poslisty)
/erase = true(white)
</picture>

<list poslisty>
/items =(16*sin(0.33*m_pi)+50, 16*sin(0.66*m_pi)+50 , 16*sin(0.99*m_pi)+50, 16*sin(1.33*m_pi)+50, 16*sin(1.66*m_pi)+50, 16*sin(1.99*m_pi)+50)
/select=list.poslistx.currentindex
/ selectionrate = always
</list>

<list poslistx>
/items =(10*cos(0.33*m_pi)+50, 10*cos(0.66*m_pi)+50, 10*cos(0.99*m_pi)+50, 10*cos(1.33*m_pi)+50, 10*cos(1.66*m_pi)+50, 10*cos(1.99*m_pi)+50)

/ selectionrate = always
</list>


<trial search>
/stimulustimes = [0=butterflies plants flowers trees leafs fruits]
/ inputdevice = keyboard
/ validresponse = ("z" "n")
</trial>



<block main>
/trials = [
    1-10=search
]
</block>

<expt>

/blocks=[1=main]
</expt>

When you need to share code that requires external files (here: various images), please provide any and all files the code requires to run. Otherwise nobody can run it or reproduce any supposed issue.

Hi Dave, Please find a simplified version of the experiment attached (insufficient space for the original). 
I tried your clearscreen suggestion and it did solve the issue, do you know where "clearscreen" is documented I did not know about this possibility.
It would be good to know if the issue is due to the scaling I used, since I can of course resize the images that are used.
Thanks
Kevin

Clearscreen is documented at https://www.millisecond.com/support/docs/current/html/language/elements/clearscreen.htm

I've also confirmed that scaling is the issue. As suspected, this throws off the location of the rectangle intended to erase the given stimulus, since the routine mistakenly assumes the entire drawing surface is scaled by the given factor. (If you want to see this for yourself, set /erase = true(black) or some other non-white value on the picture element in the script you attached.) The bug has been logged and will be fixed in an upcoming update.

You can work around the issue by any of the following:
- Using clearscreen.
- Using /size in the picture element(s) instead of scale.
- Or, as you noted, resizing the original images to the intended target size.