Viewers icon indicating copy to clipboard operation
Viewers copied to clipboard

[Bug] Issue with Reference Line Tool Not Releasing in OHIF Image Viewer

Open rmasad opened this issue 1 year ago • 8 comments

Describe the Bug

Once reference line tool selected, the tool does not seem to release properly. When selecting the tool, the previously selected tool (for example contrast change) is not selected (although it appears as active). Additionally, when the tool is selected again, it must be selected for each window (when using layouts).

Tested in 3.8-beta.27

Steps to Reproduce

  1. Open any medical image in the OHIF viewer.
  2. Activate a layout (eg. 2x2)
  3. Select the reference line tool.
  4. Attempt to change contrast (W/L).
  5. Select again contrast.
  6. Select other window in the layout.
  7. Attempt to change contrast (W/L).

The current behavior

  • Instead of being activated by default as expected, the reference line feature might require manual activation each time the software is used or for each individual session.
  • When a tool that is currently activated is selected, and the reference line tool is actived, the tool is still selected but doesn't work.
  • When tools like contrast or window/level (W/L) are selected, their effects might not apply to all windows in the layout simultaneously. This behavior contrasts with the expected uniform application across all windows, necessitating individual adjustments for each window.

The expected behavior

  • The reference line should be activated by default.
  • When selecting a tool that is activated (not used) you should not leave the previously used tool selected.
  • When selecting a tool (such as contrast, W/L) it must be for all windows in the layout.

OS

MacOS 11.7

Node version

18

Browser

Chrome 118

rmasad avatar Dec 11 '23 12:12 rmasad

Adding this in this issue since I am trying to activate reference line as the default tool.

Changed the setDefaultTool in modes\longitudinal\src\index.js as below

toolbarService.setDefaultTool({ groupId: 'ReferenceLines', itemId: 'ReferenceLines', interactionType: 'toggle', // interactionType: 'tool', commands: [ { // commandName: 'toggleReferenceLines', commandName: 'setToolActive', commandOptions: { toolName: 'ReferenceLines', }, context: 'CORNERSTONE', }, { commandName: 'setSourceViewportForReferenceLinesTool', context: 'CORNERSTONE', }, ], });

However I keep getting the error "node_modules@cornerstonejs\tools\src\utilities\planar\filterAnnotationsForDisplay.ts:50 Uncaught TypeError: Cannot read properties of null (reading 'indexOf')"

Believe need to enable below listeners as done during the creation on ReferenceLines Tool Button listeners: { [EVENTS.ACTIVE_VIEWPORT_ID_CHANGED]: ReferenceLinesCommands, [EVENTS.STACK_VIEWPORT_NEW_STACK]: ReferenceLinesCommands, },

Any pointers on how to do this in DefaultTool ?

raviaiken avatar Dec 11 '23 14:12 raviaiken

The problem with this solution is that it removes the (correct) behavior that the default tool is Windows Level (contrast).

By default Reference Lines should be active as is Image Overlay.

Furthermore, it does not solve the problem that when using a tool in one of the layout windows, it is not active for all of them.

rmasad avatar Dec 11 '23 17:12 rmasad

Agreed. Making changes in below files sets ReferenceLines to active. However like you mentioned, its not active for all the windows.

modes\longitudinal\src\initToolGroups.js -

enabled: [{ toolName: toolNames.ReferenceLines }],

modes\longitudinal\src\moreTools.ts - modes\longitudinal\src\moreToolsMpr.ts - { listeners: { [EVENTS.STACK_VIEWPORT_NEW_STACK]: ReferenceLinesCommands, [EVENTS.ACTIVE_VIEWPORT_ID_CHANGED]: ReferenceLinesCommands, }, isActive: true, }

Keep getting this error "node_modules@cornerstonejs\tools\src\utilities\planar\filterAnnotationsForDisplay.ts:50 Uncaught TypeError: Cannot read properties of null (reading 'indexOf')"

raviaiken avatar Dec 12 '23 03:12 raviaiken

I managed to get it working (although the 'indexOf' error still remains). The code with the solution is in: https://pastebin.com/RM4nLRfW

rmasad avatar Dec 18 '23 21:12 rmasad

@rmasad The URL above is not accessible. Could you please check. Did you manage to get ReferenceLines active in all the windows?

raviaiken avatar Dec 19 '23 02:12 raviaiken

rmasad well done. I managed to resolve this issue as well but its a hack. Posted in #3831

matowuut avatar Dec 19 '23 08:12 matowuut

Went into the above bug and was able to verify the following:

  • Reference lines are not on by default - the user has to go in and select the tool
  • Once you do select the Reference Line tool, you do have to go in and manually select the W/L tool (that is highlighted and looks to be enabled) in each viewport before using W/L
  • Changing the W/L on one viewport does not change it for every viewport - only the active one.

tzuccher avatar Jan 12 '24 16:01 tzuccher

I'm addressing this here https://github.com/OHIF/Viewers/pull/3961

sedghi avatar Feb 26 '24 16:02 sedghi

We just release the OHIF 3.8, you can find more details here https://ohif.org/release-notes/3p8/ If you still encounter this issue in 3.8, please re-open this.

sedghi avatar May 01 '24 17:05 sedghi