Sign up Calendar Latest Topics

  Author   Comment  

Junior Member
Posts: 3
Reply with quote  #1 
Hello all,

Has anyone run tests in ML2 with drifting gratings? With ML1, we would create drifting gratings using a 4-dimensional array. The first three dimensions created an rgb array, and the fourth was the number of frames required (obtained by dividing screen refresh rate by temporal frequency).

It seems that this method should transfer over to ML2, but we have run into an issue. Our timing file calls for the drifting grating to be presented for one second, but when we run the files, it only presents for a fraction of a second.

Can ML2 still handle 4D arrays to create drifting gratings? For reference, the following chunk of code should give a high level view of how the 4D array, GRATING, is made.


% compute phases for each frame in movie
nFrames = ceil(RefreshRate*1/temporal_freq);

phases = deg2rad(wrapTo360(linspace(grating_phase,grating_phase+360,nFrames)));

GRATING  = ones([I J 3 nFrames]); % I and J are matrix dimensions

for iFrame = 1: nFrames % make drifting grating
p = phases(iFrame);

[x,y] = meshgrid(-J/2:1[frown]J/2-1), (I/2):-1:I/2+1));
target = bg_color(1)* ... % grating, full data range [0 1]
(1 + c*square(2*pi*f*( y*sin(t) + x*cos(t) ) + p ));
s = 0;

% convert to true color RGB matrix
for rgb = 1:3 % get the indices for particular RGB colormap
RGBgun = linspace(grating_colors(1,rgb),grating_colors (2,rgb),255); % 8 bit RGB gun
ci = ceil(length(RGBgun)*target);
ci(ci == 0) = 1; ci(ci > 255) = 255;
GRATING(:,:,rgb,iFrame) = RGBgun(ci);

% apply circular mask
mask = sqrt(x.^2 + y.^2) > d/2;
for rgb = 1:3
RGBchannel = GRATING(:,:,rgb,iFrame);
RGBchannel(mask) = bg_color(rgb);
GRATING(:,:,rgb,iFrame) = RGBchannel;



Posts: 939
Reply with quote  #2 
Have you looked at the example tasks I put in the NIMH ML packages?

task\runtime v1\6 grating
task\runtime v2\19 Gabor patch

Also see

Which object type between GEN and MOV do you use to present your gratings?
Previous Topic | Next Topic

Quick Navigation:

Easily create a Forum Website with Website Toolbox.