跨通道聚类改用拟合中心:通道间偏差超过 --group-tol 就分成两条峰
检测位置只差 1 px、但 R/G 拟合中心差了 6 px 的那种线,以前会被合成一条; 现在按拟合中心聚类,分开后可在 pick 里按 m 手动合并。
This commit is contained in:
1 parent
5ed1733ccc
commit
31e41f6519
1 file changed
+4
-4
+4
-4
@@ -801,10 +801,10 @@ def group_channels(peaks: dict[str, list[dict]], tolerance_px: float,
|
|||||||
merge_tolerance_px: float = 1.5) -> list[dict]:
|
merge_tolerance_px: float = 1.5) -> list[dict]:
|
||||||
"""Merge per-channel peaks that belong to the same spectral line."""
|
"""Merge per-channel peaks that belong to the same spectral line."""
|
||||||
|
|
||||||
# Cluster on the detected local maxima, not on the fitted centres: a single
|
# Cluster on the fitted centres: if two channels put the line more than
|
||||||
# peak fit inside a blend is pulled towards its neighbour and would wrongly
|
# `tolerance_px` apart they are not the same feature, and the user can still
|
||||||
# merge two resolved lines.
|
# join them by hand in the picker (m).
|
||||||
flat = [(item["sensor_x_px"], channel, item)
|
flat = [(item.get("center_px", item["sensor_x_px"]), channel, item)
|
||||||
for channel, items in peaks.items() for item in items]
|
for channel, items in peaks.items() for item in items]
|
||||||
flat.sort(key=lambda row: row[0])
|
flat.sort(key=lambda row: row[0])
|
||||||
groups: list[list[tuple[float, str, dict]]] = []
|
groups: list[list[tuple[float, str, dict]]] = []
|
||||||
|
|||||||
Reference in new issue
Block a user