function [b] = bookfig3(a) % Simple script to generate Figure 3, chapter 14 WITHOUT SPM! Just Matlab % Book: Human Brain Function. Academic Press, 2nd edition, 2003 % Authors: Frackowiak, Friston, Frith, Dolan, Price, Zeki, Ashburner, and Penny. % Script source: http://www.poirrier.be/~jean-etienne/presentations/rft/ % !!!!! YOU SHOULD HAVE RUN SCRIPT bookfig1.m BEFORE THIS ONE % !!!!!!!!!! IN ORDER TO HAVE THE CORRECT AND SAME 'a' MATRIX ! % How to run it? "z3 = bookfig3(z);" % Argument 'a' is the square ramdom map from script bookfig1! % Requires: Image Processing Toolbox for fspecial() and conv2() % Clear screen clf; close; % Compute the "Gaussian filter" - It's not really the one used in the book! hsize = 100; % will use a Gaussian filter with this hsize FWHM = 3; % full width at half maximum sigma = FWHM / sqrt(8*log(2)); % fspecial() needs sigma and not FWHM %sigma = 1.2; G = fspecial('gaussian', hsize, sigma); % Apply filter to matrix a -becomes-> b b = conv2(G, a, 'same'); % Rescale map to match 0.0 -> 1.0 maxi = max(max(b)) for i = 1:hsize for j = 1:hsize b(i,j) = b(i,j) / maxi; end end meany = mean(mean(b)) % Now display b, the filtered matrix h = imagesc(b); % Beautify image set(gca,'YDir','normal'); colormap(gray); ylabel('Position du pixel en Y'); xlabel('Position du pixel en X');