[visionegg] Re: Mask2D and SinGrating2D problem
- From: Mark Halko <mhalko@xxxxxx>
- To: visionegg@xxxxxxxxxxxxx
- Date: Tue, 6 Sep 2005 14:26:25 -0400
On Sep 4, 2005, at 11:34 PM, Constantin Buzduga wrote:
So my first question (not really related to the message title) would
be, how can I find the members and methods of the different classes?
A good reference for this is the library reference generated from the
source:
http://visionegg.org/reference/index.html (note, this will have
"bleeding"
edge information, which may not be present in your download).
Running help on functions will also give you the same information:
>>> import VisionEgg
>>> import VisionEgg.Gratings
>>> help(VisionEgg.Gratings)
Check the source also for your particular install of Visionegg. Python
is
mostly an interpreted language, so installed code is readable.
Lastly, you can run dir(class) on any class to see what it contains:
>>> screen = VisionEgg.Core.get_default_screen()
>>> dir(screen)
['__class__', '__cursor_visible_func__', '__del__', '__delattr__',
'__doc__', '__getattribute__', '__getstate__', '__hash__', '__init__',
'__module__', '__new__', '__pygame_quit__', '__reduce__',
'__reduce_ex__', '__repr__', '__safe_for_unpickling__', '__setattr__',
'__setstate__', '__slots__', '__str__', '_create_inverted_gamma_ramp',
'_open_gamma_file', '_pixel_coord_projection',
'_put_pixels_texture_stimulus', 'clear', 'close',
'constant_parameters', 'constant_parameters_and_defaults',
'create_default', 'get_framebuffer_as_array',
'get_framebuffer_as_image', 'get_size', 'get_specified_type',
'is_constant_parameter', 'make_current', 'measure_refresh_rate',
'parameters', 'parameters_and_defaults', 'put_pixels',
'query_refresh_rate', 'set', 'set_gamma_ramp', 'set_size', 'size',
'verify_parameters']
mask = Mask2D(function='circle',
radius_parameter=300,
num_samples=(512,512))
grating = SinGrating2D(mask = mask,
position = ( 400,300 ),
size = ( 600.0 , 600.0 ),
spatial_freq = 0.0125,
temporal_freq_hz = 0.0,
color1 = (0.0,0.0,0.0),
color2 = (1.0,1.0,1.0),
on = 1,
orientation = 45.0 )
p.add_controller(grating,'size',FunctionController(during_go_func=lambd
a
t: eval(gui_window.spot_diameter.get()),
eval(gui_window.spot_diameter.get()) ))
The problem is, when I set the size of the grating to (600,600), the
circle shown on the screen is not the same height as my my screen
(800x600 px), it's smaller less than 500px in diameter, I'd say!!!
I think what's happening is your radius is the wrong size for your mask.
It needs to be 256 (512/2). (i'm actually surprised you're not seeing
a clipped circle)
See below.
If this doesn't fix it, you'll have to check your projection matrix.
Since it's not posted, I can't tell.
Can you please help me with this?This is why I was saying, I must
understand what each parameter does, to be able to do this right. I
don't know what "num_samples" does,
According to the source it is : "number of spatial samples, should be a
power of 2"
and the info in the visionegg.org
documentation didn't clear this out for me. I also don't know ho the
radius_parameter influences the circle mask, and how it is correlated
with num_samples.
The radius_parameter should be the radius of the mask in texels, for a
circle.
Num_samples ends up being the number of texels in the mask. More
texels will give you
a higher resolution anti-aliased circle.
In other words, your mask has dimensions (512,512). Unfortunately,
mapping
power of 2 texture coordinates to an arbitrary texture size is kind of
a pain. What's happening
is you're stretching a (512,512) object to cover a (600,600) object.
Therefore, your calculations
for the mask size need to be mask coordinates (num_samples).
Fortunately, in your case, it's easy - the radius needs to be half the
dimensions of
the mask. This way, your mask is a circle the full size of the grating
(no matter the size
of the grating).
Now if you wanted a smaller mask, it's slightly more complicated, as
you'd want to figure
the proportion of radius/num_samples[0] to make the right circle size.
For what it's worth, this code makes a circle grating that has a
diameter equal
to the screen height when I set window size to be 800x600):
from VisionEgg.Core import *
from VisionEgg.Textures import *
from VisionEgg.Gratings import *
screen = get_default_screen()
mask =
Mask2D(function='circle',radius_parameter=256.,num_samples=(512,512))
grating = SinGrating2D(mask = mask,
position = ( 400,300 ),
size = ( 600.0 , 600.0 ),
spatial_freq = 0.0125,
temporal_freq_hz = 0.0,
color1 = (0.0,0.0,0.0),
color2 = (1.0,1.0,1.0),
on = 1,
orientation = 0.0 )
viewport = Viewport(screen=screen, stimuli=[grating])
p = Presentation(go_duration=(1.0,'seconds'),viewports=[viewport])
p.go()
Mark
======================================
The Vision Egg mailing list
Archives: http://www.freelists.org/archives/visionegg
Website: http://www.visionegg.org/mailinglist.html
- Follow-Ups:
- [visionegg] Re: Mask2D and SinGrating2D problem
- From: Constantin Buzduga
- References:
- [visionegg] Mask2D and SinGrating2D problem
- From: Constantin Buzduga
Other related posts:
- » [visionegg] Mask2D and SinGrating2D problem
- » [visionegg] Re: Mask2D and SinGrating2D problem
- » [visionegg] Re: Mask2D and SinGrating2D problem
So my first question (not really related to the message title) would be, how can I find the members and methods of the different classes?
mask = Mask2D(function='circle', radius_parameter=300, num_samples=(512,512))
grating = SinGrating2D(mask = mask,
position = ( 400,300 ),
size = ( 600.0 , 600.0 ),
spatial_freq = 0.0125,
temporal_freq_hz = 0.0,
color1 = (0.0,0.0,0.0),
color2 = (1.0,1.0,1.0), on = 1,
orientation = 45.0 )p.add_controller(grating,'size',FunctionController(during_go_func=lambd a
t: eval(gui_window.spot_diameter.get()),
eval(gui_window.spot_diameter.get()) ))
The problem is, when I set the size of the grating to (600,600), the circle shown on the screen is not the same height as my my screen (800x600 px), it's smaller less than 500px in diameter, I'd say!!!
Can you please help me with this?This is why I was saying, I must understand what each parameter does, to be able to do this right. I don't know what "num_samples" does,
and the info in the visionegg.org documentation didn't clear this out for me. I also don't know ho the radius_parameter influences the circle mask, and how it is correlated with num_samples.
from VisionEgg.Core import * from VisionEgg.Textures import * from VisionEgg.Gratings import *
- [visionegg] Re: Mask2D and SinGrating2D problem
- From: Constantin Buzduga
- [visionegg] Mask2D and SinGrating2D problem
- From: Constantin Buzduga