# Segment statistics fail in Test with no window mode

**URL:** <https://discourse.slicer.org/t/segment-statistics-fail-in-test-with-no-window-mode/12976>\
**Category:** Support\
**Tags:** segment-statistics\
**Created:** [August 13, 2020, 3:06pm UTC](https://discourse.slicer.org/t/segment-statistics-fail-in-test-with-no-window-mode/12976 "2020-08-13T15:06:36Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Alex\_Vergara](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/alex_vergara/32/15205_2.png) [@Alex\_Vergara](https://discourse.slicer.org/u/Alex_Vergara)\
**Post date:** [August 13, 2020, 3:06pm UTC](https://discourse.slicer.org/t/segment-statistics-fail-in-test-with-no-window-mode/12976/1 "2020-08-13T15:06:36Z")

</div>

I have a case where I have several segmentations and I need to test each of them in no window mode (test mode)

The normal way to do this is to disable all of them and the enable just the one I am testing, this is done with

```auto
        displayNode = segmentationNode.GetDisplayNode()
        if displayNode is not None:
            displayNode.SetVisibility(1)

```

However without the qSlicerMainWindow the above code never gets executed as there are no display nodes in the first place. So the question is how to enable/disable the segmentation node without using the display nodes?

The problem is that when the segmentation is called by SegmenationStatistic module it is never enabled and it treats it as it were no segmentation at all.

This is related with the [failing tests here](http://slicer.cdash.org/index.php?project=SlicerPreview&filtercount=1&showfilters=1&field1=buildname&compare1=63&value1=Opendose)

---

<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 13, 2020, 6:17pm UTC](https://discourse.slicer.org/t/segment-statistics-fail-in-test-with-no-window-mode/12976/2 "2020-08-13T18:17:25Z")

</div>

You can add display nodes to the scene, regardless of having a main window or not. The problem should be somewhere else.

Add a breakpoint or trace print in `slicer.util.lookupTopLevelWidget `to get a stack trace. Then we’ll know what needs the main window, and see if it is really necessary.
