I'm not sure which matrices you need, but if you have a pair of
coregistered images, you can map from voxels in one image to voxels in
the other by:
NA=nifti('A.nii');
NB=nifti('B.nii');
% Map from voxel x,y,z in A to corresponding location in B
M = NB.mat\NA.mat;
xyzB = M(1:3,:)*[x;y;z;1]
% Map from voxel x,y,z in B to corresponding location in A
M = NA.mat\NB.mat;
xyzA = M(1:3,:)*[x;y;z;1]
Converting these M matrices into a form that FSL can work with may
require a bit of messing about. Also note that SPM indexes the first
voxel as 1,1,1 (because it is MATLAB based), whereas FSL indexes the
first voxel as 0,0,0 (as it is mostly written in C++). For this
reason, the matrices in the NIfTI headers are adjusted in order to
obtain NA.mat and NB.mat that work for the MATLAB indexing.
Best regards,
-John
On 16 February 2012 16:33, Chris Filo Gorgolewski
<[log in to unmask]> wrote:
> Silly me thinking this would be simple... Let me look into this a bit more.
>
> Thanks,
> Chris
>
> On 15 February 2012 18:11, John Ashburner <[log in to unmask]> wrote:
>> This may not be quite as simple as you think. If my understanding is
>> correct, the matrices that FSL uses seem to be a legacy from the
>> pre-NIfTI days. This complicates things slightly (see
>> http://www.nitrc.org/snippet/detail.php?type=package&id=1 for more
>> info).
>>
>> Best regards,
>> -John
>>
>>
>> On 15 February 2012 16:15, Chris Filo Gorgolewski
>> <[log in to unmask]> wrote:
>>> Hi,
>>> I would like to request a tiny feature feature which will cost very
>>> little coding. In the Coregister batch jobs the estimated
>>> transformation matrix is discarded. For interoperability with other
>>> software it would be great if it was saved in a file (for example in
>>> plain text format compatible with FSL). It would only require adding a
>>> line or two to config/ spm_run_coreg_est.m and
>>> config/spm_run_coreg_estwrite.m
>>>
>>> Best,
>>> Chris
|