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.

class Peakfinder8PeakDetection(*, radius_pixel_map, layout_info, 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:
  • radius_pixel_map (ndarray[Any, dtype[float64]]) –

    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).

  • layout_info (DetectorLayoutInformation) – 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.).

  • parameters (Peakfinder8PeakDetectionParameters) –

    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.

set_layout_info(layout_info)#
Parameters:

layout_info (DetectorLayoutInformation)

Return type:

None

get_bad_pixel_map()#
Return type:

ndarray[Any, dtype[int64]] | None

set_bad_pixel_map(bad_pixel_map)#
Parameters:

bad_pixel_map (ndarray[Any, dtype[int64]] | None)

Return type:

None

set_radius_pixel_map(radius_pixel_map)#
Parameters:

radius_pixel_map (ndarray[Any, dtype[float64]])

Return type:

None

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:

The minimum ADC threshold currently used by the algorithm.

Return type:

float

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][om.algorithms.crystallography.Peakfinder8PeakDetection.find_peaks] method will use, for the adc_thresh parameter, the value provided here.

Parameters:

adc_thresh (float) – The new value of the minimum ADC threshold for peak detection.

Return type:

None

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:

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

Return type:

float

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][om.algorithms.crystallography.Peakfinder8PeakDetection.find_peaks] method will use, for the minimum_snr algorithm parameter, the value provided here.

Parameters:

minimum_snr (float) – The new value of the minimum signal-to-noise ratio for peak detection.

Return type:

None

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:

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

Return type:

int

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][om.algorithms.crystallography.Peakfinder8PeakDetection.find_peaks] method will use, for the min_pixel_count parameter, the value provided here.

Parameters:

min_pixel_count (int) – The new minimum size for a peak in pixels.

Return type:

None

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:

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

Return type:

int

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][om.algorithms.crystallography.Peakfinder8PeakDetection.find_peaks] method will use, for the max_pixel_count parameter, the value provided here.

Parameters:

max_pixel_count (int) – The new maximum size for a peak in pixels.

Return type:

None

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:

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

Return type:

int

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][om.algorithms.crystallography.Peakfinder8PeakDetection.find_peaks] method will use, for the local_bg_radius parameter, the value provided here.

Parameters:

local_bg_radius (int) – The new radius, in pixels, to be used for the estimation of the local background.

Return type:

None

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:

The current minimum distance, in pixels, for a peak from the detector’s center.

Return type:

int

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][om.algorithms.crystallography.Peakfinder8PeakDetection.find_peaks] method will use, for the min_res parameter, the value provided here.

Parameters:

min_res (int) – The new minimum distance, in pixels, from the detector’s center for a peak.

Return type:

None

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:

The current maximum distance, in pixels, for a peak from the detector’s center.

Return type:

int

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][om.algorithms.crystallography.Peakfinder8PeakDetection.find_peaks] method will use, for the min_res parameter, the value provided here.

Parameters:

max_res (int) – The new maximum distance, in pixels, from the detector’s center for a peak.

Return type:

None

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:

data (ndarray[Any, dtype[int64]] | ndarray[Any, dtype[float64]]) – The detector data frame on which the peak-finding operation must be performed.

Returns:

A dictionary with information about the detected peaks.

Return type:

PeakList