Example #1
0
    def configure_threshold(params, datablock):
        '''
    Get the threshold strategy

    :param params: The input parameters
    :return: The threshold algorithm

    '''
        from dials.interfaces import SpotFinderThresholdIface

        # Set the gain if necessary - requires datablock
        if params.spotfinder.threshold.xds.gain is None:
            assert (datablock)
            gain = None
            for imageset in datablock.extract_imagesets():
                for panel in imageset.get_detector():
                    if gain is None:
                        gain = panel.get_gain()
                    else:
                        assert abs(gain - panel.get_gain()) < 1e-7
            params.spotfinder.threshold.xds.gain = gain

        # Configure the algotihm
        Algorithm = SpotFinderThresholdIface.extension(
            params.spotfinder.threshold.algorithm)
        return Algorithm(params)
Example #2
0
  def configure_threshold(params, datablock):
    '''
    Get the threshold strategy

    :param params: The input parameters
    :return: The threshold algorithm

    '''
    from dials.interfaces import SpotFinderThresholdIface

    # Set the gain if necessary - requires datablock
    if params.spotfinder.threshold.xds.gain is None:
      assert(datablock)
      gain = None
      for imageset in datablock.extract_imagesets():
        for panel in imageset.get_detector():
          if gain is None:
            gain = panel.get_gain()
          else:
            assert abs(gain - panel.get_gain()) < 1e-7
      params.spotfinder.threshold.xds.gain = gain

    # Configure the algotihm
    Algorithm = SpotFinderThresholdIface.extension(
      params.spotfinder.threshold.algorithm)
    return Algorithm(params)
Example #3
0
  def configure_threshold(params):
    '''
    Get the threshold strategy

    :param params: The input parameters
    :return: The threshold algorithm

    '''
    from dials.interfaces import SpotFinderThresholdIface
    Algorithm = SpotFinderThresholdIface.extension(
      params.spotfinder.threshold.algorithm)
    return Algorithm(params)
Example #4
0
    def tst_after_import_extensions(self):
        import dials.extensions  # import dependency
        from dials.interfaces import ProfileModelIface
        from dials.interfaces import SpotFinderThresholdIface
        from dials.interfaces import CentroidIface
        from dials.interfaces import BackgroundIface

        # Should have four interfaces
        interfaces = list(Interface.interfaces())
        assert (len(interfaces) == 4)

        # Check we have the expected number of extensions for each interface
        extensions = list(ProfileModelIface.extensions())
        assert (len(extensions) > 0)
        extensions = list(SpotFinderThresholdIface.extensions())
        assert (len(extensions) > 0)
        extensions = list(CentroidIface.extensions())
        assert (len(extensions) > 0)
        extensions = list(BackgroundIface.extensions())
        assert (len(extensions) > 0)

        # Check the interface contain the expected extensions
        from dials.extensions import GaussianRSProfileModelExt
        from dials.extensions import KabschSpotFinderThresholdExt
        from dials.extensions import SimpleCentroidExt
        from dials.extensions import NullBackgroundExt
        from dials.extensions import SimpleBackgroundExt

        extensions = list(ProfileModelIface.extensions())
        assert (GaussianRSProfileModelExt in extensions)
        extensions = list(SpotFinderThresholdIface.extensions())
        assert (KabschSpotFinderThresholdExt in extensions)
        extensions = list(CentroidIface.extensions())
        assert (SimpleCentroidExt in extensions)
        extensions = list(BackgroundIface.extensions())
        assert (NullBackgroundExt in extensions)
        assert (SimpleBackgroundExt in extensions)

        # Test passed
        print 'OK'
Example #5
0
    def configure_threshold(params, datablock):
        '''
    Get the threshold strategy

    :param params: The input parameters
    :return: The threshold algorithm

    '''
        from dials.interfaces import SpotFinderThresholdIface

        # Configure the algotihm
        Algorithm = SpotFinderThresholdIface.extension(
            params.spotfinder.threshold.algorithm)
        return Algorithm(params)
Example #6
0
def generate_phil_scope():
  from iotbx.phil import parse
  import dials.extensions # import dependency
  from dials.interfaces import SpotFinderThresholdIface

  phil_scope = parse('''

  spotfinder
    .help = "Parameters used in the spot finding algorithm."
  {
    include scope dials.data.lookup.phil_scope

    write_hot_mask = False
      .type = bool
      .help = "Write the hot mask"

    scan_range = None
      .help = "The range of images to use in finding spots. Number of arguments"
              "must be a factor of two. Specifying \"0 0\" will use all images"
              "by default. The given range follows C conventions"
              "(e.g. j0 <= j < j1)."
              "For sweeps the scan range is interpreted as the literal scan"
              "range. Whereas for imagesets the scan range is interpreted as"
              "the image number in the imageset"
      .type = ints(size=2)
      .multiple = True

    region_of_interest = None
      .type = ints(size=4)
      .help = "A region of interest to look for spots."
              "Specified as: x0,x1,y0,y1"
              "The pixels x0 and y0 are included in the range but the pixels x1 and y1"
              "are not. To specify an ROI covering the whole image set"
              "region_of_interest=0,width,0,height."

    filter
      .help = "Parameters used in the spot finding filter strategy."

    {
      min_spot_size = Auto
        .help = "The minimum number of contiguous pixels for a spot"
                "to be accepted by the filtering algorithm."
        .type = int(value_min=1)

      max_spot_size = 100
        .help = "The maximum number of contiguous pixels for a spot"
                "to be accepted by the filtering algorithm."
        .type = int(value_min=1)

      max_separation = 2
        .help = "The maximum peak-to-centroid separation (in pixels)"
                "for a spot to be accepted by the filtering algorithm."
        .type = float(value_min=0)
        .expert_level = 1

      max_strong_pixel_fraction = 0.25
        .help = "If the fraction of pixels in an image marked as strong is"
                "greater than this value, throw an exception"
        .type = float(value_min=0, value_max=1)

      background_gradient
        .expert_level=2
      {
        filter = False
          .type = bool
        background_size = 2
          .type = int(value_min=1)
        gradient_cutoff = 4
          .type = float(value_min=0)
      }

      spot_density
        .expert_level=2
      {
        filter = False
          .type = bool
      }

      include scope dials.util.masking.phil_scope
    }

    mp {
      method = *multiprocessing sge lsf pbs
        .type = choice
        .help = "The multiprocessing method to use"

      nproc = 1
        .type = int(value_min=1)
        .help = "The number of processes to use."

      chunksize = 20
        .type = int(value_min=1)
        .help = "The number of jobs to process per process"
    }
  }

  ''', process_includes=True)

  main_scope = phil_scope.get_without_substitution("spotfinder")
  assert(len(main_scope) == 1)
  main_scope = main_scope[0]
  main_scope.adopt_scope(SpotFinderThresholdIface.phil_scope())
  return phil_scope
Example #7
0
def generate_phil_scope():
    from iotbx.phil import parse
    import dials.extensions  # import dependency
    from dials.interfaces import SpotFinderThresholdIface

    phil_scope = parse('''

  spotfinder
    .help = "Parameters used in the spot finding algorithm."
  {
    include scope dials.data.lookup.phil_scope

    write_hot_mask = False
      .type = bool
      .help = "Write the hot mask"

    hot_mask_prefix = 'hot_mask'
      .type = str
      .help = "Prefix for the hot mask pickle file"

    force_2d = False
      .type = bool
      .help = "Do spot finding in 2D"

    scan_range = None
      .help = "The range of images to use in finding spots. Number of arguments"
              "must be a factor of two. Specifying \"0 0\" will use all images"
              "by default. The given range follows C conventions"
              "(e.g. j0 <= j < j1)."
              "For sweeps the scan range is interpreted as the literal scan"
              "range. Whereas for imagesets the scan range is interpreted as"
              "the image number in the imageset"
      .type = ints(size=2)
      .multiple = True

    region_of_interest = None
      .type = ints(size=4)
      .help = "A region of interest to look for spots."
              "Specified as: x0,x1,y0,y1"
              "The pixels x0 and y0 are included in the range but the pixels x1 and y1"
              "are not. To specify an ROI covering the whole image set"
              "region_of_interest=0,width,0,height."

    compute_mean_background = False
      .type = bool
      .help = "Compute the mean background for each image"

    filter
      .help = "Parameters used in the spot finding filter strategy."

    {
      min_spot_size = Auto
        .help = "The minimum number of contiguous pixels for a spot"
                "to be accepted by the filtering algorithm."
        .type = int(value_min=1)

      max_spot_size = 100
        .help = "The maximum number of contiguous pixels for a spot"
                "to be accepted by the filtering algorithm."
        .type = int(value_min=1)

      max_separation = 2
        .help = "The maximum peak-to-centroid separation (in pixels)"
                "for a spot to be accepted by the filtering algorithm."
        .type = float(value_min=0)
        .expert_level = 1

      max_strong_pixel_fraction = 0.25
        .help = "If the fraction of pixels in an image marked as strong is"
                "greater than this value, throw an exception"
        .type = float(value_min=0, value_max=1)

      background_gradient
        .expert_level=2
      {
        filter = False
          .type = bool
        background_size = 2
          .type = int(value_min=1)
        gradient_cutoff = 4
          .type = float(value_min=0)
      }

      spot_density
        .expert_level=2
      {
        filter = False
          .type = bool
      }

      include scope dials.util.masking.phil_scope
    }

    mp {
      method = *none drmaa sge lsf pbs
        .type = choice
        .help = "The cluster method to use"

      njobs = 1
        .type = int(value_min=1)
        .help = "The number of cluster jobs to use"

      nproc = 1
        .type = int(value_min=1)
        .help = "The number of processes to use per cluster job"

      chunksize = auto
        .type = int(value_min=1)
        .help = "The number of jobs to process per process"

      min_chunksize = 20
        .type = int(value_min=1)
        .help = "When chunksize is auto, this is the minimum chunksize"
    }
  }

  ''',
                       process_includes=True)

    main_scope = phil_scope.get_without_substitution("spotfinder")
    assert (len(main_scope) == 1)
    main_scope = main_scope[0]
    main_scope.adopt_scope(SpotFinderThresholdIface.phil_scope())
    return phil_scope