# Drawing shapes in volume rendering

**URL:** <https://discourse.slicer.org/t/drawing-shapes-in-volume-rendering/2068>\
**Category:** Development\
**Created:** [February 12, 2018, 1:43pm UTC](https://discourse.slicer.org/t/drawing-shapes-in-volume-rendering/2068 "2018-02-12T13:43:04Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jonas](https://avatars.discourse-cdn.com/v4/letter/j/aeb1de/32.png) [@Jonas](https://discourse.slicer.org/u/Jonas)\
**Post date:** [February 12, 2018, 1:43pm UTC](https://discourse.slicer.org/t/drawing-shapes-in-volume-rendering/2068/1 "2018-02-12T13:43:04Z")

</div>

Hello,  
This is my first post on this forum, and I am new to Slicer. Hopefully you will be tolerant 🙂  
I want to create a shape, which would be visible in VR - the best approach would be to use Fiducials (as they are easy to move once placed) and possibly connect them by lines to draw a shape. I need to draw a triangle. I suppose. it could be a segment in 3D.  
Any ideas what would be the best and easiest approach?  
Thanks,  
Jonas

---

<div class="post-metadata">

**Author:** ![timeanddoctor](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/timeanddoctor/32/5839_2.png) [@timeanddoctor](https://discourse.slicer.org/u/timeanddoctor)\
**Post date:** [February 12, 2018, 2:21pm UTC](https://discourse.slicer.org/t/drawing-shapes-in-volume-rendering/2068/2 "2018-02-12T14:21:20Z")

</div>

If you went to draw a point and a triangle line, the best method is “CurveMaker” module.  
[https://www.slicer.org/wiki/Documentation/Nightly/Extensions/CurveMaker](https://www.slicer.org/wiki/Documentation/Nightly/Extensions/CurveMaker)  
 ![](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/9/e/9ea933478b30a5cf7d80be7334247324b5f9daf4.png)  
 ![](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/8/9/89c975760da2c7f432a92b4f0f98a058c9f88ce4.png)

---

<div class="post-metadata">

**Author:** ![Jonas](https://avatars.discourse-cdn.com/v4/letter/j/aeb1de/32.png) [@Jonas](https://discourse.slicer.org/u/Jonas)\
**Post date:** [February 13, 2018, 12:26am UTC](https://discourse.slicer.org/t/drawing-shapes-in-volume-rendering/2068/3 "2018-02-13T00:26:54Z")

</div>

Thanks for your input. I have tested the functionality - it is on the right path to the destination 🙂  
My intention is to have a plane/area (surface?) between the dots.

 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/9/c/9c51709d6b28ae3b81fc367b100492934d73b9ad.png)  
Curve is on the left, and I want to have an area like on the right.  
Any insights how this could be achieved?

---

<div class="post-metadata">

**Author:** ![Jonas](https://avatars.discourse-cdn.com/v4/letter/j/aeb1de/32.png) [@Jonas](https://discourse.slicer.org/u/Jonas)\
**Post date:** [February 13, 2018, 12:54am UTC](https://discourse.slicer.org/t/drawing-shapes-in-volume-rendering/2068/4 "2018-02-13T00:54:50Z")

</div>

Ok, I managed to get it to work. I found a plugin markup to model and it had a function “closed surface”.  
Now I can generate such model:

 ![](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/2X/3/3046b4648242a34a9ce24e4f2db03db8866ad67d.jpg)  
Now I have additional question - if I try to make it transparent, it disappears - despite the skull having no visible voxels in the clipping ROI, it does not show model in it with transparency - any ideas how it could be solved?

---

<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:** [February 13, 2018, 2:12am UTC](https://discourse.slicer.org/t/drawing-shapes-in-volume-rendering/2068/5 "2018-02-13T02:12:15Z")

</div>

Note that there is already a Segment Editor effect (“Surface cut”), available in SegmentEditorExtraEffects extension, which uses MarkupsToModel module to create segments. I would recommend using this effect and tune it as needed, instead of redeveloping this effect from scratch.

To show semitransparent models correctly, you need to enable depth peeling in the 3D view:

![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/d/7/d727d463d03b0bd763f843382532354c3f468d66.png)

---

<div class="post-metadata">

**Author:** ![Jonas](https://avatars.discourse-cdn.com/v4/letter/j/aeb1de/32.png) [@Jonas](https://discourse.slicer.org/u/Jonas)\
**Post date:** [February 13, 2018, 12:42pm UTC](https://discourse.slicer.org/t/drawing-shapes-in-volume-rendering/2068/6 "2018-02-13T12:42:03Z")

</div>

Ok, I followed your advice - I can easily segment a triangle shape surface (which is perfect), however, I still can’t achieve to have semi-transparency in 3D rending whatever I do. Any ideas?

 ![](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/2X/c/c6100e9d8ddab701c1d5afa0b67d84225f57ac7f.jpg)

---

<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:** [February 13, 2018, 1:00pm UTC](https://discourse.slicer.org/t/drawing-shapes-in-volume-rendering/2068/7 "2018-02-13T13:00:15Z")

</div>

It looks good. To adjust opacity, move the opacity slider in Display section / 3D row.

---

<div class="post-metadata">

**Author:** ![Jonas](https://avatars.discourse-cdn.com/v4/letter/j/aeb1de/32.png) [@Jonas](https://discourse.slicer.org/u/Jonas)\
**Post date:** [February 13, 2018, 1:11pm UTC](https://discourse.slicer.org/t/drawing-shapes-in-volume-rendering/2068/8 "2018-02-13T13:11:02Z")

</div>

If I subtract any amount (ex 10%) it instantly disappears completely:

 ![](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/2X/e/e86e9cd0d0d922f2afa766c64f3b6ab720fa5999.jpg)

---

<div class="post-metadata">

**Author:** ![Jonas](https://avatars.discourse-cdn.com/v4/letter/j/aeb1de/32.png) [@Jonas](https://discourse.slicer.org/u/Jonas)\
**Post date:** [February 13, 2018, 1:15pm UTC](https://discourse.slicer.org/t/drawing-shapes-in-volume-rendering/2068/9 "2018-02-13T13:15:54Z")

</div>

If I make some other projection where are no structures behind the segmented region, it appears translucent. But if there is any structure behind it, it does not appear at all. It seems that the shape instantly goes to the background and only appears if are are no other structures in the same projection.

 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/d/b/db27b073be43d2cc316a059d2349936d7b236805.png)

---

<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:** [February 13, 2018, 2:33pm UTC](https://discourse.slicer.org/t/drawing-shapes-in-volume-rendering/2068/10 "2018-02-13T14:33:01Z")

</div>

On certain graphics cards, depth peeling does not work well in Slicer-4.8.1 and you need to use latest nightly version (not older than a couple of days).

---

<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:** [February 13, 2018, 3:13pm UTC](https://discourse.slicer.org/t/drawing-shapes-in-volume-rendering/2068/11 "2018-02-13T15:13:09Z")

</div>

I’ve just noticed that you may use volume rendering. The title of the post was just “VR” instead of volume rendering, and I assumed that this is a project about virtual reality. Nowadays, it is better not to use the VR acronym.

Compositing of volume rendering and transparent surfaces may not be correct. However, these should work:

- Option A: show volume rendering and opaque surface models
- Option B: segment your volume using Segment Editor and show transparent surfaces
- Option C: edit your volume, for example, using Mask Volume effect in Segment Editor. Requires installation of SegmentEditorExtraEffects extension.
- Option D: show volume rendering and show surface models as wireframe (Models module / Display / Representation)

---

<div class="post-metadata">

**Author:** ![Jonas](https://avatars.discourse-cdn.com/v4/letter/j/aeb1de/32.png) [@Jonas](https://discourse.slicer.org/u/Jonas)\
**Post date:** [February 13, 2018, 3:41pm UTC](https://discourse.slicer.org/t/drawing-shapes-in-volume-rendering/2068/12 "2018-02-13T15:41:47Z")

</div>

yes, I am talking about volume rendering. I have into it deeper - I tried 4.9.0 nighly, but with it I have a problem, it does not save segmentations.

---

<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:** [February 13, 2018, 4:17pm UTC](https://discourse.slicer.org/t/drawing-shapes-in-volume-rendering/2068/13 "2018-02-13T16:17:05Z")

</div>

> [@Jonas](#):
>
> it does not save segmentations

What do you do? What do you expect to happen? What happens instead? What operating system? Any related error in the log?

---

<div class="post-metadata">

**Author:** ![Jonas](https://avatars.discourse-cdn.com/v4/letter/j/aeb1de/32.png) [@Jonas](https://discourse.slicer.org/u/Jonas)\
**Post date:** [February 13, 2018, 7:01pm UTC](https://discourse.slicer.org/t/drawing-shapes-in-volume-rendering/2068/14 "2018-02-13T19:01:29Z")

</div>

Hello,  
I go to segmentations, create a segment (surface cut), mark the fiducials (as I did in 4.8.1), click “Apply”. When I click to return to Segmentations view the newly segmented triangle disappears.

I do have errors in error log:

```auto
void __cdecl qSlicerSegmentationsModuleWidget::onEditSelectedSegment(void) : MRMLNodeComboBox_Segmentation is not found in Segment Editor module

```

Traceback (most recent call last):

```auto
  File "C:/Users/Jonas/AppData/Roaming/NA-MIC/Extensions-26909/SegmentEditorExtraEffects/lib/Slicer-4.9/qt-scripted-modules/SegmentEditorSurfaceCutLib/SegmentEditorEffect.py", line 255, in onApply
    self.logic.cutSurfaceWithModel(self.segmentMarkupNode, self.segmentModel)
  File "C:/Users/Jonas/AppData/Roaming/NA-MIC/Extensions-26909/SegmentEditorExtraEffects/lib/Slicer-4.9/qt-scripted-modules/SegmentEditorSurfaceCutLib/SegmentEditorEffect.py", line 455, in cutSurfaceWithModel
    modMode = slicer.qSlicerSegmentEditorAbstractEffect.ModificationModeAdd
AttributeError: 'module' object has no attribute 'qSlicerSegmentEditorAbstractEffect'

```

In 4.8.1 I installed firstly Markups to Model and then SegmentEditorExtraEffects. In 4.9.0 nightly I installed instantly SegmentEditorExtraEffects and Markups to Model was installed together as a dependency.

Standard segmentations (draw, paint) works just fine.  
Operating system: Windows 10 64 bit.

P.S. Thanks for fixing the markup - I will get used to using them.

---

<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:** [February 13, 2018, 9:43pm UTC](https://discourse.slicer.org/t/drawing-shapes-in-volume-rendering/2068/15 "2018-02-13T21:43:10Z")

</div>

I’ve pushed a fix, the surface cut effect should work correctly in tomorrow’s nightly version.

---

<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:** [February 14, 2018, 4:42am UTC](https://discourse.slicer.org/t/drawing-shapes-in-volume-rendering/2068/16 "2018-02-14T04:42:46Z")

</div>

@jcfr did some investigation and it turned out that mixing transparent surfaces with volume rendering is supported in recent VTK versions; and [updated Slicer to take advantage of this option](https://github.com/commontk/CTK/pull/785#issuecomment-365480947). The feature will be available in the nightly builds from tomorrow. Thanks a lot Jc!

---

<div class="post-metadata">

**Author:** ![Jonas](https://avatars.discourse-cdn.com/v4/letter/j/aeb1de/32.png) [@Jonas](https://discourse.slicer.org/u/Jonas)\
**Post date:** [February 14, 2018, 10:36am UTC](https://discourse.slicer.org/t/drawing-shapes-in-volume-rendering/2068/17 "2018-02-14T10:36:52Z")

</div>

Great. Thanks for guiding me all this way step by step. I will test the new  
Nighly.

Best regards  
Jonas
