Пример #1
0
def test_explorer(explorer_one_channel: ExplorerTuple, qtbot: QtBot):

    main_win, explorer = explorer_one_channel

    mmc = main_win._mmc
    mmc.setXYPosition(0.0, 0.0)
    mmc.setPosition(0.0)

    mmc.setConfig(
        "Objective",
        "10X")  # this it is also setting mmc.setPixelSizeConfig('Res10x')

    assert not main_win.viewer.layers

    # grab these in callback so we get the real meta that is
    # created once we start the scan
    sequence = None
    meta = None

    @mmc.mda.events.sequenceStarted.connect
    def get_seq(seq: MDASequence):
        nonlocal sequence, meta
        sequence = seq
        meta = _mda.SEQUENCE_META[seq]

    with qtbot.waitSignals(
        [mmc.mda.events.sequenceStarted, mmc.mda.events.sequenceFinished]):
        explorer.start_scan_Button.click()

    # wait to finish returning to start pos
    mmc.waitForSystem()
    assert main_win.explorer.set_grid() == [
        [-256.0, 256.0, 0.0],
        [256.0, 256.0, 0.0],
        [256.0, -256.0, 0.0],
        [-256.0, -256.0, 0.0],
    ]
    assert mmc.getPixelSizeUm() == 1
    assert mmc.getROI(mmc.getCameraDevice())[-1] == 512
    assert mmc.getROI(mmc.getCameraDevice())[-2] == 512

    assert meta.mode == "explorer"

    assert main_win.viewer.layers[-1].data.shape == (512, 512)
    assert len(main_win.viewer.layers) == 4

    _layer = main_win.viewer.layers[-1]
    assert _layer.metadata["ch_name"] == "Cy5"
    assert _layer.metadata["ch_id"] == 0
    assert _layer.metadata["uid"] == sequence.uid

    # checking the linking  of the layers
    assert len(main_win.viewer.layers) == 4
    layer_0 = main_win.viewer.layers[0]
    layer_0.visible = False

    # check that also the last layer is not visible
    layer_1 = main_win.viewer.layers[1]
    assert not layer_1.visible
Пример #2
0
def test_saving_explorer(qtbot: QtBot, explorer_two_channel: ExplorerTuple):

    main_win, explorer = explorer_two_channel
    mmc = main_win._mmc
    # grab these in callback so we get the real meta that is
    # created once we start the scan
    sequence = None
    meta = None

    @mmc.mda.events.sequenceStarted.connect
    def get_seq(seq: MDASequence):
        nonlocal sequence, meta
        sequence = seq
        meta = _mda.SEQUENCE_META[seq]

    with tempfile.TemporaryDirectory() as td:
        tmp_path = Path(td)
        explorer.dir_explorer_lineEdit.setText(str(tmp_path))
        explorer.save_explorer_groupBox.setChecked(True)

        with qtbot.waitSignals(
            [mmc.mda.events.sequenceStarted, mmc.mda.events.sequenceFinished]):
            explorer.start_scan_Button.click()

        layer_list = list(main_win.viewer.layers)
        assert len(layer_list) == 8

        save_sequence(sequence, layer_list, meta)

        folder = tmp_path / "scan_Experiment_000"  # after _imsave()

        file_list = sorted(pth.name for pth in folder.iterdir())
        assert file_list == ["Cy5.tif", "FITC.tif"]

        saved_file = tifffile.imread(folder / "Cy5.tif")
        assert saved_file.shape == (4, 512, 512)

        saved_file = tifffile.imread(folder / "FITC.tif")
        assert saved_file.shape == (4, 512, 512)
Пример #3
0
def test_import_thread(qtbot: QtBot):
    path = Path(__file__).parent.joinpath("data", "io")
    paths = [
        path.joinpath("agilent", "test_ms.b"),
        path.joinpath("csv", "generic"),
        path.joinpath("npz", "test.npz"),
        path.joinpath("perkinelmer", "perkinelmer"),
        path.joinpath("textimage", "csv.csv"),
        path.joinpath("textimage", "text.text"),
        path.joinpath("thermo", "icap_columns.csv"),
    ]
    thread = ImportThread(paths, Config())

    signals = [(thread.importFinished, path.name) for path in paths]
    signals.extend([(thread.progressChanged, path.name) for path in paths])
    with qtbot.waitSignals(signals):
        thread.run()

    # Failing import
    paths = [path.joinpath("fake", "data.npz")]
    thread = ImportThread(paths, Config())

    with qtbot.waitSignal(thread.importFailed):
        thread.run()