0001 function outpoints = rest_tal2mni(inpoints)
0002
0003
0004
0005
0006
0007
0008
0009
0010 dimdim = find(size(inpoints) == 3);
0011 if isempty(dimdim)
0012 error('input must be a N by 3 or 3 by N matrix')
0013 end
0014 if dimdim == 2
0015 inpoints = inpoints';
0016 end
0017
0018
0019 rotn = rest_spm_matrix([0 0 0 0.05]);
0020 upz = rest_spm_matrix([0 0 0 0 0 0 0.99 0.97 0.92]);
0021 downz = rest_spm_matrix([0 0 0 0 0 0 0.99 0.97 0.84]);
0022
0023 inpoints = [inpoints; ones(1, size(inpoints, 2))];
0024
0025 inpoints = inv(rotn)*inpoints;
0026
0027 tmp = inpoints(3,:)<0;
0028 inpoints(:, tmp) = inv(downz) * inpoints(:, tmp);
0029 inpoints(:, ~tmp) = inv(upz) * inpoints(:, ~tmp);
0030 outpoints = inpoints(1:3, :);
0031 if dimdim == 2
0032 outpoints = outpoints';
0033 end
0034
0035
0036
0037