|
a |
|
b/ants/utils/mni2tal.py |
|
|
1 |
|
|
|
2 |
__all__ = ['mni2tal'] |
|
|
3 |
|
|
|
4 |
def mni2tal(xin): |
|
|
5 |
""" |
|
|
6 |
mni2tal for converting from ch2/mni space to tal - very approximate. |
|
|
7 |
|
|
|
8 |
This is a standard approach but it's not very accurate. |
|
|
9 |
|
|
|
10 |
ANTsR function: `mni2tal` |
|
|
11 |
|
|
|
12 |
Arguments |
|
|
13 |
--------- |
|
|
14 |
xin : tuple |
|
|
15 |
point in mni152 space. |
|
|
16 |
|
|
|
17 |
Returns |
|
|
18 |
------- |
|
|
19 |
tuple |
|
|
20 |
|
|
|
21 |
Example |
|
|
22 |
------- |
|
|
23 |
>>> import ants |
|
|
24 |
>>> ants.mni2tal( (10,12,14) ) |
|
|
25 |
|
|
|
26 |
References |
|
|
27 |
---------- |
|
|
28 |
http://bioimagesuite.yale.edu/mni2tal/501_95733_More\\%20Accurate\\%20Talairach\\%20Coordinates\\%20SLIDES.pdf |
|
|
29 |
http://imaging.mrc-cbu.cam.ac.uk/imaging/MniTalairach |
|
|
30 |
""" |
|
|
31 |
if (not isinstance(xin, (tuple,list))) or (len(xin) != 3): |
|
|
32 |
raise ValueError('xin must be tuple/list with 3 coordinates') |
|
|
33 |
|
|
|
34 |
x = list(xin) |
|
|
35 |
# The input image is in RAS coordinates but we use ITK which returns LPS |
|
|
36 |
# coordinates. So we need to flip the coordinates such that L => R and P => A to |
|
|
37 |
# get RAS (MNI) coordinates |
|
|
38 |
x[0] = x[0] * (-1) # flip X |
|
|
39 |
x[1] = x[1] * (-1) # flip Y |
|
|
40 |
|
|
|
41 |
xout = x |
|
|
42 |
|
|
|
43 |
if (x[2] >= 0): |
|
|
44 |
xout[0] = x[0] * 0.99 |
|
|
45 |
xout[1] = x[1] * 0.9688 + 0.046 * x[2] |
|
|
46 |
xout[2] = x[1] * (-0.0485) + 0.9189 * x[2] |
|
|
47 |
|
|
|
48 |
if (x[2] < 0): |
|
|
49 |
xout[0] = x[0] * 0.99 |
|
|
50 |
xout[1] = x[1] * 0.9688 + 0.042 * x[2] |
|
|
51 |
xout[2] = x[1] * (-0.0485) + 0.839 * x[2] |
|
|
52 |
|
|
|
53 |
return(xout) |
|
|
54 |
|
|
|
55 |
|
|
|
56 |
|
|
|
57 |
|
|
|
58 |
|
|
|
59 |
|