def to_ewald_sphere(list_of_images):

    from dxtbx.sweep import SweepFactory
    from dxtbx import ImageToEwaldSphere

    sweep = SweepFactory.sweep(list_of_images)
    beam = sweep.get_beam()
    detector = sweep.get_detector()
    gonio = sweep.get_goniometer()
    scan = sweep.get_scan()
    start, end = sweep.get_array_range()
    image_to_ewald_sphere = ImageToEwaldSphere(beam, detector, gonio, scan)

    for frame in range(start, end):
        intensity = sweep[frame]
        x_list = image_to_ewald_sphere(frame)
        for k, x in enumerate(x_list):
            i = intensity[k]
            print("%f %f %f %d" % (x[0], x[1], x[2], i))
示例#2
0
def to_ewald_sphere(list_of_images):

  from dxtbx.sweep import SweepFactory
  from dxtbx import ImageToEwaldSphere

  sweep = SweepFactory.sweep(list_of_images)
  beam = sweep.get_beam()
  detector = sweep.get_detector()
  gonio = sweep.get_goniometer()
  scan = sweep.get_scan()
  start, end = sweep.get_array_range()
  image_to_ewald_sphere = ImageToEwaldSphere(beam, detector, gonio, scan)

  for frame in xrange(start, end):
    intensity = sweep[frame]
    x_list = image_to_ewald_sphere(frame)
    for k, x in enumerate(x_list):
      i = intensity[k]
      print '%f %f %f %d' % (x[0], x[1], x[2], i)
  handle = NexusFile(filename, 'r')

  # Get the reflection list
  print 'Reading reflections.'
  reflections = handle.get_reflections()
  print 'Read {0} reflections.'.format(len(reflections))

  # Read images
  template = os.path.join(dials_regression,
      'centroid_test_data', 'centroid_*.cbf')
  #template = os.path.join('/home/upc86896/Data/X1_strong_M1S1_1_', 'X1_strong_M1S1_1_*.cbf')
  filenames = glob(template)

  # Load the sweep
  print 'Loading sweep'
  sweep = SweepFactory.sweep(filenames)[0:10]
  print 'Loaded sweep of {0} images.'.format(len(sweep))

  # Select the strong pixels to use in the divergence calculation
  print 'Select the strong pixels from the images.'
  trusted_range = (0, 20000)
  image, mask = select_strong_pixels(sweep, trusted_range)

  # Putting pixels into groups
  print 'Putting pixels into groups'
  objects = group_pixels(mask)
  print 'Found {0} objects'.format(len(objects))

  print 'Filtering objects'
  min_pixels = 6
  objects = filter_objects(mask, objects, min_pixels)
示例#4
0
if __name__ == "__main__":
    from dxtbx.sweep import SweepFactory
    from glob import glob
    from scipy.ndimage.measurements import histogram
    import numpy
    from scitbx.array_family import flex
    from thresholding import maximum_deviation
    from thresholding import percentage_threshold
    from thresholding import normal_threshold

    # filenames = glob("/home/upc86896/Data/X1_strong_M1S1_1_/X1_strong_M1S1_1_*.cbf")
    filenames = glob(
        "/home/upc86896/Projects/cctbx/sources/dials_regression/centroid_test_data/centroid_000*.cbf"
    )
    sweep = SweepFactory.sweep(filenames)
    trusted_range = (0, 20000)

    histo = []
    threshold_list = []
    start = 0
    stop = 3
    for i, flex_image in enumerate(sweep[start:stop]):

        image = flex_image.as_numpy_array()

        image.shape = -1
        ind = numpy.where(image < trusted_range[0])
        image[ind] = trusted_range[0]
        ind = numpy.where(image > trusted_range[1])
        image[ind] = trusted_range[1]