Skip to content

Commit

Permalink
fix: fix rgb MDA (#347)
Browse files Browse the repository at this point in the history
* fix: fix rgb MDA

* add note and change pyside test ver

* try pyside6

* back to pyside2

* disable pyside2
  • Loading branch information
tlambert03 authored Sep 26, 2024
1 parent 13758ba commit 2b29355
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 11 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ jobs:
- python-version: "3.11"
platform: ubuntu-latest
backend: pyqt5
- python-version: "3.10"
platform: windows-latest
backend: pyside2
# - python-version: "3.10"
# platform: windows-latest
# backend: pyside2

steps:
- uses: actions/checkout@v4
Expand Down
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,11 @@ You can install `napari-micromanager` via [pip]:

pip install napari-micromanager

You will also need a Qt backend such as PySide2/6, or PyQt5/6. If you've previously installed napari
into this environment with `pip install napari[all]`, then you will likely already have it. If not,
you will also need to install a Qt backend of your choice:
You will also need a Qt backend such as PySide2/6, or PyQt5/6. **PyQt is
preferred and receives more testing**. If you've previously installed napari
into this environment with `pip install napari[all]`, then you will likely
already have it. If not, you will also need to install a Qt backend of your
choice:

pip install pyqt5 # or any of {pyqt5, pyqt6, pyside2, pyside6}

Expand Down
9 changes: 5 additions & 4 deletions src/napari_micromanager/_mda_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ def _on_mda_started(self, sequence: MDASequence) -> None:
axis_labels, layers_to_create = _determine_sequence_layers(sequence)

yx_shape = [self._mmc.getImageHeight(), self._mmc.getImageWidth()]
if self._mmc.getNumberOfComponents() >= 3:
yx_shape = [*yx_shape, 3]

# now create a zarr array in a temporary directory for each layer
for id_, shape, kwargs in layers_to_create:
Expand Down Expand Up @@ -212,17 +214,16 @@ def _create_empty_image_layer(
"""
# we won't have reached this point if meta is None
meta = sequence.metadata.get(NMM_METADATA_KEY, {})
is_rgb = arr.shape[-1] == 3
scale = [1.0] * (arr.ndim - (1 if is_rgb else 0))

# add Z to layer scale
if (pix_size := self._mmc.getPixelSizeUm()) != 0:
scale = [1.0] * (arr.ndim - 2) + [pix_size] * 2
scale[-2:] = [pix_size, pix_size]
if (index := sequence.used_axes.find("z")) > -1:
if meta.get("split_channels") and sequence.used_axes.find("c") < index:
index -= 1
scale[index] = getattr(sequence.z_plan, "step", 1)
else:
# return to default
scale = [1.0, 1.0]

layer_meta["useq_sequence"] = sequence
layer_meta["uid"] = sequence.uid
Expand Down
12 changes: 11 additions & 1 deletion tests/test_multid_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from napari_micromanager.main_window import MainWindow


def test_main_window_mda(main_window: MainWindow):
def test_main_window_mda(main_window: MainWindow) -> None:
assert not main_window.viewer.layers

mda = MDASequence(
Expand All @@ -35,6 +35,16 @@ def test_main_window_mda(main_window: MainWindow):
assert all(key in layer_meta for key in keys)


def test_main_window_mda_rgb(main_window: MainWindow) -> None:
main_window._mmc.setProperty("Camera", "PixelType", "32bitRGB")
main_window._mmc.setProperty("Camera", "Mode", "Color Test Pattern")
assert not main_window.viewer.layers

mda = MDASequence(time_plan={"loops": 4, "interval": 0.01}, channels=["DAPI"])
main_window._mmc.mda.run(mda)
assert main_window.viewer.layers[-1].data.shape == (4, 1, 512, 512, 3)


def test_saving_mda(
qtbot: QtBot,
main_window: MainWindow,
Expand Down

0 comments on commit 2b29355

Please sign in to comment.