Skip to content

crystallography

Algorithms for the processing of crystallography data.

This module contains algorithms that perform data processing operations for Serial Crystallography. Additionally, it contains the definitions of several typed dictionaries that store data produced or required by these algorithms.

TypePeakList

Bases: TypedDict

Detected peaks information.

This typed dictionary stores information about a set of peaks found by a peak-finding algorithm in a detector data frame.

Attributes:

Name Type Description
num_peaks int

The number of peaks detected in the data frame.

fs List[float]

A list of fractional fs indexes that locate the detected peaks in the data frame.

ss List[float]

A list of fractional ss indexes that locate the detected peaks in the data frame.

intensity List[float]

A list of integrated intensities for the detected peaks.

num_pixels List[float]

A list storing the number of pixels in each detected peak.

max_pixel_intensity List[float]

A list storing, for each peak, the value of the pixel with the maximum intensity.

snr List[float]

A list storing the signal-to-noise ratio of each detected peak.

Peakfinder8PeakDetection

See documentation of the __init__ function.

__init__(*, radius_pixel_map, layout_info, crystallography_parameters)

Peakfinder8 algorithm for peak detection.

This algorithm stores all the parameters required to detect Bragg peaks in a detector data frame using the peakfinder8 strategy, described in the following publication:

A. Barty, R. A. Kirian, F. R. N. C. Maia, M. Hantke, C. H. Yoon, T. A. White, and H. N. Chapman, "Cheetah: software for high-throughput reduction and analysis of serial femtosecond x-ray diffraction data", J Appl Crystallogr, vol. 47, pp. 1118-1131 (2014).

After the algorithm has been initialized, it can be invoked to detect peaks in a data frame.

Parameters:

Name Type Description Default
radius_pixel_map NDArray[numpy.float_]

A pixel map storing radius information for the detector data frame on which the algorithm is applied.

  • The array must have the same shape as the data frame on which the algorithm is applied.

  • Each element of the array must store, for the corresponding pixel in the data frame, its distance (in pixels) from the origin of the detector reference system (usually the center of the detector).

required
layout_info TypeDetectorLayoutInformation

An object storing information about the internal layout of the detector data frame on which the algorithm is applied (number and size of ASICs, etc.).

required
crystallography_parameters Dict[str, Any]

A set of OM configuration parameters collected together in a parameter group. The parameter group must contain the following entries:

  • max_num_peaks: The maximum number of peaks that the algorithm should retrieve from each data frame. Additional peaks will be ignored.

  • adc_threshold: The minimum ADC threshold for peak detection.

  • minimum_snr: The minimum signal-to-noise ratio for peak detection.

  • min_pixel_count: The minimum size of a peak in pixels.

  • max_pixel_count: The maximum size of a peak in pixels.

  • local_bg_radius: The radius, in pixels, for the estimation of the local background.

  • min_res: The minimum distance at which a peak can be located, in pixels, from the center of the detector.

  • max_res: The maximum distance at which a peak can be located, in pixels, from the center of the detector.

  • bad_pixel_map_filename: The relative or absolute path to an HDF5 file containing a bad pixel map. The map can be used to exclude regions of the data frame from the peak search. If the value of this entry is None, the peak search extends to the full frame. Defaults to None.

    • The map must be a numpy array with the same shape as the data frame on which the algorithm is applied.

    • Each pixel in the map must have a value of either 0, meaning that the corresponding pixel in the data frame should be ignored, or 1, meaning that the corresponding pixel should be included in the peak search.

    • The map is only used to exclude areas from the peak search: the data is not modified in any way.

  • bad_pixel_map_hdf5_path: The internal HDF5 path to the data block where the bad pixel map data is located. Defaults to None.

    • If the bad_pixel_map_filename entry is not None, this entry must also be provided, and cannot be None. Otherwise it is ignored.
required

get_adc_thresh()

Gets the minimum ADC threshold for peak detection.

This function returns the minimum ADC threshold currently used by the algorithm to detect peaks.

Returns:

Type Description
float

The minimum ADC threshold currently used by the algorithm.

set_adc_thresh(*, adc_thresh)

Sets the current minimum ADC threshold for peak detection.

This function sets the minimum ADC threshold used by the algorithm to detect peaks. Any future call to the find_peaks method will use, for the adc_thresh parameter, the value provided here.

Parameters:

Name Type Description Default
adc_thresh float

The new value of the minimum ADC threshold for peak detection.

required

get_minimum_snr()

Gets the current minimum signal-to-noise ratio for peak detection.

This function returns the minimum signal-to-noise ratio currently used by the algorithm to detect peaks.

Returns:

Type Description
float

The minimum signal-to-noise ratio currently used by the algorithm.

set_minimum_snr(*, minimum_snr)

Sets the minimum signal-to-noise ratio for peak detection.

This function sets the minimum signal-to-noise ratio used by the algorithm to detect peaks. Any future call to the find_peaks method will use, for the minimum_snr algorithm parameter, the value provided here.

Parameters:

Name Type Description Default
minimum_snr float

The new value of the minimum signal-to-noise ratio for peak detection.

required

get_min_pixel_count()

Gets the current minimum size for a peak in pixels.

This function returns the minimum size, in pixels, that the algorithm currently expects a peak to have.

Returns:

Type Description
int

The current minimum size, in pixels, for a peak.

set_min_pixel_count(*, min_pixel_count)

Sets the minimum size for a peak in pixels.

This function sets the minimum size, in pixels, that the algorithm expects a peak to have. Any future call to the find_peaks method will use, for the min_pixel_count parameter, the value provided here.

Parameters:

Name Type Description Default
min_pixel_count int

The new minimum size for a peak in pixels.

required

get_max_pixel_count()

Gets the current maximum size for a peak in pixels.

This function returns the maximum size, in pixels, that the algorithm currently expects a peak to have.

Returns:

Type Description
int

The current maximum size, in pixels, for a peak.

set_max_pixel_count(*, max_pixel_count)

Sets the maximum size for a peak in pixels.

This function sets the maximum size, in pixels, that the algorithm expects a peak to have. Any future call to the find_peaks method will use, for the max_pixel_count parameter, the value provided here.

Parameters:

Name Type Description Default
max_pixel_count int

The new maximum size for a peak in pixels.

required

get_local_bg_radius()

Gets the radius, in pixels, currently used to estimate the local background.

This function returns the radius, in pixels, currently used by the algorithm to estimate the local background.

Returns:

Type Description
int

The radius, in pixels, currently used for the estimation of the local background.

set_local_bg_radius(*, local_bg_radius)

Sets the radius, in pixels, for the estimation of the local background.

This function sets the radius, in pixels, used by the algorithm to estimate the local background. Any future call to the find_peaks method will use, for the local_bg_radius parameter, the value provided here.

Parameters:

Name Type Description Default
local_bg_radius int

The new radius, in pixels, to be used for the estimation of the local background.

required

get_min_res()

Gets the minimum distance for a peak from the detector's center in pixels.

This function returns the minimum distance from the center of the detector, in pixels, that the algorithm currently expects a peak to have.

Returns:

Type Description
int

The current minimum distance, in pixels, for a peak from the detector's

int

center.

set_min_res(*, min_res)

Sets the minimum distance for a peak from the detector's center in pixels.

This function sets the minimum distance from the center of the detector, in pixels, that the algorithm expects a peak to have. Any future call to the find_peaks method will use, for the min_res parameter, the value provided here.

Parameters:

Name Type Description Default
min_res int

The new minimum distance, in pixels, from the detector's center for a peak.

required

get_max_res()

Gets the maximum distance for a peak from the detector's center in pixels.

This function returns the maximum distance from the center of the detector, in pixels, that the algorithm currently expects a peak to have.

Returns:

Type Description
int

The current maximum distance, in pixels, for a peak from the detector's

int

center.

set_max_res(max_res)

Sets the maximum distance for a peak from the detector's center in pixels.

This function sets the maximum distance from the center of the detector, in pixels, that the algorithm expects a peak to have. Any future call to the find_peaks method will use, for the min_res parameter, the value provided here.

Parameters:

Name Type Description Default
max_res int

The new maximum distance, in pixels, from the detector's center for a peak.

required

find_peaks(*, data)

Finds peaks in a detector data frame.

This function detects peaks in a provided detector data frame, and returns information about their location, size and intensity.

Parameters:

Name Type Description Default
data Union[NDArray[numpy.int_], NDArray[numpy.float_]]

The detector data frame on which the peak-finding operation must be performed.

required

Returns:

Type Description
TypePeakList

A TypePeakList dictionary with information about the detected peaks.