> I have used SPM realign to perform a realignment of a later image to an
> earlier image. I would now like to perform an inverse realignment of a
> tracing performed on the earlier image (and converted to analyze format)
> into the space of the later image. I was wondering how to manipulate the
> .mat file to get the inverse realignment? I realize that I could just run
> realign again in the opposite direction, transfer the .mat data to the
> traced image using spm_vol and spm_write_vol, then perform spm_reslice, but
> figured there might be a less computationally intensive/time-saving way to
> calculate the .mat data than running spm_realign again in reverse. Thanks
> for any help you may have to offer.
Providing that the tracing is stored as an image that SPM sees to be in
alignment with the early image (via Check Reg), then you can simply reslice
it using e.g. the Coregster button (with the reslice only option). Select
the late image as the reference (that defines the space that you are
reslicing into) and the image representing the tracing as the image to
reslice.
Once images are aligned, then the .mat files (for SPM2) or the NIfTI headers
(for SPM5) encode the relative orientations of the images in terms of a
"voxel-to-world" mapping. These orientations are represented as affine
transformation matrices. Mapping from a voxel in one image to the
corresponding voxel in another is a matter of going from voxel indices of the
first image to some world coordinate system (in mm) by multiplying by the
voxel-to-world mapping of the first image. Then to get to voxel indices of
the second image, the procedure is to multiply these mm coordinates by the
inverse of the voxel-to-world mapping of this image. There is no need to
modify the contents of any .mat file.
This is probably far too much information, but in Matlab, this is by:
M1 = spm_get_space('image1.img');
M2 = spm_get_space('image2.img');
coords2 = inv(M2)*M1*[x1 y1 z1 1]'
x2 = coords2(1)
y2 = coords2(2)
z2 = coords2(3)
where x1, y1 and z1 the indices in the first image. Going the other way is by
coords1 = inv(M1)*M2*[x2 y2 z2 1]'
x1 = coords1(1)
y1 = coords1(2)
z1 = coords1(3)
Best regards,
-John
|