# Show slice intersection line only in specific view

**URL:** <https://discourse.slicer.org/t/show-slice-intersection-line-only-in-specific-view/36275>\
**Category:** Development\
**Created:** [May 20, 2024, 9:52am UTC](https://discourse.slicer.org/t/show-slice-intersection-line-only-in-specific-view/36275 "2024-05-20T09:52:15Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![park](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/park/32/5717_2.png) [@park](https://discourse.slicer.org/u/park)\
**Post date:** [May 20, 2024, 9:52am UTC](https://discourse.slicer.org/t/show-slice-intersection-line-only-in-specific-view/36275/1 "2024-05-20T09:52:15Z")

</div>

Hi all,

I would like to show intersection line of 2D view only in Axial view.  
I tried codes below, but it still remain other view.

Could I get sloution about this ?

```auto
    def intersectionOnOff(self, flag):
        sliceDisplayNode9 = slicer.app.layoutManager().sliceWidget("Slice9").sliceLogic().GetSliceDisplayNode()
        sliceDisplayNode10 = slicer.app.layoutManager().sliceWidget("Slice10").sliceLogic().GetSliceDisplayNode()
        
        for sliceDisplayNode in [sliceDisplayNode9, sliceDisplayNode10]:
            sliceDisplayNode.SetIntersectingSlicesVisibility(flag)
            sliceDisplayNode.SetSliceIntersectionThickness(10)

        sliceNode = slicer.util.getNode('Slice8')
        sliceNode.Modified()

```

---

<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:** [May 20, 2024, 11:29am UTC](https://discourse.slicer.org/t/show-slice-intersection-line-only-in-specific-view/36275/2 "2024-05-20T11:29:05Z")

</div>

If the views are linked, then changing one will affect all the rest. Make sure linking is off when you set this.

---

<div class="post-metadata">

**Author:** ![park](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/park/32/5717_2.png) [@park](https://discourse.slicer.org/u/park)\
**Post date:** [May 20, 2024, 1:34pm UTC](https://discourse.slicer.org/t/show-slice-intersection-line-only-in-specific-view/36275/3 "2024-05-20T13:34:28Z")

</div>

Hi Casba

Thank you for your reply

Could you give a advise more specific (plz with codes snippet) ?

I would like to remove the lines in Yellow and Green view showed in below figure

 ![스크린샷 2024-05-20 오후 10.31.46](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/2/7/27febf3a3706255324bcd5ca1eeb46d2469d6bd6.gif)

---

<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:** [May 20, 2024, 1:59pm UTC](https://discourse.slicer.org/t/show-slice-intersection-line-only-in-specific-view/36275/4 "2024-05-20T13:59:28Z")

</div>

You need the opposite of this one  
[https://slicer.readthedocs.io/en/latest/developer\_guide/script\_repository.html#set-all-slice-views-linked-by-default](https://slicer.readthedocs.io/en/latest/developer_guide/script_repository.html#set-all-slice-views-linked-by-default)

---

<div class="post-metadata">

**Author:** ![park](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/park/32/5717_2.png) [@park](https://discourse.slicer.org/u/park)\
**Post date:** [May 21, 2024, 7:09am UTC](https://discourse.slicer.org/t/show-slice-intersection-line-only-in-specific-view/36275/5 "2024-05-21T07:09:29Z")

</div>

Hi Csaba

I tried codes like below

When the Slicer first start the lines only on ‘Slice8’ (what I want), but start moving the slice, the other lines showed up in “Slice9” and “Slice10”

```auto
  for view in ["Slice9", "Slice10"]:
  
      sliceLogic = slicer.app.layoutManager().sliceWidget(view).sliceLogic()
      sliceDisplayNode = sliceLogic.GetSliceDisplayNode()
      sliceDisplayNode.SetIntersectingSlicesVisibility(flag)
      sliceDisplayNode.SetIntersectingSlicesLineThicknessMode(1)
      
  sliceCompositeNodes = slicer.util.getNodesByClass("vtkMRMLSliceCompositeNode")
  defaultSliceCompositeNode = slicer.mrmlScene.GetDefaultNodeByClass("vtkMRMLSliceCompositeNode")
  if not defaultSliceCompositeNode:
      defaultSliceCompositeNode = slicer.mrmlScene.CreateNodeByClass("vtkMRMLSliceCompositeNode")
      defaultSliceCompositeNode.UnRegister(None) # CreateNodeByClass is factory method, need to unregister the result to prevent memory leaks
      slicer.mrmlScene.AddDefaultNode(defaultSliceCompositeNode)
  
  sliceCompositeNodes.append(defaultSliceCompositeNode)
  for sliceCompositeNode in sliceCompositeNodes:
      sliceCompositeNode.SetLinkedControl(False)
      sliceCompositeNode.SetHotLinkedControl(False)
          
  sliceNode = slicer.util.getNode('Slice8')
  sliceNode.Modified()

```

---

<div class="post-metadata">

**Author:** ![park](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/park/32/5717_2.png) [@park](https://discourse.slicer.org/u/park)\
**Post date:** [May 28, 2024, 11:20am UTC](https://discourse.slicer.org/t/show-slice-intersection-line-only-in-specific-view/36275/6 "2024-05-28T11:20:53Z")

</div>

Hi all,

I posted a question last time but did not get solution, so I’m posting it again.

I created four 2D slice views looks like the video below.  
**Among these, I only want to display the intersection view in the axial window.**

To achieve this, I tried changing the visibility to 0 or modifying the LinkedControl as shown below, but I observed that the intersection line reappeared when I moved the slice.

1. `sliceDisplayNode.SetIntersectingSlicesVisibility(0)`

2. `sliceCompositeNode.SetLinkedControl(False)`

Additionally, I performed SlabReconstruction on the leftmost panoramic view, but the line corresponding to the slab appeared, which interferes with the visualization.

Therefore, my questions are as follows:

- How can I display the intersection line only in the axial view?

- How can I remove the lines related to the slab?  
(When I enable slab reconstruction with `sliceNode.SetSlabReconstructionEnabled(True)`, the line is generated, and I couldn’t find a way to turn it off.)

* * *

- In addition, How can I change the thickness of the intersection line?  
(`sliceDisplayNode.SetIntersectingSlicesLineThicknessMode(2)` does not work.)

---

<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:** [May 28, 2024, 6:46pm UTC](https://discourse.slicer.org/t/show-slice-intersection-line-only-in-specific-view/36275/7 "2024-05-28T18:46:52Z")

</div>

I suspect nobody has tried these exact features before so nobody has an out-of-the-box answer for you. But I think you can figure this out by digging into the code a bit - what you describe shouldn’t be that much different from other view-specific visibility controls. It would be best if you find a way to generalize the implementation in Slicer so these are easy to control, so if you can find a good architectures please contribute back, but since you are building your own custom app, you can even control these in an application-specific way that you keep in your codebase.
