Skip to content

Commit

Permalink
Merge pull request #54 from GuckLab/fix/53/bump-bmlab
Browse files Browse the repository at this point in the history
fix: bump bmlab from 0.2.3 to 0.6.1 (file format changes) (close #53)
  • Loading branch information
raimund-schluessler authored Sep 21, 2022
2 parents c62664b + bf1ddb1 commit 00b0a28
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 20 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
0.4.0
- fix: bump bmlab from 0.2.3 to 0.6.1 (file format changes) (#53)
0.3.1
- fix: bump bmlab from 0.1.10 to 0.2.3 (file format changes) (#49)
0.3.0
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
description=description,
long_description=open('README.rst').read() if exists('README.rst') else '',
install_requires=["czifile==2019.7.2", # bc cgohlke and used for signature
"bmlab==0.5.1",
"bmlab==0.6.1",
"h5py>=2.10.0",
"numpy>=1.17.0",
"pyqt6>=6.2.0",
Expand Down
Binary file not shown.
Binary file not shown.
37 changes: 20 additions & 17 deletions tests/test_fmt_h5_brillouin_bmlab.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,48 +6,51 @@


def test_load_bmlab_brillouin():
paths = retrieve_data("fmt_brillouin-h5_bmlab-session_2022.zip")
paths = retrieve_data("fmt_brillouin-h5_bmlab-session_2022_water.zip")
data, meta = formats.load(paths[0])

# check metadata
assert meta["pixel size x"] == 1
assert meta["pixel size y"] == 1
assert np.isnan(meta["pixel size z"])
assert meta["shape"] == (3, 5, 1)
assert "brillouin_peak_position" in meta["channel hues"]
assert "brillouin_peak_position_f" in meta["channel hues"]

# check data
assert "brillouin_peak_position" in data
assert data["brillouin_peak_position"].shape == (3, 5, 1)
assert data["brillouin_peak_position"][2, 3, 0] == 62.28071301762982
assert meta["signature"] == "25d6ae8774fc29417facc6c9dfe061e6"
assert "brillouin_peak_position_f" in data
assert data["brillouin_peak_position_f"].shape == (3, 5, 1)
assert data["brillouin_peak_position_f"][2, 3, 0] == 7.418597699375756
assert meta["signature"] == "7692028641e09f26ad0c8caf010ecaeb"


def test_load_bmlab_brillouin_2rep():
paths = retrieve_data("fmt_brillouin-h5_bmlab-session_2022_2-rep.zip")
paths =\
retrieve_data("fmt_brillouin-h5_bmlab-session_2022_water_2-rep.zip")
data, meta = formats.load(paths[0])

# check metadata
assert meta["pixel size x"] == 1
assert meta["pixel size y"] == 1
assert np.isnan(meta["pixel size z"])
assert meta["shape"] == (3, 5, 1)
assert "rep-0_brillouin_peak_position" in meta["channel hues"]
assert "rep-1_brillouin_peak_position" in meta["channel hues"]
assert "rep-0_brillouin_peak_position_f" in meta["channel hues"]
assert "rep-1_brillouin_peak_position_f" in meta["channel hues"]

# check data
assert "rep-0_brillouin_peak_position" in data
assert data["rep-0_brillouin_peak_position"].shape == (3, 5, 1)
assert data["rep-0_brillouin_peak_position"][2, 3, 0] == 55.53730853499501
assert "rep-1_brillouin_peak_position" in data
assert data["rep-1_brillouin_peak_position"].shape == (3, 5, 1)
assert data["rep-1_brillouin_peak_position"][2, 3, 0] == 101.47705516241298
assert "rep-0_brillouin_peak_position_f" in data
assert data["rep-0_brillouin_peak_position_f"].shape == (3, 5, 1)
assert data["rep-0_brillouin_peak_position_f"][2, 3, 0] ==\
7.414767296701641
assert "rep-1_brillouin_peak_position_f" in data
assert data["rep-1_brillouin_peak_position_f"].shape == (3, 5, 1)
assert data["rep-1_brillouin_peak_position_f"][2, 3, 0] ==\
7.4293433545770124

assert meta["signature"] == "0f9dfe4cfe549859ac09ec0ead5bf58f"
assert meta["signature"] == "0fa3675745a06d6c54184aa95873280e"


def test_load_bmlab_brillouin_signature():
paths = retrieve_data("fmt_brillouin-h5_bmlab-session_2022.zip")
paths = retrieve_data("fmt_brillouin-h5_bmlab-session_2022_water.zip")
_, meta1 = formats.load(paths[0])
_, meta2 = formats.load(paths[1])
assert meta1["signature"] == meta2["signature"]
27 changes: 25 additions & 2 deletions tests/test_gui_collect.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,30 @@ def test_basic(qtbot):
mw.close()


def test_load_bmlab_brillouin_data(qtbot, monkeypatch):
paths = retrieve_data("fmt_brillouin-h5_bmlab-session_2022_water.zip")

mw = Impose()
qtbot.addWidget(mw)
monkeypatch.setattr(QtWidgets.QFileDialog, "getOpenFileNames",
lambda *args: ([str(paths[0])], None))
qtbot.mouseClick(mw.tab_collect.toolButton_add_data,
QtCore.Qt.MouseButton.LeftButton)
QtWidgets.QApplication.processEvents(
QtCore.QEventLoop.ProcessEventsFlag.AllEvents, 300)

# select the first entry in the datasets list (actual data)
qtbot.mouseClick(mw.tab_collect.tableWidget_paths.cellWidget(0, 0),
QtCore.Qt.MouseButton.LeftButton)
# sanity check (no data displayed)
assert mw.tab_collect.groupBox_struct.isEnabled()

# select the second entry in the visualization list
item = mw.tab_collect.vis.listWidget_chan.item(1)
item.setCheckState(QtCore.Qt.CheckState.Checked)
assert mw.tab_collect.groupBox_struct.isEnabled()


def test_load_bmlab_brillouin_with_nan_data(qtbot, monkeypatch):
paths = retrieve_data("fmt_brillouin-h5_bmlab-session_2022.zip")

Expand All @@ -36,10 +60,9 @@ def test_load_bmlab_brillouin_with_nan_data(qtbot, monkeypatch):
assert not mw.tab_collect.groupBox_struct.isEnabled()

# select the second entry in the visualization list
# (the first entry contains nans, the second entry contains data)
item = mw.tab_collect.vis.listWidget_chan.item(1)
item.setCheckState(QtCore.Qt.CheckState.Checked)
assert mw.tab_collect.groupBox_struct.isEnabled()
assert not mw.tab_collect.groupBox_struct.isEnabled()


def test_load_dataset(qtbot, monkeypatch):
Expand Down

0 comments on commit 00b0a28

Please sign in to comment.