#### Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Supported by

# [solved] Gabor patch parameters

edited October 2012

Hi,

I have some trouble with the gabor patch parameters in the OpenSesame function. I wanted to know how exactly spatial frequency is defined and how you can define contrast of the gabor gratings in OpenSesame using this function.

From what I understood the gabor gratings’ spatial frequency in contemporary literature is mostly defined in cycles per degree (that is visual angle). In the OpenSesame function however, it is defined in cycles per pixel, creating different gratings when filling in values defined as in cycles per degree. So my question is how do you come from the one value to the other?

The other parameter, contrast, is not entirely clear to me either. It is not definable in the function or did I overlook something? Or is it solely based on the difference between the two RGB values.

Hope you guys can help me out! Id really appreciate it!

• edited October 2012

Right, OpenSesame uses computer units, because these are unambiguous. But, of course, given knowledge of your set-up, you can translate these into other units.

I wanted to know how exactly spatial frequency is defined and how you can define contrast of the gabor gratings in OpenSesame using this function. From what I understood the gabor gratings’ spatial frequency in contemporary literature is mostly defined in cycles per degree (that is visual angle). In the OpenSesame function however, it is defined in cycles per pixel, creating different gratings when filling in values defined as in cycles per degree. So my question is how do you come from the one value to the other?

A typical monitor has about 30 to 40 pixels per degree (you can determine this from the viewing distance, display size, and display resolution). This means that 1 visual degree spans 30 to 40 pixels on the monitor. Therefore, if you want to have a spatial frequency of 1 cycle/°, you need to do something like the following:

```sfCyclesDeg = 1 # Desired spatial frequency in cycles per degree
pixelsPerDegree = 30 # Depends on your set-up
sfCyclesPx = sfCyclesDeg / pixelsPerDegree # Parameter for canvas.gabor()```

So basically, you just divide by the number of pixels per degree. Does that make sense?

The other parameter, contrast, is not entirely clear to me either. It is not definable in the function or did I overlook something? Or is it solely based on the difference between the two RGB values.

The latter: The Gabor is just an oscillation between the two colours (in the PsychoPy back-end it works a bit differently, but comes down to the same thing). So if you oscillate between 'white' and 'black' this would be a contrast of 100%, because that's the most contrast your monitor can give you. Note that saying that the contrast is 100% doesn't mean anything in an absolute sense. If you want to be more specific, you need to measure the luminosity of various colours on your monitor, ideally perform gamma-correction, etc. If you want to do that, you might want to look into PsychoPy's functionality. (I'm not saying it's necessary, or even recommending that you do this. But simply that these are things that you can do.)

Cheers!

• edited 3:05PM

Ah! That makes sense!

Thanks!

• edited 3:05PM

I'm confused. How do I factor in where so specify the size. I know my screen resolution, my screen size, my viewing distance, etc. And I need a 3cpd pattern, but the pattern changes depending on the size. ???

• edited 3:05PM

The way to convert from degrees of visual angle to pixels and vice versa is described in detail here:

If this information doesn't answer your question, could you be a bit more specific and describe what you want to do, what you've done so far, and why you don't get the expected results?

Cheers,
Sebastiaan

• edited March 2015

Thanks for your reply. I understand that ppd is `180.pi*d*r` where r is the resolution of the screen, d is the viewing distance, etc. And that I need to use cpd/ppd to get the parameter. But I don't understand where it asks for the size?

I am looking to create 3 sinusoidal grating (each at 180 and 90), black bars on a white background, each will be viewed from 40 cm on an iPad screen (needs to be a large circle in the middle of the screen (sharp edge)) and the three cpd visual angle I need are:

0.3
2.3
9.4

Can you tell me what I need to put in?

• edited 3:05PM

But I don't understand where it asks for the size?

I'm guessing that 'it' refers to the Online Gabor patch generator?

A gabor patch doesn't have a size--it's infinite. So instead you specify the standard deviation, where larger standard deviations are bigger. Because the image is, in the end, a finite-size bitmap, you do specify a size, but that's just the 'box' around the Gabor patch so to say.

Other than that it seems that you might be confusing the size of a Gabor with its spatial frequency. Only the spatial frequency is (or can be) specified in cycles/degree (cpd).

Does that clear things up?

Cheers,
Sebastiaan

• edited 3:05PM

Thanks for your reply. I'm so confused. I do mean the Online Gabor patch generator. The frequency seems to change when I specify a different size box.

• edited 3:05PM

Can I email anyone to show you what I'm trying to do

• edited 3:05PM

The frequency seems to change when I specify a different size box.

It doesn't. :P

Can I email anyone to show you what I'm trying to do

It's preferable to keep all questions on the forum, so other people can benefit as well.

• edited 3:05PM

I've no idea what I'm really doing lol What is standard deviation? Can you comment on what parameters you think I need based on my requires above? I'm trying to reproduce something called a pattern glare test. Sorry for being so stupid! I'm so out my depth here! Thanks for trying to help.