Skip to content

Commit

Permalink
Fix issue #138 (#139)
Browse files Browse the repository at this point in the history
* moved activation noise subtraction

* fixed type for mock frames

* implemented check for matching size
  • Loading branch information
fedem-p committed May 4, 2022
1 parent fc59ca5 commit 8b8f055
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion sashimi/hardware/cameras/mock.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def get_frames(self):
self.elapsed = (self.current_time - self.previous_frame_time) * 1e-9
if self.elapsed >= self._exposure_time * 1e-3:
multiplier = np.random.randint(1, 5, 1)
frames.append(self.current_mock_image * multiplier)
frames.append(np.uint16(self.current_mock_image * multiplier))
self.previous_frame_time = self.current_time
else:
self.previous_frame_time = self.current_time
Expand Down
3 changes: 2 additions & 1 deletion sashimi/processes/dispatcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ def run(self):

def process_frame(self, current_frame):
if self.calibration_ref is not None and self.noise_subtraction_active.is_set():
current_frame = neg_dif(current_frame, self.calibration_ref)
if np.shape(current_frame) == np.shape(self.calibration_ref):
current_frame = neg_dif(current_frame, self.calibration_ref)

if self.first_volume or self.volume_buffer.shape[1:3] != current_frame.shape:
self.volume_buffer = np.empty(
Expand Down
3 changes: 2 additions & 1 deletion sashimi/state.py
Original file line number Diff line number Diff line change
Expand Up @@ -597,12 +597,13 @@ def obtain_noise_average(self, n_images=50):
calibration_set[n_image, :, :] = current_image
n_image += 1

self.noise_subtraction_active.set()
self.calibration_ref = np.mean(calibration_set, axis=0).astype(
dtype=current_volume.dtype
)
self.light_source.intensity = light_intensity

self.noise_subtraction_active.set()

self.dispatcher.calibration_ref_queue.put(self.calibration_ref)

def reset_noise_subtraction(self):
Expand Down

0 comments on commit 8b8f055

Please sign in to comment.