nipy/niwidgets

Ability to Disable Guide Lines

cancan101 opened this issue · 3 comments

e.g.

# draw guides to show selected coordinates
guide_positions = [val for jj, val in enumerate(coords)
if jj != ii]
imh.axes.lines[0].set_xdata(2*[guide_positions[0]])
imh.axes.lines[1].set_ydata(2*[guide_positions[1]])

Nice idea, will take a look at this

diff --git a/niwidgets/niwidget_volume.py b/niwidgets/niwidget_volume.py
index a5f0b6c..b74963e 100644
--- a/niwidgets/niwidget_volume.py
+++ b/niwidgets/niwidget_volume.py
@@ -142,6 +142,8 @@ class NiftiWidget:
                 value=0, min=0, max=data_array.shape[3] - 1,
                 continuous_update=False
             )
+        if 'show_guide' in kwargs:
+            kwargs['show_guide'] = fixed(kwargs['show_guide'])

         widgets.interact(self._plot_slices, data=fixed(data_array), **kwargs)

@@ -149,7 +151,7 @@ class NiftiWidget:
         plt.ion()  # return to interactive state

     def _plot_slices(self, data, x, y, z, t,
-                     colormap='viridis', figsize=(15, 5)):
+                     colormap='viridis', figsize=(15, 5), show_guide=True):
         """
         Plot x,y,z slices.

@@ -183,10 +185,16 @@ class NiftiWidget:
             )

             # draw guides to show selected coordinates
-            guide_positions = [val for jj, val in enumerate(coords)
+            if show_guide:
+                guide_positions = [val for jj, val in enumerate(coords)
                                if jj != ii]
-            imh.axes.lines[0].set_xdata(2*[guide_positions[0]])
-            imh.axes.lines[1].set_ydata(2*[guide_positions[1]])
+                imh.axes.lines[0].set_xdata(2*[guide_positions[0]])
+                imh.axes.lines[1].set_ydata(2*[guide_positions[1]])
+                imh.axes.lines[0].set_linewidth(1.5)
+                imh.axes.lines[1].set_linewidth(1.5)
+            else:
+                imh.axes.lines[0].set_linewidth(0)
+                imh.axes.lines[1].set_linewidth(0)

             imh.set_cmap(colormap)

Nice - I was thinking of this as a checkbox in the widget that you'd be able to tick and untick, but this is a good start!