Sinewave Gratings/Squarewave Gratings with different hue and contrast.

Hello All,


Do you have any codes on Color Look Up Table (CLUT)? Would you mind to find why the following codes are running for me? I think that MATLAB codes are running fine but there is a problem on the Psychtoolbox part?


I am trying to build a sinewave gratings/squarewave gratings with hue and contrast change.


If anyone can help me out.


% STEP 1: Creating a sinusoidal image in a MATLAB matrix.

nPixels = 256;

cyclesPerImage = 4;

sinVector = 1+254*(1+ sin(2*pi*cyclesPerImage*(1:nPixels)/nPixels))/2;

sinImage =ones(nPixels,1)*sinVector;


% STEP 2: Create a set of color lookup tables (cluts) for animating the grating.

nCluts = 80;

theCluts=zeros(256,3*nCluts);

theContrasts =sin(2*pi*(0:nCluts-1)/nCluts);

for i = 1:nCluts

    contrast = theContrasts(i);

    lowVal = 127.5-contrast*127.5;

    highVal = 127.5+contrast*127.5;

    clutEntries =[round(linspace(lowVal,highVal,256)')];

    theCluts(:,(i-1)*3+1:i*3)= clutEntries*ones(1,3);

       

end

 

offClut = 128*ones(256,3);


firstClutEntry=0;

framesPerClut=3;

nCycles =2;


% STEP 3: Open up a window on the main screen, initialize the clut, and draw a grating onto the screen.


whichScreen = max(Screen('Screens')); % find the main monitor

[windowPtr, rect] = PsychImaging('OpenWindow',whichScreen);

% Screen('ClutMovie',windowPtr, theCluts, firstClutEntry, framesPerClut, nCluts*nCycles);

Screen('LoadNormalizedGammaTable',windowPtr, theCluts, firstClutEntry, framesPerClut, nCluts*nCycles);

% Screen('LoadCLUT',windowPtr, offClut); 

Screen('SetClut', windowPtr,offClut);

Screen('Flip',windowPtr);


Screen('CloseScreen');


It would be great if anyone could help me out this.


Thank you,


Best,


Debarshi Datta


Hi,

the code you posted looks so wrong, and suggests you didn't even read the basic intro material or tutorials, or know how to use the basic help system for functions. Therefore i think you should first learn proper basic use of Psychtoolbox via our docs or Peter Scarfe's beginner friendly tutorials. See the "Tutorial" and "Function reference" links at http://psychtoolbox.org and also the primer on how to use the forum (Link "Forum") as well as the intro pdf docs in the PsychDocumentation folder.

best,
-mario


On Tue, Mar 26, 2019 at 7:17 PM debarshi_optometry@... [PSYCHTOOLBOX] <PSYCHTOOLBOX@yahoogroups.com> wrote:

Hello All,


Do you have any codes on Color Look Up Table (CLUT)? Would you mind to find why the following codes are running for me? I think that MATLAB codes are running fine but there is a problem on the Psychtoolbox part?


I am trying to build a sinewave gratings/squarewave gratings with hue and contrast change.


If anyone can help me out.


% STEP 1: Creating a sinusoidal image in a MATLAB matrix.

nPixels = 256;

cyclesPerImage = 4;

sinVector = 1+254*(1+ sin(2*pi*cyclesPerImage*(1:nPixels)/nPixels))/2;

sinImage =ones(nPixels,1)*sinVector;


% STEP 2: Create a set of color lookup tables (cluts) for animating the grating.

nCluts = 80;

theCluts=zeros(256,3*nCluts);

theContrasts =sin(2*pi*(0:nCluts-1)/nCluts);

for i = 1:nCluts

contrast = theContrasts(i);

lowVal = 127.5-contrast*127.5;

highVal = 127.5+contrast*127.5;

clutEntries =[round(linspace(lowVal,highVal,256)')];

theCluts(:,(i-1)*3+1:i*3)= clutEntries*ones(1,3);

end

offClut = 128*ones(256,3);


firstClutEntry=0;

framesPerClut=3;

nCycles =2;


% STEP 3: Open up a window on the main screen, initialize the clut, and draw a grating onto the screen.


whichScreen = max(Screen('Screens')); % find the main monitor

[windowPtr, rect] = PsychImaging('OpenWindow',whichScreen);

% Screen('ClutMovie',windowPtr, theCluts, firstClutEntry, framesPerClut, nCluts*nCycles);

Screen('LoadNormalizedGammaTable',windowPtr, theCluts, firstClutEntry, framesPerClut, nCluts*nCycles);

% Screen('LoadCLUT',windowPtr, offClut);

Screen('SetClut', windowPtr,offClut);

Screen('Flip',windowPtr);


Screen('CloseScreen');


It would be great if anyone could help me out this.


Thank you,


Best,


Debarshi Datta


Hi Mario,
Thanks for your suggestions. The code I posted MATLAB part of the codes is running very fine. But the stuck only on the Psychtoolbox syntax. I know how to use the help function. But, probably the syntax is so old that there is no much help regarding that. These codes I got from online, change a bit but it is not working. Surely, I will learn more, but if anyone knows better please send some CLUT related codes or fix the odds on my codes- the way I will have better understandings.

Thank you,

Best,

Debarshi

On Wed, Mar 27, 2019 at 1:18 PM Mario Kleiner mario.kleiner.de@... [PSYCHTOOLBOX] <PSYCHTOOLBOX@yahoogroups.com> wrote:

Hi,

the code you posted looks so wrong, and suggests you didn't even read the basic intro material or tutorials, or know how to use the basic help system for functions. Therefore i think you should first learn proper basic use of Psychtoolbox via our docs or Peter Scarfe's beginner friendly tutorials. See the "Tutorial" and "Function reference" links at http://psychtoolbox.org and also the primer on how to use the forum (Link "Forum") as well as the intro pdf docs in the PsychDocumentation folder.

best,
-mario


On Tue, Mar 26, 2019 at 7:17 PM debarshi_optometry@... [PSYCHTOOLBOX] <PSYCHTOOLBOX@yahoogroups.com> wrote:

Hello All,


Do you have any codes on Color Look Up Table (CLUT)? Would you mind to find why the following codes are running for me? I think that MATLAB codes are running fine but there is a problem on the Psychtoolbox part?


I am trying to build a sinewave gratings/squarewave gratings with hue and contrast change.


If anyone can help me out.


% STEP 1: Creating a sinusoidal image in a MATLAB matrix.

nPixels = 256;

cyclesPerImage = 4;

sinVector = 1+254*(1+ sin(2*pi*cyclesPerImage*(1:nPixels)/nPixels))/2;

sinImage =ones(nPixels,1)*sinVector;


% STEP 2: Create a set of color lookup tables (cluts) for animating the grating.

nCluts = 80;

theCluts=zeros(256,3*nCluts);

theContrasts =sin(2*pi*(0:nCluts-1)/nCluts);

for i = 1:nCluts

contrast = theContrasts(i);

lowVal = 127.5-contrast*127.5;

highVal = 127.5+contrast*127.5;

clutEntries =[round(linspace(lowVal,highVal,256)')];

theCluts(:,(i-1)*3+1:i*3)= clutEntries*ones(1,3);

end

offClut = 128*ones(256,3);


firstClutEntry=0;

framesPerClut=3;

nCycles =2;


% STEP 3: Open up a window on the main screen, initialize the clut, and draw a grating onto the screen.


whichScreen = max(Screen('Screens')); % find the main monitor

[windowPtr, rect] = PsychImaging('OpenWindow',whichScreen);

% Screen('ClutMovie',windowPtr, theCluts, firstClutEntry, framesPerClut, nCluts*nCycles);

Screen('LoadNormalizedGammaTable',windowPtr, theCluts, firstClutEntry, framesPerClut, nCluts*nCycles);

% Screen('LoadCLUT',windowPtr, offClut);

Screen('SetClut', windowPtr,offClut);

Screen('Flip',windowPtr);


Screen('CloseScreen');


It would be great if anyone could help me out this.


Thank you,


Best,


Debarshi Datta


Hello Marion,

Thanks for your suggestions. I just want to do square wave gratings with different hue and contrast. For those reasons, I was thinking to use CLUT.

Best,

Debarshi

On Wed, Mar 27, 2019 at 2:13 PM Mario Kleiner mario.kleiner.de@... [PSYCHTOOLBOX] <PSYCHTOOLBOX@yahoogroups.com> wrote:

On Wed, Mar 27, 2019 at 6:31 PM Debarshi Datta ddatta2014@...
[PSYCHTOOLBOX] <PSYCHTOOLBOX@yahoogroups.com> wrote:
> Hi Mario,
> Thanks for your suggestions. The code I posted MATLAB part of the codes is running very fine. But the stuck only on the Psychtoolbox syntax. I know how to use the help function. But, probably the syntax is so old that there is no much help regarding that. These codes I got from online, change a bit but it is not working. Surely, I will learn more, but if anyone knows better please send some CLUT related codes or fix the odds on my codes- the way I will have better understandings.
>

But if you know how to use our help system, it should have been
absolutely obvious within 5 minutes that that code can not possibly
work, not on any PTB released within the last 15 years? So far your
questions looked like one of these "i don't want to do my homework,
can somebody else do it for me, please?" posts.

Clut's in the conventional sense nowadays are only useful for display
color/gamma calibration, nothing else. The current design of operating
systems makes them a no-go for almost any other classic use case.

Psychtoolbox PsychImaging() command has a special clut mode that
allows to use clut's for things other than gamma correction, by
emulating old behaviour from the 90's.

But the thing is, it is not clear at all to me what exactly you want
to achieve and what the requirements of your optimal stimulus are. It
seems pretty likely that any kind of clut's would be the wrong or at
least highly inefficient approach to ait.

You probably should post an exact description of what you want to
achieve - paradigm, mathematic formulas defining your stimulus,
possibly Matlab sample code that would implement that stimulus purely
in Matlab, ie. outputting a simple image matrix for display. Then
somebody - and not neccessarily myself - might be able to guide you on
how to solve that task efficiently and accurately in the year 2019 on
hardware from this decade.

-mario

> Thank you,
>
> Best,
>
> Debarshi
>
> On Wed, Mar 27, 2019 at 1:18 PM Mario Kleiner mario.kleiner.de@... [PSYCHTOOLBOX] <PSYCHTOOLBOX@yahoogroups.com> wrote:
>>
>>
>>
>> Hi,
>>
>> the code you posted looks so wrong, and suggests you didn't even read the basic intro material or tutorials, or know how to use the basic help system for functions. Therefore i think you should first learn proper basic use of Psychtoolbox via our docs or Peter Scarfe's beginner friendly tutorials. See the "Tutorial" and "Function reference" links at http://psychtoolbox.org and also the primer on how to use the forum (Link "Forum") as well as the intro pdf docs in the PsychDocumentation folder.
>>
>> best,
>> -mario
>>
>>
>> On Tue, Mar 26, 2019 at 7:17 PM debarshi_optometry@... [PSYCHTOOLBOX] <PSYCHTOOLBOX@yahoogroups.com> wrote:
>>>
>>>
>>>
>>> Hello All,
>>>
>>>
>>> Do you have any codes on Color Look Up Table (CLUT)? Would you mind to find why the following codes are running for me? I think that MATLAB codes are running fine but there is a problem on the Psychtoolbox part?
>>>
>>>
>>> I am trying to build a sinewave gratings/squarewave gratings with hue and contrast change.
>>>
>>>
>>> If anyone can help me out.
>>>
>>>
>>> % STEP 1: Creating a sinusoidal image in a MATLAB matrix.
>>>
>>> nPixels = 256;
>>>
>>> cyclesPerImage = 4;
>>>
>>> sinVector = 1+254*(1+ sin(2*pi*cyclesPerImage*(1:nPixels)/nPixels))/2;
>>>
>>> sinImage =ones(nPixels,1)*sinVector;
>>>
>>>
>>> % STEP 2: Create a set of color lookup tables (cluts) for animating the grating.
>>>
>>> nCluts = 80;
>>>
>>> theCluts=zeros(256,3*nCluts);
>>>
>>> theContrasts =sin(2*pi*(0:nCluts-1)/nCluts);
>>>
>>> for i = 1:nCluts
>>>
>>> contrast = theContrasts(i);
>>>
>>> lowVal = 127.5-contrast*127.5;
>>>
>>> highVal = 127.5+contrast*127.5;
>>>
>>> clutEntries =[round(linspace(lowVal,highVal,256)')];
>>>
>>> theCluts(:,(i-1)*3+1:i*3)= clutEntries*ones(1,3);
>>>
>>>
>>>
>>> end
>>>
>>>
>>>
>>> offClut = 128*ones(256,3);
>>>
>>>
>>> firstClutEntry=0;
>>>
>>> framesPerClut=3;
>>>
>>> nCycles =2;
>>>
>>>
>>> % STEP 3: Open up a window on the main screen, initialize the clut, and draw a grating onto the screen.
>>>
>>>
>>> whichScreen = max(Screen('Screens')); % find the main monitor
>>>
>>> [windowPtr, rect] = PsychImaging('OpenWindow',whichScreen);
>>>
>>> % Screen('ClutMovie',windowPtr, theCluts, firstClutEntry, framesPerClut, nCluts*nCycles);
>>>
>>> Screen('LoadNormalizedGammaTable',windowPtr, theCluts, firstClutEntry, framesPerClut, nCluts*nCycles);
>>>
>>> % Screen('LoadCLUT',windowPtr, offClut);
>>>
>>> Screen('SetClut', windowPtr,offClut);
>>>
>>> Screen('Flip',windowPtr);
>>>
>>>
>>> Screen('CloseScreen');
>>>
>>>
>>> It would be great if anyone could help me out this.
>>>
>>>
>>> Thank you,
>>>
>>>
>>> Best,
>>>
>>>
>>> Debarshi Datta
>>>
>>>
>

On Wed, Mar 27, 2019 at 7:43 PM Debarshi Datta ddatta2014@... [PSYCHTOOLBOX] <PSYCHTOOLBOX@yahoogroups.com> wrote:

Hello Marion,

Thanks for your suggestions. I just want to do square wave gratings with different hue and contrast. For those reasons, I was thinking to use CLUT.


"help PsychDemos" or that section of our online reference would have pointed you to multiple demos on how to do that. Every into text of ours and on how to use the forum tells you to have a good look at the provided tutorials and PsychDemos first, before asking questions. E.g.,

ProceduralSquareWaveDemo.m for efficient square wave gratings, or DriftDemo4.m for efficient sine gratings, or ProceduralGarboriumDemo.m for other gratings like gaussian blobs or gabor patches. Obviously you have to read and understand the help for the functions used inside those demos on how to use and control these procedural stimuli properly. And maybe our Tutorial pdf slides on how to use alpha-blending efficiently with these.

This definitely allows fast online control of frequency, phase, contrast, and color. The way we define contrast may not be exactly the way you want it, because in vision science and engineering there seem to be multiple slightly conflicting definitions, so read everything about contrast and signal amplitude in the help texts very carefully. How the possible color manipulations relate to hue, and if they control hue in the way you want to control them, i don't know, because you still don't give detailed explanations.

-mario

Best,

Debarshi

On Wed, Mar 27, 2019 at 2:13 PM Mario Kleiner mario.kleiner.de@... [PSYCHTOOLBOX] <PSYCHTOOLBOX@yahoogroups.com> wrote:

On Wed, Mar 27, 2019 at 6:31 PM Debarshi Datta ddatta2014@...
[PSYCHTOOLBOX] <PSYCHTOOLBOX@yahoogroups.com> wrote:
> Hi Mario,
> Thanks for your suggestions. The code I posted MATLAB part of the codes is running very fine. But the stuck only on the Psychtoolbox syntax. I know how to use the help function. But, probably the syntax is so old that there is no much help regarding that. These codes I got from online, change a bit but it is not working. Surely, I will learn more, but if anyone knows better please send some CLUT related codes or fix the odds on my codes- the way I will have better understandings.
>

But if you know how to use our help system, it should have been
absolutely obvious within 5 minutes that that code can not possibly
work, not on any PTB released within the last 15 years? So far your
questions looked like one of these "i don't want to do my homework,
can somebody else do it for me, please?" posts.

Clut's in the conventional sense nowadays are only useful for display
color/gamma calibration, nothing else. The current design of operating
systems makes them a no-go for almost any other classic use case.

Psychtoolbox PsychImaging() command has a special clut mode that
allows to use clut's for things other than gamma correction, by
emulating old behaviour from the 90's.

But the thing is, it is not clear at all to me what exactly you want
to achieve and what the requirements of your optimal stimulus are. It
seems pretty likely that any kind of clut's would be the wrong or at
least highly inefficient approach to ait.

You probably should post an exact description of what you want to
achieve - paradigm, mathematic formulas defining your stimulus,
possibly Matlab sample code that would implement that stimulus purely
in Matlab, ie. outputting a simple image matrix for display. Then
somebody - and not neccessarily myself - might be able to guide you on
how to solve that task efficiently and accurately in the year 2019 on
hardware from this decade.

-mario

> Thank you,
>
> Best,
>
> Debarshi
>
> On Wed, Mar 27, 2019 at 1:18 PM Mario Kleiner mario.kleiner.de@... [PSYCHTOOLBOX] <PSYCHTOOLBOX@yahoogroups.com> wrote:
>>
>>
>>
>> Hi,
>>
>> the code you posted looks so wrong, and suggests you didn't even read the basic intro material or tutorials, or know how to use the basic help system for functions. Therefore i think you should first learn proper basic use of Psychtoolbox via our docs or Peter Scarfe's beginner friendly tutorials. See the "Tutorial" and "Function reference" links at http://psychtoolbox.org and also the primer on how to use the forum (Link "Forum") as well as the intro pdf docs in the PsychDocumentation folder.
>>
>> best,
>> -mario
>>
>>
>> On Tue, Mar 26, 2019 at 7:17 PM debarshi_optometry@... [PSYCHTOOLBOX] <PSYCHTOOLBOX@yahoogroups.com> wrote:
>>>
>>>
>>>
>>> Hello All,
>>>
>>>
>>> Do you have any codes on Color Look Up Table (CLUT)? Would you mind to find why the following codes are running for me? I think that MATLAB codes are running fine but there is a problem on the Psychtoolbox part?
>>>
>>>
>>> I am trying to build a sinewave gratings/squarewave gratings with hue and contrast change.
>>>
>>>
>>> If anyone can help me out.
>>>
>>>
>>> % STEP 1: Creating a sinusoidal image in a MATLAB matrix.
>>>
>>> nPixels = 256;
>>>
>>> cyclesPerImage = 4;
>>>
>>> sinVector = 1+254*(1+ sin(2*pi*cyclesPerImage*(1:nPixels)/nPixels))/2;
>>>
>>> sinImage =ones(nPixels,1)*sinVector;
>>>
>>>
>>> % STEP 2: Create a set of color lookup tables (cluts) for animating the grating.
>>>
>>> nCluts = 80;
>>>
>>> theCluts=zeros(256,3*nCluts);
>>>
>>> theContrasts =sin(2*pi*(0:nCluts-1)/nCluts);
>>>
>>> for i = 1:nCluts
>>>
>>> contrast = theContrasts(i);
>>>
>>> lowVal = 127.5-contrast*127.5;
>>>
>>> highVal = 127.5+contrast*127.5;
>>>
>>> clutEntries =[round(linspace(lowVal,highVal,256)')];
>>>
>>> theCluts(:,(i-1)*3+1:i*3)= clutEntries*ones(1,3);
>>>
>>>
>>>
>>> end
>>>
>>>
>>>
>>> offClut = 128*ones(256,3);
>>>
>>>
>>> firstClutEntry=0;
>>>
>>> framesPerClut=3;
>>>
>>> nCycles =2;
>>>
>>>
>>> % STEP 3: Open up a window on the main screen, initialize the clut, and draw a grating onto the screen.
>>>
>>>
>>> whichScreen = max(Screen('Screens')); % find the main monitor
>>>
>>> [windowPtr, rect] = PsychImaging('OpenWindow',whichScreen);
>>>
>>> % Screen('ClutMovie',windowPtr, theCluts, firstClutEntry, framesPerClut, nCluts*nCycles);
>>>
>>> Screen('LoadNormalizedGammaTable',windowPtr, theCluts, firstClutEntry, framesPerClut, nCluts*nCycles);
>>>
>>> % Screen('LoadCLUT',windowPtr, offClut);
>>>
>>> Screen('SetClut', windowPtr,offClut);
>>>
>>> Screen('Flip',windowPtr);
>>>
>>>
>>> Screen('CloseScreen');
>>>
>>>
>>> It would be great if anyone could help me out this.
>>>
>>>
>>> Thank you,
>>>
>>>
>>> Best,
>>>
>>>
>>> Debarshi Datta
>>>
>>>
>

Hello Mario,

Thanks for your post. I made the gratings with different hue by using only Matlab coding. The output of the function I used there was an image. So I got the square wave grating on the image. I want that on screen by using psych tool box. Please see the codes I attached (), it runs fine. I used this: [x,y]=meshgrid(linspace(0, wDeg, nxPix+1), linspace(0, wDeg, nyPix+1));

But, when I try to run the code on psychtoolbox the colormap I used before does not run in psychtoolbox. Please see the attachment ( I sent the code, It runs also fine, but square wave gratings comes on grayscale on screen. I thought then CLUT might go here fine.

Please see the codes I attached.

Thanks for your help,

Best,

Debarshi

On Wed, Mar 27, 2019 at 3:20 PM Mario Kleiner mario.kleiner.de@... [PSYCHTOOLBOX] <PSYCHTOOLBOX@yahoogroups.com> wrote:

On Wed, Mar 27, 2019 at 7:43 PM Debarshi Datta ddatta2014@... [PSYCHTOOLBOX] <PSYCHTOOLBOX@yahoogroups.com> wrote:

Hello Marion,

Thanks for your suggestions. I just want to do square wave gratings with different hue and contrast. For those reasons, I was thinking to use CLUT.


"help PsychDemos" or that section of our online reference would have pointed you to multiple demos on how to do that. Every into text of ours and on how to use the forum tells you to have a good look at the provided tutorials and PsychDemos first, before asking questions. E.g.,

ProceduralSquareWaveDemo.m for efficient square wave gratings, or DriftDemo4.m for efficient sine gratings, or ProceduralGarboriumDemo.m for other gratings like gaussian blobs or gabor patches. Obviously you have to read and understand the help for the functions used inside those demos on how to use and control these procedural stimuli properly. And maybe our Tutorial pdf slides on how to use alpha-blending efficiently with these.

This definitely allows fast online control of frequency, phase, contrast, and color. The way we define contrast may not be exactly the way you want it, because in vision science and engineering there seem to be multiple slightly conflicting definitions, so read everything about contrast and signal amplitude in the help texts very carefully. How the possible color manipulations relate to hue, and if they control hue in the way you want to control them, i don't know, because you still don't give detailed explanations.

-mario

Best,

Debarshi

On Wed, Mar 27, 2019 at 2:13 PM Mario Kleiner mario.kleiner.de@... [PSYCHTOOLBOX] <PSYCHTOOLBOX@yahoogroups.com> wrote:

On Wed, Mar 27, 2019 at 6:31 PM Debarshi Datta ddatta2014@...
[PSYCHTOOLBOX] <PSYCHTOOLBOX@yahoogroups.com> wrote:
> Hi Mario,
> Thanks for your suggestions. The code I posted MATLAB part of the codes is running very fine. But the stuck only on the Psychtoolbox syntax. I know how to use the help function. But, probably the syntax is so old that there is no much help regarding that. These codes I got from online, change a bit but it is not working. Surely, I will learn more, but if anyone knows better please send some CLUT related codes or fix the odds on my codes- the way I will have better understandings.
>

But if you know how to use our help system, it should have been
absolutely obvious within 5 minutes that that code can not possibly
work, not on any PTB released within the last 15 years? So far your
questions looked like one of these "i don't want to do my homework,
can somebody else do it for me, please?" posts.

Clut's in the conventional sense nowadays are only useful for display
color/gamma calibration, nothing else. The current design of operating
systems makes them a no-go for almost any other classic use case.

Psychtoolbox PsychImaging() command has a special clut mode that
allows to use clut's for things other than gamma correction, by
emulating old behaviour from the 90's.

But the thing is, it is not clear at all to me what exactly you want
to achieve and what the requirements of your optimal stimulus are. It
seems pretty likely that any kind of clut's would be the wrong or at
least highly inefficient approach to ait.

You probably should post an exact description of what you want to
achieve - paradigm, mathematic formulas defining your stimulus,
possibly Matlab sample code that would implement that stimulus purely
in Matlab, ie. outputting a simple image matrix for display. Then
somebody - and not neccessarily myself - might be able to guide you on
how to solve that task efficiently and accurately in the year 2019 on
hardware from this decade.

-mario

> Thank you,
>
> Best,
>
> Debarshi
>
> On Wed, Mar 27, 2019 at 1:18 PM Mario Kleiner mario.kleiner.de@... [PSYCHTOOLBOX] <PSYCHTOOLBOX@yahoogroups.com> wrote:
>>
>>
>>
>> Hi,
>>
>> the code you posted looks so wrong, and suggests you didn't even read the basic intro material or tutorials, or know how to use the basic help system for functions. Therefore i think you should first learn proper basic use of Psychtoolbox via our docs or Peter Scarfe's beginner friendly tutorials. See the "Tutorial" and "Function reference" links at http://psychtoolbox.org and also the primer on how to use the forum (Link "Forum") as well as the intro pdf docs in the PsychDocumentation folder.
>>
>> best,
>> -mario
>>
>>
>> On Tue, Mar 26, 2019 at 7:17 PM debarshi_optometry@... [PSYCHTOOLBOX] <PSYCHTOOLBOX@yahoogroups.com> wrote:
>>>
>>>
>>>
>>> Hello All,
>>>
>>>
>>> Do you have any codes on Color Look Up Table (CLUT)? Would you mind to find why the following codes are running for me? I think that MATLAB codes are running fine but there is a problem on the Psychtoolbox part?
>>>
>>>
>>> I am trying to build a sinewave gratings/squarewave gratings with hue and contrast change.
>>>
>>>
>>> If anyone can help me out.
>>>
>>>
>>> % STEP 1: Creating a sinusoidal image in a MATLAB matrix.
>>>
>>> nPixels = 256;
>>>
>>> cyclesPerImage = 4;
>>>
>>> sinVector = 1+254*(1+ sin(2*pi*cyclesPerImage*(1:nPixels)/nPixels))/2;
>>>
>>> sinImage =ones(nPixels,1)*sinVector;
>>>
>>>
>>> % STEP 2: Create a set of color lookup tables (cluts) for animating the grating.
>>>
>>> nCluts = 80;
>>>
>>> theCluts=zeros(256,3*nCluts);
>>>
>>> theContrasts =sin(2*pi*(0:nCluts-1)/nCluts);
>>>
>>> for i = 1:nCluts
>>>
>>> contrast = theContrasts(i);
>>>
>>> lowVal = 127.5-contrast*127.5;
>>>
>>> highVal = 127.5+contrast*127.5;
>>>
>>> clutEntries =[round(linspace(lowVal,highVal,256)')];
>>>
>>> theCluts(:,(i-1)*3+1:i*3)= clutEntries*ones(1,3);
>>>
>>>
>>>
>>> end
>>>
>>>
>>>
>>> offClut = 128*ones(256,3);
>>>
>>>
>>> firstClutEntry=0;
>>>
>>> framesPerClut=3;
>>>
>>> nCycles =2;
>>>
>>>
>>> % STEP 3: Open up a window on the main screen, initialize the clut, and draw a grating onto the screen.
>>>
>>>
>>> whichScreen = max(Screen('Screens')); % find the main monitor
>>>
>>> [windowPtr, rect] = PsychImaging('OpenWindow',whichScreen);
>>>
>>> % Screen('ClutMovie',windowPtr, theCluts, firstClutEntry, framesPerClut, nCluts*nCycles);
>>>
>>> Screen('LoadNormalizedGammaTable',windowPtr, theCluts, firstClutEntry, framesPerClut, nCluts*nCycles);
>>>
>>> % Screen('LoadCLUT',windowPtr, offClut);
>>>
>>> Screen('SetClut', windowPtr,offClut);
>>>
>>> Screen('Flip',windowPtr);
>>>
>>>
>>> Screen('CloseScreen');
>>>
>>>
>>> It would be great if anyone could help me out this.
>>>
>>>
>>> Thank you,
>>>
>>>
>>> Best,
>>>
>>>
>>> Debarshi Datta
>>>
>>>
>