3

I want to plot a 3D image of an anatomical structure with colour gradation depending on the Z-value

I've searched for prior help on this topic, e.g. on 3D surfaces here, here and here, but it all appears to deal with datasets with evenly spaced X and Y values. Also none of the surfaces appear to back around under themselves.

In the dataset I'm dealing with (example below), only the X-values are evenly spaced.

Notes on data:

  1. Come from magnetic resonance imaging scans of an anatomical structure. So X is the image number.
  2. X,Y,Z contain the coordinates of each point.
  3. Strand could be used to define a wire mesh:
    • X increases monotonically from left to right side of the anatomical structure.
    • For each X there are 12 Strands which go from one image (X) to the next.
    • The Strand number runs clockwise starting with 1 and then to 12 to form a polygon.
    • Thus Strand 12 is directly next to Strand 1.
    • The picture at the very bottom showes how the Strand numbers line up in each X (image).

Does anyone have experience with this? Or is this just not do-able in R?

    X   Y       Z       Strand
    1   179.3   213.8   1
    1   184.1   213.8   2
    1   188.8   213.8   3
    1   195.9   214.9   4
    1   200.7   214.9   5
    1   200.7   216.1   6
    1   201.9   219.7   7
    1   195.9   220.9   8
    1   190.0   220.9   9
    1   182.9   222.1   10
    1   178.1   223.3   11
    1   178.1   217.3   12
    2   176.6   213.8   1
    2   182.3   213.8   2
    2   190.6   213.8   3
    2   196.8   214.0   4
    2   201.6   214.0   5
    2   203.4   216.1   6
    2   203.7   218.8   7
    2   197.7   220.9   8
    2   190.0   221.8   9
    2   182.0   223.0   10
    2   176.3   224.1   11
    2   175.5   218.2   12
    3   175.2   213.8   1
    3   181.1   213.8   2
    3   190.6   213.2   3
    3   197.7   213.2   4
    3   203.1   213.2   5
    3   204.3   215.5   6
    3   204.3   217.9   7
    3   198.3   220.3   8
    3   190.6   222.7   9
    3   181.7   223.3   10
    3   175.2   224.4   11
    3   174.0   219.1   12
    4   173.7   214.0   1
    4   180.2   213.8   2
    4   189.4   212.6   3
    4   197.4   212.6   4
    4   204.3   212.6   5
    4   204.5   214.9   6
    4   204.5   217.3   7
    4   198.6   219.7   8
    4   191.2   223.5   9
    4   181.1   223.5   10
    4   174.0   224.7   11
    4   173.1   219.7   12
    5   171.0   214.9   1
    5   179.3   213.8   2
    5   187.6   212.6   3
    5   194.8   212.6   4
    5   204.3   212.6   5
    5   205.4   214.9   6
    5   205.4   217.3   7
    5   199.5   219.7   8
    5   191.2   224.4   9
    5   179.3   224.4   10
    5   172.2   225.6   11
    5   172.2   219.7   12
    6   171.0   214.0   1
    6   178.4   213.8   2
    6   187.6   211.7   3
    6   197.4   211.7   4
    6   205.1   212.6   5
    6   205.4   214.9   6
    6   206.3   217.3   7
    6   199.5   219.7   8
    6   191.2   224.4   9
    6   180.2   224.4   10
    6   172.2   226.5   11
    6   171.3   219.7   12
    7   169.8   214.3   1
    7   176.3   213.8   2
    7   187.0   211.4   3
    7   196.5   211.4   4
    7   205.4   212.6   5
    7   206.0   214.9   6
    7   206.0   217.3   7
    7   199.5   219.1   8
    7   190.6   224.4   9
    7   179.3   224.4   10
    7   171.0   226.2   11
    7   169.8   219.7   12
    8   168.6   214.6   1
    8   174.9   213.8   2
    8   186.1   211.1   3
    8   194.8   211.4   4
    8   205.4   212.9   5
    8   206.3   214.9   6
    8   205.4   217.3   7
    8   198.9   218.8   8
    8   190.0   224.4   9
    8   177.8   224.7   10
    8   169.5   225.9   11
    8   168.6   219.7   12
    9   168.6   213.8   1
    9   175.8   213.8   2
    9   185.3   210.2   3
    9   194.8   211.4   4
    9   205.4   213.8   5
    9   205.4   214.9   6
    9   205.4   217.3   7
    9   197.1   219.7   8
    9   190.0   224.4   9
    9   176.9   225.6   10
    9   168.6   226.8   11
    9   168.6   219.7   12
    10  168.6   212.9   1
    10  175.8   212.9   2
    10  187.0   210.2   3
    10  195.6   211.4   4
    10  203.7   212.9   5
    10  205.4   214.9   6
    10  205.4   217.3   7
    10  196.2   219.7   8
    10  189.1   224.4   9
    10  176.0   224.7   10
    10  169.5   226.8   11
    10  168.6   219.7   12
    11  168.6   212.6   1
    11  175.8   212.6   2
    11  187.6   210.2   3
    11  195.9   211.4   4
    11  203.7   212.6   5
    11  205.4   214.9   6
    11  205.4   217.3   7
    11  195.9   219.7   8
    11  188.2   225.0   9
    11  176.3   225.0   10
    11  169.8   226.8   11
    11  168.6   219.1   12
    12  169.2   212.6   1
    12  176.3   212.9   2
    12  187.9   210.2   3
    12  196.2   211.7   4
    12  204.3   212.6   5
    12  205.1   214.9   6
    12  205.4   217.3   7
    12  196.5   219.7   8
    12  187.9   225.3   9
    12  176.9   225.3   10
    12  169.8   226.8   11
    12  168.9   218.5   12
    13  171.0   212.6   1
    13  178.1   213.8   2
    13  188.8   210.2   3
    13  197.1   212.6   4
    13  204.3   212.6   5
    13  204.3   214.9   6
    13  205.4   217.3   7
    13  198.3   219.7   8
    13  188.8   224.4   9
    13  176.9   224.4   10
    13  169.8   226.8   11
    13  169.8   218.5   12
    14  171.0   212.6   1
    14  176.3   213.8   2
    14  187.9   211.1   3
    14  198.9   212.6   4
    14  204.3   213.5   5
    14  205.1   215.8   6
    14  205.4   218.2   7
    14  198.3   219.7   8
    14  189.7   224.4   9
    14  177.8   225.3   10
    14  170.7   226.8   11
    14  170.7   219.4   12
    15  171.6   212.6   1
    15  176.3   213.8   2
    15  188.2   211.4   3
    15  198.3   212.0   4
    15  204.3   213.2   5
    15  205.4   215.5   6
    15  205.4   217.9   7
    15  198.9   219.1   8
    15  190.0   225.0   9
    15  177.5   225.6   10
    15  171.0   226.2   11
    15  171.0   219.1   12
    16  172.2   212.9   1
    16  177.2   214.0   2
    16  189.1   211.4   3
    16  197.1   211.7   4
    16  203.7   212.6   5
    16  205.1   214.9   6
    16  205.1   217.6   7
    16  199.2   218.8   8
    16  190.0   225.3   9
    16  177.2   225.3   10
    16  171.3   225.9   11
    16  171.3   218.5   12
    17  172.2   213.8   1
    17  178.1   214.9   2
    17  190.0   211.4   3
    17  197.1   212.6   4
    17  201.9   212.6   5
    17  204.3   214.9   6
    17  204.3   218.5   7
    17  198.3   219.7   8
    17  190.0   224.4   9
    17  178.1   224.4   10
    17  172.2   226.8   11
    17  172.2   218.5   12
    18  174.0   213.8   1
    18  179.0   214.9   2
    18  189.1   213.2   3
    18  196.2   213.5   4
    18  201.9   213.5   5
    18  203.4   215.8   6
    18  203.4   218.5   7
    18  197.4   220.6   8
    18  190.0   224.4   9
    18  179.9   224.4   10
    18  173.1   225.9   11
    18  173.1   218.5   12
    19  175.8   213.8   1
    19  181.1   214.9   2
    19  190.0   213.8   3
    19  196.5   213.8   4
    19  201.3   213.8   5
    19  201.9   216.7   6
    19  201.9   219.7   7
    19  196.5   222.1   8
    19  189.4   224.4   9
    19  182.3   224.4   10
    19  175.8   225.0   11
    19  175.2   218.5   12
    20  178.1   214.0   1
    20  183.5   214.9   2
    20  190.9   214.0   3
    20  195.9   214.0   4
    20  199.5   214.0   5
    20  200.1   217.3   6
    20  200.4   220.6   7
    20  195.6   223.3   8
    20  189.1   224.1   9
    20  184.4   224.1   10
    20  178.7   224.4   11
    20  177.8   218.2   12
    21  181.7   214.9   1
    21  185.3   214.9   2
    21  190.0   214.9   3
    21  192.4   214.9   4
    21  195.9   214.9   5
    21  198.3   217.3   6
    21  199.5   219.7   7
    21  194.8   223.3   8
    21  190.0   223.3   9
    21  185.3   223.3   10
    21  180.5   224.4   11
    21  180.5   217.3   12

For any given image (X) 12 individual Ys and Zs define the outer surface of the structure and are ordered around the structure:

Example image showing <code>Strand</code> number

For X=2 and Strand=1, the surface triangles could be defined as the points located at:

  1. Triangle

    • X=2, Strand=1
    • X=2, Strand=2
    • X=3, Strand=1
  2. Triangle

    • X=2, Strand=1
    • X=1, Strand=2
    • X=1, Strand=1
  3. Triangle

    • X=2, Strand=1
    • X=2, Strand=12
    • X=3, Strand=1
  4. Triangle

    • X=2, Strand=1
    • X=2, Strand=12
    • X=1, Strand=1

Xs of 1 (first image) and 12 (last image) would be a different set up, just because they form the left and right "walls" of the object.

Community
  • 1
  • 1
  • I asked a [similar question](http://stackoverflow.com/questions/22607406/plotting-surface-of-a-sphere-using-3d-delaunay-triangulated-panels-in-r) a while back, but got no answers. I'm pretty sure that the rgl package is the one for this type of plotting however. – Marc in the box Aug 08 '14 at 05:47
  • 2
    `install.packages("sos");require(sos); findFn("teapot")` – IRTFM Aug 08 '14 at 06:27
  • 2
    To draw 3d objects you need more than your data has. If I read it correctly you have X,Y,Z point locations and this "Strand" number which goes from 1 to 12, so there's a lot XYZs with Strand=6, for example. To make a 3d solid object you have to define how your points (vertexes) connect to create triangles (faces) and which side of those faces is the outside surface. How is there enough information in your data to build that kind of structure? – Spacedman Aug 08 '14 at 06:43
  • After looking into the comment from @BondedDust, I came accross the `surfaceTriangles` function of the package `misc3d`. It appears I need to work out how to set up my data such that it can be fed into `surfaceTriangles`. Unfortunately the examples I can find for `surfaceTriangles` use mathematical functions and not "data" like in my example. So I'm struggling to work out how to use `surfaceTriangles` I'll play with it in the course of the week, but if anyone has any bright ideas about this, then I am open to suggestions. – user3243131 Aug 11 '14 at 01:59
  • @Spacedman: I've edited the question to explain the data setup a bit more. I am very open to more tips. – user3243131 Aug 11 '14 at 02:00
  • @Marc in the box: thanks for that link, it provides some clues. For my scenario having triangles within the object would also be sub-optimal, but possibly not a game breaker. – user3243131 Aug 11 '14 at 02:00

0 Answers0