def identify_outliers(self, params, experiments, indexed): if not params.indexing.stills.candidate_outlier_rejection: return flex.bool(len(indexed), True) logger.info("$$$ stills_indexer::identify_outliers") refiner = e_refine(params, experiments, indexed, graph_verbose=False) RR = refiner.predict_for_reflection_table(indexed) px_sz = experiments[0].detector[0].get_pixel_size() class Match(object): pass matches = [] for item in RR.rows(): m = Match() m.x_obs = item["xyzobs.px.value"][0] * px_sz[0] m.y_obs = item["xyzobs.px.value"][1] * px_sz[1] m.x_calc = item["xyzcal.px"][0] * px_sz[0] m.y_calc = item["xyzcal.px"][1] * px_sz[1] m.miller_index = item["miller_index"] matches.append(m) from rstbx.phil.phil_preferences import indexing_api_defs import iotbx.phil hardcoded_phil = iotbx.phil.parse(input_string=indexing_api_defs).extract() from rstbx.indexing_api.outlier_procedure import OutlierPlotPDF # comment this in if PDF graph is desired: # hardcoded_phil.indexing.outlier_detection.pdf = "outlier.pdf" # new code for outlier rejection inline here if hardcoded_phil.indexing.outlier_detection.pdf is not None: hardcoded_phil.__inject__( "writer", OutlierPlotPDF(hardcoded_phil.indexing.outlier_detection.pdf) ) # execute Sauter and Poon (2010) algorithm from rstbx.indexing_api import outlier_detection od = outlier_detection.find_outliers_from_matches( matches, verbose=True, horizon_phil=hardcoded_phil ) if hardcoded_phil.indexing.outlier_detection.pdf is not None: od.make_graphs(canvas=hardcoded_phil.writer.R.c, left_margin=0.5) hardcoded_phil.writer.R.c.showPage() hardcoded_phil.writer.R.c.save() return od.get_cache_status()
def _detect_outliers(self, cols): # cols is guaranteed to be a list of three flex arrays, containing miller # indices, observed pixel coordinates and calculated pixel coordinates. # Copy the data into matches class match: pass matches = [] for hkl in cols[0]: m = match() m.miller_index = hkl matches.append(m) for obs, m in zip(cols[1], matches): m.x_obs = obs[0] * self._px_sz[0] m.y_obs = obs[1] * self._px_sz[1] for calc, m in zip(cols[2], matches): m.x_calc = calc[0] * self._px_sz[0] m.y_calc = calc[1] * self._px_sz[1] import iotbx.phil from rstbx.phil.phil_preferences import indexing_api_defs hardcoded_phil = iotbx.phil.parse( input_string=indexing_api_defs).extract() # set params into the hardcoded_phil hardcoded_phil.indexing.outlier_detection.verbose = self._verbose hardcoded_phil.indexing.outlier_detection.pdf = self._pdf from rstbx.indexing_api.outlier_procedure import OutlierPlotPDF if self._pdf is not None: ## new code for outlier rejection inline here hardcoded_phil.__inject__( "writer", OutlierPlotPDF(hardcoded_phil.indexing.outlier_detection.pdf)) # execute Sauter and Poon (2010) algorithm from rstbx.indexing_api import outlier_detection od = outlier_detection.find_outliers_from_matches( matches, verbose=self._verbose, horizon_phil=hardcoded_phil) # flex.bool of the inliers outliers = ~od.get_cache_status() return outliers
def _detect_outliers(self, cols): # cols is guaranteed to be a list of three flex arrays, containing miller # indices, observed pixel coordinates and calculated pixel coordinates. # Copy the data into matches class match: pass matches = [] for hkl in cols[0]: m = match() m.miller_index = hkl matches.append(m) for obs, m in zip(cols[1], matches): m.x_obs = obs[0]*self._px_sz[0] m.y_obs = obs[1]*self._px_sz[1] for calc, m in zip(cols[2], matches): m.x_calc = calc[0]*self._px_sz[0] m.y_calc = calc[1]*self._px_sz[1] from rstbx.phil.phil_preferences import indexing_api_defs import iotbx.phil hardcoded_phil = iotbx.phil.parse( input_string=indexing_api_defs).extract() # set params into the hardcoded_phil hardcoded_phil.indexing.outlier_detection.verbose = self._verbose hardcoded_phil.indexing.outlier_detection.pdf = self._pdf from rstbx.indexing_api.outlier_procedure import OutlierPlotPDF if self._pdf is not None: ## new code for outlier rejection inline here hardcoded_phil.__inject__("writer",OutlierPlotPDF(hardcoded_phil.indexing.outlier_detection.pdf)) # execute Sauter and Poon (2010) algorithm from rstbx.indexing_api import outlier_detection hardcoded_phil = hardcoded_phil od = outlier_detection.find_outliers_from_matches( matches, verbose=self._verbose, horizon_phil=hardcoded_phil) # flex.bool of the inliers outliers = ~od.get_cache_status() return outliers
def identify_outliers(self, params, experiments, indexed): print "$$$ stills_indexer::identify_outliers" refiner = e_refine(params, experiments, indexed, graph_verbose=False) RR = refiner.predict_for_reflection_table(indexed) px_sz = experiments[0].detector[0].get_pixel_size() class match: pass matches = [] for item in RR: m = match() m.x_obs = item["xyzobs.px.value"][0]*px_sz[0] m.y_obs = item["xyzobs.px.value"][1]*px_sz[1] m.x_calc= item["xyzcal.px"][0]*px_sz[0] m.y_calc= item["xyzcal.px"][1]*px_sz[1] m.miller_index = item["miller_index"] matches.append(m) from rstbx.phil.phil_preferences import indexing_api_defs import iotbx.phil hardcoded_phil = iotbx.phil.parse( input_string=indexing_api_defs).extract() from rstbx.indexing_api.outlier_procedure import OutlierPlotPDF #comment this in if PDF graph is desired: #hardcoded_phil.indexing.outlier_detection.pdf = "outlier.pdf" # new code for outlier rejection inline here if hardcoded_phil.indexing.outlier_detection.pdf is not None: hardcoded_phil.__inject__("writer",OutlierPlotPDF(hardcoded_phil.indexing.outlier_detection.pdf)) # execute Sauter and Poon (2010) algorithm from rstbx.indexing_api import outlier_detection od = outlier_detection.find_outliers_from_matches( matches, verbose=True, horizon_phil=hardcoded_phil) if hardcoded_phil.indexing.outlier_detection.pdf is not None: od.make_graphs(canvas=hardcoded_phil.writer.R.c,left_margin=0.5) hardcoded_phil.writer.R.c.showPage() hardcoded_phil.writer.R.c.save() return od.get_cache_status()