When you reset the origin of the images in SPM, it will ask you what other images you want to apply the changes to. You can select all the images from the same session.
Anyway, this can be scripted as I have done this before. We had problems when trying to import images after processing in FSL.
If you have matlab, make sure you have SPM in the search path.
Assume you have an image img; and XYZ (in voxel space) will be your new origin
You can try this function I just wrote and tested. It should work (might need modification if you are working with 4D nifty)
If you enter 'center' for XYZ , this function will reset the origin to the center of the image volume.
There is no gurantee that this script works in all situations. Hope this helps.
function VO=resetOrigin(imgIn,imgOut,XYZ)
% reset the origin of img to X,Y,Z (Voxel space)
% All rights reversed
% Author: Tony Jiang
% [log in to unmask]
% Last updated : 04/10/2013
V=spm_vol(imgIn);
M=V.mat;M=M(1:3,1:3);
if ischar(XYZ) && strcmp(XYZ,'center')
XYZ=0.5*V.dim;
end
if isnumeric(XYZ) && numel(XYZ)>3
error('Too many element in XYZ!');
end
dXYZ=-M*XYZ(:);
newM=[M dXYZ(:); 0 0 0 1];
VO=V;
VO.fname=imgOut;
VO.mat=newM;
D=spm_read_vols(V);
VO=spm_write_vol(VO,D);
VO.descrip=sprintf('Origin reset at %f %f %f By resetOrigin',XYZ(1),XYZ(2),XYZ(3));
-----------------------------------------------
Tony Jiang, Ph.D.
Human Performance & Engineering Laboratory
Kessler Foundation Research Center
1199 Pleasant Valley Way
West Orange, NJ 07052
Tel: (973) 324-3516
Email: [log in to unmask]
-----Original Message-----
From: SPM (Statistical Parametric Mapping) [mailto:[log in to unmask]] On Behalf Of Ze Wang
Sent: Tuesday, April 09, 2013 4:28 PM
To: [log in to unmask]
Subject: Re: [SPM] Automatic change the origin in NIFTI files
No.
But if you reset both the structural image and functional images or whatever you want to register to the structural image, you can see spm does a good job for registering them together as well as for registering both of them to the MNI space when DARTEL is used.
Ze
On 4/9/2013 4:12 PM, Lucas Lessa wrote:
> Hello Ze Wang,
>
> Good afternoon.
> I don't want to mess with the orientation or just reset the origin of an image, istead I'd like to set the correct origin in the images.
> Is there an automatic way to do this?
> Or do I have to change each image origin manually?
> Thank you.
>
> Lucas Lessa.
>
>
--
Ze Wang, Ph.D
Research Assistant Professor of Biomedical Engineering, Departments of Psychiatry and Radiology, Perelman School of Medicine, University of Pennsylvania,
3900 Chestnut Street,
Philadelphia, PA 19104, USA
http://cfn.upenn.edu/~zewang
Tel: 215-222-3200 ext 123
Kessler Foundation is proud to be recognized as one of the Best Places to Work in New Jersey.
The information in this transmission is intended for official use of the Kessler Foundation. It is intended for the exclusive use of the persons or entities to which it is addressed. If you are not an intended recipient or the employee or agent responsible for delivering this transmission to an intended recipient, be aware that any disclosure, dissemination, distribution or copying of this communication, or the use of its contents, is strictly prohibited. If you received this transmission in error, please notify the sender by return e-mail and delete the material from any computer.
|