Millisecond Forums

When does picture preloading occur?

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

By Blackadder - 10/21/2013

Simple question: at what point during an experiment are pictures preloaded into (graphics) memory?


Follow-up question: can that point be controlled programatically?


Best wishes,
  Malte 

By Dave - 10/21/2013

To the best of my knowledge:


Into main memory (i.e. RAM): When the script is parsed.


Into graphics memory: When the stim is prepared by a <trial>, i.e. during /pretrialpause if there is any.

By Blackadder - 10/21/2013

Thanks, that's what I was hoping for.


I asked because we recently observed a picture loading delay when pictures are loaded over a busy LAN connection. Each trial would take some time to start. The delay vanishes when the network connection is unthrottled.


Plus, the picture files used by the script are write-protected during the whole runtime of the script. That should not happen if parsing & memory loading occurred at the start of the script, should it?

By Dave - 10/21/2013

How exactly are you using the picture files throughout the script? There are situations where parsing into memory up-front may not be possible (e.g. not enough RAM available or -- more likely -- when you dynamically shuffle items around at runtime). Anything of that sort going on here?

By Blackadder - 10/21/2013

Yes, exactly. I preload the stimuli (only 4 rather small BMP files) as an <item> list referenced by a <picture> element. Then I set the / select property of other <picture> elements to the appropriate indices at runtime.


Will that pose a problem?

By Dave - 10/21/2013

If I understand your setup correctly, I'd say no, shouldn't pose a problem. To give you an example,


<expressions>
/ rnd = noreplace(1,2)
</expressions>

<values>
/ a = 1
/ b = 1
</values>

<trial mytrial>
/ ontrialbegin = [values.a=expressions.rnd; values.b=expressions.rnd]
/ stimulustimes = [0=a; 1000=b]
/ validresponse = (noresponse)
/ trialduration = 1500
</trial>

<picture a>
/ items = myitems
/ select = values.a
</picture>

<picture b>
/ items = myitems
/ select = values.b
</picture>

<item myitems>
/ 1 = "pic01.jpg"
/ 2 = "pic02.jpg"
</item>

<block myblock>
/ trials = [1-10=mytrial]
</block>


should perform better than


<expressions>
/ rnd = noreplace(1,2)
</expressions>

<trial mytrial>
/ ontrialbegin = [picture.a.item=getitem(item.myitems, expressions.rnd);
    picture.b.item=getitem(item.myitems, expressions.rnd)]
/ ontrialend = [clear(picture.a); clear(picture.b)]
/ stimulustimes = [0=a; 1000=b]
/ validresponse = (noresponse)
/ trialduration = 1500
</trial>

<picture a>
</picture>

<picture b>
</picture>

<item myitems>
/ 1 = "pic01.jpg"
/ 2 = "pic02.jpg"
</item>

<block myblock>
/ trials = [1-10=mytrial]
</block>


although -- at the surface level -- both do the same thing.

By Blackadder - 10/29/2013

That is interesting. I tested several variants now and found your first suggestion to be fastest among all. Thanks for pointing that out!