Hello Horatio,
if you search spm's m-files for "Reset", you will find a promising hit
in spm_image.m in about line 205. You can steal the code there and paste
the following into Matlab's command window:
% == start ==
[P,sts] = spm_select([1 Inf], 'image','Images to reset orientation of');
if ~sts, return; else P = cellstr(P); end
spm_progress_bar('Init',numel(P),'Resetting orientations',...
'Images Complete');
for i=1:numel(P)
V = spm_vol(P{i});
M = V.mat;
vox = sqrt(sum(M(1:3,1:3).^2));
if det(M(1:3,1:3))<0, vox(1) = -vox(1); end
orig = (V.dim(1:3)+1)/2;
off = -vox.*orig;
M = [vox(1) 0 0 off(1)
0 vox(2) 0 off(2)
0 0 vox(3) off(3)
0 0 0 1];
spm_get_space(P{i},M);
spm_progress_bar('Set',i);
end
spm_progress_bar('Clear');
% == end ==
Alternatively, there is a tool within vbm8 that allows you to reset the
origin to the center of the biggest cluster in the image, which usually
is the head (Toolbox, vbm8, Extended tools, set origin using center of
mass).
Hope this helps,
Marko
Horatio Dyball wrote:
> Dear Friends,
>
> Unfortunately the images I get from our scanner are in a very different
> space to the SPM template space, and must have their origins reset
> before processing. I would like to script this but have not been able to
> find where in the spm catalog the process called by "Display>Reset..."
> can be found. Could someone please tell me where this is, or better yet,
> if you have a script could it be sent to me?
>
> With regards
> Horatio
--
____________________________________________________
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/
____________________________________________________
|