def index_and_integrate_one(work_params, image_mdls_miller_indices, pixels): from rstbx.simage import run_spotfinder spots = run_spotfinder.process(work_params=work_params, pixels=pixels, show_spots=False) if (spots.size() < work_params.min_number_of_spots_for_indexing): print "Insufficient number of spots for indexing." print sys.stdout.flush() return (spots.size(), None) from rstbx.simage import run_labelit_index ai = run_labelit_index.process(work_params=work_params, spots=spots) good_i_seqs, miller_indices, co = run_labelit_index.report_uc_cr(ai) from rstbx.simage import refine_uc_cr refined = refine_uc_cr.refine( work_params=work_params, spots=spots, good_i_seqs=good_i_seqs, miller_indices=miller_indices, unit_cell=co.unit_cell(), crystal_rotation=co.crystal_rotation_matrix()) from rstbx.simage import integrate_crude predicted_spot_positions, \ predicted_spot_miller_index_i_seqs = integrate_crude.predict_spot_positions( work_params=work_params, miller_indices=image_mdls_miller_indices, unit_cell=refined.unit_cell, crystal_rotation=refined.crystal_rotation) print "Number of predicted spot positions:", predicted_spot_positions.size( ) print spot_intensities = integrate_crude.collect_spot_intensities( pixels=pixels, spot_positions=predicted_spot_positions, point_spread_inner=work_params.point_spread, point_spread_outer=work_params.point_spread + 4) sel = spot_intensities != 0 return ( spots.size(), image_model( spot_positions=predicted_spot_positions.select(sel), spot_intensities=spot_intensities.select(sel), miller_index_i_seqs=predicted_spot_miller_index_i_seqs.select(sel), unit_cell=refined.unit_cell, crystal_rotation=refined.crystal_rotation))
def index_and_integrate_one(work_params, image_mdls_miller_indices, pixels): from rstbx.simage import run_spotfinder spots = run_spotfinder.process( work_params=work_params, pixels=pixels, show_spots=False) if (spots.size() < work_params.min_number_of_spots_for_indexing): print "Insufficient number of spots for indexing." print sys.stdout.flush() return (spots.size(), None) from rstbx.simage import run_labelit_index ai = run_labelit_index.process(work_params=work_params, spots=spots) good_i_seqs, miller_indices, co = run_labelit_index.report_uc_cr(ai) from rstbx.simage import refine_uc_cr refined = refine_uc_cr.refine( work_params=work_params, spots=spots, good_i_seqs=good_i_seqs, miller_indices=miller_indices, unit_cell=co.unit_cell(), crystal_rotation=co.crystal_rotation_matrix()) from rstbx.simage import integrate_crude predicted_spot_positions, \ predicted_spot_miller_index_i_seqs = integrate_crude.predict_spot_positions( work_params=work_params, miller_indices=image_mdls_miller_indices, unit_cell=refined.unit_cell, crystal_rotation=refined.crystal_rotation) print "Number of predicted spot positions:", predicted_spot_positions.size() print spot_intensities = integrate_crude.collect_spot_intensities( pixels=pixels, spot_positions=predicted_spot_positions, point_spread_inner=work_params.point_spread, point_spread_outer=work_params.point_spread+4) sel = spot_intensities != 0 return ( spots.size(), image_model( spot_positions=predicted_spot_positions.select(sel), spot_intensities=spot_intensities.select(sel), miller_index_i_seqs=predicted_spot_miller_index_i_seqs.select(sel), unit_cell=refined.unit_cell, crystal_rotation=refined.crystal_rotation))
def run_labelit_index(O, use_original_uc_cr=False): if (O.spots is None): O.run_spotfinder() if (O.spots is None): return if (O.spots.size() < 10): print "Insufficient number of spotfinder spots." print return else: if (use_original_uc_cr): print print "Using original unit cell and crystal rotation" \ " for spot prediction." print uc = O.work_params.unit_cell cr = O.work_params.crystal_rotation_matrix else: from rstbx.simage.run_labelit_index import process try: ai = process(work_params=O.work_params, spots=O.spots) except Exception, e: print "Indexing exception:", e print return print "Spots indexed: %d of %d" % ( ai.hklobserved().size(), O.spots.size()) co = ai.getOrientation() uc = co.unit_cell() cr = co.crystal_rotation_matrix() print "labelit index unit cell:", uc from rstbx.simage import refine_uc_cr refined = refine_uc_cr.refine( work_params=O.work_params, spots=O.spots, good_i_seqs=ai.get_observed_spot_i_seqs_good_only(), miller_indices=ai.hklobserved(), unit_cell=uc, crystal_rotation=cr) uc = refined.unit_cell cr = refined.crystal_rotation print import cctbx.crystal crystal_symmetry = cctbx.crystal.symmetry( unit_cell=uc, space_group_symbol="P1") d_min = O.work_params.d_min if (d_min is None): d_min = O.work_params.wavelength import cctbx.miller miller_set = cctbx.miller.build_set( crystal_symmetry=crystal_symmetry, d_min=d_min, anomalous_flag=True) from rstbx.simage import image_simple O.predicted_spots = image_simple(store_spots=True).compute( unit_cell=miller_set.unit_cell(), miller_indices=miller_set.indices(), spot_intensity_factors=None, crystal_rotation_matrix=cr, ewald_radius=1/O.work_params.wavelength, ewald_proximity=O.work_params.ewald_proximity, signal_max=O.work_params.signal_max, detector_distance=O.work_params.detector.distance, detector_size=O.work_params.detector.size, detector_pixels=O.work_params.detector.pixels, point_spread=O.work_params.point_spread, gaussian_falloff_scale=O.work_params.gaussian_falloff_scale).spots print "Number of predicted spots:", O.predicted_spots.size() print
def run_labelit_index(O, use_original_uc_cr=False): if (O.spots is None): O.run_spotfinder() if (O.spots is None): return if (O.spots.size() < 10): print("Insufficient number of spotfinder spots.") print() return else: if (use_original_uc_cr): print() print("Using original unit cell and crystal rotation" \ " for spot prediction.") print() uc = O.work_params.unit_cell cr = O.work_params.crystal_rotation_matrix else: from rstbx.simage.run_labelit_index import process try: ai = process(work_params=O.work_params, spots=O.spots) except Exception as e: print("Indexing exception:", e) print() return print("Spots indexed: %d of %d" % (ai.hklobserved().size(), O.spots.size())) co = ai.getOrientation() uc = co.unit_cell() cr = co.crystal_rotation_matrix() print("labelit index unit cell:", uc) from rstbx.simage import refine_uc_cr refined = refine_uc_cr.refine( work_params=O.work_params, spots=O.spots, good_i_seqs=ai.get_observed_spot_i_seqs_good_only(), miller_indices=ai.hklobserved(), unit_cell=uc, crystal_rotation=cr) uc = refined.unit_cell cr = refined.crystal_rotation print() import cctbx.crystal crystal_symmetry = cctbx.crystal.symmetry(unit_cell=uc, space_group_symbol="P1") d_min = O.work_params.d_min if (d_min is None): d_min = O.work_params.wavelength import cctbx.miller miller_set = cctbx.miller.build_set( crystal_symmetry=crystal_symmetry, d_min=d_min, anomalous_flag=True) from rstbx.simage import image_simple O.predicted_spots = image_simple(store_spots=True).compute( unit_cell=miller_set.unit_cell(), miller_indices=miller_set.indices(), spot_intensity_factors=None, crystal_rotation_matrix=cr, ewald_radius=1 / O.work_params.wavelength, ewald_proximity=O.work_params.ewald_proximity, signal_max=O.work_params.signal_max, detector_distance=O.work_params.detector.distance, detector_size=O.work_params.detector.size, detector_pixels=O.work_params.detector.pixels, point_spread=O.work_params.point_spread, gaussian_falloff_scale=O.work_params.gaussian_falloff_scale ).spots print("Number of predicted spots:", O.predicted_spots.size()) print() O.Refresh()