In my experiment I am displaying lots of different gratings. To save time during the experiment's execution, I'm pre-drawing the corresponding textures and keep them in a buffer. However, this takes about 10-20 seconds depending on how many stimuli the run uses, and how fast the machine is.
I was wondering whether there is a way of storing the pre-drawn textures on the hard drive and just have them read in?
Here is the current code:
tic
stimulus_matrix = [];
for ifrequencies = 1:length(frequencies)
for iphase = 1:length(phases)
for icontrast_manipulation = 1:length(contrast_manipulation)
for icontrast_values = 1:length(contrast_values(1,:))
grating = makeStimulus(contrast_values(icontrast_manipulation,icontrast_values),grating_size_degrees,phases(iphase),frequencies(ifrequencies,1));
stimulus_matrix(ifrequencies,iphase,icontrast_manipulation,icontrast_values) = Screen('MakeTexture', my_window, grating);
Screen('FillOval', stimulus_matrix(ifrequencies,iphase,icontrast_manipulation,icontrast_values), background, CenterRect(ovalRect,gratingRect));
% Display a progress bar during buffering
% code for progress bar removed for clarity
end
end
end
end