Skip to content

Commit 27e4feb

Browse files
committed
DOC: move neuro/radio discussion into own document
Maybe the discussion is a little specialized, so put it into a more optional separate document.
1 parent 8261397 commit 27e4feb

File tree

2 files changed

+136
-91
lines changed

2 files changed

+136
-91
lines changed

doc/source/coordinate_systems.rst

Lines changed: 1 addition & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -942,96 +942,6 @@ contain codes that specify whether the affine maps to scanner or MNI or
942942
Talairach RAS+ space. For the moment, you have to consult the specifics of
943943
each format to find which RAS+ space the affine maps to.
944944

945-
****************************************
946-
Radiological vs neurological conventions
947-
****************************************
948-
949-
It is relatively common to talk about images being in "radiological" compared
950-
to "neurological" convention. Now we have the vocabulary to be explicit
951-
about what these terms mean.
952-
953-
Radiologists like looking at their images with the patient's left on the right
954-
of the image. If they are looking at a brain image, it is as if they were
955-
looking at the brain slice from the point of view of the patient's feet.
956-
Neurologists like looking at brain images with the patient's right on the
957-
right of the image. This perspective is as if the neurologist is looking at
958-
the slice from the top of the patient's head. The convention is one of image
959-
display. The image can have any voxel arrangement on disk or memory, and any
960-
output reference space; it is only necessary for the software displaying the
961-
image to know the reference space and the (probably affine) mapping between
962-
voxel space and reference space; then the software can work out which voxels
963-
are on the left or right of the subject and flip the images to the taste of
964-
the viewer. We could unpack these uses as *neurological display convention*
965-
and *radiological display convention*.
966-
967-
Radiological and neurological are sometimes used to refer to particular
968-
alignments of the voxel input axes to scanner RAS+ output axes. If we look at
969-
the affine mapping between voxel space and scanner RAS+, we may find that
970-
moving along the first voxel axis by one unit results in a equivalent scanner
971-
RAS+ movement that is mainly left to right. This can happen with a diagonal
972-
affine mapping to scanner RAS+:
973-
974-
.. plot::
975-
:context:
976-
:nofigs:
977-
978-
>>> diag_affine = np.array([[3., 0, 0, 0],
979-
... [0, 3., 0, 0],
980-
... [0, 0, 4.5, 0],
981-
... [0, 0, 0, 1]])
982-
>>> ijk = [1, 0, 0] # moving one unit on the first voxel axis
983-
>>> apply_affine(diag_affine, ijk)
984-
array([ 3., 0., 0.])
985-
986-
In this case the voxel axes are aligned to the output axes, in the sense that
987-
moving in a positive direction on the first voxel axis results in increasing
988-
values on the "R+" output axis, and similarly for the second voxel axis with
989-
output "A+" and the third voxel axis with output "S+".
990-
991-
Some people therefore refer to this alignment of voxel and RAS+ axes as
992-
*RAS" voxel axes*.
993-
994-
Very confusingly, some people also refer to an image with "RAS" voxel axes as
995-
having "neurological" voxel layout. This is because the simplest way to
996-
display slices from this voxel array will result in the left of the subject
997-
appearing towards the left hand side of the screen and therefore neurological
998-
display convention. If we take a slice over the third axis of the image data
999-
array (``epi_img_data[:, : 0]``), the resulting slice will have a first array
1000-
axis going from left to right in terms of spatial position and the second
1001-
array axis going from posterior to anterior. If we display this image with
1002-
the first axis going from left to right on screen and the second from bottom
1003-
to top, it will have the subject's right towards the right of the screen, and
1004-
anterior towards the top of the screen, as neurologists like it. Similarly,
1005-
an "LAS" alignment of voxel axes to RAS+ axes would result in an image with
1006-
the left of the subject towards the right of the screen, as radiologists like
1007-
it. "LAS" voxel axes can also be called "radiological" voxel
1008-
layout for this reason [#memory-layout]_.
1009-
1010-
Over time it has become more common for the scanner to generate images with
1011-
almost any orientation of the voxel axes relative to the reference axes.
1012-
Maybe for this reason, the terms "radiological" and "neurological" are less
1013-
commonly used as applied to voxel layout. We nipyers try to avoid the
1014-
terms neurological or radiological for voxel layout because they can make it
1015-
harder to separate the idea of voxel and reference space axes and the affine
1016-
as a mapping between them.
1017-
1018-
.. rubric:: Footnotes
1019-
1020-
.. [#memory-layout] We have deliberately not fully defined what we mean by
1021-
"voxel layout" in the text. Conceptually, an image array could be stored
1022-
in any layout on disk; the definition of the image format specifies how
1023-
the image reader should interpret the data on disk to return the right
1024-
array value for a given voxel coordinate. The relationship of the values
1025-
on disk to the coordinate values in the array has no bearing on the fact
1026-
that the voxel axes align to the output axes. In practice the terms RAS /
1027-
neurological and LAS / radiogical as applied to voxel layout appear to
1028-
refer exclusively to the situation where image arrays are stored in
1029-
"Fortran array layout" on disk. Imagine an image array of shape $(I, J,
1030-
K)$ with values of length $v$. For an image of 64-bit floating point
1031-
values, $v = 8$. An image array is stored in Fortran array layout only if
1032-
the value for voxel coordinate (1, 0, 0) is $v$ bytes on disk from the
1033-
value for (0, 0, 0); (0, 1, 0) is $I * v$ bytes from (0, 0, 0); and (0, 0,
1034-
1) is $I * J * v$ bytes from (0, 0, 0). Analyze_ and NIfTI_ images use
1035-
Fortran array layout.
945+
See also :doc:`neuro_radio_conventions`
1036946

1037947
.. include:: links_names.txt
Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
2+
########################################
3+
Radiological vs neurological conventions
4+
########################################
5+
6+
It is relatively common to talk about images being in "radiological" compared
7+
to "neurological" convention, but the terms can be used in different and
8+
confusing ways.
9+
10+
See :doc:`coordinate_systems` for background on voxel space, reference space
11+
and affines.
12+
13+
************************************************
14+
Neurological and radiological display convention
15+
************************************************
16+
17+
Radiologists like looking at their images with the patient's left on the right
18+
of the image. If they are looking at a brain image, it is as if they were
19+
looking at the brain slice from the point of view of the patient's feet.
20+
Neurologists like looking at brain images with the patient's right on the
21+
right of the image. This perspective is as if the neurologist is looking at
22+
the slice from the top of the patient's head. The convention is one of image
23+
display. The image can have any voxel arrangement on disk or memory, and any
24+
output reference space; it is only necessary for the software displaying the
25+
image to know the reference space and the (probably affine) mapping between
26+
voxel space and reference space; then the software can work out which voxels
27+
are on the left or right of the subject and flip the images to the taste of
28+
the viewer. We could unpack these uses as *neurological display convention*
29+
and *radiological display convention*.
30+
31+
**************************************
32+
Neurological / radiological voxel axes
33+
**************************************
34+
35+
Radiological and neurological are sometimes used to refer to particular
36+
alignments of the voxel input axes to scanner RAS+ output axes. If we look at
37+
the affine mapping between voxel space and scanner RAS+, we may find that
38+
moving along the first voxel axis by one unit results in a equivalent scanner
39+
RAS+ movement that is mainly left to right. This can happen with a diagonal
40+
3x3 part of the affine mapping to scanner RAS+ (see
41+
:doc:`coordinate_systems`):
42+
43+
.. plot::
44+
:context:
45+
:nofigs:
46+
47+
>>> import numpy as np
48+
>>> from nibabel.affines import apply_affine
49+
>>> diag_affine = np.array([[3., 0, 0, 0],
50+
... [0, 3., 0, 0],
51+
... [0, 0, 4.5, 0],
52+
... [0, 0, 0, 1]])
53+
>>> ijk = [1, 0, 0] # moving one unit on the first voxel axis
54+
>>> apply_affine(diag_affine, ijk)
55+
array([ 3., 0., 0.])
56+
57+
In this case the voxel axes are aligned to the output axes, in the sense that
58+
moving in a positive direction on the first voxel axis results in increasing
59+
values on the "R+" output axis, and similarly for the second voxel axis with
60+
output "A+" and the third voxel axis with output "S+".
61+
62+
Some people therefore refer to this alignment of voxel and RAS+ axes as
63+
*RAS voxel axes*.
64+
65+
****************************************
66+
Neurological / radiological voxel layout
67+
****************************************
68+
69+
Very confusingly, some people also refer to images with "RAS" voxel axes as
70+
having "neurological" voxel layout. This is because the simplest way to
71+
display slices from this voxel array will result in the left of the subject
72+
appearing towards the left hand side of the screen and therefore neurological
73+
display convention. If we take a slice $k$ over the third axis of the image
74+
data array (``img_data[:, :, k]``), the resulting slice will have a first
75+
array axis going from left to right in terms of spatial position and the
76+
second array axis going from posterior to anterior. If we display this image
77+
with the first axis going from left to right on screen and the second from
78+
bottom to top, it will have the subject's right towards the right of the
79+
screen, and anterior towards the top of the screen, as neurologists like it.
80+
Here we are showing the middle slice of :download:`an image
81+
</downloads/someones_anatomy.nii.gz>` with RAS voxel axes:
82+
83+
.. plot::
84+
:context:
85+
86+
>>> import nibabel as nib
87+
>>> import matplotlib.pyplot as plt
88+
>>> img = nib.load('downloads/someones_anatomy.nii.gz')
89+
>>> # The 3x3 part of the affine is diagonal with all +ve values
90+
>>> img.affine
91+
array([[ 2.75, 0. , 0. , -78. ],
92+
[ 0. , 2.75, 0. , -91. ],
93+
[ 0. , 0. , 2.75, -91. ],
94+
[ 0. , 0. , 0. , 1. ]])
95+
>>> img_data = img.get_data()
96+
>>> a_slice = img_data[:, :, 28]
97+
>>> # Need transpose to put first axis left-right, second bottom-top
98+
>>> plt.imshow(a_slice.T, cmap="gray", origin="lower")
99+
100+
This slice does have the voxels from the right of isocenter towards the right
101+
of the screen, neurology style.
102+
103+
Similarly, an "LAS" alignment of voxel axes to RAS+ axes would result in an
104+
image with the left of the subject towards the right of the screen, as
105+
radiologists like it. "LAS" voxel axes can also be called "radiological"
106+
voxel layout for this reason [#memory-layout]_.
107+
108+
Over time it has become more common for the scanner to generate images with
109+
almost any orientation of the voxel axes relative to the reference axes.
110+
Maybe for this reason, the terms "radiological" and "neurological" are less
111+
commonly used as applied to voxel layout. We nipyers try to avoid the
112+
terms neurological or radiological for voxel layout because they can make it
113+
harder to separate the idea of voxel and reference space axes and the affine
114+
as a mapping between them.
115+
116+
.. rubric:: Footnotes
117+
118+
.. [#memory-layout] We have deliberately not fully defined what we mean by
119+
"voxel layout" in the text. Conceptually, an image array could be stored
120+
in any layout on disk; the definition of the image format specifies how
121+
the image reader should interpret the data on disk to return the right
122+
array value for a given voxel coordinate. The relationship of the values
123+
on disk to the coordinate values in the array has no bearing on the fact
124+
that the voxel axes align to the output axes. In practice the terms RAS /
125+
neurological and LAS / radiogical as applied to voxel layout appear to
126+
refer exclusively to the situation where image arrays are stored in
127+
"Fortran array layout" on disk. Imagine an image array of shape $(I, J,
128+
K)$ with values of length $v$. For an image of 64-bit floating point
129+
values, $v = 8$. An image array is stored in Fortran array layout only if
130+
the value for voxel coordinate (1, 0, 0) is $v$ bytes on disk from the
131+
value for (0, 0, 0); (0, 1, 0) is $I * v$ bytes from (0, 0, 0); and (0, 0,
132+
1) is $I * J * v$ bytes from (0, 0, 0). Analyze_ and NIfTI_ images use
133+
Fortran array layout.
134+
135+
.. include:: links_names.txt

0 commit comments

Comments
 (0)