Display

class @display.display(varargin)

DISPLAY Class for displaying standard STXM and XRF maps.

d = display()

Note, that the display class should be linked to an instance of the nanodiffraction class by using the display.attach() function (see help attach for usage information).

The following arguments are accepted:
axis:: [‘image’]

Default axis of images plotted

Options: Default Matlab options.

cmap:: [{gray,inverse}]
Default colormap
colorbar:: [‘on’]

Adds a colorbar by default

Options: ‘on’|’off’

caxis:: [‘auto’]
Automatic color scaling by default. Another useful option is to use the helper function autoc which scales to the 5 - 95 percentile.
xlabel:: [‘’]
Standard x-label.
ylabel:: [‘’]
Standard y-label.
zlabel:: [‘’]
Standard z-label.
It contains the following functionality:
add_circle():
adds circles at certain q_r to the diffraction pattern
add_line():
adds a vertical line to a SAXS curve
add_quiver():
superimposes a PCA result with quiver lines indicating the orientation of the scattering of the structure orientation.
autoc():
Auto-contrast based on the 5% percentile.
autonorm():
Normalizes a distribution (z-transform).
azimuthal_colormap():
Several colormaps to plot phase angles are available.
composite():
displays a composite image.
diffraction():
shows a diffraction pattern
imlap():
processes an image and then displays it on a log. scale.
image_overlay():
Overlays an image with a transparent second image.
saxs():
shows one or more 1d saxs curves
scalebar():
Adds a scalebar (in pixel units) to an image.
show_location():
Highlights a scan point in a map based on its linear index.
stxm():
displays darkfield images
pca():
shows a darkfield with arrows superimposed to indicate the director of the anisotropic field

Copyright 2017 Institute for X-ray Physics (University of Göttingen)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the ‘’), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED ‘’, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

add_circle(qCircles, varargin)

ADD_CIRCLE Superimposes circles on a diffraction pattern. Multiple circle radii can be given to the function. The radii are expected in units of rec. nanometers.

add_circle(qCircles, opts)
The following arguments are accepted:
qCircles: [] (required)
One-dimensional array of circle radii in units of the reciprocal wavevector (inverse nanometers).
opts: [see default values below]

Structure that can contain the following fields. Note that all fields are optional. Default values that are otherwise used are given as usual in angle brackets below:

circleColor:: [black]
Color of the circles to be plotted. Any default Matlab color can be chosen.
wedge:: [0 360]
One-dimensional array of circle radii in units of the reciprocal wavevector (inverse nanometers).

Example

See the following example for help:

d = display();
e = nanodiffraction();
frame = e.read(1);
d.diffraction(frame);
d.add_circle([0.2 0.6 1.2],'white');
Output arguments:
This function does not return any arguments.
add_line(qr_values)

ADD_LINE plots a vertical line at a specific location given in units of the reciprocal wavevector (inverse nanometers). This function is used to plot vertical lines in SAXS plots. The vertical lines run through the entire y-range.

add_line(qr_values)

The following arguments are supported:

qr_values: [] (required)
A one-dimensional vector of values in units of inverse nanometers. Each entry specifies the location of a vertical line that is superimposed onto the current plot.

Example

See the following example for help:

d = display();
d.saxs(some_saxs_data);
d.add_line([0.2 0.6 1.2]);
Output arguments:
This function does not return any arguments.
add_quiver(orientation, varargin)

ADD_QUIVER Adds quiver lines onto an image, based on the orientation.

add_quiver(orientation, opts)
The following arguments are supported:
orientation: [] (required)
2d-array that contains angles in degrees confined to the interval [-90 90].
opts: [see default values below] (optional)

Structure that can contain the following fields. Note, that all fields are optional. Default values that are otherwise used are as used given in angle brackets:

sampling: [1]
plot quiver lines every n-th pixel/scan point.
scale: [0.1]
length of quiver lines.
selection: []
display quiver lines only on selected scanpoints. selection is a 2d logical array.
dir: [‘v2’]
Can either be set to ‘v2’ or ‘v1’ where ‘v2’ denotes the fiber direction and ‘v1’ the scattering direction, respectively.

Example

See the following example for help:

d = display();
d.add_quiver(orientation,struct('sampling',1,'scale',0.1));
Output arguments:
This function does not return any arguments.
add_scalebar(sl_pixel, varargin)

ADD_SCALEBAR adds a scale bar to the current figure.

add_scalebar(sl_pixel, opts)
The following options are accepted:
sl_pixel: [] (required)
Scale bar length in pixel units.
opts: [see default values below] (optional)

Structure that can contain the following fields. Note, that all fields are optional. Default values that are otherwise used are as usual given in angle brackets:

sb_height: [0.2]
height of the scalebar in figure units.
margin_right: [0.05]
right margin of the scalebar in figure units.
margin_bottom: [0.05]
bottom margin of the scalebar in figure units.

Example

See the following example for help:

d = display();
d.stxm(some_map);
d.add_scalebar(100); % scale bar length = 100 scan points * 2 µm steps
Output arguments:
This function does not return any arguments.
add_title(varargin)

ADD_TITLE Adds a title to the image that includes the caxis range and the length of a scalebar.

add_title(opts)
The following arguments are supported:
opts: [see default values below] (optional)

Structure that can contain the following fields. Note, that all fields are optional. Default values that are otherwise used are as used given in angle brackets:

limits: [auto]
Per default choses the limits of the current axis. Otherwise, a two-element vector with a range can be used, e.g. [1 2].
sb_len: []
Length of the scale bar in µm.
subtitle: [false]
The information can be plotted as a regular title (false, the default) to a figure or subplot or can be inserted as an xlabel (true).

Example

See the following example for help:

d = display();
d.add_title(struct('sb_len',5,'subtitle',true));
Output arguments:
This function does not return any arguments.
attach(nanodiffraction_handle)

ATTACH Attaches a nanodiffraction-module to this class.

attach(nanodiffraction_handle)
The following arguments are supported:
files_handle: [] (required)
Handle to a files-module.

Example

See the following example for help:

e = nanodiffraction(...);
d = display(...);
d.attach(e);
Output arguments:
This function does not return any arguments.
autoc = u'@(im) caxis([prctile(reshape(im,1,[]),5) prctile(reshape(im,1,[]),95)])'

autocontrast

autonorm = u'@(im) (im - mean(reshape(im,1,[])))/(std(reshape(im,1,[])))'

autonormalization

azimuthal_colormap(varargin)

AZIMUTHAL_COLORMAP Returns a colormap suitable for orientation visualization. Note, that by default, hsv is used as colormap, however, the more uniform colormap by Peter Kovesi is recommended.

azimuthal_colormap(colormap_name)
The following arguments are supported:
colormap_name: [‘hsv’] (required)

The following colormap names are currently implemented:

‘hsv’:default HSV colormap
‘pmkmp’:based on the matlab package ‘Perceptually improved colormaps’ by Matteo Niccoli and the adaptation by Mike Bostock (https://bl.ocks.org/mbostock/310c99e53880faec2434) (https://github.com/d3/d3-scale)
‘isoAz’:uses pmkmp
‘peterkovesi’:Based on “Peter Kovesi. Good Colour Maps: How to Design Them. arXiv:1509.03700 [cs.GR] 2015”

Example

See the following example for help:

d = display();
d.stxm(some_stxm_map);
d.remove_axis();
cmap = d.azimuthal_colormap('pmkmp');
colormap(gca,cmap);
Output arguments:
new_map:
Colormap based on the choice made using the colormap name.
composite(comp, p)

COMPOSITE shows a collection of diffraction patterns as a composite with default styling.

composite(comp, p)
The following options are supported:
composite: [] (required)
A two-dimensional composite image.
p: [see default values below] (required)

Parameters that were used for composite calculation. p is obtained as a second argument from e.calculate_composite(). It can also be defined manually. p is a structure that can contain the following fields:

Ny: [] (required)
Number of pixels along the horizontal dimension of a single frame.
Nz: [] (required)
Number of pixels along the vertical dimension of a single frame.
imsY: [] (required)
Number of images displayed along the horizontal dimension of the composite image.
imsZ: [] (required)
Number of images displayed along the vertical dimension of the composite image.
yCrop: [1 obj.scan.SNy] (optional)
Description. This value is optional, but useful for future reference.
zCrop: [1 obj.scan.SNz] (optional)
Description. This value is optional, but useful for future reference.
ySkip: [1] (optional)
Description. This value is optional, but useful for future reference.
zSkip: [1] (optional)
Description. This value is optional, but useful for future reference.
correction: [‘off’] (optional)
Description. This value is optional, but useful for future reference.
emptySub: [‘off’] (optional)
Description. This value is optional, but useful for future reference.
empty: [] (optional)
Description. This value is optional, but useful for future reference.
heal: [‘off’] (optional)
Switch that toggled healing on or off for the calculation of the composite image. This value is optional, but useful for future reference.
healmask: [] (optional)
Mask that has been used for healing of the diffraction patterns. This value is optional, but useful for future reference.
binning: [] (optional)
Description. This value is optional, but useful for future reference.
detRoiY: [] (optional)
Description. This value is optional, but useful for future reference.
detRoiZ: [] (optional)
Description. This value is optional, but useful for future reference.

Example

See the following example for help:

e = nanodiffraction(<some settings here>);
e.set_scan_info(<some settings here>);
[comp,p] = e.calculate_composite(...
                struct('ySkip',4,'zSkip',4));
d = display();
d.composite(comp,p);
Output arguments:
This function does not return any arguments.
copy()

COPY Makes a copy of a handle object. This keeps track of all the given parameters so that multiple instances of a display module can be used.

new_instance = copy(display_object)

The following arguments are supported:

display_object: [] (required)
This function requires a display object that should be copied.

Example

See the following example for help:

d_generic = display();
d_saxsdata = copy(d_generic);
d_waxsdata = copy(d_generic);
Output arguments:
new_instance:
A copy of the initial display_object.
diffraction(data, varargin)

DIFFRACTION Displays a diffraction patterns with pre-defined settings. Simplifies the correct addition of labels to the x- and y-axis of the figure. By default, diffraction patterns are shown in log-scale and display in grayscale (a linear scale that does not highlight any particular q-range).

diffraction(data, opts)
The following arguments are supported:
data: [] (required)
A two-dimensional diffraction pattern. By default, this diffraction pattern is automatically processed to be in accordance with the currently active settings for a detector ROI and a binning factor. Processing can however be switched off using the second optional argument ‘opts’.
opts: [see default values below] (optional)

Structure that can contain the following fields. Note, that all fields are optional. Default values that are otherwise used are as usual given in angle brackets:

process: [‘on’]
Either ‘on’ or ‘off’. If activated (‘on’), then data of the size of a raw detector frame is expected and the data will be automatically binned and cropped based on the detector roi and binning settings
qRange: [-max(max(e.qr)) max(max(e.qr))]
Lower and upper limit for the detector q-range to be plotted on the axis of the figure. Typically, the full q-range of the detector is used. The q-range of the currently linked nanodiffraction object (shorthand: e) is used for this purpose.
qSteps: [round((2*max(max(obj.exp.qr)))) / 10]
Distance between ticks in units of the radial wavevector transfer. The q-range of the currently linked nanodiffraction object (shorthand: e) is used for this purpose.
alpha: []
A two-dimensional alpha map.

Example

See the following example for help:

d = display();
e = nanodiffraction();
frame = e.read(1);
d.diffraction(frame,struct('process','off','qSteps',5);
Output arguments:
This function does not return any arguments.
image_overlay(im1, im2, transp)

IMAGE_OVERLAY Overlays two images. The second image is placed on top of the first image, and the transparency channel of the second image can be tuned for overlay. Note, that the images should be given in rgb color. To create rgb images use e.g.:

rgbimage1 = ind2rgb(round(mat2gray(data)*63 + 1),gray);

or for a single color overlay

rgbimage2 = ind2rgb(ones(256)*16,gray);

a colormap can be defined by e.g.:

    d = display();
    testColormap = d.single_hue_colormap(265,0.4,gray);

``image_overlay(image1, image2, transparency)``
The following arguments are supported:
image1: [] (required)
Base image.
image2: [] (required)
Overlay image.
transparency: []
Transparency of image2. Values should range within the interval (0,1).

Example

Example is missing.

Output arguments:
This function does not return any arguments.
imlap(frame)

IMLAP Displays a detector image in logscale. The detector image is hearby automatically processed, based on the currect setting of the detector ROI and binning factors.

imlap(frame)
The following arguments are supported:
frame: [] (required)
Detector image. The image should have identical dimensions as the detector.

Example

See the following example for help:

d = display();
e = nanodiffraction();
frame = e.read(1);
d.imlap(frame);
Output arguments:
This function does not return any arguments.
lims = u"@(xlow,xhigh,ylow,yhigh) set(gca,'XLim',[xlow xhigh],'YLim',[ylow yhigh])"

wrapper for limits

p = u'struct'

holds parameters for plotting

pca(angle, varargin)

PCA Creates a visual representation of the map of orientations. By default, angles are visualized using color, however, lines can be superimposed. Color can also be weighted by saturation.

pca(angle, opts)
The following arguments are supported:
angle: [] (required)
Map of angles that is e.g. output from a PCA analysis.
opts: [see default values below] (optional)

Structure that can contain the following fields. Note, that all fields are optional. Default values that are otherwise used are as usual givin in angle brackets.

dir: [‘v2’]
By default, the input angle represents the orientation of the diffraction streak/modulation/peak. However, by default, the angle is rotated by 90 degrees to reflect the orientation of the fibre axis. Using the ‘dir’ option, one can choose ‘v2’ or ‘v1’ as options that indicate which eigenvector direction should be used.
quiver: [‘off’]
If set to ‘on’ quiver lines will be superimposed on each data point to indicate fibre or streak orientation. Note, that default quiver arguments are used. For a more custom quiver display, please use display.add_quiver.
alpha: []
alpha can be given a map of alpha values that can be used for mapping color saturation to another parameter map. If an alpha map is given, it will be automatically used.

Example

See the following example for help:

d.display();
 d.pca(some_orientation_map,struct('quiver','on');
Output arguments:
This function does not return any arguments.
remove_axis(varargin)

REMOVE_AXIS removes the axis and ticks from the active figure.

remove_axis()

The function does not require any arguments.

Example

See the following example for help:

d = display();
d.stxm(some_map);
d.remove_axis();
Output arguments:
This function does not return any arguments.
round_limits(varargin)

ROUND_LIMITS rounds the caxis limits of the current figure to a given decimal digit level:

e.g.: round(1342,-3) => 1000
e.g.: round(0.042,2) => 0.04
round_limits(level)
The following arguments are supported:
level: [1] (optional)
The rounding level. The same level as used in the Matlab-round function.

Example

See the following example for help:

d = display();
d.stxm(some_map);
d.round_limits(-3);
Output arguments:
This function does not return any arguments.
saxs(saxsresult, varargin)

SAXS Creates a loglog or semilog plot of the one-dimensional structure factor I(qr) with default labeling of x- and y-axis.

saxs(sf, opts)
The following arguments are supported:
sf: [] (required)
Structure factor, given as a structure that contains at least the fields “dat_1d” and ‘’. Both fields should contain a one-dimensional array that should have the same lengths. A cell array of structures is also supported if multiple one-dimensional saxs curves should be plotted.
opts: [see default values below] (optional)

Structure that can contain the following fields. Note, that all fields are optional. Default values that are otherwise used are as usual given in angle brackets:

limits: []
Limits [xlow xhigh ylow yhigh]. By default, this is set to ‘’.
pixel: [‘off’]
If the structure factor should be plotted as a function of detector pixel, ‘pixel’ should be set to ‘’. In this case, the SF should contain a field ‘’.
mode: [‘semilogy’]
Either ‘semilogy’ or ‘loglog’ are accepted.

Example

See the following example for help:

d = display();
d.saxs({my_1d_averaged_data,...
   struct('dat_1d',some_1d_data,'qr',some_qr_axis)},...
   struct('mode','loglog'));
Output arguments:
This function does not return any arguments.
show_location(scanpoint, varargin)

SHOW_LOCATION highlights the location of a given scanpoint in a two-dimensional parameter map.

show_location(scanpoint, opts)
The following options are supported:
scanpoint: [] (required)
A single index, corresponding to the location in the scan. Note, that the index starts with 1 in the top-left corner of the scan.
opts: [] (optional)

Structure that can contain the following field. Note that currently, only a single field can be set, which is likely to be made more flexible in the future.

dir: [‘row’]
Specifies the direction along the single index should be incremented. Either ‘col’ or ‘row’ are allowed.

Example

See the following example for help:

d = display();
imagesc(rand(60,21));
d.show_location(150,struct('dir','row'));
Output arguments:
This function does not return any arguments.
stxm(data, varargin)

STXM plots parameter maps with with pre-defined settings.

stxm(data, opts)

The following options are supported:

data: [] (required)
Parameter map.
opts: [see default values below] (optional)

Structure that can contain the following fields. Note, that all fields are optional. Default values that are otherwise used are as usual given in angle brackets:

sampl: [100]
A tick is added to every N-th pixel/scan point.
scale: [1]
Length of one pixel/scan point in units ‘unit’.
unit: [mm]
Either ‘um’ or ‘mm’.
alpha: []
An alpha/transparency map, values of the map should range within (0,1).

Example

See the following example for help:

d = display();
d.stxm(data,struct('sampl',100,...
                   'scale',10,...
                   'unit','um'));
Output arguments:
This function does not return any arguments.