Skip to content

LiberTEM/LiberTEM-panel-ui

Repository files navigation

LiberTEM-panel-ui

Widget-based web GUI package intended to support the LiberTEM library for electron microscopy data analysis. The primary usage environment is from within Jupyter Notebooks. Built using the Panel and Bokeh frameworks.

Runs LiberTEM User Defined Functions (UDFs) in interactive panels, which simplies adjustment of parameters and exploring data.

The framework is capable of running certain analyses on top of the LiberTEM-live framework, allowing for interactive live acquisitions in a Jupyter Notebook.

There are two ways to use the UI tools:

  • as standalone analysis windows connected to a dataset
  • through a UIContext window manager, which can dynamically add and remove windows as required

The standalone case (where ctx, ds are LiberTEM Context and DataSet objects):

from libertem_ui.windows.com import CoMImagingWindow
# Create the window using a context and dataset
com_window = CoMImagingWindow.using(ctx, ds)
# Display the window itself
com_window.layout()
# Results from the window are stored in a dataframe-based results manager
# This provides a GUI result browser using a .layout() method
com_window.results_manager.layout()
# Results in the manager can be extracted into Python objects using methods
result_id = '3kd9sn'
rc = com_window.results_manager.get_result_container(result_id)
assert isinstance(rc.data, np.ndarray)

examples/com_window.png

A second standalone window can be linked to the first, and will share the data and LiberTEM resources. Results from both windows will appear in the same results_manager.

from libertem_ui.windows.imaging import VirtualDetectorWindow
# Create new window linked to the previous window
v_window = VirtualDetectorWindow.linked_to(com_window)
# Display the new window
v_window.layout()

When two-or-more windows are linked, certain results can be displayed in other windows to help navigate the data. For example, a log-sum over all frames generated by the FrameImagingWindow can be displayed in the VirtualDetectorWindow frame plot, to help parametrize an annular darkfield analysis.

For a more tightly-integrated experience, the managed UIContext can dynamically add and remove windows, as well as run analyses from multiple windows in parallel:

from libertem_ui.api import UIContext

# Create the UIContext object
# This orchestrates:
#  - add/remove analysis windows
#  - providing work to the LiberTEM Context
#  - managing and saving results from analyses
ui_context = UIContext.for_offline(ctx, ds)
# Display main window for running analyses
ui_context.layout()
# Display table / dataframe-based results manager
ui_context.results_manager.layout()

examples/ui_context.png

see examples/ for some more complete example use cases.

Installation

libertem_ui requires Python 3.9 or greater.

As always, it is advisable to use a virtual or conda environment for testing packages.

At this time, libertem_ui is not availble through PyPi, but can be installed using (requires git):

pip install 'libertem_ui @ git+https://github.com/LiberTEM/LiberTEM-panel-ui'

Certain components require an installation of NodeJS to run correctly. If you don't already have an installation of NodeJS, you can use conda to easily install it using:

conda install nodejs

(particularly on Windows), or use a tool like nvm on linux.

Disclaimer

LiberTEM-panel-ui is at an early proof-of-concept stage. All interfaces and functionality is subject to change in the future.

If you are interested in the project and would like to see it taken further, please don't hesitate to get in touch by posting an Issue.

About

Panel and Bokeh-based GUI Toolkit for LiberTEM

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages