From 5c15b79ef674974dc190c8ed07d95a3aa1829226 Mon Sep 17 00:00:00 2001 From: diegoasua Date: Sat, 20 Feb 2021 00:17:10 -0500 Subject: [PATCH 1/3] Scale bar In pixel units, with show/hide pushbutton --- sashimi/gui/camera_gui.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/sashimi/gui/camera_gui.py b/sashimi/gui/camera_gui.py index afab32f5..05696a2b 100644 --- a/sashimi/gui/camera_gui.py +++ b/sashimi/gui/camera_gui.py @@ -131,12 +131,14 @@ def __init__(self, state: State, timer: QTimer, style: str): self.bottom_layout.addWidget(self.viewer.window.qt_viewer.viewerButtons) self.auto_contrast_chk = QCheckBox("Autoadjust contrast") + self.toggle_scalebar_btn = QPushButton("Show/hide scalebar") self.contrast_range = ContrastSettings() self.wid_contrast_range = ParameterGui(self.contrast_range) self.bottom_layout.addWidget(self.auto_contrast_chk) self.bottom_layout.addWidget(self.wid_contrast_range) + self.bottom_layout.addWidget(self.toggle_scalebar_btn) self.bottom_layout.addStretch() @@ -147,6 +149,7 @@ def __init__(self, state: State, timer: QTimer, style: str): # Connect changes of camera and laser to contrast reset: self.auto_contrast_chk.stateChanged.connect(self.update_auto_contrast) self.contrast_range.sig_param_changed.connect(self.set_manual_contrast) + self.toggle_scalebar_btn.pressed.connect(self.toggle_scalebar) self.auto_contrast_chk.setChecked(True) @@ -254,6 +257,12 @@ def update_auto_contrast(self, is_checked): def set_manual_contrast(self): self.frame_layer.contrast_limits = self.contrast_range.contrast_range + def toggle_scalebar(self): + if self.viewer.scale_bar.visible: + self.viewer.scale_bar.visible = False + else: + self.viewer.scale_bar.visible = True + class CameraSettingsWidget(QWidget): """Widget to modify parameters for the camera. From b23ee53238189984435b2d4c2706d2e6d7c36ed8 Mon Sep 17 00:00:00 2001 From: diegoasua Date: Sun, 21 Feb 2021 15:22:11 -0500 Subject: [PATCH 2/3] pixel size Supports pixel size, without units --- sashimi/gui/camera_gui.py | 1 + sashimi/processes/streaming_save.py | 2 -- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/sashimi/gui/camera_gui.py b/sashimi/gui/camera_gui.py index 05696a2b..66fd1215 100644 --- a/sashimi/gui/camera_gui.py +++ b/sashimi/gui/camera_gui.py @@ -100,6 +100,7 @@ def __init__(self, state: State, timer: QTimer, style: str): ), blending="translucent", name="frame_layer", + scale=self.voxel_size, ) # Add square ROI of size max image size: diff --git a/sashimi/processes/streaming_save.py b/sashimi/processes/streaming_save.py index 9da69418..d15fb99c 100644 --- a/sashimi/processes/streaming_save.py +++ b/sashimi/processes/streaming_save.py @@ -207,10 +207,8 @@ def receive_save_parameters(self): pass try: new_duration = self.duration_queue.get(timeout=0.001) - print(new_duration) self.n_volumes = int( np.ceil(self.save_parameters.volumerate * new_duration) ) - print(self.n_volumes) except Empty: pass From 12d2767da516a9a3d0fd4b2764739b03b97e0d47 Mon Sep 17 00:00:00 2001 From: diegoasua Date: Sun, 21 Feb 2021 15:25:25 -0500 Subject: [PATCH 3/3] black formatting --- .../hardware/cameras/hamamatsu/interface.py | 2 +- sashimi/processes/streaming_save.py | 8 ++++-- sashimi/state.py | 27 +++++++++++++------ 3 files changed, 26 insertions(+), 11 deletions(-) diff --git a/sashimi/hardware/cameras/hamamatsu/interface.py b/sashimi/hardware/cameras/hamamatsu/interface.py index b6db49ac..edcab219 100644 --- a/sashimi/hardware/cameras/hamamatsu/interface.py +++ b/sashimi/hardware/cameras/hamamatsu/interface.py @@ -511,7 +511,7 @@ def get_camera_properties(self): "dcamprop_getname", ) - if properties == {'': 0}: + if properties == {"": 0}: raise ConnectionError("The Hamamatsu camera seems to be off!") return properties diff --git a/sashimi/processes/streaming_save.py b/sashimi/processes/streaming_save.py index d15fb99c..5bbf746b 100644 --- a/sashimi/processes/streaming_save.py +++ b/sashimi/processes/streaming_save.py @@ -130,7 +130,8 @@ def fill_dataset(self, volume): if self.current_data is None: self.calculate_optimal_size(volume) self.current_data = np.empty( - (self.save_parameters.chunk_size, *volume.shape), dtype=self.dtype, + (self.save_parameters.chunk_size, *volume.shape), + dtype=self.dtype, ) self.current_data[self.i_in_chunk, :, :, :] = volume @@ -165,7 +166,10 @@ def finalize_dataset(self): ) as f: json.dump( { - "shape_full": (self.n_volumes, *self.current_data.shape[1:],), + "shape_full": ( + self.n_volumes, + *self.current_data.shape[1:], + ), "shape_block": ( self.save_parameters.chunk_size, *self.current_data.shape[1:], diff --git a/sashimi/state.py b/sashimi/state.py index 14f2de90..e68e7ead 100644 --- a/sashimi/state.py +++ b/sashimi/state.py @@ -71,7 +71,8 @@ def __init__(self): super().__init__() self.name = "general/scanning_state" self.scanning_state = Param( - "Paused", ["Paused", "Calibration", "Planar", "Volume"], + "Paused", + ["Paused", "Calibration", "Planar", "Volume"], ) @@ -183,7 +184,11 @@ def __init__(self): def add_calibration_point(self): self.calibrations_points.append( - (self.z_settings.piezo, self.z_settings.lateral, self.z_settings.frontal,) + ( + self.z_settings.piezo, + self.z_settings.lateral, + self.z_settings.frontal, + ) ) self.calculate_calibration() @@ -219,7 +224,8 @@ def calculate_calibration(self): def get_voxel_size( - scanning_settings: ZRecordingSettings, camera_settings: CameraSettings, + scanning_settings: ZRecordingSettings, + camera_settings: CameraSettings, ): scan_length = ( scanning_settings.piezo_scan_range[1] - scanning_settings.piezo_scan_range[0] @@ -522,7 +528,9 @@ def send_scansave_settings(self): elif self.global_state == GlobalState.PLANAR_PREVIEW: params = convert_single_plane_params( - self.planar_setting, self.single_plane_settings, self.calibration, + self.planar_setting, + self.single_plane_settings, + self.calibration, ) elif self.global_state == GlobalState.VOLUME_PREVIEW: @@ -644,10 +652,13 @@ def get_waveform(self): return None def calculate_pulse_times(self): - return np.arange( - self.volume_setting.n_skip_start, - self.volume_setting.n_planes - self.volume_setting.n_skip_end, - ) / (self.volume_setting.frequency * self.volume_setting.n_planes) + return ( + np.arange( + self.volume_setting.n_skip_start, + self.volume_setting.n_planes - self.volume_setting.n_skip_end, + ) + / (self.volume_setting.frequency * self.volume_setting.n_planes) + ) def set_trigger_mode(self, mode: bool): if mode: