Beispiel #1
0
    def __init__(self, spot_resolutions, firstBinCount, fractionCalculator,
                 image):
        RingFinder.__init__(self, spot_resolutions, firstBinCount,
                            fractionCalculator)
        # use Hough transform to locate ellipses
        frame = hough()
        frame.importData(image.linearintdata, image.pixel_size)
        frame.setGeometry(float(fractionCalculator.pd['xbeam']),
                          float(fractionCalculator.pd['ybeam']),
                          float(fractionCalculator.pd['distance']),
                          float(fractionCalculator.pd['twotheta']))
        frame.cannyEdge(2, 0.95, 0.97)
        frame.findEllipse(2, 750.0, 3.5)
        self.rings = frame.getRings()
        self.col = 7
        self.nRings = len(self.rings) // self.col

        # add ellipses to existing list of rings
        for i in xrange(self.nRings):
            res = radius_to_resol(
                self.rings[i * self.col + 6] * image.pixel_size,
                fractionCalculator.pd)
            RingFinder.add_interval(self, (res + 0.015, res - 0.015))

        # ensure that rings from hough are definitely ice rings
        self.impact = flex.int([0] * len(self.intervals))
        for i in xrange(len(self.intervals)):
            for j in xrange(self.nRings):
                res = radius_to_resol(
                    self.rings[j * self.col + 6] * image.pixel_size,
                    fractionCalculator.pd)
                if (res <= self.intervals[i][0]
                        and res >= self.intervals[i][1]):
                    self.impact[i] = 15
Beispiel #2
0
  def __init__(self,spot_resolutions,firstBinCount,fractionCalculator,
               image):
    RingFinder.__init__(self,spot_resolutions,firstBinCount,fractionCalculator)
    # use Hough transform to locate ellipses
    frame = hough()
    frame.importData(image.linearintdata,image.pixel_size)
    frame.setGeometry( float(fractionCalculator.pd['xbeam']),
                       float(fractionCalculator.pd['ybeam']),
                       float(fractionCalculator.pd['distance']),
                       float(fractionCalculator.pd['twotheta']) )
    frame.cannyEdge(2,0.95,0.97)
    frame.findEllipse(2,750.0,3.5)
    self.rings = frame.getRings()
    self.col = 7
    self.nRings = len(self.rings)//self.col

    # add ellipses to existing list of rings
    for i in xrange(self.nRings):
      res = radius_to_resol(self.rings[i*self.col+6]*image.pixel_size,
                            fractionCalculator.pd)
      RingFinder.add_interval(self,(res+0.015,res-0.015))

    # ensure that rings from hough are definitely ice rings
    self.impact = flex.int([0]*len(self.intervals))
    for i in xrange(len(self.intervals)):
      for j in xrange(self.nRings):
        res = radius_to_resol(self.rings[j*self.col+6]*image.pixel_size,
                              fractionCalculator.pd)
        if (res <= self.intervals[i][0] and
            res >= self.intervals[i][1]):
          self.impact[i] = 15
Beispiel #3
0
  def determine_maxcell(self,frame,pd):
    if self.phil_params.codecamp.maxcell != None:
      self.images[frame]['maxcel']=self.phil_params.codecamp.maxcell
      return
    if self.images[frame]['N_spots_inlier']>2:
      neighbors   = self.images[frame]['neighbors']
      n_ave,n_std = scitbx_stats(neighbors)

      average_nearest_neighbor = n_ave

      NNBIN = self.NspotMin//2 # recommended bin size for nearest neighbor histogram
      peak_of_interest = n_ave

      for pss in xrange(1):  #make two passes thru histo

        fineness = max( [self.pixel_size / 2.,
          peak_of_interest / (1.0+float(len(neighbors))/float(NNBIN))] )
        min_neighbors = min(neighbors)

        def histo_index_to_mm(index):
          return min_neighbors+index*fineness

        #neighbor_histogram
        histogram = [0]*int(peak_of_interest*4/fineness)
        for y in neighbors:
          ibin = int( (y-min_neighbors)/fineness )
          if ibin < len(histogram):
            histogram[ibin]+=1

        if TALLY2:
          for row in xrange(len(histogram)):
            low = histo_index_to_mm(row)
            hi  = histo_index_to_mm(row+1)
            print "%.2f to %.2f, %5.1f Ang"%(low,hi,radius_to_resol(histo_index_to_mm(row+.5),pd)),
            print "*"*histogram[row],
            print

        most_probable_neighbor = histo_index_to_mm(0.5 + histogram.index(max(histogram)))

        #Compute yet another measure of unit cell--first peak in histogram
        peak1 = 0; peak1i = 0
        for peakpt in xrange(len(histogram)):
          if histogram[peakpt]>peak1i:
            peak1=peakpt; peak1i=histogram[peakpt]
          if histogram[peakpt]<0.5*peak1i and peak1i> 0.1*(max(histogram)):
            break

        first_peak_if_any = histo_index_to_mm(0.5 + peak1)
        peak_of_interest = min(first_peak_if_any,most_probable_neighbor)

        # Another trial measure: 5th percentile neighbor
        sort_perm = flex.sort_permutation(neighbors)
        cutoff_mm = neighbors[sort_perm[ int(0.05*len(sort_perm)) ]]

      #Caveat: this rough calculation becomes less accurate for non-zero two-theta
      self.images[frame]['neighboring_spot_separation']=min(most_probable_neighbor , cutoff_mm)
      MAXTOL = 1.5 # Margin of error for max unit cell estimate
                   # 11/19/02 old value 1.4; new value 2.0 to accomodate a
                   #   pathological case where zone is down the large unit cell.
                   #   Larger value is now tolerable because of post-mosflm
                   #   check for systematic absences.
                   # 9/28/03 change back to 1.5 with new autoindexer because
                   #   value of 2.0 can (infrequently) lead to misindexing;
                   #   based on experience preparing figure 4.
      maxcell = max(MAXTOL * radius_to_resol(most_probable_neighbor,pd),
                    0.0    * radius_to_resol(min(neighbors),pd),
                    0.0    * radius_to_resol(first_peak_if_any,pd),
                    MAXTOL * radius_to_resol(cutoff_mm,pd))
      self.images[frame]['maxcel']=maxcell