ALBULA API is a general purpose library, which lets you manipulate, analyse and visualize Dectris detector images. The core of the framework is the class DImage providing functionality to manipulate detector images. Use DImageSeries in order to gain access to series of image files through DImage objects. Class DImageWriter allows you to write DImage objects to various formats. Please note ALBULA API is not available for Macintosh or Windows.
Prerequisites:
Your python script has to include the module dectris.albula. The module dectris.albula must be imported before any other module that links against libstdc++.so.6. This does not pose any problem for standard python modules. However, third party libraries like e.g. matplotlib or PyQt must be imported after dectris.albula.
By default the module dectris.albula resides in /opt/dectris/albula/<version>/python, so e.g. for version 4.0 do
Hint: Inserting the install directory to sys.path is not necessary if the ALBULA installer has been run with the option "––python=</path/to/python_interpreter>".
Hint: If you get ImportError: /usr/lib64/libstdc++.so.6: version `GLIBCXX_3.4.15' not found, this means there has been some module imported before dectris.albula that links against libstdc++.so.6. Import dectris.albula as the first module.
Starting from version 3 ALBULA is subject to many non backwards compatible changes as described below:
DImageSeries gives you access to series of image file or hdf5 container files. The images themselves are represented by DImage objects.
Image data may be accessed via DImage.pixel(x,y), DImage.setPixel(x,y) or as a NumPy array DImage.data(). Note that NumPy arrays are in row major order i.e. the y (x) position is accessed by the first (second) index. Starting from 3.0 DImage.data() returns a copy of the image data. So manipulating the returned numpy array do no longer affect the DImage itself. You may pass a numpy array to the DImage constructor.
After we did something more or less useful with img we write it back to /tmp/img.tif and /tmp/img.cbf:
The viewer window consists of a DMainFrame that may contain multiple DSubFrames. Create and display a DMainFrame object and open one DSubFrame inside the DMainFrame
An image may be displayed in a DSubFrame by either opening a file
or by passing a DImage object to the DSubFrame
Starting from version 2.2 you may achieve the same in one line of code:
For further useful commands please refer to the documentation of DSubFrame.
Starting from 3.0 there is just one class that gives you access to both Hdf5 container files and series of single image files. Class DImageSeries turns the single frames in hdf5 files into DImage objects. Let's say you have in your current working directory the master file "series_16_master.h5" and mulitple data files "series_16_data_000000.h5", "series_16_data_000001.h5",... The only thing you have to do is to open the master file.
The frames of the image series may be accessed via
All images of the series provide access to the full hdf5 header data, e.g.
It is a common pitfall to merge line 1 and 3 of the example above into one expression:
Accessing optData leads to a segmentation fault. This is because optionalData() returns a reference to an internal DImageOptionalData object, which is destroyed as soon as the temporary DImage object returned by h5Cont[0] is garbage collected.
You may also access the NeXus tree from the DImageSeries :
The following lines let you write the image data to an hdf5 file
After we have worked through the examples above, it is a simple execise to write hdf5 data to a series of cbf files. Here is the solution:
See also DImage, DImageSeries, DImageOptionalData, DNeXusTree, DNeXusNode.