Hi Mike,
you can do that by iteratively calling spm_functions, as in this example:
% ==== snippet start ====
clc;
mydir = spm_select([1 Inf],'dir','Please select directories with
images to process',[],pwd);
expr = spm_input('Expression to evaluate','!+1','s','i1+100');
mod = spm_input('Filename modifier','!+1','s','_p100');
for i = 1:size(mydir,1)
currdir = deblank(mydir(i,:));
imgs = spm_select('list', currdir, ['.*.img|nii']);
for ii = 1:size(imgs,1)
currimg = imgs(ii,:);
[p nm e v] = spm_fileparts(currimg);
evalc(['spm_imcalc_ui([currdir currimg],[currdir nm mod
e],expr,{[],[],[],7});']);
end;
disp(['... done processing ' num2str(size(imgs,1)) ' images from
directory ' num2str(i) '/' num2str(size(mydir,1)) ', proceeding...']);
end;
disp(['... done processing all images from ' num2str(size(mydir,1)) '
directories!']);
% ==== snippet end ===
Watch out for linebreaks when copying to the Matlab window. Note that
calling spm_imcalc_ui allows for multiple further options (e.g., note I
chose '7' as the interpolation type, which may not be what you want). In
general, though, this may do the job.
Cheers,
Marko
Michael Schlund wrote:
> Hi folks,
> Is there a way to use Imcalc to perform the same calculation on a large
> number of images that are in the same directory?
>
> We'd like to make a simple conversion to each and every file and get a
> corresponding output image that is named something like
> OUT_nameofinputimage.
> EG: So, we select all our inout files A, B, C..... (do
> calculation, eg. f=i1+100) and then get output files: OUT_A, OUT_B,
> OUT_C......
>
> Thanks for any help!!
> Mike Schlund
>
--
____________________________________________________
PD Dr. med. Marko Wilke
Facharzt für Kinder- und Jugendmedizin
Leiter, Experimentelle Pädiatrische Neurobildgebung
Universitäts-Kinderklinik
Abt. III (Neuropädiatrie)
Marko Wilke, MD, PhD
Pediatrician
Head, Experimental Pediatric Neuroimaging
University Children's Hospital
Dept. III (Pediatric Neurology)
Hoppe-Seyler-Str. 1
D - 72076 Tübingen, Germany
Tel. +49 7071 29-83416
Fax +49 7071 29-5473
[log in to unmask]
http://www.medizin.uni-tuebingen.de/kinder/epn
____________________________________________________
|