Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ability to Disable Guide Lines #30

Open
cancan101 opened this issue Jan 16, 2018 · 3 comments
Open

Ability to Disable Guide Lines #30

cancan101 opened this issue Jan 16, 2018 · 3 comments

Comments

@cancan101
Copy link
Contributor

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]])

@janfreyberg
Copy link
Contributor

Nice idea, will take a look at this

@cancan101
Copy link
Contributor Author

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)

@janfreyberg
Copy link
Contributor

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants