# Slice view annotation controls

**URL:** <https://discourse.slicer.org/t/slice-view-annotation-controls/37430>\
**Category:** Support\
**Created:** [July 17, 2024, 12:37pm UTC](https://discourse.slicer.org/t/slice-view-annotation-controls/37430 "2024-07-17T12:37:12Z")\
**Posts on this page:** 4\
**Page:** 1

<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:** [July 17, 2024, 12:37pm UTC](https://discourse.slicer.org/t/slice-view-annotation-controls/37430/1 "2024-07-17T12:37:12Z")

</div>

Hi all,

I just wanted to turn off slice view annotations in the latest Slicer and I found that it does not work. The main checkbox in the module does not have any effect:  
 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/0/f/0f217a9f146d51d85a0fa822dd2af4048af65283.png)

Steps:

- Load MRHead (see annotation in all slice views bottom left)
- Go to DataProbe module
- Uncheck checkbox shown above

Similarly, the code here also does not have any effect:  
[https://slicer.readthedocs.io/en/latest/developer\_guide/script\_repository.html#hide-slice-view-annotations](https://slicer.readthedocs.io/en/latest/developer_guide/script_repository.html#hide-slice-view-annotations)

Has anything around the topic changed lately?

Update: Same behavior in 5.6.2. Looking at the SliceViewAnnotations code but it’s barely commented and a bit convoluted, so if someone knows it well any advice would be welcome. Thanks!

---

<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:** [July 17, 2024, 12:57pm UTC](https://discourse.slicer.org/t/slice-view-annotation-controls/37430/2 "2024-07-17T12:57:30Z")

</div>

It seems to me that the update

> <https://github.com/Slicer/Slicer/blob/8c6219abd3f171f938fd5d003cd551db20842c7e/Modules/Scripted/DataProbe/DataProbeLib/SliceViewAnnotations.py#L327>

is not called due to the early return

> <https://github.com/Slicer/Slicer/blob/8c6219abd3f171f938fd5d003cd551db20842c7e/Modules/Scripted/DataProbe/DataProbeLib/SliceViewAnnotations.py#L317>

What I don’t understand

- Why nobody noticed this in the past several months
- Git log on this file shows basically no functional change for years

Although there is this commit that touches just what is broken:

> <https://github.com/Slicer/Slicer/commit/5b0bcad4f3241c63ca455d2b6f5885534d92ea30>
>
> Also simplify setting of checkbox state in SliceViewAnnotations

I think for now I’ll use the workaround to call `updateCornerAnnotation` with each slice logic, but it would be good to get to the bottom of this.

---

<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:** [July 18, 2024, 4:29am UTC](https://discourse.slicer.org/t/slice-view-annotation-controls/37430/3 "2024-07-18T04:29:45Z")

</div>

Disabling corner annotation has never worked for me. I always force update manually add you described.

The current implementation of this feature is so low quality (fragile, complicated, very limited functionality, poor visual appearance) that I would rewrite it from scratch. See details here:

> <https://github.com/Slicer/Slicer/issues/7184>
>
> \## Is your feature request related to a problem? Please describe.
> 
> Since its i…nception started in 2014, the support for rendering slice annotations has been very useful.
> 
> It is ultimately done in the \`SliceAnnotations\`\[^1\] class instantiated based on the workflow described below.
> 
> Once the \`SliceAnnotations\` is instantiated, it is then responsible to add observation on slice logics (see \`addSliceViewObserver()\`\[^6\]) by systematically checking if new slice viewer have been instantiated within the function \`updateViewAnnotations()\`\[^7\] it self called when any of the slice logic is modified.
> 
> \*\*Problem:\*\* As outlined below by @lassoan, the current design is not extensible & flexible as it requires to hard-code module specific behavior into a single script. It for example, prevent extension from registering new annotation that should take precedence.
> 
> \[^6\]: https://github.com/Slicer/Slicer/blob/8c92a12d6acecde092439981af70b1a27b6d2cf1/Modules/Scripted/DataProbe/DataProbeLib/SliceViewAnnotations.py#L346-L357
> \[^7\]: https://github.com/Slicer/Slicer/blob/8c92a12d6acecde092439981af70b1a27b6d2cf1/Modules/Scripted/DataProbe/DataProbeLib/SliceViewAnnotations.py#L363-L380
> 
> \## Describe the solution you'd like
> 
> \* Re-implemented in C++
> \* Organize the content to display in \`vtkMRMLTextNode\` nodes with associated displayable manager
> \* Allow customization of displayed fields
> \* Support displaying
> \* Slice position
> \* Anatomical direction codes
> \* Image display parameters (window, level, slice thickness, etc)
> \* Patient/study/series metadata
> 
> \## Describe alternatives you've considered
> 
> NA
> 
> \## Additional context
> 
> \### Related posts & issues
> 
> \* https://discourse.slicer.org/t/how-to-show-orientation-marker-label-left-right-anterior-posterior/20231
> \* https://github.com/Slicer/Slicer/issues/4854
> 
> \### Excerpt copied from the prior comments and emails
> 
> \_Originally shared by @lassoan over email on August 19th, 2023\_
> 
> \> We want to display a lot of things around image sides and corners:
> \> - Patient/study/series metadata (with much more flexibility than now) 
> \> - Anatomical direction codes (L, R, A, P, LA, LPI,... similarly to slice offset sliders) 
> \> - Image display parameters (window, level, slice thickness, etc)
> \> - Slice position, maybe some data probe content
> \> - Any text node content (that would allow a flexible way for modules to display custom content; which corner, color, etc. could be specified in display node)
> \> 
> \> The current design is very limited, inflexible, non-extensible in any way. The implementation is also very fragile, low quality.
> \> 
> \> The best would be to reimplement it in C++, using MRML nodes to store data, displayable manager to render, etc.
> \> 
> \> Maybe all the corner text could be specified using HTML-like description using placeholders, for example:
> \> 
> \> \`\`\`html
> \> \<b\>\<PatientName/\> \<PatientAge/\> \<PatientSex format="short" /\>\</b\>\<br\>
> \> \<StudyDate/\>\<br\>
> \> \<WindowWidthLevel/\>\<br\>
> \> \<TextNode id="vtkMRMLTextNode1" color="red" /\>
> \> \`\`\`
> 
> \_Originally posted by @lassoan in https://github.com/Slicer/Slicer/issues/7176#issuecomment-1684865471\_
> 
> \> Slice view annotations is a mess. It was a quick prototype that got integrated to have this important feature in Slicer, but the design is really fragile and limited. We would need to rebuild it from scratch, using proper MRML-based design and flexibility and extensibility in mind, as overlay on image corners is very important space for displaying information.
> 
> \_Originally posted by @pieper in https://github.com/Slicer/Slicer/issues/7176#issuecomment-1685033306\_
> 
> \> Many viewers also use these as UI controls/widgets too (e.g. control reslice rotation or window/level tools by clicking on the corresponding corner annotation can be logical and 
> 
> \### Workflow: Instantiation of \`DataProbeLib.SliceAnnotations\`
> 
> 1. \`DataProbe\` module constructor, \`slicer.app.startupCompleted()\` is connected to \`DataProbe.DataProbe.addView()\`\[^2\]
> 3. \`DataProbe.DataProbe.addView()\` instantiates\[^3\] \`DataProbeInfoWidget.DataProbeInfoWidget\`\[^4\] class 
> 4. In \`DataProbeInfoWidget\` constructor, the function \`DataProbeInfoWidget.\_createSmall()\` which intern instantiates \`DataProbeLib.SliceAnnotations()\`\[^5\]
> 
> \[^1\]: https://github.com/Slicer/Slicer/blob/main/Modules/Scripted/DataProbe/DataProbeLib/SliceViewAnnotations.py
> \[^2\]: https://github.com/Slicer/Slicer/blob/8c92a12d6acecde092439981af70b1a27b6d2cf1/Modules/Scripted/DataProbe/DataProbe.py#L40-L41
> \[^3\]: https://github.com/Slicer/Slicer/blob/8c92a12d6acecde092439981af70b1a27b6d2cf1/Modules/Scripted/DataProbe/DataProbe.py#L59-L60
> \[^4\]: https://github.com/Slicer/Slicer/blob/8c92a12d6acecde092439981af70b1a27b6d2cf1/Modules/Scripted/DataProbe/DataProbe.py#L68-L106
> \[^5\]: https://github.com/Slicer/Slicer/blob/8c92a12d6acecde092439981af70b1a27b6d2cf1/Modules/Scripted/DataProbe/DataProbe.py#L401-L406

---

<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:** [July 19, 2024, 11:15am UTC](https://discourse.slicer.org/t/slice-view-annotation-controls/37430/4 "2024-07-19T11:15:45Z")

</div>

Agreed, thanks. If this is not a recent regression then let’s leave any improvement or fix for the complete revamp.
