-
Notifications
You must be signed in to change notification settings - Fork 1
/
vox2ras_tkreg.m
53 lines (42 loc) · 1.14 KB
/
vox2ras_tkreg.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
function T = vox2ras_tkreg(voldim, voxres)
% T = vox2ras_tkreg(voldim, voxres)
% voldim = [ncols nrows nslices ...]
% volres = [colres rowres sliceres ...]
%
% Computes the 0-based vox2ras transform of a volume
% compatible with the registration matrix produced
% by tkregister. May work with MINC xfm.
%
%
% vox2ras_tkreg.m
%
% Original Author: Doug Greve
% CVS Revision Info:
% $Author: nicks $
% $Date: 2011/03/02 00:04:13 $
% $Revision: 1.4 $
%
% Copyright © 2011 The General Hospital Corporation (Boston, MA) "MGH"
%
% Terms and conditions for use, reproduction, distribution and contribution
% are found in the 'FreeSurfer Software License Agreement' contained
% in the file 'LICENSE' found in the FreeSurfer distribution, and here:
%
% https://surfer.nmr.mgh.harvard.edu/fswiki/FreeSurferSoftwareLicense
%
% Reporting: [email protected]
%
T = [];
if(nargin ~= 2)
fprintf('T = vox2ras_tkreg(voldim, voxres)\n');
return;
end
T = zeros(4,4);
T(4,4) = 1;
T(1,1) = -voxres(1);
T(1,4) = voxres(1)*voldim(1)/2;
T(2,3) = voxres(3);
T(2,4) = -voxres(3)*voldim(3)/2;
T(3,2) = -voxres(2);
T(3,4) = voxres(2)*voldim(2)/2;
return;