# surface plot from 2D slices

**URL:** <https://discourse.slicer.org/t/surface-plot-from-2d-slices/6235>\
**Category:** Support\
**Created:** [March 21, 2019, 12:55pm UTC](https://discourse.slicer.org/t/surface-plot-from-2d-slices/6235 "2019-03-21T12:55:31Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![nahida](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/nahida/32/3307_2.png) [@nahida](https://discourse.slicer.org/u/nahida)\
**Post date:** [March 21, 2019, 12:55pm UTC](https://discourse.slicer.org/t/surface-plot-from-2d-slices/6235/1 "2019-03-21T12:55:31Z")

</div>

Hi , I have 24 slices of one eye from OCT images. When I load them in slicer and view in volume rendering all slices are placed in horizontally, not make a circle, I want every slices spaced at 30 degree and makes a round eye.

Can anyone please help me in this regards?

---

<div class="post-metadata">

**Author:** ![pieper](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/pieper/32/8_2.png) [@pieper](https://discourse.slicer.org/u/pieper)\
**Post date:** [March 21, 2019, 2:32pm UTC](https://discourse.slicer.org/t/surface-plot-from-2d-slices/6235/2 "2019-03-21T14:32:40Z")

</div>

Could you add a screenshot so we have a better idea about the data?

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [March 21, 2019, 3:12pm UTC](https://discourse.slicer.org/t/surface-plot-from-2d-slices/6235/3 "2019-03-21T15:12:06Z")

</div>

Do you read the images from DICOM? If yes, then you might be able to reconstruct acquisition geometry by setting “Acquisition geometry regularization” to “apply regularization transform” in application settings (menu: Edit / Application settings / DICOM / DICOMScalarVolumePlugin) before loading the image from the DICOM browser.

---

<div class="post-metadata">

**Author:** ![nahida](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/nahida/32/3307_2.png) [@nahida](https://discourse.slicer.org/u/nahida)\
**Post date:** [March 21, 2019, 11:44pm UTC](https://discourse.slicer.org/t/surface-plot-from-2d-slices/6235/4 "2019-03-21T23:44:19Z")

</div>

Thank you Andras, my images are not from DICOM, they are in jpg format. export as jpeg from OCT pentacam machine.

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [March 22, 2019, 12:07am UTC](https://discourse.slicer.org/t/surface-plot-from-2d-slices/6235/5 "2019-03-22T00:07:06Z")

</div>

If you only have a set of JPEG images, then there is no information about positions of each image slice in 3D. Slicer assumes that they should be stacked on top of each other with a constant spacing. Is this a correct assumption? Or they should be arranged in some circular pattern?

As Steve asked above, could you post screenshots of how the images should appear (e.g., screenshot from your OCT imaging console) and how it appears in Slicer?

---

<div class="post-metadata">

**Author:** ![nahida](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/nahida/32/3307_2.png) [@nahida](https://discourse.slicer.org/u/nahida)\
**Post date:** [March 22, 2019, 12:42am UTC](https://discourse.slicer.org/t/surface-plot-from-2d-slices/6235/6 "2019-03-22T00:42:14Z")

</div>

![Untitled](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/a/a/aa42089c760b317a5de6ecfeba6778ca57c5f30a.png)

Hi Steve, here are the screenshot, all the slices sectioning by green color, total 25 slices from whole section.  
Now i want to reconstruct the original round image from all of those slices.

---

<div class="post-metadata">

**Author:** ![nahida](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/nahida/32/3307_2.png) [@nahida](https://discourse.slicer.org/u/nahida)\
**Post date:** [March 22, 2019, 12:58am UTC](https://discourse.slicer.org/t/surface-plot-from-2d-slices/6235/7 "2019-03-22T00:58:33Z")

</div>

Hi Andras, they should be arranged in circular pattern. I also upload the real images in reply of Steve and here I am uploading how they appear when I saw as volume rendering.

 ![slicer2](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/6/2/62fcc81a45e5599d14f67780891a7e0ff725e909.jpeg)

It could be great if I select every slices and I can manually fix their position.

---

<div class="post-metadata">

**Author:** ![pieper](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/pieper/32/8_2.png) [@pieper](https://discourse.slicer.org/u/pieper)\
**Post date:** [March 22, 2019, 1:04pm UTC](https://discourse.slicer.org/t/surface-plot-from-2d-slices/6235/8 "2019-03-22T13:04:07Z")

</div>

Thanks, those images help a lot. The acquisitions need to be resampled into a rectilinear space for Slicer to volume render them. There are many ways to do this with a little programming, but no point-and-click method right now that I’m aware of. If you are up for the programming we’d be glad to give some suggestions.

---

<div class="post-metadata">

**Author:** ![nahida](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/nahida/32/3307_2.png) [@nahida](https://discourse.slicer.org/u/nahida)\
**Post date:** [March 22, 2019, 1:21pm UTC](https://discourse.slicer.org/t/surface-plot-from-2d-slices/6235/9 "2019-03-22T13:21:00Z")

</div>

Thanks Steve, I can do some programming, would you please tell me the details.

---

<div class="post-metadata">

**Author:** ![pieper](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/pieper/32/8_2.png) [@pieper](https://discourse.slicer.org/u/pieper)\
**Post date:** [March 22, 2019, 2:06pm UTC](https://discourse.slicer.org/t/surface-plot-from-2d-slices/6235/10 "2019-03-22T14:06:00Z")

</div>

> [@nahida](#):
>
> Thanks Steve, I can do some programming, would you please tell me the details

Great, well, depending on how concerned you are about efficiency you might need to try some more sophisticated methods, but I’d suggest starting with something simple that you can use as a baseline.

As an example, here’s an easy way to make a volume node with random data in it. Run this in the python interactor and you should be able to see the random noise in the slice views.

```auto
n = slicer.mrmlScene.CreateNodeByClass('vtkMRMLScalarVolumeNode')
n.SetName('my volume')
slicer.mrmlScene.AddNode(n)
import numpy
slicer.util.updateVolumeFromArray(n, numpy.random.sample([30,30,30]))

```

Working from there you could make an array of zeros instead, and then iterate through the OCT slices and just copy (or interpolate) the pixels into the corresponding voxels. Since you have the jpg files loaded you can get them as numpy arrays with `slicer.util.arrayFromVolume(volumeNode)`.

---

<div class="post-metadata">

**Author:** ![nahida](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/nahida/32/3307_2.png) [@nahida](https://discourse.slicer.org/u/nahida)\
**Post date:** [March 22, 2019, 2:40pm UTC](https://discourse.slicer.org/t/surface-plot-from-2d-slices/6235/11 "2019-03-22T14:40:15Z")

</div>

Thank you Steve, I will try these code and let you know how it goes.
