cpinter
(Csaba Pinter)
July 17, 2024, 12:37pm
1
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:
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
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!
cpinter
(Csaba Pinter)
July 17, 2024, 12:57pm
2
It seems to me that the update
is not called due to the early return
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:
committed 12:08AM - 28 Sep 23 UTC
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.
lassoan
(Andras Lasso)
July 18, 2024, 4:29am
3
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:
opened 02:38AM - 22 Aug 23 UTC
Type: Enhancement
## 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
cpinter
(Csaba Pinter)
July 19, 2024, 11:15am
4
Agreed, thanks. If this is not a recent regression then let’s leave any improvement or fix for the complete revamp.