Refactor/parallel and dedup #1
+13
-10
@@ -2540,16 +2540,19 @@ class SrasViewerWindow(QMainWindow):
|
|||||||
ref_idx = 0
|
ref_idx = 0
|
||||||
threshold_mv = self.spin_threshold_mv.value()
|
threshold_mv = self.spin_threshold_mv.value()
|
||||||
seed: dict[int, ManualAngleParams] = {}
|
seed: dict[int, ManualAngleParams] = {}
|
||||||
if (self._alignment_result is not None
|
# Seed only from a previously *saved manual* alignment (this dialog's
|
||||||
and self._alignment_result.ref_angle_idx == ref_idx):
|
# own Save also writes this sidecar) -- never from self._alignment_result
|
||||||
seed = {a: ManualAngleParams(t.rotation_deg, t.shift_mm)
|
# when it holds the automatic Fusion -> Angle Alignment's output. That
|
||||||
for a, t in self._alignment_result.per_angle.items()}
|
# path's translation comes from FFT phase correlation, which is the
|
||||||
threshold_mv = self._alignment_result.dc_threshold_mv
|
# very thing manual mode exists to work around; inheriting it here
|
||||||
else:
|
# would silently reintroduce the same bad translations under a
|
||||||
sidecar = load_manual_alignment(self._sras)
|
# "manual" label, on top of the (correct) analytic rotation, which is
|
||||||
if sidecar is not None and sidecar.ref_angle_idx == ref_idx:
|
# exactly what makes manual mode look like it "still does the same
|
||||||
seed = dict(sidecar.per_angle)
|
# thing" the automatic one does.
|
||||||
threshold_mv = sidecar.dc_threshold_mv
|
sidecar = load_manual_alignment(self._sras)
|
||||||
|
if sidecar is not None and sidecar.ref_angle_idx == ref_idx:
|
||||||
|
seed = dict(sidecar.per_angle)
|
||||||
|
threshold_mv = sidecar.dc_threshold_mv
|
||||||
|
|
||||||
cached_dc4 = {a: img for (a, ch), img in self._dc_cache.items() if ch == CH4_IDX}
|
cached_dc4 = {a: img for (a, ch), img in self._dc_cache.items() if ch == CH4_IDX}
|
||||||
dlg = ManualAlignmentDialog(
|
dlg = ManualAlignmentDialog(
|
||||||
|
|||||||
+10
-9
@@ -278,20 +278,21 @@ def main():
|
|||||||
-(float(s.angles_deg[a]) - float(s.angles_deg[0])))
|
-(float(s.angles_deg[a]) - float(s.angles_deg[0])))
|
||||||
for a in range(s.n_angles)))
|
for a in range(s.n_angles)))
|
||||||
|
|
||||||
# --- Open, seeding from the still-live automatic AlignmentResult --------
|
# --- Open: must NOT seed from the still-live automatic AlignmentResult --
|
||||||
|
# The automatic result's translation comes from FFT phase correlation --
|
||||||
|
# the very thing manual mode exists to work around -- so manual mode
|
||||||
|
# must start from identity (centroids coincide, zero shift) regardless
|
||||||
|
# of whatever the automatic run last computed. Only a previously *saved
|
||||||
|
# manual* alignment (sidecar) should ever seed this dialog.
|
||||||
win._on_manual_alignment()
|
win._on_manual_alignment()
|
||||||
check("dialog opened", win._manual_align_dialog is not None)
|
check("dialog opened", win._manual_align_dialog is not None)
|
||||||
dlg = win._manual_align_dialog
|
dlg = win._manual_align_dialog
|
||||||
check("mask prep needed no background worker (already DC-cached)",
|
check("mask prep needed no background worker (already DC-cached)",
|
||||||
not win._job_running("manual_align_masks"))
|
not win._job_running("manual_align_masks"))
|
||||||
r = win._alignment_result # still the automatic result from the block above
|
check("no manual sidecar yet -> dialog starts at identity, not the "
|
||||||
if r is not None:
|
"automatic result",
|
||||||
check("seeded rotation matches the automatic result",
|
all(dlg._angle_params[a] == compute.ManualAngleParams()
|
||||||
all(dlg._angle_params[a].rotation_deg == r.per_angle[a].rotation_deg
|
for a in range(s.n_angles)))
|
||||||
for a in range(s.n_angles)))
|
|
||||||
check("seeded shift matches the automatic result",
|
|
||||||
all(dlg._angle_params[a].shift_mm == r.per_angle[a].shift_mm
|
|
||||||
for a in range(s.n_angles)))
|
|
||||||
|
|
||||||
# --- Reference angle is locked -------------------------------------------
|
# --- Reference angle is locked -------------------------------------------
|
||||||
dlg.combo_active_angle.setCurrentIndex(dlg._ref_angle_idx)
|
dlg.combo_active_angle.setCurrentIndex(dlg._ref_angle_idx)
|
||||||
|
|||||||
Reference in New Issue
Block a user