On 16/12/2010 02:23, Marco Maas wrote:
> I get an error when i want to try ElementArrayStim. I want to use a
> Nx1 array for the Size of the elements and then i get an error. Below
> my code and the errormessage:
>
>
> mon = monitors.Monitor('program')
> pixsize = misc.deg2pix(6,mon)
> globForm = visual.ElementArrayStim(win, fieldPos=(0.0,0.0),
> fieldSize=pixSize, fieldShape = 'circle', nElements=50,sizes=[[10]
> [20]],sfs=3, elementTex=None, elementMask=None)
>
>
> ---------------------------------------------------
> File "C:\Users\Marco\Documents\My Dropbox\Python\distractor\test
> \elementArrays.py", line 32, in<module>
> globForm = visual.ElementArrayStim(win, fieldPos=(0.0,0.0),
> fieldSize= fieldSize, fieldShape = 'circle', nElements=N,sizes=[[10]
> [20]],sfs=3, elementTex=None, elementMask=None)
> IndexError: list index out of range
ah, there's a bug that prevents that. Really easy to fix though in
visual.py:
go to ElementArrayStim.setSizes and change the line (around 3150?) from
if value.shape in [(),(1,)]:
to
if value.shape in [(),(1,),(2,)]:
After that fix, this works for me:
from psychopy import monitors, visual, misc, event
win=visual.Window([800,600])
globForm = visual.ElementArrayStim(win, fieldPos=(0.0,0.0),units='pix',
fieldSize=[800,600], fieldShape = 'circle',
nElements=50,sizes=[10,20],sfs=0, elementTex=None, elementMask=None)
globForm.draw()
win.flip()
event.waitKeys()
>
> thank you.
>
> Further question in this case, is it possible with the depth
> parameter, to draw two stimuli in the same position, and one overlap
> the other?
Yes, in theory, but things get strange when you have stimuli with alpha
masks because the depth system doesn't understand those. Better simply
to draw things that you want to appear on top (with a 'lower' depth)
after things that you want to appear obscured.
> The documentation give not so much information, how to use
> this parameter. My first testing brought no results. Or if this not
> work, has psychopy something implemented for masking? For example i
> have an elementarraystim to present a star field in a square, but i
> want to mask it, that i have only a circle with the stars as output
> and the rest of the square is hidden?
To create a circular field you should be able simply to set the
fieldShape='circle', as above.
But if you wanted, you could create an inverse circle as a mask and draw
it after (above) the element array:
from psychopy import filters
invCircle = filters.makeMask(512,'circle')*-1
maskStim = visual.PatchStim(win,tex=None,mask=invCircle, size=[1.0,1.0],
contrast=0)
all the best,
Jon
--
Dr. Jonathan Peirce
Nottingham Visual Neuroscience
But it's also kind of a strange thing to mask for a 2D PatchStim with a
one-dimensional array. That's why the bug has never been spotted before.
Jon
--
Dr. Jonathan Peirce
Nottingham Visual Neuroscience
This message and any attachment are intended solely for the addressee and may contain confidential information. If you have received this message in error, please send it back to me, and immediately delete it. Please do not use, copy or disclose the information contained in this message or in any attachment. Any views or opinions expressed by the author of this email do not necessarily reflect the views of the University of Nottingham.
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.
about setting the orientation of the elementarray? You've obviously seen
the setOris method to set the ori of each element. There isn't a method
to alter the orientation of the whole array, but since you can set the
location and orientation of each element you can manage it that way I
guess? e.g. you could convert the XYs to polar coords, add an angle and
convert back.
By the way, I noticed you're using lots of loops. If you have a large
number of elements it will be worth moving that code to use numpy arrays
instead for speed.
Jon
thanks,
Jon
--