# Show/hide segment surface in 3D view

**URL:** https://discourse.slicer.org/t/show-hide-segment-surface-in-3d-view/837
**Category:** Support
**Tags:** feature, segmentation, bug
**Created:** [August 7, 2017, 4:53pm UTC](https://discourse.slicer.org/t/show-hide-segment-surface-in-3d-view/837 "2017-08-07T16:53:05Z")
**Posts on this page:** 16
**Page:** 1

<div class="post-metadata">

### Author: ![fedorov](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/fedorov/32/14_2.png) [@fedorov](https://discourse.slicer.org/u/fedorov)
#### Post date: [August 7, 2017, 4:53pm UTC](https://discourse.slicer.org/t/show-hide-segment-surface-in-3d-view/837/1 "2017-08-07T16:53:05Z")

</div>

I created a segment, and I confirmed its master representation is Binary labelmap.

I then created surface by pushing the button “Create surface” in Segment Editor. I noticed that having a 3D surface rendered while performing editing in-slice leads to a noticeable slow-down of editor interactions, so I was looking for an option to disable surface rendering in 3D view, but I could not find this option.

I can un-click “Create surface” button (as aside, it is somewhat non-intuitive to me that “create” button acts as a checkbox) - the surface is gone from 3D view, but apparently it is also deleted and if I click “Create surface” it is being re-generated, since there is a noticeable delay.

The “eye” button in the segments list disables both segment overlay in slice and its rendering in 3d view. If mouse over the “eye” I see some mention of advanced visibility options, but long press does not trigger any such options (or maybe I need to press in some specific location of the button? there is no hint in its appearance about the advanced capability).

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

As a suggestion:

- I think “Create surface” should not be checkable, or if it stays checkable, its title should change to something else other than “Create surface” after surface has been created (“Delete surface”?)
- I think it would be helpful to be able to control visibility of the segment surface in 3d view without having to delete the surface.
- Tooltip for the eye icon in the segments list appears to be inconsistent with the actual behavior.

Tested with the latest available nightly of Slicer on mac - Aug 1.

---

<div class="post-metadata">

### Author: ![fedorov](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/fedorov/32/14_2.png) [@fedorov](https://discourse.slicer.org/u/fedorov)
#### Post date: [August 9, 2017, 6:49pm UTC](https://discourse.slicer.org/t/show-hide-segment-surface-in-3d-view/837/2 "2017-08-09T18:49:16Z")

</div>

@cpinter just wanted to make sure you saw this

---

<div class="post-metadata">

### Author: ![cpinter](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/cpinter/32/7995_2.png) [@cpinter](https://discourse.slicer.org/u/cpinter)
#### Post date: [August 9, 2017, 7:37pm UTC](https://discourse.slicer.org/t/show-hide-segment-surface-in-3d-view/837/3 "2017-08-09T19:37:09Z")

</div>

- Makes sense, we can change the name of the button. @lassoan please comment, as you had pretty strong opinions about this button earlier
- The surface is not “deleted” and “created”. This is a very important feature of Segmentations (see Validity problem in [slides](https://www.slicer.org/w/images/a/ae/20160526_Segmentations.pdf)), that the non-master representations are either up-to-date, or invalidated (removed so that they are re-created on demand). When you edit the labelmap, the surface becomes invalid immediately, and needs to be updated.
- I’ll fix it, this used to work. Two other ways to hide/show the surface
  - Segmentations module Display section
  - Subject hierarchy right-click on the eye icon in the row of the segmentation

---

<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: [August 10, 2017, 2:21am UTC](https://discourse.slicer.org/t/show-hide-segment-surface-in-3d-view/837/4 "2017-08-10T02:21:24Z")

</div>

2 posts were split to a new topic: [How to use masking in Segment editor](https://discourse.slicer.org/t/how-to-use-masking-in-segment-editor/852)

---

<div class="post-metadata">

### Author: ![cpinter](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/cpinter/32/7995_2.png) [@cpinter](https://discourse.slicer.org/u/cpinter)
#### Post date: [August 9, 2017, 10:00pm UTC](https://discourse.slicer.org/t/show-hide-segment-surface-in-3d-view/837/6 "2017-08-09T22:00:11Z")

</div>

@fedorov As it turns out about the third point, the options are there, but the flag that determines whether the advanced options are visible is false by default, but the tooltip was set nevertheless. What I did so far was to set the tooltip only if the advanced options are available.

As far as I remember we kept it disabled by default to avoid further clutter. Thoughts?

---

<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: [August 9, 2017, 10:03pm UTC](https://discourse.slicer.org/t/show-hide-segment-surface-in-3d-view/837/7 "2017-08-09T22:03:24Z")

</div>

> Makes sense, we can change the name of the button. @lassoan please comment, as you had pretty strong opinions about this button earlier

We already got feedback about the misleading button name (state button has action name) and I agree we should change it. The name should clearly indicate that it toggles closed surface representation (and not just hides/shows it) but otherwise I don’t have any strong preference.

---

<div class="post-metadata">

### Author: ![fedorov](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/fedorov/32/14_2.png) [@fedorov](https://discourse.slicer.org/u/fedorov)
#### Post date: [August 10, 2017, 3:12am UTC](https://discourse.slicer.org/t/show-hide-segment-surface-in-3d-view/837/8 "2017-08-10T03:12:26Z")

</div>

> [@cpinter](#):
>
> As far as I remember we kept it disabled by default to avoid further clutter. Thoughts?

I don’t think it adds much clutter, since it will not be shown by default. I assume you meant to add a little drop-down hint, as done in slice views link button? This by far would be a lot more convenient than the other options you mentioned to control surface view by going to other modules.

> [@cpinter](#):
>
> The surface is not “deleted” and “created”.

I definitely don’t know what is happening under the hood, but from the user perspective, if I un-click “Create surface” button, and then click it again right away (i.e., the representation does not change in between, so I would expect it to be up-to-date), there is a significant delay until I see the surface again in 3d view. It looks like the surface is re-generated, but perhaps it should not be if it didn’t change. You should be able to easily reproduce the delay by thresholding a whole body CT to make a segment.

I did find the other option to control 3d view in Segmentations. It shows up faster when I re-enable it, but there is still some delay.

---

<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: [August 10, 2017, 3:31am UTC](https://discourse.slicer.org/t/show-hide-segment-surface-in-3d-view/837/9 "2017-08-10T03:31:48Z")

</div>

> [@fedorov](#):
>
> This by far would be a lot more convenient

The issue with the long-press dropdown was that we often activated those advanced visualization options unintentionally and that slowed down the operation. Also, keeping closed surface representation but not showing it should be discouraged, as you would still need to wait for the closed surface representation to be computed but you would not see the result. Implementing background conversion between representations would be nice and we plan to do it in the future, but it is quite low priority.

We could easily add segmentation display options to the Segment Editor module, but it would make an already complex module even more complicated (similarly, it would be useful to have segment import/export directly there…). Do you think we should merge Segmentations module features into Segment editor? Or fuse the two modules into one?

I think for now we should focus on making it more clear what the show/hide icon and Create surface buttons do. What do you think about keeping the button as a checkbox but change the title to simply `3D` or `Show in 3D`?

---

<div class="post-metadata">

### Author: ![cpinter](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/cpinter/32/7995_2.png) [@cpinter](https://discourse.slicer.org/u/cpinter)
#### Post date: [August 10, 2017, 1:30pm UTC](https://discourse.slicer.org/t/show-hide-segment-surface-in-3d-view/837/10 "2017-08-10T13:30:47Z")

</div>

> [@fedorov](#):
>
> un-click “Create surface” button, and then click it again right away

I see. I don’t see this as a real use case, but we can certainly not delete it just hide it.

> [@fedorov](#):
>
> This by far would be a lot more convenient

For sure. What we could also do is to add these options to the segment right-click menu as well. I don’t see any disadvantage of exposing this option in multiple places, especially if (as you also seem to agree) the long-press option is disabled by default. Currently the only action in that right-click menu is “Show only selected segments”. We could add the 2D outline, 2D fill, and 3D visibility options as well.

---

<div class="post-metadata">

### Author: ![cpinter](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/cpinter/32/7995_2.png) [@cpinter](https://discourse.slicer.org/u/cpinter)
#### Post date: [August 10, 2017, 3:15pm UTC](https://discourse.slicer.org/t/show-hide-segment-surface-in-3d-view/837/11 "2017-08-10T15:15:00Z")

</div>

> [@cpinter](#):
>
> I see. I don’t see this as a real use case, but we can certainly not delete it just hide it.

Actually this will be problematic after all. If we hide it but keep the representation, then after every editing step the conversion will still take place. According to the original design this should not be the case, but apparently some part of the code requests the surface so it’s re-generated.

Can you tell us whether this quick show/hide of only the surface while keeping the 2D is a general request, or is it annoying in a specific use case?  
Would it be enough to show/hide the segment or the segmentation?

---

<div class="post-metadata">

### Author: ![fedorov](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/fedorov/32/14_2.png) [@fedorov](https://discourse.slicer.org/u/fedorov)
#### Post date: [August 10, 2017, 4:19pm UTC](https://discourse.slicer.org/t/show-hide-segment-surface-in-3d-view/837/12 "2017-08-10T16:19:18Z")

</div>

> [@lassoan](#):
>
> keeping closed surface representation but not showing it should be discouraged, as you would still need to wait for the closed surface representation to be computed but you would not see the result.

You might want to think about use cases where the user does not need to always see all of the segments. If you, for example, work with an atlas, you need to toggle visibility of individual structures, out of hundreds, while, for example, editing one single segment. If the segments are not edited, there should be no need to recompute the surface.

I don’t think the user should be discouraged from certain actions based on how things are implemented. They will see the performance hit, and will adjust their actions accordingly. But there should also not be unnecessary performance degradation where it is not needed, such as toggling surface visibility.

> [@lassoan](#):
>
> Do you think we should merge Segmentations module features into Segment editor? Or fuse the two modules into one?

Sometimes I ask myself the same question, but I see good and bad either way… Maybe as a compromise to help users in the short term, add a shortcut button to jump directly to Segmentations from Segment Editor, and give some hint about what capabilities are available from there?

> [@cpinter](#):
>
> > I see. I don’t see this as a real use case, but we can certainly not delete it just hide it.
> 
> Actually this will be problematic after all. If we hide it but keep the representation, then after every editing step the conversion will still take place. According to the original design this should not be the case, but apparently some part of the code requests the surface so it’s re-generated.
> 
> Can you tell us whether this quick show/hide of only the surface while keeping the 2D is a general request, or is it annoying in a specific use case?
> 
> Would it be enough to show/hide the segment or the segmentation?

@cpinter the example I provided is not a real use case, but just a simple way to reproduce the problem.

The specific situation where I came across this is the following. I played with brain MR images to segment the tumor. I had surface rendering enabled, and noticed that there is a delay in applying Segment Editor effects. So I thought if I disable surface rendering, I can do editing more quickly, and then show the surface again after I am done. That’s when I noticed that even if I don’t touch the segment, and change my mind and need to look at 3d again after looking around in 2d, I get this delay.

It’s definitely not a stopper. Should I file a bug report about the fact that surface is re-generated when segment is unchanged? As I mentioned earlier, the behavior in show/hide of surface is different between Segmentations and Segment Editor, so maybe making those consistent is a good task to tackle, whenever there are cycles.

---

<div class="post-metadata">

### Author: ![cpinter](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/cpinter/32/7995_2.png) [@cpinter](https://discourse.slicer.org/u/cpinter)
#### Post date: [August 10, 2017, 4:36pm UTC](https://discourse.slicer.org/t/show-hide-segment-surface-in-3d-view/837/13 "2017-08-10T16:36:20Z")

</div>

> [@fedorov](#):
>
> add a shortcut button to jump directly to Segmentations from Segment Editor, and give some hint about what capabilities are available from there

I like this idea.

> [@fedorov](#):
>
> If the segments are not edited, there should be no need to recompute the surface

True, validity could be handled on a per-segment basis. Unfortunately this would be a considerable implementation task, as representations are currently handled per-segmentation, and this change would require moving all the master representation and conversion related logic to the vtkSegment level. Imagine the segments and representations the rows and columns of a table. Now we can only remove whole rows or columns, but after this change we could remove individual cells. It’s a major change in the code, especially considering all testing and bugfixing etc.  
A relatively easy way I see to support this is a specialized segment editor, where you have your atlas, and you edit one segment at a time. So basically we would have two segmentations: the atlas, and the edited segment only.

> [@fedorov](#):
>
> I did find the other option to control 3d view in Segmentations. It shows up faster when I re-enable it, but there is still some delay.

We tried and found the same. We’ll investigate, as there should be no delay in simply showing a segment in 3D.

Summarizing the definite actionables so far:

- Rename Create surface button (“Show 3D” ?)
- Investigate slow show/hide of only the surface representation
- Add button to Segment Editor to switch to Segmentations. Its name TBD. The tooltip should mention visibility options, import/export, conversion parameters. Maybe long-click for quick export?

---

<div class="post-metadata">

### Author: ![fedorov](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/fedorov/32/14_2.png) [@fedorov](https://discourse.slicer.org/u/fedorov)
#### Post date: [August 10, 2017, 4:56pm UTC](https://discourse.slicer.org/t/show-hide-segment-surface-in-3d-view/837/14 "2017-08-10T16:56:20Z")

</div>

@cpinter thank you for the detailed explanation and suggestions! This all makes sense to me.

Yes, a shortcut for quick export would probably be helpful, considering how often this question comes up.

---

<div class="post-metadata">

### Author: ![cpinter](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/cpinter/32/7995_2.png) [@cpinter](https://discourse.slicer.org/u/cpinter)
#### Post date: [August 30, 2017, 3:38pm UTC](https://discourse.slicer.org/t/show-hide-segment-surface-in-3d-view/837/15 "2017-08-30T15:38:52Z")

</div>

Just referencing the PR which contains the changes requested here:

> <https://github.com/Slicer/Slicer/issues/783>
>
> This issue was created automatically from an original Mantis Issue. Further discussion may take place here.

---

<div class="post-metadata">

### Author: ![cpinter](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/cpinter/32/7995_2.png) [@cpinter](https://discourse.slicer.org/u/cpinter)
#### Post date: [September 9, 2017, 3:54pm UTC](https://discourse.slicer.org/t/show-hide-segment-surface-in-3d-view/837/16 "2017-09-09T15:54:56Z")

</div>

PR above integrated in  
[https://github.com/Slicer/Slicer/commit/36fe64b16734c962156c5f574280a6fa7b9cccb6](https://github.com/Slicer/Slicer/commit/36fe64b16734c962156c5f574280a6fa7b9cccb6)

---

<div class="post-metadata">

### Author: ![cpinter](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/cpinter/32/7995_2.png) [@cpinter](https://discourse.slicer.org/u/cpinter)
#### Post date: [September 9, 2017, 3:57pm UTC](https://discourse.slicer.org/t/show-hide-segment-surface-in-3d-view/837/17 "2017-09-09T15:57:49Z")

</div>

Show/hide segmentation performance issue fixed in  
[https://github.com/Slicer/Slicer/commit/0a4374c08b401d23f88159ee45ae2dc81243205d](https://github.com/Slicer/Slicer/commit/0a4374c08b401d23f88159ee45ae2dc81243205d)  
Tested on the brain atlas. Hiding the segmentation is faster than hiding the model hierarchy, and show seems to take the same amount of time.
