dials.algorithms.spot_finding

Contains implementation interface for finding spots on one or many images

class dials.algorithms.spot_finding.finder.ExtractPixelsFromImage(imageset, threshold_function, mask, region_of_interest, max_strong_pixel_fraction, compute_mean_background)[source]

Bases: object

A class to extract pixels from a single image

__init__(imageset, threshold_function, mask, region_of_interest, max_strong_pixel_fraction, compute_mean_background)[source]

Initialise the class

Parameters
  • imageset – The imageset to extract from

  • threshold_function – The function to threshold with

  • mask – The image mask

  • region_of_interest – A region of interest to process

  • max_strong_pixel_fraction – The maximum fraction of pixels allowed

class dials.algorithms.spot_finding.finder.ExtractPixelsFromImage2DNoShoeboxes(imageset, threshold_function, mask, region_of_interest, max_strong_pixel_fraction, compute_mean_background, min_spot_size, max_spot_size, filter_spots)[source]

Bases: dials.algorithms.spot_finding.finder.ExtractPixelsFromImage

A class to extract pixels from a single image

__init__(imageset, threshold_function, mask, region_of_interest, max_strong_pixel_fraction, compute_mean_background, min_spot_size, max_spot_size, filter_spots)[source]

Initialise the class

Parameters
  • imageset – The imageset to extract from

  • threshold_function – The function to threshold with

  • mask – The image mask

  • region_of_interest – A region of interest to process

  • max_strong_pixel_fraction – The maximum fraction of pixels allowed

class dials.algorithms.spot_finding.finder.ExtractSpots(threshold_function=None, mask=None, region_of_interest=None, max_strong_pixel_fraction=0.1, compute_mean_background=False, mp_method=None, mp_nproc=1, mp_njobs=1, mp_chunksize=1, min_spot_size=1, max_spot_size=20, filter_spots=None, no_shoeboxes_2d=False, min_chunksize=50, write_hot_pixel_mask=False)[source]

Bases: object

Class to find spots in an image and extract them into shoeboxes.

__init__(threshold_function=None, mask=None, region_of_interest=None, max_strong_pixel_fraction=0.1, compute_mean_background=False, mp_method=None, mp_nproc=1, mp_njobs=1, mp_chunksize=1, min_spot_size=1, max_spot_size=20, filter_spots=None, no_shoeboxes_2d=False, min_chunksize=50, write_hot_pixel_mask=False)[source]

Initialise the class with the strategy

Parameters
  • threshold_function – The image thresholding strategy

  • mask – The mask to use

  • mp_method – The multi processing method

  • nproc – The number of processors

  • max_strong_pixel_fraction – The maximum number of strong pixels

class dials.algorithms.spot_finding.finder.ExtractSpotsParallelTask(function)[source]

Bases: object

Execute the spot finder task in parallel

We need this external class so that we can pickle it for cluster jobs

__init__(function)[source]

Initialise with the function to call

class dials.algorithms.spot_finding.finder.SpotFinder(threshold_function=None, mask=None, region_of_interest=None, max_strong_pixel_fraction=0.1, compute_mean_background=False, mp_method=None, mp_nproc=1, mp_njobs=1, mp_chunksize=1, mask_generator=None, filter_spots=None, scan_range=None, write_hot_mask=True, hot_mask_prefix='hot_mask', min_spot_size=1, max_spot_size=20, no_shoeboxes_2d=False, min_chunksize=50, is_stills=False)[source]

Bases: object

A class to do spot finding and filtering.

__init__(threshold_function=None, mask=None, region_of_interest=None, max_strong_pixel_fraction=0.1, compute_mean_background=False, mp_method=None, mp_nproc=1, mp_njobs=1, mp_chunksize=1, mask_generator=None, filter_spots=None, scan_range=None, write_hot_mask=True, hot_mask_prefix='hot_mask', min_spot_size=1, max_spot_size=20, no_shoeboxes_2d=False, min_chunksize=50, is_stills=False)[source]

Initialise the class.

Parameters
  • find_spots – The spot finding algorithm

  • filter_spots – The spot filtering algorithm

  • scan_range – The scan range to find spots over

  • is_stills – [ADVANCED] Force still-handling of experiment ID remapping for dials.stills_process.

find_spots(experiments: dxtbx_model_ext.ExperimentList) dials_array_family_flex_ext.reflection_table[source]

Do spotfinding for a set of experiments.

Parameters

experiments – The experiment list to process

Returns

A new reflection table of found reflections

dials.algorithms.spot_finding.finder.pixel_list_to_reflection_table(imageset: dxtbx_imageset_ext.ImageSet, pixel_labeller: Iterable[dials_model_data_ext.PixelListLabeller], filter_spots, min_spot_size: int, max_spot_size: int, write_hot_pixel_mask: bool) Tuple[dials_array_family_flex_ext.shoebox, Tuple[scitbx_array_family_flex_ext.size_t, ...]][source]

Convert pixel list to reflection table

dials.algorithms.spot_finding.finder.pixel_list_to_shoeboxes(imageset: dxtbx_imageset_ext.ImageSet, pixel_labeller: Iterable[dials_model_data_ext.PixelListLabeller], min_spot_size: int, max_spot_size: int, write_hot_pixel_mask: bool) Tuple[dials_array_family_flex_ext.shoebox, Tuple[scitbx_array_family_flex_ext.size_t, ...]][source]

Convert a pixel list to shoeboxes

dials.algorithms.spot_finding.finder.shoeboxes_to_reflection_table(imageset: dxtbx_imageset_ext.ImageSet, shoeboxes: dials_array_family_flex_ext.shoebox, filter_spots) dials_array_family_flex_ext.reflection_table[source]

Filter shoeboxes and create reflection table

class dials.algorithms.spot_finding.factory.BackgroundGradientFilter(background_size=2, gradient_cutoff=4)[source]

Bases: object

__init__(background_size=2, gradient_cutoff=4)[source]
run(flags, sequence=None, shoeboxes=None, **kwargs)[source]
class dials.algorithms.spot_finding.factory.FilterRunner(filters=None)[source]

Bases: object

A class to run multiple filters in succession.

__init__(filters=None)[source]

Initialise with a list of filters.

Parameters

filters – The list of filters

check_flags(flags, predictions=None, observations=None, shoeboxes=None, **kwargs)[source]

Check the flags are set, if they’re not then create a list of Trues equal to the number of items given.

Parameters
  • flags – The input flags

  • predictions – The predictions

  • observations – The observations

  • shoeboxes – The shoeboxes

Returns

The filtered flags

class dials.algorithms.spot_finding.factory.PeakCentroidDistanceFilter(maxd)[source]

Bases: object

__init__(maxd)[source]

Initialise

Parameters

maxd – The maximum distance allowed

run(flags, observations=None, shoeboxes=None, **kwargs)[source]

Run the filtering.

class dials.algorithms.spot_finding.factory.SpotDensityFilter(nbins=50, gradient_cutoff=0.002)[source]

Bases: object

__init__(nbins=50, gradient_cutoff=0.002)[source]
run(flags, sequence=None, observations=None, **kwargs)[source]
class dials.algorithms.spot_finding.factory.SpotFinderFactory[source]

Bases: object

Factory class to create spot finders

static configure_filter(params)[source]

Get the filter strategy.

Parameters

params – The input parameters

Returns

The filter algorithm

static configure_threshold(params)[source]

Get the threshold strategy

Parameters

params – The input parameters

Returns

The threshold algorithm

static from_parameters(params=None, experiments=None, is_stills=False)[source]

Given a set of parameters, construct the spot finder

Parameters
  • params – The input parameters

  • is_stills – [ADVANCED] Force still-handling of experiment ID remapping for dials.stills_process.

Returns

The spot finder instance

static load_image(filename_or_data)[source]

Given a filename, load an image. If the data is already loaded, return it.

Parameters

filename_or_data – The input filename (or data)

Returns

The image or None

dials.algorithms.spot_finding.factory.generate_phil_scope()[source]