\(\renewcommand\AA{\unicode{x212B}}\)

IntegratePeaksMD v2

Summary

Integrate single-crystal peaks in reciprocal space, for MDEventWorkspaces.

Sphere is the default shape: tick Ellipsoid or Cylinder to change shape.

See Also

CentroidPeaksMD, IntegratePeaksHybrid, IntegratePeaksMDHKL, IntegratePeaksUsingClusters, IntegratePeaksCWSD

Properties

Name

Direction

Type

Default

Description

InputWorkspace

Input

MDEventWorkspace

Mandatory

An input MDEventWorkspace.

PeakRadius

Input

dbl list

1

Fixed radius around each peak position in which to integrate, or the semi-axis lengths (a,b,c) describing an ellipsoid shape used for integration (in the same units as the workspace).

BackgroundInnerRadius

Input

dbl list

0

Inner radius, or three values for semi-axis lengths (a,b,c) of the ellipsoid shape, used to evaluate the background of the peak. If smaller than PeakRadius, then we assume BackgroundInnerRadius = PeakRadius.

BackgroundOuterRadius

Input

dbl list

0

Outer radius, or three values for semi-axis lengths (a,b,c) of the ellipsoid shape, to use to evaluate the background of the peak. The signal density around the peak (BackgroundInnerRadius < r < BackgroundOuterRadius) is used to estimate the background under the peak. If smaller than PeakRadius, no background measurement is done.

PeaksWorkspace

Input

IPeaksWorkspace

Mandatory

A PeaksWorkspace containing the peaks to integrate.

OutputWorkspace

Output

IPeaksWorkspace

Mandatory

The output PeaksWorkspace will be a copy of the input PeaksWorkspace with the peaks’ integrated intensities.

ReplaceIntensity

Input

boolean

True

Always replace intensity in PeaksWorkspacem (default). If false, then do not replace intensity if calculated value is 0 (used for SNSSingleCrystalReduction)

IntegrateIfOnEdge

Input

boolean

True

Only warning if all of peak outer radius is not on detector (default). If false, do not integrate if the outer radius is not on a detector.

AdaptiveQBackground

Input

boolean

False

Default is false. If true, BackgroundOuterRadius + AdaptiveQMultiplier * |Q| and BackgroundInnerRadius + AdaptiveQMultiplier * |Q|

Ellipsoid

Input

boolean

False

Default is sphere.

FixQAxis

Input

boolean

False

Fix one axis of ellipsoid to be along direction of Q.

Cylinder

Input

boolean

False

Default is sphere. Use next five parameters for cylinder.

CylinderLength

Input

number

0

Length of cylinder in which to integrate (in the same units as the workspace).

PercentBackground

Input

number

0

Percent of CylinderLength that is background (20 is 20%)

ProfileFunction

Input

string

Gaussian

Fitting function for profile that is used only with Cylinder integration. Allowed values: [‘AsymmetricPearsonVII’, ‘BackToBackExponential’, ‘Bk2BkExpConvPV’, ‘DeltaFunction’, ‘ElasticDiffRotDiscreteCircle’, ‘ElasticDiffSphere’, ‘ElasticIsoRotDiff’, ‘ExamplePeakFunction’, ‘Gaussian’, ‘IkedaCarpenterPV’, ‘Lorentzian’, ‘PearsonIV’, ‘PseudoVoigt’, ‘Voigt’, ‘NoFit’]

IntegrationOption

Input

string

GaussianQuadrature

Integration method for calculating intensity used only with Cylinder integration. Allowed values: [‘Sum’, ‘GaussianQuadrature’]

ProfilesFile

Input

string

Save (Optionally) as Isaw peaks file with profiles included. Allowed values: [‘profiles’]

AdaptiveQMultiplier

Input

number

0

PeakRadius + AdaptiveQMultiplier * |Q| so each peak has a different integration radius. Q includes the 2*pi factor.

CorrectIfOnEdge

Input

boolean

False

Only warning if all of peak outer radius is not on detector (default). If false, correct for volume off edge for both background and intensity (the peak is assumed uniform Gaussian so this only applies to spherical integration).

UseOnePercentBackgroundCorrection

Input

boolean

True

If this options is enabled, then the top 1% of the background will be removedbefore the background subtraction.

FixMajorAxisLength

Input

boolean

True

This option is ignored if all peak radii are specified. Otherwise, if True the ellipsoid radidi (proportional to the sqrt of the eigenvalues of the covariance matrix) are scaled such that the major axis radius is equal to the PeakRadius. If False then the ellipsoid radii are set to 3 times the sqrt of the eigenvalues of the covariance matrix

UseCentroid

Input

boolean

False

Perform integration on estimated centroid not peak position (ignored if all three peak radii are specified).

MaxIterations

Input

number

1

Number of iterations in covariance estimation (ignored if all peak radii are specified). 2-3 should be sufficient.

MaskEdgeTubes

Input

boolean

True

Mask tubes on the edge of all banks in the PeaksWorkspace instrument (note the edge pixels at top/bottom of all tubes will always be masked even if this property is False). Note the algorithm will treat any masked pixels as edges (including pixels already masked prior to the execution of this algorithm) - this means a custom mask can be applied to the PeaksWorkspace before integration.

Description

This algorithm performs integration of single-crystal peaks within a radius (with optional background subtraction) in reciprocal space.

Similar algorithms

See IntegrateEllipsoids v3 for a ways of integrating peaks from data collected in EventWorkspace. PeakIntensityVsRadius v1 is meant to help determine an appropriate value for PeakRadius.

Inputs

The algorithms takes two input workspaces:

  • A MDEventWorkspace containing the events in multi-dimensional space. This would be the output of ConvertToDiffractionMDWorkspace v3.

  • As well as a PeaksWorkspace containing single-crystal peak locations. This could be the output of FindPeaksMD v1

  • The OutputWorkspace will contain a copy of the input PeaksWorkspace, with the integrated intensity and error found being filled in.

Calculations

Integration is performed by summing the weights of each MDEvent within the provided radii. Errors are also summed in quadrature.

IntegratePeaksMD_graph1.png

IntegratePeaksMD_graph1.png

  • All the Radii are specified in \(\AA^{-1}\)

  • A sphere or ellipsoid of radius PeakRadius is integrated around the center of each peak.

    • This gives the summed intensity \(I_{peak}\) and the summed squared error \(\sigma I_{peak}^2\).

    • The volume of integration is \(V_{peak}\).

    • An ellipsoidal shape is integrated when the Ellipsoid option is enabled (the following also applies to BackgroundInnerRadius and BackgroundOuterRadius):

      • When only one value for PeakRadius is given, then the ellipsoidal shape is calculated automatically with axes proportional to the sqrt of the eigenvalues of the covariance matrix. If FixMajorAxisLength = true then with the ellipsoid will be scaled such that the radius along the major axis is equal to the radius of the spherical region over which the covariance was estimated. In addition the covariance can be estimated iteratively (by setting MaxIterations > 1) - points outside of 3 standard deviations will be exluded and the covariance will be estimated again. If the ellipsoid is large enough to fully contain the spherical region then the spherical region will be used instead.

      • Three values for PeakRadius can be given, which correspond to the semi-axis lengths (a,b,c) of the ellipsoid.

  • If BackgroundOuterRadius is specified, then a shell, with radius r where BackgroundInnerRadius < r < BackgroundOuterRadius, is integrated.

    • This gives the summed intensity \(I_{shell}\) and the summed squared error \(\sigma I_{shell}^2\).

    • The volume of integration is \(V_{shell}\).

    • BackgroundInnerRadius allows you to give some space between the peak and the background area.

    • If the option UseOnePercentBackgroundCorrection is enabled, which it is by default, then the top one percent of the background events are removed so that there are no intensity spikes near the edges.

  • AdaptiveQMultiplier can be used for the radius to vary as a function of the modulus of Q. If the AdaptiveQBackground option is set to True, the background radius also changes so each peak has a different integration radius. Q includes the 2*pi factor.

    • PeakRadius + AdaptiveQMultiplier * |Q|

    • BackgroundOuterRadius + AdaptiveQMultiplier * |Q|

    • BackgroundInnerRadius + AdaptiveQMultiplier * |Q|

Background Subtraction

The background signal within PeakRadius is calculated by scaling the background signal density in the shell to the volume of the peak:

\(I_{bg} = I_{shell} \frac{V_{peak}}{V_{shell}}\)

with the error squared on that value:

\(\sigma I_{bg}^2 = (\frac{V_{peak}}{V_{shell}})^2 \sigma I_{shell}^2\)

This is applied to the integrated peak intensity \(I_{peak}\) to give the corrected intensity \(I_{corr}\):

\(I_{corr} = I_{peak} - I_{bg}\)

with the errors summed in quadrature:

\(\sigma I_{corr}^2 = \sigma I_{peak}^2 + \sigma I_{bg}^2\)

If BackgroundInnerRadius is Omitted

If BackgroundInnerRadius is left blank, then BackgroundInnerRadius = PeakRadius, and the integration is as follows:

IntegratePeaksMD_graph2.png

IntegratePeaksMD_graph2.png

IntegrateIfOnEdge option

Edges for each bank or pack of tubes of the instrument are defined by masking the edges in the PeaksWorkspace instrument. e.g. For TOPAZ pixels 0 and 255 in both directions for the Rectangular Detector. Q in the lab frame for every peak is calculated, call it C For every point on the edge, the trajectory in reciprocal space is a straight line, going through:

\(\vec{O}=(0,0,0)\)

Calculate a point at a fixed momentum, say k=1. Q in the lab frame:

\(\vec{E}=(-k \cdot \sin(\theta) \cdot \cos(\phi),-k \cdot \sin(\theta) \cdot \sin(\phi),k-k \cdot \cos(\phi))\)

Normalize E to 1:

\(\vec{E}=\vec{E} \cdot (1./\left|\vec{E}\right|)\)

The distance from C to OE is given by:

\(dv=\vec{C}-\vec{E} \cdot (\vec{C} \cdot \vec{E})\)

If:

\(\left|dv\right|<PeakRadius\)

for the integration, one of the detector trajectories on the edge is too close to the peak This method is also applied to all masked pixels. If there are masked pixels trajectories inside an integration volume, the peak must be rejected.

CorrectIfOnEdge option

This is an extension of what was calculated for the IntegrateIfOnEdge option. It will only be calculated if this option is true and the minimum dv is less than PeakRadius or BackgroundOuterRadius.

For the background if

\(\left|dv\right|_{\text{min}}<BackgroundOuterRadius\)

\(h = BackgroundOuterRadius - \left|dv\right|_{\text{min}}\)

From the minimum of dv the volume of the cap of the sphere is found:

\(V_{cap} = \pi h^2 / 3 (3 \cdot BackgroundOuterRadius - h)\)

The volume of the total sphere is calculated and for the background the volume of the inner radius must be subtracted:

\(V_{shell} = 4/3 \pi (BackgroundOuterRadius^3 - BackgroundInnerRadius^3)\)

The integrated intensity is multiplied by the ratio of the volume of the sphere divided by the volume where data was collected

\(I_{bkgMultiplier} = V_{shell} / (V_{shell} - V_{cap})\)

For the peak assume that the shape is Gaussian. If

\(\left|dv\right|_{\text{min}}<PeakRadius\)

\(\sigma = PeakRadius / 3\)

\(h = PeakRadius \cdot \exp(-\left|dv\right|_{min}^2 / (2 \sigma^2)\)

From the minimum of dv the volume of the cap of the sphere is found:

\(V_{cap} = \pi h^2 / 3 (3 \cdot PeakRadius - h)\)

and the volume of the sphere is calculated

\(V_{sphere} = 4/3 \pi PeakRadius^3\)

The integrated intensity is multiplied by the ratio of the volume of the sphere divided by the volume where data was collected

\(I_{peakMultiplier} = V_{sphere} / (V_{sphere} - V_{cap})\)

Usage

Example - IntegratePeaks:

User should provide its own event nexus file instead of TOPAZ_3132_event.nxs used within this example. The original TOPAZ_3132_event.nxs file is available in Mantid system tests repository.

 1def print_tableWS(pTWS,nRows):
 2    ''' Method to print part of the table workspace '''
 3    tab_names=pTWS.keys()
 4    row = ""
 5    for name in tab_names:
 6        if len(name)>8:
 7           name= name[:8]
 8        row += "| {:8} ".format(name)
 9    print(row + "|")
10
11    for i in range(nRows):
12        row = ""
13        for name in tab_names:
14              col = pTWS.column(name);
15              data2pr=col[i]
16              if type(data2pr) is float:
17                  row += "| {:8.1f} ".format(data2pr)
18              else:
19                  row += "| {:8} ".format(str(data2pr))
20        print(row + "|")
21
22 # Load a SCD data set and find the peaks
23LoadEventNexus(Filename=r'TOPAZ_3132_event.nxs',OutputWorkspace='TOPAZ_3132_nxs')
24ConvertToDiffractionMDWorkspace(InputWorkspace='TOPAZ_3132_nxs',OutputWorkspace='TOPAZ_3132_md',LorentzCorrection='1')
25FindPeaksMD(InputWorkspace='TOPAZ_3132_md',PeakDistanceThreshold='0.15',MaxPeaks='100',OutputWorkspace='peaks')
26FindUBUsingFFT(PeaksWorkspace='peaks',MinD='2',MaxD='16')
27
28 # Perform the peak integration, in-place in the 'peaks' workspace.
29peaks= IntegratePeaksMD(InputWorkspace='TOPAZ_3132_md', PeaksWorkspace='peaks',\
30     PeakRadius=0.12, BackgroundOuterRadius=0.2, BackgroundInnerRadius=0.16,\
31     OutputWorkspace='peaks')
32
33# print the integration results
34print_tableWS(peaks,10)

Output:

 1| RunNumbe | DetID    | h        | k        | l        | Waveleng | Energy   | TOF      | DSpacing | Intens   | SigInt   | BinCount | BankName | Row      | Col      | QLab     | QSample  | PeakNumb |
 2| 3132     | 1168209  |      0.0 |      0.0 |      0.0 |      1.1 |     66.9 |   5158.0 |      0.7 |   2160.9 |     32.3 |   1326.0 | bank17   |     81.0 |    211.0 | [4.42961,2.81707,7.86314] | [8.75838,3.55459,-0.205083] | 1        |
 3| 3132     | 1124983  |      0.0 |      0.0 |      0.0 |      1.6 |     33.9 |   7250.6 |      1.0 |   1990.0 |     14.4 |   1060.0 | bank17   |    119.0 |     42.0 | [3.14813,2.43563,4.75389] | [5.9822,1.62965,0.00130101] | 2        |
 4| 3132     | 1141521  |      0.0 |      0.0 |      0.0 |      1.7 |     28.1 |   7959.1 |      1.0 |    644.6 |      7.3 |   1034.0 | bank17   |     17.0 |    107.0 | [2.60893,2.31831,4.86248] | [5.69311,1.79103,-0.453311] | 3        |
 5| 3132     | 1125238  |      0.0 |      0.0 |      0.0 |      3.1 |      8.4 |  14518.9 |      2.0 |    750.5 |      2.2 |    880.0 | bank17   |    118.0 |     43.0 | [1.57116,1.21649,2.37775] | [2.98926,0.816337,-0.00161709] | 4        |
 6| 3132     | 1170852  |      0.0 |      0.0 |      0.0 |      1.6 |     34.0 |   7235.3 |      1.0 |   1826.4 |     14.7 |    762.0 | bank17   |    164.0 |    221.0 | [3.4229,1.70246,5.39532] | [6.0734,2.6008,0.271523] | 5        |
 7| 3132     | 1156497  |      0.0 |      0.0 |      0.0 |      2.1 |     18.9 |   9718.2 |      1.3 |   5137.6 |     13.4 |    518.0 | bank17   |    145.0 |    165.0 | [2.49117,1.46093,3.88649] | [4.5291,1.70753,0.129446] | 6        |
 8| 3132     | 1207828  |      0.0 |      0.0 |      0.0 |      1.7 |     27.9 |   7989.1 |      1.3 |   3233.6 |     12.7 |   1024.0 | bank18   |     20.0 |    110.0 | [2.80538,2.29342,3.08833] | [4.71342,0.553533,0.380727] | 7        |
 9| 3132     | 1218593  |      0.0 |      0.0 |      0.0 |      1.0 |     79.6 |   4729.3 |      0.8 |   3018.1 |     35.4 |    756.0 | bank18   |     33.0 |    152.0 | [4.96533,3.60693,5.32436] | [7.98578,1.19927,0.895763] | 8        |
10| 3132     | 1232694  |      0.0 |      0.0 |      0.0 |      1.2 |     53.4 |   5772.9 |      0.9 |   3464.5 |     25.9 |    631.0 | bank18   |     54.0 |    207.0 | [4.29539,2.63813,4.45945] | [6.53086,1.27477,1.00974] | 9        |
11| 3132     | 1200023  |      0.0 |      0.0 |      0.0 |      0.7 |    159.1 |   3345.1 |      0.6 |   3796.1 |     71.1 |    509.0 | bank18   |    151.0 |     79.0 | [6.75629,4.8092,5.93224] | [10.0166,0.773518,1.74245] | 10       |

Categories: AlgorithmIndex | MDAlgorithms\Peaks | Crystal\Integration

Source

C++ header: IntegratePeaksMD2.h

C++ source: IntegratePeaksMD2.cpp