Streak Finder algorithm for CBD experiment #2

Merged
augustin_s merged 46 commits from ext-dorofe_e/dap:chapman into main 2025-07-14 11:18:07 +02:00
2 changed files with 16 additions and 3 deletions
Showing only changes of commit 0962f48349 - Show all commits

View File

@@ -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**

View File

@@ -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})