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

IPywidgets UI #1544

Merged
merged 296 commits into from May 24, 2017
Merged

Conversation

francisco-dlp
Copy link
Member

@francisco-dlp francisco-dlp commented Mar 21, 2017

In this PR

  • New IPywidgets User Interface
  • New UI for ROIs
  • traitsui and ipywidgets are now optional
  • New register mechanism to register user interface elements
  • ipywidgets are fully convered by unittests
  • Multiple UI issues fixed.
  • Creating an EELSModel with a spectrum without the required parameters no longer raises a GUI element
  • Deprecate AxesManager.show and Signal1D.integrate_in_range.
  • All functions that take a signal range can now take a roi.SpanRoi.
  • Fix the nbagg backend sluggishness.
  • Improveme interactive plotting speed for all mpl backends.
  • All functions that take a signal range argument now accept a SpanRoi.
  • New signal slicing using ROIs
  • New hs.link_directional and hs.link_bidirectional functions to link traits, traitlets and traits to traitlets.
  • Split the GUI code into two separate packages: https://github.com/hyperspy/hyperspy_gui_traitsui and https://github.com/hyperspy/hyperspy_gui_ipywidget

To test it

  1. Install ipywidgets and enable them:
jupyter nbextension enable --py --sys-prefix widgetsnbextension
  1. Install https://github.com/hyperspy/hyperspy_gui_traitsui and/or https://github.com/hyperspy/hyperspy_gui_ipywidgets and https://github.com/hyperspy/link_traits .

  2. Then start hyperspy as usual using any matplotlib backend except the inline backend. This PR makes the nbagg backend usable. To use try it:

%matplotlib nbagg
import hyperspy.api as hs

TODO

Widgets

  • Add ROI gui doc
  • Fix busy nbagg again
  • preferences
  • Spikes removal tool
  • Signal navigation sliders
  • Axes manager gui
  • Data axis gui
  • Model signal range
  • Smoothers
    • Savitzky Golay
    • Lowess
    • TV
  • Background removal
  • Fit component
  • Crop
  • Signal calibration: s.calibrate()
  • SEM/TEM parameter: s.set_microscope_parameters()
  • Load: hs.load() [No equivalent widget -> not implementing]
  • ImageContrastEditor: press h on an image, I actually never used this one...
  • Integrade signal: s.integrate_in_range() (enable use ROI instead)
  • Add progress bar to spikesremovaltool
  • set value slider step
  • Add GUI to set_microscope_parameters
  • Add non-continuous update
  • Use gui instead of get_gui where possible
  • Disable left/right traitsui
  • Add ROIs widgets
  • Add display to methods that call gui internally
  • Fix EDS missing parameters message

Deprecate:

  • AxesManager.show
  • Integrate in range
  • Crop

Other tasks

  • Fix setting widget value out of axis bounds
  • Fix remove_background error out of axis limits
  • Add link and dlink to api
  • Add transform to link
  • All gui starts by gui
  • Remove interactive as it is no longer necessary
  • slice signal with SpanRoi and Rectangle2D
  • Tests
    • Axes
    • micro parameters
    • model
    • tools
    • preferences
    • roi
  • Fix existing non bidirectional widgets
  • Fix traitsui color still breaking things
  • Add toolkit option
  • Add preferences option to disable individual toolkits
  • Unlink on close
  • Add register
  • Split traitsui into a separate package
  • Fix long labels
  • signal_range with ROIs
    • Implementation
    • Documentation
    • Test
  • Documentation
  • Manual testing
    • Preferences
      • ipywidgets
      • traitsui
    • AxesManager
      • ipywidgets
      • traitsui
    • Sliders
      • ipywidgets
      • traitsui
    • Smooth lowess
      • ipywidgets
      • traitsui
    • Smooth savitzky
      • ipywidgets
      • traitsui
    • Smooth TV
      • ipywidgets
      • traitsui
    • Background
      • ipywidgets
      • traitsui
    • Spikes removal tool
      • ipywidgets
      • traitsui
    • Calibrate
      • ipywidgets
      • traitsui
    • Image contrast
      • ipywidgets
      • traitsui
    • Model
      • ipywidgets
    • Fit component
      • ipywidgets
      • traitsui
    • Parameter
      • ipywidgets
    • Component
      • ipywidgets
    • EELSCL
      • ipywidgets
    • Scalable Fixed
      • ipywidgets
    • Interactive range
      • ipywidgets
      • traitsui
    • Load
      • traitsui
    • EELS parameters
      • ipywidgets
      • traitsui
    • EDS TEM parameter
      • ipywidgets
      • traitsui
    • EDS SEM parameter
      • ipywidgets
      • traitsui
    • Integrate in rage
      • traitsui

(am I missing something else?)

@ericpre
Copy link
Member

ericpre commented Mar 21, 2017

A few more:

  • Signal calibration: s.calibrate()
  • SEM/TEM parameter: s.set_microscope_parameters()
  • Load: hs.load()
  • ImageContrastEditor: press h on an image, I actually never used this one...
  • Integrade signal: s.integrate_in_range()

If you could please add a bit of documentation to the dev guide, this will help us to give a hand with this! ;)

@francisco-dlp
Copy link
Member Author

Thanks!

@magnunor
Copy link
Contributor

I'm not very familiar with IPywidgets: can they work outside a notebook? In other words: without a web browser?

@francisco-dlp
Copy link
Member Author

No, they're HTML widgets. The nice things is that we're not replacing/removing traitsui, we are adding a "jupyter notebook interface".

@jat255
Copy link
Member

jat255 commented Mar 22, 2017

This is super cool. Is it expected behavior right now that the traits gui also opens when you call the methods?

@francisco-dlp
Copy link
Member Author

This is WIP so we still have to decide those sort of things. What I would suggest is:

  • traitsui becomes optional
  • ipywidgets mandatory (?)
  • Whether traitsui is used or not is decided in preferences (?)
  • Whether ipywidgets is used or not is decided in preferences (?)

Opinions more than welcome!

@@ -38,7 +38,7 @@ def set_ets_toolkit(toolkit):
_logger.debug('Current MPL backend: %s', backend)
if "WX" in backend:
set_ets_toolkit("wx")
elif "Qt" in backend:
elif "Qt4" in backend:
Copy link
Member

@ericpre ericpre Mar 31, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it fixing #1559? If so, does it mean that instead of using %matplotlib qt, we should recommend using %matplotlib qt4, before importing hyperspy?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, it's not fixing #1559. This fixes using that qt5 backend albeit without the traitsui gui as it does not yet support qt5.

The ipywidgets give us a lot more flexibility when choosing the mpl backend as the ipywidgets are obviously backend independent. Therefore this PR should make hspy usable with e.g. tk or nbagg.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok. Forgot my previous comment, it does not make sense...

@francisco-dlp
Copy link
Member Author

@thomasaarholt, @magnunor and @vidartf, thank you for reporting the issues. I think that I have fixed them all except for the image contrast editor that, I suspect, is a mpl issue that will get solved in mpl 2.1 when the canvas becomes an ipywidget. Is anybody against merging this?

@francisco-dlp
Copy link
Member Author

Thanks @ericpre, @thomasaarholt and @vidartf for reviewing and beta testing this.

@carmenmakepeace
Copy link

I have tried my best to follow the steps as clearly as possible but I am still getting

/anaconda3/lib/python3.6/site-packages/h5py/init.py:36: FutureWarning: Conversion of the second argument of issubdtype from float to np.floating is deprecated. In future, it will be treated as np.float64 == np.dtype(float).type.
from ._conv import register_converters as _register_converters
WARNING:hyperspy.api:The traitsui GUI elements are not available, probably because the hyperspy_gui_traitui package is not installed.

after trying to
%matplotlib qt
import hyperspy.api as hs
import numpy as np
import matplotlib.pyplot as plt

I downloaded the github files onto my mac os and then did the pip installs of the hyperspy-gui-traitsui and the ipywidgets

I have installed hyperspy on windows in the past and the process seems a lot simpler. Any help would be greatly appreciated. I am to some extent still very new to hyperspy so I really dont mind even what seems like an obvious answer.

@francisco-dlp
Copy link
Member Author

@carmenmakepeace, this is an old pull request that has been merged. For installing the latest HyperSpy and hyperspy_gui_ipywidgets you can follow the instruction in the User Guide and the hyperspy_gui_ipywidgets repository. Due to recent updates to external libraries, things may not go as smoothly as they should. If you experience any issue you are welcome to ask for help in hyperspy's gitter chat.

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

Successfully merging this pull request may close these issues.

None yet

8 participants