Parameters#
PeakParams controls peak detection and fitting. IndexParams controls orientation indexing. Both are immutable dataclasses that the Indexer validates during construction.
Start with the defaults#
Use default values for an initial API check, but do not assume that they are appropriate for every detector, exposure, or material.
from lauelab.indexing import Indexer, IndexParams, PeakParams
indexer = Indexer(
"geometry.xml",
"crystal.xml",
peak_params=PeakParams(),
index_params=IndexParams(),
)
Record the complete parameter objects with analysis output. A result alone does not contain every setting needed to reproduce processing.
Peak-search parameters#
Parameter |
Default |
Units |
Effect and constraint |
|---|---|---|---|
|
|
px |
Half-width of the square fitting region. Must be positive. |
|
|
dimensionless |
Maximum accepted fit residual factor. Must be positive. |
|
|
px |
Minimum accepted peak size. Must be positive. |
|
|
px |
Minimum separation between accepted peaks. Must be positive. |
|
|
detector counts |
Absolute detection threshold. Use |
|
|
dimensionless |
Scale applied to the frame standard deviation for automatic thresholding. |
|
|
none |
Fit model. Exactly |
|
|
peaks |
Maximum number of returned peaks. Must be positive. |
|
|
none |
Applies native image smoothing before detection and fitting. Frame sums continue to describe the raw input image; an automatically derived threshold is computed from the smoothed image. |
When threshold is not None, threshold_ratio does not determine the threshold. When threshold is None, the native stage calculates the threshold from frame statistics and the resolved threshold_ratio. XML provenance records the resolved value (4.0 when configured as None).
Indexing parameters#
Parameter |
Default |
Units |
Effect and constraint |
|---|---|---|---|
|
|
keV |
Maximum energy used to calculate candidate reflections. Must be positive. |
|
|
keV |
Maximum energy used when testing candidate reflections. Must be positive. |
|
|
deg |
Angular matching tolerance. Must be positive. |
|
|
deg |
Search-cone angle. Must be positive. |
|
|
Miller indices |
Preferred direction. Must contain exactly three integers. |
|
|
peaks |
Maximum detected peaks supplied to orientation indexing. Must be at least two. |
These fields configure the native orientation search. Their scientifically appropriate values depend on the experiment and crystal. This guide does not prescribe universal tuning values.
Derive a configuration#
Use dataclasses.replace() instead of mutating a parameter object:
from dataclasses import replace
base_peaks = PeakParams()
automatic_threshold = replace(
base_peaks,
threshold=None,
threshold_ratio=4.0,
max_peaks=200,
)
Construct a new indexer or use Indexer.replace() to validate changed settings:
updated = indexer.replace(peak_params=automatic_threshold)
Indexer.replace() constructs independent native geometry and crystal state for the new instance.
Parameter interactions#
Several interactions follow directly from processing behavior:
thresholdselects absolute or automatic thresholding.threshold_ratioaffects automatic thresholding only.max_peakslimits the output of peak search.max_datalimits how many detected peaks enter orientation indexing.Orientation indexing runs only when a crystal is present and at least two peaks were detected.
start,group, anddepthaffect pixel-to-q conversion rather than peak fitting.A mask changes which frame pixels peak search can use.
Changes to peak acceptance can change the scattering vectors available to indexing. Compare the intermediate peak count and fit fields before attributing a changed pattern result only to IndexParams.
A conservative tuning workflow#
Save the original frame, geometry, crystal description, and parameter objects.
Run peak search with a fixed configuration.
Inspect
threshold_used,n_peaks, fitted positions, widths, residuals, and masked regions.Change one peak-search parameter at a time.
Hold the accepted peak set fixed before comparing indexing parameters.
Compare pattern count, assignments, and angular errors across runs.
Record the chosen values and the reason for each change.
This process isolates parameter effects. Numerical thresholds and acceptance criteria still require experiment-specific review.
Performance and reproducibility#
Do not infer speed from elapsed_seconds alone. It sums recorded peak-search and orientation-indexing time but excludes pixel-to-q conversion and Python setup.
For a reproducible comparison, record:
Package version or Git commit
Frame identifier and checksum when possible
Geometry and crystal file versions
Detector selection
start,group, anddepthMask identity
Complete
PeakParamsandIndexParamsHardware and process configuration for timing comparisons
Invalid configurations#
The Indexer raises InputError for invalid parameter ranges, unsupported peak models, malformed hkl_prefer, and max_data below two. See Configuration for exact field definitions.