空间转换
很多时候,我们拿到的MRI图像大多是原始空间的,或者是其他空间的,而且图像时处理好的,不需要再次配准,只是需要将坐标转化到MNI标准空间下的坐标,所以我们就需要一个转换的函数实现这个坐标的转换,坐标的转换函数如下,下面时matlab的代码,其他语言可以根据这个版本进行转换。
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% cor2mni
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function mni = cor2mni(cor, T)
% function mni = cor2mni(cor, T)
% convert matrix coordinate to mni coordinate
%
% cor: an Nx3 matrix
% T: rotation matrix
% mni is the returned coordinate in mni space
%
% caution: if T is not given, the default T is
% T = [-3,0,0,93;0,3,0,-129;0,0,3,-75;0,0,0,1];
%if nargin == 1
% T = [-3,0,0,93;0,3,0,-129;0,0,3,-75;0,0,0,1];
%end
cor = round(cor);
mni = T*[cor(:,1) cor(:,2) cor(:,3) ones(size(cor,1),1)]';
mni = mni';
mni(:,4) = [];
return;
end
其中,参数cor就是原始空间下的三维坐标,T是转化矩阵,即头文件中的转换矩阵,举例子如下
如果用SPM读取头文件
fileread=spm_vol(tempfile);
读取出来的头文件是一个结构体,点开是这样的
特别注意的是 如果不是用的matlab,读取的文件的时候,可能坐标的顺序不同,需要按要求转化成对应的格式