Print

Print


> I wonder if "imcalc"  could be used for calculations leading to  an
> "multiple file" output ( input i1... i100, output i1´ ... i100´  for
> example linear "detrended")...

I'm afraid there is no multiple file output from imcalc.  To do something
like detrending, you would need code something like the untested stuff below:
___________________________________________________________________________
% get a handle for each image...
V  = spm_vol(spm_get(Inf,'*.img'));

% Create output images...
VO = V;
for k=1:length(V),
        [pth,nm,xt,vr] = fileparts(deblank(V(k).fname));
        VO(k).fname    = fullfile(pth,['detrended_' nm xt vr]);
        VO(k)          = spm_create_image(VO(k));
end;

dat = zeros([VO(1).dim(1:2) length(VO)]);

% Loop over planes...
for i=1:V(1).dim(3),
        % Read a plane for each image...
        M = spm_matrix([0 0 i]);
        for k=1:length(V),
                dat(:,:,k) = spm_slice_vol(V(k),M,V(1).dim(1:2),0);
        end;

        % do the detrending on dat, something like...
        dat = reshape(dat,[prod(V(1).dim(1:2)) length(V)])';
        A   = [ones(length(V),1) [1:length(V)]']; % Design matrix
        dat = dat - A*(A\dat); % Residuals after fitting a straight line
        dat = reshape(dat',[V(1).dim(1:2) length(V)]);

        % Write a plane for each image...
        for k=1:length(V),
                VO(k) = spm_write_plane(VO(k),dat(:,:,k),i);
        end;
end;
___________________________________________________________________________

best regards,
-John
--
Dr John Ashburner.
Wellcome Department of Cognitive Neurology.
12 Queen Square, London WC1N 3BG, UK.
tel: +44 (0)20 78337491 or +44 (0)20 78373611 x4381
fax: +44 (0)20 78131420
http://www.fil.ion.ucl.ac.uk/~john
mail: [log in to unmask]