Using Sitka#
In this section, we’ll give information for starting the Sitka GUI, loading, and using datafiles. The Sitka GUI can be used as a stand-alone GUI application or from within a Python REPL or Jupyter Notebook.
Starting the sitka GUI from a command-line#
To run sitka from a command-line terminal, use
sitka
You can use the ‘-d’ option to specify a directory from which to read datasets, as with
sitka -d /home/User/data
Creating and Using a Desktop shortcut#
To create a Desktop shortcut for Sitka, use
sitka -m
From a command-line terminal. Once created, you can double-click on that desktop shortcut (see Creating the Desktop Shortcut), then clicking on that should launch the main Sitka application.
Basic Usage of the Sitka GUI#
On startup, the Sitka GUI will look like this:
with an empty panel in the upper left. To read in data from an HDF5 file or Zarr directory store, use File -> Read Data File, or Ctrl-O (Option-O on macOS), or simply drag the file on the Data Tree portion of the Sitka app. The file will be opened and shown in the Data Tree section of the Window. Sitka always opens the files in “read only” mode, and will not ever write to the data files you open.
Note
The examples shown here can be downloaded by running the get_sitka_examples.py script.
Note
Zarr can support multiple storage formats. At this writing, both FileStorage (that is, using the the native filesystem folder structure) and SQLiteStore (that is, using an SQLite3 datafile) are supported.
Overview of the main Sitka Window#
The main window is broken into several sections, as shown above. This should be familiar to anyone who has used one of the other HDF5 viewers (see Motivation for a partial list).
A Data Tree in the upper left lets you browse through the Tree-like structure of the hierarchical datasets.
An Info Section in the lower left will show information about the Groups and Datasets (or Arrays), including datatype, shape, chunking, compression, and the list of attributes saved in the Group or Dataset.
The Right-hand panel has a notebook interface with pages for Image Display, XY Plot Display, Table Display, and Named Arrays. The first three of the pages help you select and display multi-dimensional arrays, and have similar forms, with the sections shown in the screenshot above.
An Array Selection panel in the upper section of the notebook page allows you to select one or more dimensions of the Array data.
A Dimension Reduction panel in the middle section of the notebook page allows you to select how to “reduce” other dimensions of the dataset, either selecting a single element or a range of values to sum. See The Dimension Reduction Panel for more details.
An Array Saving panel at the bottom of the notebook page allows you to give a name to the array selected, which can then be shown or exported later. See Saving Arrays by Name and Copying the Array Address for details.
Plots and Table displays for selected data arrays will be shown in separate windows. Each of the notebook pages will be discussed in detail in a separate section:
In the following sections we discuss common features for many of these panels.
Saving Arrays by Name#
For the Notebook Panels, the array data selected for viewing can be saved to a named array, which allows it to be used later (and without having to re-extract it from the file). In the lower panel, simply typing a name (which must follow the valid conventions for a Python variable: a letter or underscore followed by any number of letters, numbers, or underscores) and hitting return or the “Save Array” button will save the array by name. By default, this will ask to verify overwriting an existing array, but this can be controlled with the “Verify Overwrite” checkbox.
Copying the Array Address#
As you browse through Groups and Datasets and as you build arrays for plotting or display, you may find data components, slices, and addresses that you want to use for downstream processing. Using Ctrl-C (Option-C on macOS), or hitting the “Copy Address” button above the Notebook pages will copy the Python syntax for the array address to the system clipboard. For an image display that sums over a selected number of frames, the copied address may look like
['myeiger_file.h5']['/entry/data/data'][10:20,:,:].sum(axis=0)
If you are using Sitka from a Jupyter notebook or Python shell, you may need to prepend the address to the Sitka datasets, as with
myimage = sview.data.datasets['myeiger_file.h5']['/entry/data/data'][10:20,:,:].sum(axis=0)
Exporting Group/Dataset Metadata#
Just as you can copy array addresses, you can also export the values shown in the “Info Section” for any Group or Dataset. Using Ctrl-E (Option-E on macOS) will bring up a dialog to save the data shown in the table in the “Info Section” to a tab-separated file.
The Dimension Reduction Panel#
The “Dimension Reduction” panel assists you in converting multi-dimensional datasets into 1- and 2-dimensional arrays for XY plots, image display, and table display.
This panel might look like this:
Here, dimensions 1 and 2 are disabled or “grayed out”, so must have been selected as the Y or X arrays for an image or table display. The remaining dimension has 270 points, and selections here tella Sitka how to turn this data into a single dimension, to reduce the 3-dimensional data to 2 dimensions for display. The example here will select a sum value, pixels 0 to 270 – all the data. The method can be one of sum, mean, or single, and the Min and Max value chosen to select a “slice” of the array dimension to sum (and perhaps divide by the number of points to give the mean value).
If choosing a slice range for sum or mean, you can check the “Fix Width” box. With this checked, changing either the Min or Max value (with the arrows or by typing in a number) will update both values to try to preserve their difference. You can change the size of the step taken by the arrow with the “Min/Max Step Size” selection - this has a pre-loaded set of choices, but you can enter any integer step size you like.
Finally, if you check the “Auto Update” box, then changing the Min or Max value will update the displayed data to reflect the newly sliced data.
Using Sitka from a Python shell or Jupyter Notebook#
An important feature of Sitka is the ability to run it from within a Python REPL shell or Jupyter notebook that is connected to your computer (that is, supports drawing to your local screen). This will give the ability to have an interactive graphical exploration of the data in your Python session or Jupyter notebook. To do this, use:
from sitka_spruce import sitka_viewer
sview = sitka_viewer()
You can also optionally specify a directory from which to read datasets with
sview = sitka_viewer(folder='/home/User/data')
This will launch the Sitka GUI application as shown above in a new Window, outside of the Python shell or browser running the Jupyter notebook.
The Sitka Viewer will work in a background thread, allowing the shell or notebook to remain active while the viewer also runs and updates. This allows you to use the shell or notebook to access the data in the Sitka Viewer, either adding datasets to the GUI or pulling arrays from the GUI into the shell. For example, if you have a dataset called “mydata.h5” with a dataset “/entry/data/data”, you can load and visualize data as with the standalone application. .. literalinclude:: ../examples/jupyter_sitka.py
With this approach, you can quickly load and explore your datasets and extract and use the arrays you want for downstream processing. That is, Sitka can act as a general-purpose viewer of 1-D and 2-D arrays. With the ability to save named arrays to an external HDF5 file, Sitka also gives you a convenient way to save and later extract data.
A note on speed of Array Selection#
Both HDF5 and Zarr hold data in chunks of binary data on disk, with optional compression. These settings are displayed in the Info section.
Extracting data from HDF5 and Zarr may not be instantaneous. In certain cases, it may even appear to be “slow”. The extraction speed can depend greatly on the chunking and compression used, and the data size. We will assert that the speed of extracting data from HDF5 files is fully within the HDF5 library, and not because “Python is slow” or “matplotlib is slow” or “wxPython is slow”. We have a bit less experience with Zarr, but it also appears that it is extracting the compressed, chuncked data from disk is typically slower than feeding it through the analysis and visualization tools. If you have suggestions for speeding up data extraction or display, we’ll be happy to hear them.