diff --git a/sashimi/state.py b/sashimi/state.py index 2af6118..fd72b3c 100644 --- a/sashimi/state.py +++ b/sashimi/state.py @@ -5,6 +5,7 @@ from lightparam.param_qt import ParametrizedQt from lightparam import Param, ParameterTree from sashimi.hardware.light_source import light_source_class_dict +from typing import Union # from sashimi.hardware import light_source_class_dict from sashimi.processes.scanning import ScannerProcess @@ -224,16 +225,20 @@ def calculate_calibration(self): def get_voxel_size( - scanning_settings: ZRecordingSettings, + scanning_settings: Union[ZRecordingSettings, SinglePlaneSettings], camera_settings: CameraSettings, ): - scan_length = ( - scanning_settings.piezo_scan_range[1] - scanning_settings.piezo_scan_range[0] - ) binning = int(camera_settings.binning) - inter_plane = scan_length / scanning_settings.n_planes + if isinstance(scanning_settings, SinglePlaneSettings): + inter_plane = 1 + else: + scan_length = ( + scanning_settings.piezo_scan_range[1] + - scanning_settings.piezo_scan_range[0] + ) + inter_plane = scan_length / scanning_settings.n_planes return ( inter_plane, @@ -244,13 +249,16 @@ def get_voxel_size( def convert_save_params( save_settings: SaveSettings, - scanning_settings: ZRecordingSettings, + scanning_settings: Union[ZRecordingSettings, SinglePlaneSettings], camera_settings: CameraSettings, trigger_settings: TriggerSettings, ): - n_planes = scanning_settings.n_planes - ( - scanning_settings.n_skip_start + scanning_settings.n_skip_end - ) + if isinstance(scanning_settings, SinglePlaneSettings): + n_planes = 0 + else: + n_planes = scanning_settings.n_planes - ( + scanning_settings.n_skip_start + scanning_settings.n_skip_end + ) return SavingParameters( output_dir=Path(save_settings.save_dir), @@ -472,12 +480,21 @@ def n_planes(self): @property def save_params(self): - return convert_save_params( - self.save_settings, - self.volume_setting, - self.camera_settings, - self.trigger_settings, - ) + if self.global_state == GlobalState.PLANAR_PREVIEW: + save_p = convert_save_params( + self.save_settings, + self.single_plane_settings, + self.camera_settings, + self.trigger_settings, + ) + else: + save_p = convert_save_params( + self.save_settings, + self.volume_setting, + self.camera_settings, + self.trigger_settings, + ) + return save_p @property def scan_params(self):