# Previous turning on individual slice intersection not working

**URL:** <https://discourse.slicer.org/t/previous-turning-on-individual-slice-intersection-not-working/23183>\
**Category:** Support\
**Created:** [April 28, 2022, 5:21pm UTC](https://discourse.slicer.org/t/previous-turning-on-individual-slice-intersection-not-working/23183 "2022-04-28T17:21:37Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![jamesobutler](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/jamesobutler/32/7511_2.png) [@jamesobutler](https://discourse.slicer.org/u/jamesobutler)\
**Post date:** [April 28, 2022, 5:21pm UTC](https://discourse.slicer.org/t/previous-turning-on-individual-slice-intersection-not-working/23183/1 "2022-04-28T17:21:37Z")

</div>

Using an older Slicer version 2021-09-14 I was able to turn on a single slice intersection with the following:

```python
slice_widget = slicer.app.layoutManager().sliceWidget("Red")
composite_node = slice_widget.sliceLogic().GetSliceCompositeNode()
composite_node.SetSliceIntersectionVisibility(True)

```

 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/0/2/0277a258304e6c7b62383eee1af89d12c904dd9f.png)

but now with a recent Slicer version (2022-04-26) it doesn’t produce the same output. There is no red line observed in the green and yellow slice view:

 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/e/6/e6d5af4bec98662031d9932af89d7a334527369e.png)

Is this a bug? Is there a better way to turn on a single slice intersection as was attempted before?

---

<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:** [April 28, 2022, 6:02pm UTC](https://discourse.slicer.org/t/previous-turning-on-individual-slice-intersection-not-working/23183/2 "2022-04-28T18:02:07Z")

</div>

Does this explain the change and helpful for updating your code?

[https://www.slicer.org/wiki/Documentation/Nightly/Developers/Tutorials/MigrationGuide/Slicer#Slicer\_5.0:\_SliceIntersectionVisibility\_was\_moved\_from\_vtkMRMLSliceCompositeNode\_to\_vtkMRMLSliceDisplayNode](https://www.slicer.org/wiki/Documentation/Nightly/Developers/Tutorials/MigrationGuide/Slicer#Slicer_5.0:_SliceIntersectionVisibility_was_moved_from_vtkMRMLSliceCompositeNode_to_vtkMRMLSliceDisplayNode)

---

<div class="post-metadata">

**Author:** ![jamesobutler](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/jamesobutler/32/7511_2.png) [@jamesobutler](https://discourse.slicer.org/u/jamesobutler)\
**Post date:** [April 28, 2022, 6:27pm UTC](https://discourse.slicer.org/t/previous-turning-on-individual-slice-intersection-not-working/23183/3 "2022-04-28T18:27:46Z")

</div>

> [@jamesobutler](#):
>
> ```auto
> slice_widget = slicer.app.layoutManager().sliceWidget("Red")
> composite_node = slice_widget.sliceLogic().GetSliceCompositeNode()
> composite_node.SetSliceIntersectionVisibility(True)
> 
> ```

^ Using the above code in latest Slicer preview I get the following warning which indicates that method is deprecated, but it doesn’t actually produce the same results as before. There seems to be broken backwards compatibility behavior introduced in [ENH: Add back vtkMRMLSliceCompositeNode::SetSliceIntersectionVisibili… · Slicer/Slicer@0798137 · GitHub](https://github.com/Slicer/Slicer/commit/0798137cca6c4b93e683d88cff15bb76d338fd62)?

```auto
[WARNING][VTK] 28.04.2022 14:19:07 [vtkMRMLSliceCompositeNode (0000024DDED0EEB0)] (D:\D\P\S-0\Libs\MRML\Core\vtkMRMLSliceCompositeNode.cxx:301) - SetSliceIntersectionVisibility method is deprecated. Use SetIntersectingSlicesVisibility method of vtkMRMLSliceDisplayNode object instead.

```

Attempting to use a newer method I’m still unable to achieve the same results as previously (there is no red line in the green and yellow slice views upon calling `SetIntersectingSlicesVisibility`.

```python
slice_widget = slicer.app.layoutManager().sliceWidget("Red")
slice_widget.sliceLogic().GetSliceDisplayNode().SetIntersectingSlicesVisibility(True)

```

 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/0/c/0cca726ad5f8c3cdb9cd37f9fbcc851ae4dfa220.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:** [April 28, 2022, 7:04pm UTC](https://discourse.slicer.org/t/previous-turning-on-individual-slice-intersection-not-working/23183/4 "2022-04-28T19:04:27Z")

</div>

Both the deprecated and the new methods work, but the changes only take effect if a slice nodes are updated, for example like this:

```python
sliceNodes = getNodesByClass('vtkMRMLSliceNode')
for sliceNode in sliceNodes:
    sliceNode.Modified()

```

Of course this forced update should not be necessary. This is a regression introduced when the interactive slice intersection feature was introduced. We spent a lot of time trying to fix all the issues, but at some point we had to decide between rejecting this feature or get it in even though there are still problems with it. I think we fixed most of the issues that come up when using the GUI, but workarounds are needed when the feature is used programmatically.

You can submit a bug report and we’ll eventually get to it, but probably only when there is interest/funding for making interactive slice intersections fully functional (e.g., compatible with Segment Editor).

---

<div class="post-metadata">

**Author:** ![jamesobutler](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/jamesobutler/32/7511_2.png) [@jamesobutler](https://discourse.slicer.org/u/jamesobutler)\
**Post date:** [April 28, 2022, 8:57pm UTC](https://discourse.slicer.org/t/previous-turning-on-individual-slice-intersection-not-working/23183/5 "2022-04-28T20:57:41Z")

</div>

The force update works. I’ve issued [DOC: Include workaround to force visual update of intersecting slices by jamesobutler · Pull Request #6339 · Slicer/Slicer · GitHub](https://github.com/Slicer/Slicer/pull/6339) to update the documentation around the script repository example to include this update.

> [@lassoan](#):
>
> You can submit a bug report and we’ll eventually get to it

I’ve written up the bug report at [Programmatically setting slice intersection visibility does not update slice views immediately · Issue #6338 · Slicer/Slicer · GitHub](https://github.com/Slicer/Slicer/issues/6338)

For my specific case of updating a single slice view intersection the following works for me which is also using the non-deprecated API.

```python
slice_widget = slicer.app.layoutManager().sliceWidget("Red")
slice_widget.sliceLogic().GetSliceDisplayNode().SetIntersectingSlicesVisibility(True)
slice_widget.sliceLogic().GetSliceNode().Modified()

```
