Exemple #1
0
    def integrate_cctbx(self, tag, grid_point=0, single_image=False):
        """ Runs integration using the Integrator class """

        # Check to see if the image is suitable for grid search / integration
        if self.fail != None:
            self.grid = []
            self.final['final'] = None
        else:
            from iota.components.iota_cctbx import Integrator
            integrator = Integrator(params=self.params,
                                    source_image=self.conv_img,
                                    output_image=self.fin_file,
                                    viz=self.viz_path,
                                    log=self.int_log,
                                    tag=tag,
                                    tmp_base=self.tmp_base,
                                    gain=self.gain,
                                    single_image=single_image)
            if tag == 'grid search':
                self.log_info.append('\nCCTBX grid search:')
                for i in range(len(self.grid)):

                    # If aborted from GUI
                    if os.path.isfile(self.abort_file):
                        self.fail = 'aborted'
                        return self

                    int_results = integrator.integrate(self.grid[i])
                    self.grid[i].update(int_results)
                    img_filename = os.path.basename(self.conv_img)
                    log_entry ='{:<{width}}: S = {:<3} H = {:<3} ' \
                               'A = {:<3} ---> {}'.format(img_filename,
                                self.grid[i]['sih'],
                                self.grid[i]['sph'],
                                self.grid[i]['spa'],
                                self.grid[i]['info'],
                                width = len(img_filename) + 2)
                    self.log_info.append(log_entry)
                    self.gs_results.append(log_entry)

                # Throw out grid search results that yielded no integration
                self.grid = [i for i in self.grid if "not integrated" not in i['info'] and\
                             "no data recorded" not in i['info']]
                self.status = 'grid search'

            elif tag == 'split grid':

                if os.path.isfile(self.abort_file):
                    self.fail = 'aborted'
                    return self

                self.log_info.append('\nCCTBX INTEGRATION grid search:')
                int_results = integrator.integrate(self.grid[grid_point])
                self.grid[grid_point].update(int_results)
                img_filename = os.path.basename(self.conv_img)
                log_entry ='{:<{width}}: S = {:<3} H = {:<3} ' \
                           'A = {:<3} ---> {}'.format(img_filename,
                                                      self.grid[grid_point]['sih'],
                                                      self.grid[grid_point]['sph'],
                                                      self.grid[grid_point]['spa'],
                                                      self.grid[grid_point]['info'],
                                                      width = len(img_filename) + 2)
                self.log_info.append(log_entry)
                self.gs_results.append(log_entry)

            elif tag == 'integrate':

                if os.path.isfile(self.abort_file):
                    self.fail = 'aborted'
                    return self

                self.log_info.append('\nCCTBX final integration:')
                final_results = integrator.integrate(self.final)
                self.final.update(final_results)
                self.status = 'final'
                img_filename = os.path.basename(self.conv_img)
                log_entry ='{:<{width}}: S = {:<3} H = {:<3} ' \
                           'A = {:<3} ---> {}'.format(img_filename,
                            self.final['sih'],
                            self.final['sph'],
                            self.final['spa'],
                            self.final['info'],
                            width = len(img_filename) + 2)
                self.log_info.append(log_entry)

                if self.params.analysis.viz == 'integration':
                    viz.make_png(self.final['img'], self.final['final'],
                                 self.viz_file)
                elif self.params.analysis.viz == 'cv_vectors':
                    viz.cv_png(self.final['img'], self.final['final'],
                               self.viz_file)

            # Save image object to file
            ep.dump(self.obj_file, self)

        return self
Exemple #2
0
  def integrate_cctbx(self, tag, grid_point=0, single_image=False):
    """ Runs integration using the Integrator class """

    # Check to see if the image is suitable for grid search / integration
    if self.fail != None:
      self.grid = []
      self.final['final'] = None
    else:
      from iota.components.iota_cctbx import Integrator
      integrator = Integrator(self.conv_img,
                              self.fin_file,
                              self.params.cctbx.selection.min_sigma,
                              self.params.cctbx.target,
                              self.params.analysis.charts,
                              self.viz_path,
                              self.int_log,
                              tag,
                              self.tmp_base,
                              self.gain,
                              self.params.mp_method,
                              self.params.mp_queue,
                              single_image)
      if tag == 'grid search':
        self.log_info.append('\nCCTBX grid search:')
        for i in range(len(self.grid)):

          # If aborted from GUI
          if os.path.isfile(self.abort_file):
            self.fail = 'aborted'
            return self

          int_results = integrator.integrate(self.grid[i])
          self.grid[i].update(int_results)
          img_filename = os.path.basename(self.conv_img)
          log_entry ='{:<{width}}: S = {:<3} H = {:<3} ' \
                     'A = {:<3} ---> {}'.format(img_filename,
                      self.grid[i]['sih'],
                      self.grid[i]['sph'],
                      self.grid[i]['spa'],
                      self.grid[i]['info'],
                      width = len(img_filename) + 2)
          self.log_info.append(log_entry)
          self.gs_results.append(log_entry)

        # Throw out grid search results that yielded no integration
        self.grid = [i for i in self.grid if "not integrated" not in i['info'] and\
                     "no data recorded" not in i['info']]
        self.status = 'grid search'

      elif tag == 'split grid':

        if os.path.isfile(self.abort_file):
          self.fail = 'aborted'
          return self

        self.log_info.append('\nCCTBX INTEGRATION grid search:')
        int_results = integrator.integrate(self.grid[grid_point])
        self.grid[grid_point].update(int_results)
        img_filename = os.path.basename(self.conv_img)
        log_entry ='{:<{width}}: S = {:<3} H = {:<3} ' \
                   'A = {:<3} ---> {}'.format(img_filename,
                                              self.grid[grid_point]['sih'],
                                              self.grid[grid_point]['sph'],
                                              self.grid[grid_point]['spa'],
                                              self.grid[grid_point]['info'],
                                              width = len(img_filename) + 2)
        self.log_info.append(log_entry)
        self.gs_results.append(log_entry)

      elif tag == 'integrate':

        if os.path.isfile(self.abort_file):
          self.fail = 'aborted'
          return self

        self.log_info.append('\nCCTBX final integration:')
        final_results = integrator.integrate(self.final)
        self.final.update(final_results)
        self.status = 'final'
        img_filename = os.path.basename(self.conv_img)
        log_entry ='{:<{width}}: S = {:<3} H = {:<3} ' \
                   'A = {:<3} ---> {}'.format(img_filename,
                    self.final['sih'],
                    self.final['sph'],
                    self.final['spa'],
                    self.final['info'],
                    width = len(img_filename) + 2)
        self.log_info.append(log_entry)

        if self.params.analysis.viz == 'integration':
          viz.make_png(self.final['img'], self.final['final'], self.viz_file)
        elif self.params.analysis.viz == 'cv_vectors':
          viz.cv_png(self.final['img'], self.final['final'], self.viz_file)

      # Save image object to file
      ep.dump(self.obj_file, self)

    return self