0

We are using the Psychtoolbox in Matlab to make an experiment. We want to do is placing smaller images (locations are specified beforehand) over a large one. The trouble is that we lose the background image once we try putting the smaller ones on top of it. Also, every image is always centered and we are having trouble figuring out how to place the images in the specified locations.

We have tried doing this using 'DrawTextures' and 'PutImage', but it is failing so far. Could you help us?

Here is some of our code:

[w,screenrect]=Screen('OpenWindow',screennr);
Screen(w,'fillrect',background_color);
Screen('Flip', w);

sr = [0 0 s_grootte s_grootte];
dst = CenterRect(sr,screenrect);

nr=max(Screen('Screens'));
Screen('PutImage', w, image); %% image is defined beforehand, ofcourse

%% We want to put smaller images on top of this

for i = 1:n_images:

% coordinates should be picked randomly from beforehand specified matrix
location_number = r(1,i);
coordinates = locations(location_number,:);
x = coordinates(1,1);
y = coordinates(1,2);

%% Now we have selected the coordinates, we want to place the smaller image on 
%% that location

end
Boreq
  • 95
  • 6

1 Answers1

0

I found out myself how to do it. The problem was the timing in flipping the screen (placing the matrices on screen).

The location of the stimuli had to be coded in this way:

Screen('DrawTexture',window,ImageArray,[size],[location])

Where size and location were coded in this order: [Left, Top, Right, Bottom]. The screen had to be flipped after all the calculations were done, otherwise the screen is overwritten. Hopefully I can help some else with this in the future.

Boreq
  • 95
  • 6