# Toggle segment view for all segments in segment editor instead of segmentations module

**URL:** https://discourse.slicer.org/t/toggle-segment-view-for-all-segments-in-segment-editor-instead-of-segmentations-module/14552
**Category:** Support
**Tags:** segmentation
**Created:** [November 11, 2020, 10:55pm UTC](https://discourse.slicer.org/t/toggle-segment-view-for-all-segments-in-segment-editor-instead-of-segmentations-module/14552 "2020-11-11T22:55:49Z")
**Posts on this page:** 18
**Page:** 1

<div class="post-metadata">

### Author: ![pr4deepr](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/pr4deepr/32/8810_2.png) [@pr4deepr](https://discourse.slicer.org/u/pr4deepr)
#### Post date: [November 11, 2020, 10:55pm UTC](https://discourse.slicer.org/t/toggle-segment-view-for-all-segments-in-segment-editor-instead-of-segmentations-module/14552/1 "2020-11-11T22:55:49Z")

</div>

HI  
Is it possible to toggle visibility of all segments in Segment Editor?  
In segment editor, I right click on a segment of interest and click “Show only selected segments"to view my segment of interest and correct the annotation. Once I’m done, I would like to view all segmentations in Segment Editor module instead of going to segmentations module. If it was a few segments, then it wouldn’t matter, but when I’m annotating \>20-30 objects it does become quite cumbersome. Is there a way for this already?

Thanks a lot.

Cheers  
Pradeep

---

<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: [November 12, 2020, 12:41am UTC](https://discourse.slicer.org/t/toggle-segment-view-for-all-segments-in-segment-editor-instead-of-segmentations-module/14552/2 "2020-11-12T00:41:12Z")

</div>

I think the use case of bulk show/hide “all other segments” has not come up before. Can you tell why do you want to show only a single segment? Do all those segment overlap with your current segment and therefore it decreases its visibility? Or do you do this for performance reasons? (Is update is slower if you show more segments? It should not be)

---

<div class="post-metadata">

### Author: ![pr4deepr](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/pr4deepr/32/8810_2.png) [@pr4deepr](https://discourse.slicer.org/u/pr4deepr)
#### Post date: [November 12, 2020, 12:57am UTC](https://discourse.slicer.org/t/toggle-segment-view-for-all-segments-in-segment-editor-instead-of-segmentations-module/14552/3 "2020-11-12T00:57:27Z")

</div>

Hi @lassoan  
Thanks for your reply.

Its mostly because I use Fill between Slices option to create a segment and since that works on only the visible segment, I need to toggle visibility of all other segments off to use this option. After I am done, I want to see all other segments to figure out which ones I need to correct or add. I need to switch between segmentation and segment editor modules to do this.

Example image:

 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/e/8/e86949eb03d5865db7be45ddb1b7b9f6d1d526e7.jpeg)

> [@lassoan](#):
>
> Do all those segment overlap with your current segment and therefore it decreases its visibility?

Yes, this is another reason as well.

If you think there is a better approach than using Fill between slices, please do let me know.

Thanks

Pradeep

---

<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: [November 12, 2020, 1:11am UTC](https://discourse.slicer.org/t/toggle-segment-view-for-all-segments-in-segment-editor-instead-of-segmentations-module/14552/4 "2020-11-12T01:11:55Z")

</div>

I guess you mean “Grow from seeds” - the attached image contains small blobs, which are not well suited for “Fill between slices”. Anyway, both these effects can process any number of visible segments at once, so it should not be necessary to define segments one by one.

A simple way to segment images like this can be to generate seed points by Thresholding and Islands split. If sometimes blobs are fused together then you can use a higher threshold value (so high that blobs are not connected anymore), then run Grow from seeds on the result (to get the complete blob from the small seed).

---

<div class="post-metadata">

### Author: ![pr4deepr](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/pr4deepr/32/8810_2.png) [@pr4deepr](https://discourse.slicer.org/u/pr4deepr)
#### Post date: [November 12, 2020, 2:03am UTC](https://discourse.slicer.org/t/toggle-segment-view-for-all-segments-in-segment-editor-instead-of-segmentations-module/14552/5 "2020-11-12T02:03:38Z")

</div>

Hi @lassoan  
Thanks for the suggestion, this is really handy for images I label from scratch.

Apologies, I was not clear, but for most of the images I get label predictions from a different program and correct it in 3D Slicer, so Fill between slices is a quick way to add a few more labels or correct labels. Currently, I use paint or level tracing to create segments, and then use Fill between slices+Smoothing to complete it. So, if the mask/label I imported already had 50 objects, I would like to hide all of them to activate Fill between slices to make a new segment and then re-display them after.

Hope it is clearer now.

Cheers  
Pradeep

---

<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: [November 12, 2020, 6:29am UTC](https://discourse.slicer.org/t/toggle-segment-view-for-all-segments-in-segment-editor-instead-of-segmentations-module/14552/6 "2020-11-12T06:29:06Z")

</div>

Showing/hiding segments and using “Fill between slices” should not be necessary for this segmentation task. Most likely you can fix all these blobs at once, by keeping all of them displayed and adding a “background” segment, and applying “Grow from seeds” effect. You probably don’t need the label predictions from another program, because you can generate seeds by thresholding and island splitting. You may also try local thresholding (in SegmentEditorExtraEffects extension).

If you can share a volume (upload to dropbox/onedrive/google drive and post the link here) then you can get more specific advice.

---

<div class="post-metadata">

### Author: ![pr4deepr](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/pr4deepr/32/8810_2.png) [@pr4deepr](https://discourse.slicer.org/u/pr4deepr)
#### Post date: [November 13, 2020, 1:07am UTC](https://discourse.slicer.org/t/toggle-segment-view-for-all-segments-in-segment-editor-instead-of-segmentations-module/14552/7 "2020-11-13T01:07:41Z")

</div>

Thanks for that.  
Its a small image which can be found here:

[Image download link](https://www.dropbox.com/s/mec1jegwx4ta31r/dapi_20-50.tif?dl=0)

To give more context and make sure I’m clear. I use 3D slicer to generate labelmaps which are then used as ground truth for training deep learning models to automate image segmentation tasks.  
The seed thresholding and island splitting is a really good idea. I am so used to ImageJ that I am still getting my head around workflows in 3D Slicer. Thanks, I have installed the SegmentEditorExtraEffects extension.  
Would you mind having a look at the dataset I uploaded and let me know if you have any other suggestions? I do appreciate that the image is quite small and noisy.

Thanks  
Pradeep

---

<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: [November 13, 2020, 4:11pm UTC](https://discourse.slicer.org/t/toggle-segment-view-for-all-segments-in-segment-editor-instead-of-segmentations-module/14552/8 "2020-11-13T16:11:47Z")

</div>

Thank you for the sample image, it helped a lot in understanding the task and challenges. These images are different from usual 3D clinical images in that objects can overlap in the 3D space, so you will need some manual work to review and resolve these overlaps.

You can get a good starting point by automatically generating seeds and growing them:

- Add segment
- Thresholding effect: select range 10000 to maximum, click Apply (these will be the basis of seed points)
- Smoothing effect: Median, 3mm (removes small speckles, fill small holes)
- Margin: Shrink, 1mm (splits connected seeds, but needs to be used carefully, as it can also remove small seeds)
- Islands: Split islands to segments, Minimum size: 10 voxels
- Grow from seeds effect: in Masking section, check “Editable intensity range”, set range 5000 to maximum, click initialize, then Apply
- Smoothing: Joint smoothing method

 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/f/1/f16106673ba8ded9a4a68e2413f8b2c09d279431.jpeg)

These may seem like a lot of steps, but once you experimented with it manually and know what parameters work the best, you perform all the steps fully automatically by a Python script.

You might consider reducing noise in the image and use that as master volume, especially for the last “Grow from seeds” step. To do this noise filtering, first you need to cast the image to float using Cast scalar volume module, then use Simple Filters module - Gradient anisotropic smoothing filter. There are many other noise reduction filters in Simple Filters module that you might try.

Unfortunately, these automated processing needs manual fixing, mostly splitting of fused segments. If you can see fused blobs in the 3D view then you can separate them by using Scissors effect with Masking/Editable area → Inside all segments, Operation → Fill inside. After setting this up, you can add a new segment and in circle in a 3D view the part of a segment that you want separate out into a new segment.

You may also find Paint tool useful, you can enable sphere brush to paint in multiple slices at once and set Editable intensity range to restrict it to bright regions.

---

<div class="post-metadata">

### Author: ![pr4deepr](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/pr4deepr/32/8810_2.png) [@pr4deepr](https://discourse.slicer.org/u/pr4deepr)
#### Post date: [November 13, 2020, 6:16pm UTC](https://discourse.slicer.org/t/toggle-segment-view-for-all-segments-in-segment-editor-instead-of-segmentations-module/14552/9 "2020-11-13T18:16:31Z")

</div>

Hi @lassoan  
This is super useful and I’m already getting some nice results… This has also given me an idea on the workflows and possibilities with 3D slicer.

I agree that it needs some manual fixing, but this is a great start. Restricting the editing area using Masking/Editable area is really handy. Didn’t realise I could use it here.

Just one question, I tried Gradient Anisotropic Diffusion filter under Filtering-\>Denoising and it worked without casting the image to float. Is this the same as using the same filter under Simple Filters module?

An unrelated question, in cases of using big images, are filters in 3D Slicer GPU-accelerated or does it use the CPU mainly?

Thanks a lot

Pradeep

---

<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: [November 13, 2020, 6:34pm UTC](https://discourse.slicer.org/t/toggle-segment-view-for-all-segments-in-segment-editor-instead-of-segmentations-module/14552/10 "2020-11-13T18:34:39Z")

</div>

> [@pr4deepr](#):
>
> Just one question, I tried Gradient Anisotropic Diffusion filter under Filtering-\>Denoising and it worked without casting the image to float. Is this the same as using the same filter under Simple Filters module?

Probably the Gradient anisotropic diffusion filter module does the same as Simple Filters module’s filter. I recommended Simple Filters because it has many other noise filtering modules that you can experiment with, but if you end up using gradient anisotropic diffusion then it is simpler to use that module.

> [@pr4deepr](#):
>
> An unrelated question, in cases of using big images, are filters in 3D Slicer GPU-accelerated or does it use the CPU mainly?

With a very few exceptions, image processing filters run on the CPU. GPU is mainly used in Slicer for rendering.

---

<div class="post-metadata">

### Author: ![pr4deepr](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/pr4deepr/32/8810_2.png) [@pr4deepr](https://discourse.slicer.org/u/pr4deepr)
#### Post date: [November 16, 2020, 1:29am UTC](https://discourse.slicer.org/t/toggle-segment-view-for-all-segments-in-segment-editor-instead-of-segmentations-module/14552/11 "2020-11-16T01:29:34Z")

</div>

Thanks for that.

> [@lassoan](#):
>
> With a very few exceptions, image processing filters run on the CPU. GPU is mainly used in Slicer for rendering.

Is it of interest in 3D Slicer to use GPU-accelerated filters?  
If so, perhaps this may be of interest?

> **[GitHub - clEsperanto/pyclesperanto\_prototype: GPU-accelerated bio-image...](https://github.com/clEsperanto/pyclesperanto_prototype)**
>
> GPU-accelerated bio-image analysis focusing on 3D+t microscopy image data - GitHub - clEsperanto/pyclesperanto\_prototype: GPU-accelerated bio-image analysis focusing on 3D+t microscopy image data

This is a project where OpenCL kernels are being translated for use in Python.  
This is from a GPU accelerated image processing library in ImageJ/FIJI which uses OpenCL kernels: [https://clij.github.io/](https://clij.github.io/)  
The OpenCL implementations here are being ported for use in Python. There are quite few ITK filters in there as well.

Cheers  
Pradeep

---

<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: [November 16, 2020, 6:54am UTC](https://discourse.slicer.org/t/toggle-segment-view-for-all-segments-in-segment-editor-instead-of-segmentations-module/14552/12 "2020-11-16T06:54:49Z")

</div>

We haven’t had have huge success stories with GPU-acceleration in image processing filters. Maybe it is because processing speed on CPU is a problem mainly on big data sets and with complex algorithms. However, big data is not very well suited for GPU processing either, as CPU/GPU transfer time can be very significant and available GPU memory may be limited. Complex algorithms get even more complex when you want to run them efficiently on the GPU and often you need to develop a new algorithm almost from scratch. Additional difficulty is that development, debugging, and maintenance of OpenCL code requires special skillset which only a small fraction of developers have.

Slicer is using more and more of the GPU as ITK (and various other packages) take advantage of the GPU. We may also look into improving speed of a few specific operations that are performed very frequently and noticeably slow. But I would expect that most of the image and mesh processing operations will remain mostly on the CPU in the near term.

---

<div class="post-metadata">

### Author: ![pr4deepr](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/pr4deepr/32/8810_2.png) [@pr4deepr](https://discourse.slicer.org/u/pr4deepr)
#### Post date: [November 16, 2020, 2:00pm UTC](https://discourse.slicer.org/t/toggle-segment-view-for-all-segments-in-segment-editor-instead-of-segmentations-module/14552/13 "2020-11-16T14:00:51Z")

</div>

Thanks for the detailed reply.  
The transfer time isn’t too bad, but when we are using the GPU in an image processing workflow it is better to chain the GPU operations together so that the transfer time is reduced. Its usually a balance between if the image sits in the memory and if so, is the transfer time and processing quicker than using the CPU.  
I do agree that the development and maintenance can be a specialised skillset.  
There is a nice list of operations that are being translated into Python here, if its of interest to yoursel or anyone else who comes across this thread in the future:

> <https://github.com/clEsperanto/pyclesperanto_prototype/issues/15>
>
> I'm just trying to get organized and split all CLIJ2 operations (which might be translated to clesperanto at some point) into...

Thanks for your help again @lassoan  
Pradeep

---

<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: [November 16, 2020, 2:48pm UTC](https://discourse.slicer.org/t/toggle-segment-view-for-all-segments-in-segment-editor-instead-of-segmentations-module/14552/14 "2020-11-16T14:48:47Z")

</div>

I did some experiments with Slicer and OpenCL a while ago using PyOpenCL. Generally it worked very well. In addition to the issues Andras noted, at least when I was testing this I found a wide variety of performance and feature support across platforms (probably some drivers were buggy) so code that worked well on one machine was slow or just didn’t work on another.

That said, I agree with the overall goal of processing on the best hardware available and keeping the data in memory close to where it will be rendered. The code linked below has example segmentation and volume rendering kernels.

[![](https://img.youtube.com/vi/dfu2gugHLHs/maxresdefault.jpg "growcutcl.mov") ](https://www.youtube.com/watch?v=dfu2gugHLHs)

> **[GitHub - pieper/SlicerCL: Extensions for Slicer that use OpenCL](https://github.com/pieper/SlicerCL)**
>
> Extensions for Slicer that use OpenCL. Contribute to pieper/SlicerCL development by creating an account on GitHub.

(yikes, was it really 9 years ago??)

---

<div class="post-metadata">

### Author: ![JohnMiles](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/johnmiles/32/8871_2.png) [@JohnMiles](https://discourse.slicer.org/u/JohnMiles)
#### Post date: [November 18, 2020, 12:01pm UTC](https://discourse.slicer.org/t/toggle-segment-view-for-all-segments-in-segment-editor-instead-of-segmentations-module/14552/15 "2020-11-18T12:01:39Z")

</div>

Useful topic for me, useful information to be applied in my laboratory, thanks to all! [🤝](https://www.buyessayscheap.com/research-paper-writing-service.html)

---

<div class="post-metadata">

### Author: ![Bethrg](https://avatars.discourse-cdn.com/v4/letter/b/e99b99/32.png) [@Bethrg](https://discourse.slicer.org/u/Bethrg)
#### Post date: [January 22, 2022, 11:40pm UTC](https://discourse.slicer.org/t/toggle-segment-view-for-all-segments-in-segment-editor-instead-of-segmentations-module/14552/16 "2022-01-22T23:40:31Z")

</div>

Hello,

It looks like this thread theme changed a bit, so circling back, I also need to frequently turn off/toggle between many segments at a time. In my case it is because it is very busy/lots of overlap. Is there a quick way to do this without unclicking each one in the data section?

PS. Awesome program, and all these threads have been super helpful as I’ve been learning!

---

<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: [January 25, 2022, 3:21pm UTC](https://discourse.slicer.org/t/toggle-segment-view-for-all-segments-in-segment-editor-instead-of-segmentations-module/14552/17 "2022-01-25T15:21:31Z")

</div>

There are lots of ways to achieve this. You can move group of segments temporarily into another segmentation so that you can show/hide them with a single click. You can also assign a [keyboard shortcut](https://slicer.readthedocs.io/en/latest/developer_guide/script_repository.html#customize-keyboard-shortcuts) to show/hide that separate segmentation or to show/hide a custom list of segments. For example, [this script toggles visibility of completed segments](https://slicer.readthedocs.io/en/latest/developer_guide/script_repository.html#create-keyboard-shortcut-for-toggling-visibility-of-a-set-of-segments).

---

<div class="post-metadata">

### Author: ![Bethrg](https://avatars.discourse-cdn.com/v4/letter/b/e99b99/32.png) [@Bethrg](https://discourse.slicer.org/u/Bethrg)
#### Post date: [January 26, 2022, 4:36am UTC](https://discourse.slicer.org/t/toggle-segment-view-for-all-segments-in-segment-editor-instead-of-segmentations-module/14552/18 "2022-01-26T04:36:57Z")

</div>

Thanks so much! I’ve move to other segments before as a work around, but the other tips are very helpful.
