How to efficiently generate multiple textures?

I am using PTB-3 to produce gratings of different spatial frequencies (sf) and display them in random order. I find if the number of different sf is large, say, 10+, the time used on making these textures would be considerable. So, is there some methods to efficiently make multiple textures?

Thank you for your time!
One possible solution is to generate one large low SF texture, and take a part of it, and shrink it during drawing if necessary.
Xiangrui

--- In psychtoolbox@yahoogroups.com, "yanxia.pan" <yanxia.pan@...> wrote:
>
> I am using PTB-3 to produce gratings of different spatial frequencies (sf) and display them in random order. I find if the number of different sf is large, say, 10+, the time used on making these textures would be considerable. So, is there some methods to efficiently make multiple textures?
>
> Thank you for your time!
>
Yes that's a great idea and I have tried before however I didn't make it...anyway I'll consider it later.
But how about different temporal frequencies and contrasts?? It seems the only solution is to truly generate multiple textures...

BTW: are you from USTC, xiangrui?

--- In psychtoolbox@yahoogroups.com, "xrli2002" <xrli@...> wrote:
>
> One possible solution is to generate one large low SF texture, and take a part of it, and shrink it during drawing if necessary.
> Xiangrui
>
> --- In psychtoolbox@yahoogroups.com, "yanxia.pan" <yanxia.pan@> wrote:
> >
> > I am using PTB-3 to produce gratings of different spatial frequencies (sf) and display them in random order. I find if the number of different sf is large, say, 10+, the time used on making these textures would be considerable. So, is there some methods to efficiently make multiple textures?
> >
> > Thank you for your time!
> >
>
For TF, are you talking about drifting or reversing? The former can be easily done by shift pixels in texture (see DriftDemo series). The latter may be complicated. For contrast modulation, you could achieve it by alpha blending, but probably it is not necessary, since you are unlikely to manipulate several parameters in a single run. If the display onset timing is not critical, as for most experiments such as for psychphysics or fMRI, it is okay to make texture for each trial on the fly. BTW, I am from USTC.
Xiangrui

--- In psychtoolbox@yahoogroups.com, "yanxia.pan" <yanxia.pan@...> wrote:
>
> Yes that's a great idea and I have tried before however I didn't make it...anyway I'll consider it later.
> But how about different temporal frequencies and contrasts?? It seems the only solution is to truly generate multiple textures...
>
> BTW: are you from USTC, xiangrui?
>
> --- In psychtoolbox@yahoogroups.com, "xrli2002" <xrli@> wrote:
> >
> > One possible solution is to generate one large low SF texture, and take a part of it, and shrink it during drawing if necessary.
> > Xiangrui
> >
> > --- In psychtoolbox@yahoogroups.com, "yanxia.pan" <yanxia.pan@> wrote:
> > >
> > > I am using PTB-3 to produce gratings of different spatial frequencies (sf) and display them in random order. I find if the number of different sf is large, say, 10+, the time used on making these textures would be considerable. So, is there some methods to efficiently make multiple textures?
> > >
> > > Thank you for your time!
> > >
> >
>
This can be problematic because the combination of downsampling and bilinear filtering itself can introduce filtering artifacts if there isn't a reasonably close match between the size of the texture and the size in which it is finally drawn. It might change the spatial frequency distribution in your stim.

Procedural gratings are the fastest and most flexible way on a modern graphics card.
-mario

--- In psychtoolbox@yahoogroups.com, "xrli2002" <xrli@...> wrote:
>
> One possible solution is to generate one large low SF texture, and take a part of it, and shrink it during drawing if necessary.
> Xiangrui
>
> --- In psychtoolbox@yahoogroups.com, "yanxia.pan" <yanxia.pan@> wrote:
> >
> > I am using PTB-3 to produce gratings of different spatial frequencies (sf) and display them in random order. I find if the number of different sf is large, say, 10+, the time used on making these textures would be considerable. So, is there some methods to efficiently make multiple textures?
> >
> > Thank you for your time!
> >
>
> p.s.
> Mario: how difficult would it be to add a circular mask in the sine grating shader; I've had a brief look at the shader files but don't fully understand how to do it in GSLS...
>

Trivial,

and implemented for next beta. If you want to try it earlier, grab the modified m-file and new shader from here (careful, still hot!):

<http://svn.berlios.de/wsvn/osxptb/?op=revision&rev=1768&peg=1768>

-mario
--- In psychtoolbox@yahoogroups.com, "Mario" <mario.kleiner@...> wrote:
> > p.s.
> > Mario: how difficult would it be to add a circular mask in the sine grating shader; I've had a brief look at the shader files but don't fully understand how to do it in GSLS...
> >
>
> Trivial,
>
> and implemented for next beta. If you want to try it earlier, grab the modified m-file and new shader from here (careful, still hot!):
>
> <http://svn.berlios.de/wsvn/osxptb/?op=revision&rev=1768&peg=1768>

Mario, you are a STAR!!! Thanks, hope I can look at the diffs between the shaders and work out what you did. Shaders are so powerful I'd love to easily code them to demand as you do!

Cheers, Ian
Hi Ian! Surprise to see you here! I will try the suggestion you and Mario gave...I didn't even know the existence of this thing...


--- In psychtoolbox@yahoogroups.com, "tattooed.tentacle" <iandol@...> wrote:
>
> --- In psychtoolbox@yahoogroups.com, "yanxia.pan" <yanxia.pan@>
> > I am using PTB-3 to produce gratings of different spatial frequencies (sf) and display them in random order. I find if the number of different sf is large, say, 10+, the time used on making these textures would be considerable.
>
> Hi Pan :-)
>
> Have you tried using procedural gratings?
>
> http://docs.psychtoolbox.org/CreateProceduralSineGrating
>
> The grating is rendered in the graphics engine and you just need to enter the various parameters on each refresh. This makes drifting gratings and gabors (CreateProceduralGabor) easy. See ProceduralGaborDemo and ProceduralGarboriumDemo for examples.
>
> another idea: if you are showing gratings with a pause between the randomised stimuli, could you generate the next stimulus in the pause between stimuli, that would reduce the initial delay?
>
> Take care, Ian
>
> p.s.
> Mario: how difficult would it be to add a circular mask in the sine grating shader; I've had a brief look at the shader files but don't fully understand how to do it in GSLS...
>