-
Notifications
You must be signed in to change notification settings - Fork 0
/
icbm_spm2tal.m
49 lines (43 loc) · 1.39 KB
/
icbm_spm2tal.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
function outpoints = icbm_spm2tal(inpoints)
%
% This function converts coordinates from MNI space (normalized
% using the SPM software package) to Talairach space using the
% icbm2tal transform developed and validated by Jack Lancaster
% at the Research Imaging Center in San Antonio, Texas.
%
% http://www3.interscience.wiley.com/cgi-bin/abstract/114104479/ABSTRACT
%
% FORMAT outpoints = icbm_spm2tal(inpoints)
% Where inpoints is N by 3 or 3 by N matrix of coordinates
% (N being the number of points)
%
% ric.uthscsa.edu 3/14/07
% find which dimensions are of size 3
dimdim = find(size(inpoints) == 3);
if isempty(dimdim)
error('input must be a N by 3 or 3 by N matrix')
end
% 3x3 matrices are ambiguous
% default to coordinates within a row
if dimdim == [1 2]
disp('input is an ambiguous 3 by 3 matrix')
disp('assuming coordinates are row vectors')
dimdim = 2;
end
% transpose if necessary
if dimdim == 2
inpoints = inpoints';
end
% Transformation matrices, different for each software package
icbm_spm = [0.9254 0.0024 -0.0118 -1.0207
-0.0048 0.9316 -0.0871 -1.7667
0.0152 0.0883 0.8924 4.0926
0.0000 0.0000 0.0000 1.0000];
% apply the transformation matrix
inpoints = [inpoints; ones(1, size(inpoints, 2))];
inpoints = icbm_spm * inpoints;
% format the outpoints, transpose if necessary
outpoints = inpoints(1:3, :);
if dimdim == 2
outpoints = outpoints';
end