Zhi,
For #2 below, try the attached script.
Kathy Pearson
UAB Psychology
________________________________________
From: SPM (Statistical Parametric Mapping) [mailto:[log in to unmask]] On
Behalf Of WANG, Zhi
Sent: Sunday, June 22, 2008 5:15 AM
To: [log in to unmask]
Subject: [SPM] help about script of SPM
Dear all
I have questions about how to write scripts to :
1. display or insert a title of a figure of SPM in the figure window,
instead of clicking the insert button of figure window;
2. save the result of SPM to a image file in scripts
I read a lot of the spm command m files, but could not find any clue. Can
any body help me?
Best
Zhi
function uab_spm2image(fname)
%__________________________________________________________________________
%
% Syntax:
% function uab_spm2image(fname)
%
% Description:
% If fname is specified and the spm figure tagged 'Graphics' does exist,
% then the image file name is created to hold a copy of the image.
% The image type is specified by the fname extension such as png or jpg.
% If the file specified by fname already exists, it will be overwritten.
%
% Examples:
% uab_spm2image('img1.jpg');
% uab_spm2image('img2.png');
%
% Kathy Pearson
% UAB Psychology Department
% 06/26/2008
%__________________________________________________________________________
%
if nargin < 1
return;
end
fg = spm_figure('FindWin', 'Graphics');
if ~isempty(fg)
if exist(fname, 'file')
delete(fname);
end
set(fg, 'PaperPositionMode', 'auto');
cmdline = ['print -f' num2str(fg) ' -djpeg -painters -append -noui ' fname];
disp(cmdline);
eval(cmdline);
end
|