drawing an array of irregular shapes with ElementArrayStim

106 views
Skip to first unread message

Tao Gao

unread,
Jun 24, 2010, 9:16:10 PM6/24/10
to psychopy-users
Hi,

I’m trying to figure out how to draw any array of objects with the
ElementArrayStim class. Here is what I’m trying to do:

1. Define an irregular shape (Perhaps using the ShapeStim?)


2. Draw an array of this irregular shape with the ElementArrayStim.

Here are my questions.

1. How to convert a ShapeStim to a texture object which can be called
by the ElementArraySim? I see that I can save the ShapeStim as a .tif
file, and then read it as a picture. However, I do want to know if
there is any more direct way, without bothering to save a picture.

2. I noticed that the ElementArrayStim is optimized for drawing gabor-
like stimuli. This is great. However, it is not clear to me how to
turn the mask and the filter of spatial-frequency off. In other words,
if I have defined an irregular shape, and I want to draw *exactly* an
array of that shape without any mask and filter, what should I do?

Thanks very much!!

Tao

Tao Gao

unread,
Jun 26, 2010, 8:54:52 AM6/26/10
to psychopy-users
Hi

I have already figured out how to turn the mask of ElementArrayStim
off. However, I still don't know how to draw an array of irregular
shape with ElementArrayStim.

The API says:
the element of a dotStim could be none or a visual stimulus object.
This can be any object that has a .draw() method and a .setPos([x,y])
method (e.g. a PatchStim, TextStim...)!! See ElementArrayStim for a
faster implementation of this idea.

So I assume that the I can draw an irregular shape as a
visual.shapeStim, and then use this shapeStim as the element of the
ElementArrayStim. Unfortunately, when I tried this way, it seems that
the shapestim can not be called by ElementArrayStim.setTex()

Any suggestion will be greatly appreciated!

Thanks!

Tao

Jon Peirce

unread,
Jun 28, 2010, 4:40:23 AM6/28/10
to psychop...@googlegroups.com
No, I'm afraid there isn't a way to do that at the moment. ElementArrayStim requires a texture (ie a bitmap) as its input, both to the texture and the mask (which defines the shape) parameters. ShapeStim doesn't generate a texture at any point - it gets drawn geometrically to the screen so can't be combined directly here.

If you don't mind the elements all having the same shape you could pre-generate your shape(s) and save it to disk then use it as a mask for your ElementArrayStim. And you could use ShapeStim and win.getMovieFrame to do this initial generation step. But there is no way for the elements of an ElementArrayStim all to have different shapes. For that you'll need to implement your own drawing code using OpenGL.

Alternatively keep track of a list of shapestims and draw them in a loop - much easier if you dont have too many and/or don't mind potentially dropping frames.

Jon

PS, I'm afraid the API snippet there should be in DotStim not
On 26/06/2010 13:54, Tao Gao wrote:
Hi

I have already figured out how to turn the mask of ElementArrayStim
off. However, I still don't know how to draw an array of irregular
shape with ElementArrayStim.

The API says:
the element of a dotStim could be none or a visual stimulus object.
This can be any object that has a .draw() method and a .setPos([x,y])
method (e.g. a PatchStim, TextStim...)!! See ElementArrayStim for a
faster implementation of this idea.

So I assume that the I can draw an irregular shape as a
visual.shapeStim, and then use this shapeStim as the element of the
ElementArrayStim. Unfortunately, when I tried this way, it seems that
the shapestim can not be called by ElementArrayStim.setTex()

Any suggestion will be greatly appreciated!

Thanks!

Tao



On Jun 24, 9:16�pm, Tao Gao <taogao....@gmail.com> wrote:
  
Hi,

I�m trying to figure out how to draw any array of objects with the
ElementArrayStim class. �Here is what I�m trying to do:

1. Define an irregular shape (Perhaps using the ShapeStim?)

2. Draw an array of this irregular shape with the ElementArrayStim.

Here are my questions.

1. How to convert a ShapeStim to a texture object which can be called
by the ElementArraySim? I see that I can save the ShapeStim as a .tif
file, and then read it as a picture. However, I do want to know if
there is any more direct way, without bothering to save a picture.

2. �I noticed that the ElementArrayStim is optimized for drawing gabor-
like stimuli. This is great. However, it is not clear to me how to
turn the mask and the filter of spatial-frequency off. In other words,
if I have defined an irregular shape, and I want to draw *exactly* an
array of that shape without any mask and filter, what should I do?

Thanks very much!!

Tao
    
  

This message has been checked for viruses but the contents of an attachment may still contain software viruses which could damage your computer system: you are advised to perform your own checks. Email communications with the University of Nottingham may be monitored as permitted by UK legislation.

Reply all
Reply to author
Forward
0 new messages