Skip to content

Commit

Permalink
fix optimizer's first frame (clear image buffer)
Browse files Browse the repository at this point in the history
  • Loading branch information
nvladimus committed Jan 27, 2023
1 parent 873bbc3 commit 1174f7d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
File renamed without changes.
7 changes: 3 additions & 4 deletions mesoSPIM/src/mesoSPIM_Optimizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit 1174f7d

Please sign in to comment.