Adjust WL (window level) using right mouse button

Operating system: n/a
Slicer version: 4.13
Expected behavior: n/a
Actual behavior: n/a

Is there a way to bind window/level scaling to right mouse button and make it permanent (at least within active module)? For now when segmenting image, one have to switch between e.g. ‘Paint’ or ‘Draw’ tool and ‘Adjust window/level’ which is more than annoying.
These functionalities should be enabled simultaneously:

  • ‘Paint’ or ‘Draw’ under left mouse button
  • ‘Adjust window/level’ under right mouse button

If there is no option to bind mouse buttons as described above how can override current behavior from scripted module? I have developed scripted module that combines ‘Volumes’ and ‘Segment Editor’ widgets along with my own widget, I could implement it here, but I have no idea how to do it.

Thanks for help.

You have many options to configure appearance of your segmentation to ensure that underlying structures are well visible without keeping adjusting the window/level. You can reduce the fill opacity of the segmentation or just show the contour.

You can also quickly switch between mouse modes by right-clicking in a view (in recent Slicer Preview Releases). We can also add keyboard shortcuts for making the switch between mouse modes even faster.

But if none of these are what you would like then you can add/reconfigure all keyboard/mouse gestures any way you want. I’ve added a short script to the script repository that maps Ctrl+Right-click-and-drag to window/level adjustment. You can add this code snippet to your Slicer startup file to persistently enable this shortcut. It requires tomorrow’s Slicer Preview Release, because I had to add a few missing APIs.

1 Like

I tried to use your snippet but unfortunately it does not change anything :confused:. I executed it inside custom scripted module, then in .slicerrc.py and finally in slicer console. Right mouse button still scales size of slice instead of adjusting WL.

Of course I’m using newest preview version of Slicer. With older one I received errors, as expected.

The example code snippet uses Ctrl + Right-click-and-drag. On macOS, Ctrl may be called Cmd.

1 Like

Oh sorry, my mistake…
Works well with Ctrl.

Thank you for your support.

1 Like

Hi Andras,

I found out that proposed shortcut does not work when Draw tool in Segment Editor is active. I’ve tried to setup different shortcuts e.g. right mouse button without modifier, but result is the same. Shortcut works with the rest of tools from Segment Editor.

Could you help us with this issue?

Thanks,
Szymon

I’ve updated the effects in Segment Editor to ignore mouse button push events if a modifier (Ctrl/Alt/Shift) modifier is pressed. The Slicer Preview Release that you download tomorrow or later will contain these changes and that will allow you to use Ctrl + Right-click-and-drag while in a Segment Editor effect.

I’ve tested new configuration and unfortunately there is no way to use Right Mouse Button + any modifier and work with Draw Tool. Clicking RMB causes Draw Tool to end its drawing cycle. Apart of that when executing below scenario, WL mode stays active after releasing modifier + RMB:

  • enter Draw Tool mode
  • start drawing on image
  • press e.g. Ctrl + RMB to adjust WL
  • Draw Tool ends its cycle (inserts created shape to segments)
  • release Ctrl + RMB
  • WL mode is still active

Good thing is that it is working well with Middle Mouse Button :wink: and I think it’s enough for us.

The fix that was implemented two weeks ago had a small bug. I’ve fixed it now, it’ll be available in the Slicer Preview Release that you download on Friday or later.

1 Like