From ff532af0d6624d713bc5f461cf7c33f8a16c2a2e Mon Sep 17 00:00:00 2001 From: Lisa Dorofeeva Date: Fri, 4 Jul 2025 11:14:32 +0200 Subject: [PATCH] Chane image in-place if snr selected; Use concentric mask --- dap/algos/streakfind.py | 7 ++++--- dap/worker.py | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/dap/algos/streakfind.py b/dap/algos/streakfind.py index ee47f1f..8e99e07 100644 --- a/dap/algos/streakfind.py +++ b/dap/algos/streakfind.py @@ -148,9 +148,9 @@ def _calc_streakfinder_analysis(results, cryst_data: CrystData): streaks = det_obj.to_streaks(detected) if x_center is not None and y_center is not None: - streaks = streaks.concentric_only(x_center, y_center) + streaks_mask = streaks.concentric_only(x_center, y_center) - streak_lines = streaks.lines + streak_lines = streaks.lines[streaks_mask] streak_lengths = np.sqrt( np.pow((streak_lines[..., 2] - streak_lines[..., 0]), 2) + np.pow((streak_lines[..., 2] - streak_lines[..., 0]), 2) @@ -161,7 +161,8 @@ def _calc_streakfinder_analysis(results, cryst_data: CrystData): print(f"Found {number_of_streaks} streaks") list_result = [line.tolist() for line in streak_lines] # arr(4, n_lines); 0coord x0, y0, x1, y1 - bragg_counts = [streak.total_mass() for streak in detected.streaks.values()] + detected_streaks = np.asarray(detected.streaks.values())[streaks_mask] + bragg_counts = [streak.total_mass() for streak in detected_streaks] results.update({"number_of_streaks": number_of_streaks}) results.update({"is_hit_frame": number_of_streaks > 0}) diff --git a/dap/worker.py b/dap/worker.py index 8ea7e66..02f0c0b 100644 --- a/dap/worker.py +++ b/dap/worker.py @@ -121,7 +121,7 @@ def work(backend_address, accumulator_host, accumulator_port, visualisation_host print(f"Applying whitefield correction") calc_apply_whitefield_correction(results, image) # changes image in place print(f"Searching streaks") - calc_streakfinder_analysis(results, image, pixel_mask_pf) + image = calc_streakfinder_analysis(results, image, pixel_mask_pf) # changes image in place is do_snr=True print(f"Done\n{results=}") image, aggregation_is_ready = calc_apply_aggregation(results, image, pixel_mask_pf, aggregator)