Ejemplo n.º 1
0
def test_config_cli_edit(conf_path):
    runner = CliRunner()
    runner.invoke(
        config.cli_modify_config,
        ["edit", "-n", "z_board.read.min_val", "-v", "7", "-p", str(conf_path)],
    )
    conf = config.read_config(conf_path)
    assert conf["z_board"]["read"]["min_val"] == 7
Ejemplo n.º 2
0
    def _apply_config(self):
        global conf
        config_key = self.retrieve_keys_from_nested(
            self.config_combo.currentText(), "-"
        )
        value = self._search_nested_dict(config_key, conf)
        new_value = int(self.config_key_value.toPlainText())
        new_value = type(value)(new_value)  # Convert to keep the same type

        write_config_value(config_key, new_value)
        conf = read_config()
        self.restart_lbl.show()
Ejemplo n.º 3
0
from sashimi.state import (
    State,
    get_voxel_size,
)
import napari

# TODO: In future realeases of napari remove monkey patched code. Accessing protected elements is bad practice
from napari.layers.shapes._shapes_constants import Mode
import numpy as np
from warnings import warn
from sashimi.hardware.cameras.interface import CameraWarning
from sashimi.config import read_config
from enum import Enum
from multiprocessing import Queue

conf = read_config()


class RoiState(Enum):
    FULL = 1
    DISPLAYED = 2
    SET = 3


ROI_TEXTS = {
    RoiState.FULL: "Select ROI",
    RoiState.DISPLAYED: "Set ROI",
    RoiState.SET: "Reset full frame",
}

Ejemplo n.º 4
0
def test_write_config_val(conf_path):
    val = 6
    config.write_config_value(["z_board", "read", "min_val"], val, file_path=conf_path)
    conf = config.read_config(file_path=conf_path)
    assert conf["z_board"]["read"]["min_val"] == val
Ejemplo n.º 5
0
def test_config_creation(conf_path):
    conf = config.read_config(file_path=conf_path)
    assert conf == config.TEMPLATE_CONF_DICT
Ejemplo n.º 6
0
 def __init__(self, process_name):
     self.file: Optional[TextIO] = None
     self.process_name = process_name
     configuration = config.read_config()
     self.root = Path(configuration["default_paths"]["log"])
Ejemplo n.º 7
0
    def __init__(self):
        self.conf = read_config()
        self.sample_rate = conf["sample_rate"]

        self.logger = ConcurrenceLogger("main")

        self.calibration_ref = None
        self.waveform = None
        self.current_plane = 0
        self.stop_event = LoggedEvent(self.logger, SashimiEvents.CLOSE_ALL)
        self.restart_event = LoggedEvent(self.logger,
                                         SashimiEvents.RESTART_SCANNING)
        self.experiment_start_event = LoggedEvent(
            self.logger, SashimiEvents.SEND_EXT_TRIGGER)
        self.noise_subtraction_active = LoggedEvent(
            self.logger, SashimiEvents.NOISE_SUBTRACTION_ACTIVE, Event())
        self.is_saving_event = LoggedEvent(self.logger,
                                           SashimiEvents.IS_SAVING)

        # The even active during scanning preparation (before first real camera trigger)
        self.is_waiting_event = LoggedEvent(self.logger,
                                            SashimiEvents.WAITING_FOR_TRIGGER)

        self.experiment_state = ExperimentPrepareState.PREVIEW
        self.status = ScanningSettings()

        self.scanner = ScannerProcess(
            stop_event=self.stop_event,
            restart_event=self.restart_event,
            waiting_event=self.is_waiting_event,
            sample_rate=self.sample_rate,
        )
        self.camera_settings = CameraSettings()
        self.trigger_settings = TriggerSettings()

        self.settings_tree = ParameterTree()

        self.pause_after = False
        if self.conf["scopeless"]:
            self.light_source = light_source_class_dict["mock"]()
        else:
            self.light_source = light_source_class_dict[
                conf["light_source"]["name"]](
                    port=conf["light_source"]["port"])
        self.camera = CameraProcess(
            stop_event=self.stop_event,
            wait_event=self.scanner.wait_signal,
            exp_trigger_event=self.experiment_start_event,
        )

        self.multiprocessing_manager = MultiprocessingManager()

        self.experiment_duration_queue = self.multiprocessing_manager.Queue()

        self.external_comm = ExternalComm(
            stop_event=self.stop_event,
            experiment_start_event=self.experiment_start_event,
            is_saving_event=self.is_saving_event,
            is_waiting_event=self.is_waiting_event,
            duration_queue=self.experiment_duration_queue,
        )

        self.saver = StackSaver(
            stop_event=self.stop_event,
            is_saving_event=self.is_saving_event,
            duration_queue=self.experiment_duration_queue,
        )

        self.dispatcher = VolumeDispatcher(
            stop_event=self.stop_event,
            saving_signal=self.saver.saving_signal,
            wait_signal=self.scanner.wait_signal,
            noise_subtraction_on=self.noise_subtraction_active,
            camera_queue=self.camera.image_queue,
            saver_queue=self.saver.save_queue,
        )

        self.camera_settings = CameraSettings()
        self.save_settings = SaveSettings()

        self.settings_tree = ParameterTree()

        self.global_state = GlobalState.PAUSED

        self.planar_setting = PlanarScanningSettings()
        self.light_source_settings = LightSourceSettings()
        self.light_source_settings.params.intensity.unit = (
            self.light_source.intensity_units)

        self.save_status: Optional[SavingStatus] = None

        self.single_plane_settings = SinglePlaneSettings()
        self.volume_setting = ZRecordingSettings()
        self.calibration = Calibration()

        for setting in [
                self.planar_setting,
                self.light_source_settings,
                self.single_plane_settings,
                self.volume_setting,
                self.calibration,
                self.calibration.z_settings,
                self.camera_settings,
                self.save_settings,
        ]:
            self.settings_tree.add(setting)

        self.status.sig_param_changed.connect(self.change_global_state)

        self.planar_setting.sig_param_changed.connect(
            self.send_scansave_settings)
        self.calibration.z_settings.sig_param_changed.connect(
            self.send_scan_settings)
        self.single_plane_settings.sig_param_changed.connect(
            self.send_scan_settings)
        self.volume_setting.sig_param_changed.connect(self.send_scan_settings)

        self.save_settings.sig_param_changed.connect(
            self.send_scansave_settings)

        self.camera.start()
        self.scanner.start()
        self.external_comm.start()
        self.saver.start()
        self.dispatcher.start()

        self.current_binning = conf["camera"]["default_binning"]
        self.send_scansave_settings()
        self.logger.log_message("initialized")

        self.voxel_size = None