Functions¶
-
functions.
pca
(dat, qy, qz, mask, sel)¶ PCA calculates the covariance of the diffraction pattern and determines the eigenvalues of the scattering distribution
result = pca(data, qy, qz, mask, selection)
In a principal component analysis of a scattering distribution, the covariance matrix of the distribution is calculated and orthogonalized. The procedure is described in more detail in Bernhardt et al., 2016.
Parameters: - data (numerical array) – Diffraction pattern
- qy (numerical array) – Numerical array of the size of the input data that contains the horizontal momentum transfer
- qz (numerical array) – Numerical array of the size of the input data that contains the vertical momentum transfer
- mask (logical array, default = []) – Logical array of the size of the input data that defines which pixels are considered bad (1 = bad, 0 = valid)
- selection (logical array, default = []) – Logical array of the size of the input data that defines which pixels should be analyzed (1 = valid, 0 = invalid)
Returns: result – Structure with the following fields:
- w: Anisotropy of the data
- angle: Orientation of the first principal component. Note that 0 degrees is along the -y axis and the angle is defined counter-clockwise
- lambda_1: Eigenvalue of the first principal component
- lambda_2: Eigenvalue of the second principal component
Return type: structure
Notes
Example 1:
e = nanodiffraction(); streak = e.simulate_streak(); QY = ; QZ = ; pca_result = pca(streak,QY,QZ,[],[]);
See also EIG
-
functions.
stxm
(data, mask, sel)¶ STXM Integrated the intensity in a diffraction pattern or part of a diffraction pattern
result = stxm(data,mask,selection)
Parameters: - data (two-dimensional numeric array) – A diffraction pattern
- mask (logical array, default = []) – Logical array of the size of the input data that defines which pixels are considered bad (1 = bad, 0 = valid)
- selection (logical array, default = []) – Logical array of the size of the input data that defines which pixels should be analyzed (1 = valid, 0 = invalid)
Returns: result – The integrated intensity of data within a given selection and without masked pixels
Return type: Double
Notes
Example 1:
stxm_result = stxm(data,[],[]);
See also PCA
-
functions.
baseline
(data, winSize, iterations)¶ BASELINE Iterative baseline identification using the strip algorithm as used in pyMCA, see Kieffer et al., 2014.
data = baseline(data, winSize, iterations)
Parameters: - data (One-dimensional numeric array) – Input data
- winSize (integer) – Integer value greater than 0, that defines the size of the filter window used for the strip algorithm.
- iterations (integer) – Integer value greater than 0, that defines the number of iterations.
Returns: data – Baseline that can be used for background subtraction
Return type: One-dimensional numeric array
Notes
Example 1:
[x,y] = split_struct(b1d(data,[],[],e.qr,512),{'x','y'}); bl = baseline(y, 4, 1000);
Example 2:
e = nanodiffraction(); [x,y] = split_struct(b1d(data,[],[],e.qr,512),{'x','y'}); bl = baseline(y, 4, 1000); bgr_2d = e.azimuthal_spread(...); bgr_sub = data - bgr_2d;
-
functions.
autoc
(data)¶ AUTOC estimates the contrast of an image to lie within the 5 and 95 percentile of an image. Data will be clipped to the according value
[DATA,LOW,HIGH] = AUTOC(DATA)
Parameters: data (Numeric array) – Numeric array of any dimension Returns: - data (Numeric array) – Input data clipped at the lower and upper percentile
- low (Floating-point number) – Value of the lower (5%) percentile
- high (Floating-point number) – Value of the upper (95%) percentile
Notes
Example 1:
data = magic(256); [data_clipped,low,high] = autoc(data);
-
functions.
binning_2d
(image, binx, biny)¶ BINNING_2D bins and image according to the binning factors binx and biny.
BINNED_IMAGE = BINNING_2D(IMAGE, BINX, BINY)
Parameters: - image (Two-dimensional numeric array) – Input image
- binx (Integer) – Integer binning factor along the horizontal dimension
- biny (Integer) – Integer binning factor along the vertical dimension
Returns: binned_image – Image binned by the binning factors binx and biny
Return type: Two-dimensional numeric array
Notes
Example 1:
testimage = magic(256); binned_im = binning_2d(testimage,2,2);
-
functions.
dpc
(Mass)¶ DPC calculates center of mass for an image
[dpcx, dpcy] = dpc(data)
Parameters: data (numerical array) – Diffraction pattern Returns: - dpcx (Floating-point number) – center of mass along the horizontal dimension
- dpcy (Floating-point number) – center of mass along the vertical dimension
-
functions.
get_index
(y, val)¶ GET_INDEX calculates the index of a data entry within the data array which is closest to a reference value
[I,X] = GET_INDEX(Y,VAL)
Parameters: - Y (One-dimensional numerical array) – Data array
- VAL (Integer of floating-point value) – Reference value
Returns: - I (Integer) – Index within the search array Y
- X (Integer of floating-point value)
- Value of the entry at position I in the search array Y
Notes
Example 1:
y = 1:100; [I,X] = get_index(y,22.7);
-
functions.
imla
(dat)¶ IMLA Shows an intensity image on a logarithmic scale.
imla(data)
Parameters: data (numerical array) – Diffraction pattern Notes
imla is a short-hand notation for
imagesc(log10(abs(dat)))
-
functions.
split_struct
(struct_name, arglist)¶ SPLIT_STRUCT Returns each indicated field as a separate variable.
result = split_struct(structure, cell_array_of_arguments)
Parameters: - structure (Structure) – A structure that contains any number of fields. It can also be a nested structure
- cell_array_of_arguments (Cell array) – A cell array of field names. Each field name will be searched in the (possibly nested) structure. If a field name was found in the structure, it is added to the output argument list.
Returns: Return type: Variable-length output argument list. The length of the list is given by the number of fields that matched a query field name.
Notes
Example 1:
test_structure = struct('w',magic(25),'angle',pi/6); [w,angle] = split_struct(test_structure,{'w','angle'});
Example 2:
test_structure = struct('w', magic(25), 'angle', pi/6, struct('power', 2^3, 'prime', 13)); [w,angle,prime] = split_struct(test_structure,{'w','angle','prime'});
-
functions.
symmetry
(data, bgr, sigma, noise_level, obj)¶ SYMMETRY identifies peaks in the image and determines whether n-fold rotational symmetry exists.
LN = SYMMETRY(DAT,BGR,SIGMA,NOISELEVEL,OBJ)
Parameters: - data (Two-dimensional numeric array) – Diffraction pattern
- bgr (Two-dimensional numeric array) – Background, that will be subtracted from diffraction pattern. bgr has to be of the same size as data
- sigma (Integer or floating-point value) – Width of Gaussian filter applied onto the data
- noiselevel (Integer or floating-point value) – SNR level that functions as a threshold for peak detection.
- obj (Class handle) – Handle to a nanodiffraction object
Returns: - Ln – Description missing.
- binCenter – Description missing.
-
functions.
crystals
(data, mask, sel, threshold)¶ CRYSTAL Calculates the signal-to-noise ratio and calculates the integrated intensity for data above a given threshold
[result] = crystals(data,mask,sel,threshold)
Parameters: - data (Two-dimensional numeric array) – Diffraction pattern
- mask (logical array, default = []) – Logical array of the size of the input data that defines which pixels are considered bad (1 = bad, 0 = valid)
- selection (logical array, default = []) – Logical array of the size of the input data that defines which pixels should be analyzed (1 = valid, 0 = invalid)
- threshold (numeric value) – Data above which the scattered intensity should be integrated
Returns: result – Integrated intensity of scattered intensity of all valid data points above the given threshold
Return type: Numeric value
-
functions.
sort_scan
(data, rows, cols, varargin)¶ SORT_SCAN Reshapes a given one-dimensional or two-dimensional numerical array or cell array into the dimensions of the scan. In the case of a two-dimensional array, each column is treated independently and the result will be output as a stack of two-dimensional numerical arrays.
out_array = sort_scan(data,rows,cols,scanmode)
Parameters: - data (One- or two-dimensional numerical array or cell array) – One-dimensional or two-dimensional numerical array. If the data is two-dimensional, each column will be treated seperately and stored in the third dimension of the output array, since the first dimension of the input array will be expanded into the first two dimensions of the output array. Input data can also be in form of a cell array.
- rows (Integer) – Number of scan lines
- cols (Integer) – Number of scan points per line
- scanmode (Default = 'horz') –
Several raster scanning modes are possible, see ASCII art in the following code block:
1 horizontal <horz> *===================> ====================> ========>... 2 horizontal, alternating <horzalt> *===================> v <===================< v 3 vertical <vert> * v v v v v v v v . v v v v . v v v v . 4 vertical,alternating <vertalt> * A > v A > v v A v A . v A v A . v > A v > A .
Returns: out_array – Two- or three-dimensional numeric array. The first two dimensions are of the size of the scan dimensions.
Return type: Two- or three-dimensional numeric array
-
functions.
update_defaults
(defaults, opts)¶ UPDATE_DEFAULTS overwrites values in a structure with given values from a reference structure
config = update_defaults(defaults,opts)
Parameters: - defaults (Structure) – Structure containing default entries.
- opts (Structure) – Structure containing entries that should be used to overwrite entries in the default structure.
Returns: config – A structure that contains all fields from the default structure
Return type: Structure
Notes
Example 1:
config = update_defaults(struct('a',1,'b','test'),struct('b','replaced'));