From 1174f7df6a23baff04fa452aaef93625238a0a84 Mon Sep 17 00:00:00 2001 From: Nikita Vladimirov Date: Fri, 27 Jan 2023 12:24:40 +0100 Subject: [PATCH] fix optimizer's first frame (clear image buffer) --- ..._logo_royalBlueLight1c.ico => mesoSPIM-logo.ico} | Bin mesoSPIM/src/mesoSPIM_Optimizer.py | 7 +++---- 2 files changed, 3 insertions(+), 4 deletions(-) rename mesoSPIM/gui/{SPIM_logo_royalBlueLight1c.ico => mesoSPIM-logo.ico} (100%) diff --git a/mesoSPIM/gui/SPIM_logo_royalBlueLight1c.ico b/mesoSPIM/gui/mesoSPIM-logo.ico similarity index 100% rename from mesoSPIM/gui/SPIM_logo_royalBlueLight1c.ico rename to mesoSPIM/gui/mesoSPIM-logo.ico diff --git a/mesoSPIM/src/mesoSPIM_Optimizer.py b/mesoSPIM/src/mesoSPIM_Optimizer.py index 69855ee..e5a0bdc 100644 --- a/mesoSPIM/src/mesoSPIM_Optimizer.py +++ b/mesoSPIM/src/mesoSPIM_Optimizer.py @@ -61,9 +61,6 @@ def set_image(self, image): self.image = image self.roi = self.image[self.roi_dims[1]:self.roi_dims[1] + self.roi_dims[3], self.roi_dims[0]:self.roi_dims[0] + self.roi_dims[2]] - # DEBUG mode, create new window for each snap - #roi_window = pg.ImageWindow() - #roi_window.setImage(self.roi) @QtCore.pyqtSlot(tuple) def get_roi_dims(self, roi_dims): @@ -173,6 +170,8 @@ def run_optimization(self): for i, v in enumerate(self.search_grid): self.set_state(v) time.sleep(self.delay_s) + if i == 0: + self.core.snap(write_flag=False, laser_blanking=True) # clears the first image from buffer self.core.snap(write_flag=False, laser_blanking=True) # this shares downsampled image via slot self.set_image() self.metric_array[i] = shannon_dct(self.roi) @@ -237,7 +236,7 @@ def accept_new_state(self): self.set_state(self.new_state) print(f"Fitted value: {self.new_state:.3f}") time.sleep(self.delay_s) - self.core.snap(write_flag=False) + self.core.snap(write_flag=False, laser_blanking=True) state_str = f"{self.state[self.state_key]}" if self.mode == 'focus' else f"{self.state[self.state_key]:.3f}" print(f"New {self.state_key}:{state_str}") self.results_window.deleteLater()