diff --git a/README.md b/README.md index 97f8438..f3ee580 100644 --- a/README.md +++ b/README.md @@ -136,7 +136,9 @@ options: streak is no more than ``sf_xtol``. Algorithm Output: - * `'number_of_streaks': int` - Indicates the count of identified peaks. + * `'number_of_streaks': int` - Indicates the count of identified streaks. + * `'streak_lengths': list[float]` - Provides the lengths of identified streaks. + * `'bragg_counts': list[float]` - Provides the intensity sum within identified streaks. * `'streaks': 4*list[float]` - Provides coordinates of the identified streaks: x0, y0, x1, y1 * **Radial Profile Integration** diff --git a/dap/algos/streakfind.py b/dap/algos/streakfind.py index 14d7cdc..9b66bfb 100644 --- a/dap/algos/streakfind.py +++ b/dap/algos/streakfind.py @@ -6,10 +6,13 @@ Requires Convergent beam streak finder package installed: https://github.com/simply-nicky/streak_finder (note g++ 11 required for building) """ +from math import sqrt, pow from streak_finder import PatternStreakFinder from streak_finder.label import Structure2D +from skimage.measure import profile_line + def calc_streakfinder_analysis(results, data, pixel_mask_sf): do_streakfinder_analysis = results.get("do_streakfinder_analysis", False) @@ -52,8 +55,14 @@ def calc_streakfinder_analysis(results, data, pixel_mask_sf): # Streak finding algorithm. Starting from the set of seed peaks, the lines are iteratively # extended with a connectivity structure. - streaks = psf.detect_streaks(peaks=peaks, xtol=xtol, vmin=vmin) - streak_lines = streaks.to_lines().T + streaks = psf.detect_streaks(peaks=peaks, xtol=xtol, vmin=vmin).to_lines() + streak_lengths = [] + bragg_counts = [] + for streak in streaks: + x0, y0, x1, y1 = streak + streak_lengths.append(sqrt(pow((x1 - x0), 2) + pow((y1 - y0), 2))) + bragg_counts.append(profile_line(data, (x0, y0), (x1, y1))) + streak_lines = streaks.T _, number_of_streaks = streak_lines.shape print(f"Found {number_of_streaks} streaks") list_result = [] @@ -61,3 +70,5 @@ def calc_streakfinder_analysis(results, data, pixel_mask_sf): list_result.append(line.tolist()) results.update({"number_of_streaks": number_of_streaks}) results.update({"streaks": list_result}) + results.update({"streak_lengths": streak_lengths}) + results.update({"bragg_counts": bragg_counts})