## How to create slices of a 3D Volume?

### Layla (view profile)

on 21 Mar 2014
Latest activity Commented on by Sean de Wolski

### Sean de Wolski (view profile)

on 26 Mar 2014
Accepted Answer by Sean de Wolski

### Sean de Wolski (view profile)

Hi everyone,

I have 14 sets of 3D points where each set represents a sub-nucleus of a region in the brain. I'd like to do two things with this data:

1. Create volumes (not surfaces!) of each sub-nuclei data set

2. Plot all 14 volumes at once, and view (orthogonal) slices at whatever X-value (for YZ, or Sagittal Images), Y-value (for XZ, or Coronal Images), or Z-value (for XY, or Axial images) I choose.

So far, I've done this by generating Delaunay Triangulations, and changing the limits of the axes. However, the resulting plots are quite messy. I dislike being able to see the lines that show the triangles. The sub-nuclei are color-coded, so I'd rather not see any connectivity lines. Is there a cleaner, smoother way of doing this?

Thanks!

Layla

### Layla (view profile)

on 21 Mar 2014

I have edited the code for simplicity to demonstrate what I'm doing:

` for i = 1:14`
```%Generate the Delaunay Triangulation for each nucleus
Nuclei(i,1).Delaunay = delaunay(Nuclei(i).XCoordinates,  Nuclei(i).YCoordinates, Nuclei(i).ZCoordinates);
```
``` %Specify color for each nucleus from a pre-defined Colormap cell
Nuclei(i,1).Color = Colormap{i};```
``` %Plot all nuclei
tri = trisurf(Nuclei(i).Delaunay, Nuclei(i).XCoordinates, Nuclei(i).YCoordinates, Nuclei(i).ZCoordinates);
set(tri, 'FaceColor', Nuclei(i,1).Color)```
` end`
``` %View this plot at roughly Z = 4 for an Axial projection
axis([3,28,-23,5,3.95,4.0]) ```

I've attached a picture of what the result looks like. It's messy. I wish I could get rid of the black lines! Maybe there's a different way of generating volumes out of this XYZ-coordinate data though?

## Products

No products are associated with this question.

### Sean de Wolski (view profile)

on 21 Mar 2014
Edited by Sean de Wolski

### Sean de Wolski (view profile)

on 21 Mar 2014

Well I can help you with the lines, set the 'edgecolor' to 'none'

```[x,y] = meshgrid(1:15,1:15);
tri = delaunay(x,y);
z = peaks(15);
h=trisurf(tri,x,y,z);
set(h,'EdgeColor','none')
```

Layla

### Layla (view profile)

on 21 Mar 2014

Thanks Sean! That certainly makes the slices look nicer.

Would a Delaunay Triangulation be your choice for creating the 3D volume in the first place?

Sean de Wolski

### Sean de Wolski (view profile)

on 26 Mar 2014

That really depends on your end goal. For just viewing it? Sure!

For more complicated analysis, I would probably first voxelize it and then work on it as a three dimensional image (at least to get started).

http://www.mathworks.com/matlabcentral/fileexchange/27390-mesh-voxelisation

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi