Find_crystal: add new filter for 30% max spots.
This commit is contained in:
@@ -141,13 +141,13 @@ def create_quality_filtered_array(scan_results: List,
|
||||
Create array with comprehensive quality filtering
|
||||
"""
|
||||
|
||||
def quality_condition(result, max_spots_low_res, min_background, min_spots, min_efficiency, min_res_spots = 10.0):
|
||||
def quality_condition(result, max_spots_low_res, min_background, min_spots, min_efficiency, min_low_res_spots, max_filter: float = 0.3):
|
||||
if exclude_ice and (result.spots_ice / max(result.spots_low_res, 1.0)) == 1.0:
|
||||
# print(f"all ice for {result.number}")
|
||||
return False
|
||||
if min_low_res_spots and result.spots_low_res < min_low_res_spots:
|
||||
return False
|
||||
if result.spots_low_res < (max_spots_low_res * (30/100)):
|
||||
if result.spots_low_res < (max_spots_low_res * max_filter):
|
||||
return False
|
||||
if exclude_ice and result.spots_ice > result.spots * 0.8: # More than 50% ice
|
||||
# print(f"more than 80% ice for {result.number}")
|
||||
@@ -171,6 +171,8 @@ def create_quality_filtered_array(scan_results: List,
|
||||
|
||||
if min_spots is None:
|
||||
min_spots = min((result.spots for result in scan_results if result.spots is not None), default=1)
|
||||
if min_low_res_spots is None:
|
||||
min_low_res_spots = min((result.spots_low_res for result in scan_results if result.spots_low_res is not None), default=1)
|
||||
if min_background is None:
|
||||
min_background = min((result.bkg for result in scan_results if result.bkg is not None), default=1)
|
||||
if min_efficiency is None:
|
||||
@@ -180,7 +182,7 @@ def create_quality_filtered_array(scan_results: List,
|
||||
for result in scan_results:
|
||||
if result.nx is not None and result.ny is not None:
|
||||
if quality_condition(result, max_spots_low_res=max_spots_low_res, min_background=min_background, min_spots=min_spots,
|
||||
min_efficiency=min_efficiency, min_res_spots=min_low_res_spots):
|
||||
min_efficiency=min_efficiency, min_low_res_spots=min_low_res_spots):
|
||||
filtered_results.append(result)
|
||||
else:
|
||||
# Create a copy with zero value for filtered positions
|
||||
@@ -246,6 +248,8 @@ def get_best_res(result_list: List):
|
||||
best_res = min((img for img in result_list if img.res is not None),
|
||||
key=lambda img: img.res,
|
||||
default=None)
|
||||
if best_res is None:
|
||||
return None
|
||||
logger.info(f"Best res: {best_res.res}")
|
||||
return best_res.res
|
||||
|
||||
@@ -281,6 +285,8 @@ def get_grid_mm_from_com(com, r:RasterGridRequest):
|
||||
grid_mm_y = com[1] * r.grid_size_mm.y
|
||||
if r.n_x == 1:
|
||||
grid_mm_x += (0.5 * r.grid_size_mm.x)
|
||||
else:
|
||||
grid_mm_y += (0.5 * r.grid_size_mm.y)
|
||||
return grid_mm_x, grid_mm_y
|
||||
|
||||
|
||||
@@ -288,6 +294,5 @@ def raster_centre_of_mass(result_array, r:RasterGridRequest):
|
||||
com = ndimage.center_of_mass(result_array)
|
||||
logger.info(f"Center of mass: {com}")
|
||||
grid_mm_x, grid_mm_y = get_grid_mm_from_com(com, r)
|
||||
logger.debug("using spot count instead of COM")
|
||||
return grid_mm_x, grid_mm_y, com
|
||||
|
||||
|
||||
Reference in New Issue
Block a user