From 1a41b1dba437e88cdb59052652e19c5d375ce292 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Paul=20M=C3=BCller?= Date: Fri, 20 Nov 2026 10:20:53 +0100 Subject: [PATCH] enh: consistent medium and viscosity model names, tooltips - list the Young's modulus media with the names used by dclab and the product name as a hint (e.g. "0.49% MC-PBS (CellCarrier)"); aliases from older sessions are mapped to the preferred names - use the same viscosity model names in the Dataset tab, bulk action, and preferences - tooltips for the Quick View polygon button and the isoelastics LUT selection - fix: make the encrypted token link in the preferences clickable - docs: remove the QtCreator version requirement Co-Authored-By: Claude Opus 5.5 --- CHANGELOG | 10 +++++ dcscope/gui/analysis/ana_plot_ui.py | 1 + dcscope/gui/analysis/ana_slot.py | 25 +++++++------ dcscope/gui/bulk/bulk_emodulus.py | 16 +++----- dcscope/gui/defaults.py | 19 ++++++++++ dcscope/gui/preferences_ui.py | 1 + dcscope/gui/quick_view/qv_main_ui.py | 2 + docs/scrots/make_scrots_qg_emodulus.py | 6 +-- docs/sec_devs.rst | 6 --- docs/sec_qg_youngs_modulus.rst | 14 ++++--- tests/test_gui_bulk_emodulus.py | 8 +++- tests/test_gui_emodulus.py | 51 +++++++++++++++++++++++++- ui/analysis/ana_plot.ui | 6 ++- ui/preferences.ui | 3 ++ ui/quick_view/qv_main.ui | 9 ++++- 15 files changed, 135 insertions(+), 42 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index a33106d..3d54daa 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -20,6 +20,8 @@ renamed to "Choose filters..." after editing box filters - fix: the help button of the statistical significance dialog opened the dclab documentation instead of the R-lme4 quick guide + - fix: the "What are encrypted tokens?" link in the DCOR preferences + could not be clicked - enh: user-defined default settings for new plots ("Save as default" in the plot settings) and default Young's modulus viscosity model and look-up table for new datasets (preferences) (#129) @@ -40,6 +42,13 @@ the viscosity model) in the plots (#144) - enh: help links for fluorescence crosstalk correction (Dataset tab) and S3 basins (preferences) + - enh: list the Young's modulus media with the names used by dclab + (no aliases) and the product name as a hint (e.g. "0.49% MC-PBS + (CellCarrier)") + - enh: use the same viscosity model names ("Buyukurganci (2022)", + "Herold (2017)") in the Dataset tab, bulk action, and preferences + - enh: tooltips for the polygon filter button in the Quick View and + the isoelasticity line look-up table selection - docs: add quick guide for fluorescence crosstalk correction (#120) - docs: screenshot scripts download missing datasets from figshare and use the icon theme of DCscope @@ -63,6 +72,7 @@ encrypted DCOR access tokens, S3 basins, Quick View, Filter, Plot, and Block Matrix options) - docs: link to the dclab documentation where applicable + - docs: remove outdated QtCreator version requirement 2.28.4 - setup: bump dclab to 0.73.0 (chopped image basins support) 2.28.3 diff --git a/dcscope/gui/analysis/ana_plot_ui.py b/dcscope/gui/analysis/ana_plot_ui.py index c181889..418a10f 100644 --- a/dcscope/gui/analysis/ana_plot_ui.py +++ b/dcscope/gui/analysis/ana_plot_ui.py @@ -467,6 +467,7 @@ def retranslateUi(self, Form): self.label_17.setText(_translate("Form", "Y")) self.toolButton_spacing_find_best.setText(_translate("Form", "Find best spacing")) self.checkBox_isoelastics.setText(_translate("Form", "Isoelasticity lines")) + self.comboBox_lut.setToolTip(_translate("Form", "Look-up table for the isoelasticity lines")) self.label_18.setText(_translate("Form", "After clicking apply, set:")) self.toolButton_auto_xy_range.setToolTip(_translate("Form", "from minimum to maximum with 5% margin")) self.toolButton_auto_xy_range.setText(_translate("Form", "default XY range")) diff --git a/dcscope/gui/analysis/ana_slot.py b/dcscope/gui/analysis/ana_slot.py index 9ee2dd3..6c0aeee 100644 --- a/dcscope/gui/analysis/ana_slot.py +++ b/dcscope/gui/analysis/ana_slot.py @@ -2,12 +2,13 @@ import dclab from dclab.features.emodulus.viscosity import ( - ALIAS_MEDIA, KNOWN_MEDIA, TemperatureOutOfRangeWarning + ALIAS_MEDIA, KNOWN_MEDIA, SAME_MEDIA, TemperatureOutOfRangeWarning ) import numpy as np from PyQt6 import QtCore, QtWidgets from ... import meta_tool +from .. import defaults from .ana_slot_ui import Ui_Form from .dlg_slot_reorder import DlgSlotReorder @@ -125,7 +126,11 @@ def write_pipeline_state(self, state): self._update_emodulus_temp_choices() emodulus = state["emodulus"] self.ui.groupBox_emod.setVisible(emodulus["emodulus enabled"]) - idx_med = self.ui.comboBox_medium.findData(emodulus["emodulus medium"]) + medium = emodulus["emodulus medium"] + idx_med = self.ui.comboBox_medium.findData(medium) + if idx_med == -1 and medium in ALIAS_MEDIA: + # alias of a medium (e.g. "CellCarrier" from older sessions) + idx_med = self.ui.comboBox_medium.findData(ALIAS_MEDIA[medium]) if idx_med == -1: # empty medium string idx_med = self.ui.comboBox_medium.findData("other") self.ui.comboBox_medium.setCurrentIndex(idx_med) @@ -208,16 +213,14 @@ def get_dataset_choices_medium(ds): else: medium = "undefined" if medium in KNOWN_MEDIA: + # The medium is defined in the metadata and cannot be changed. valid_media = [medium] else: - valid_media = KNOWN_MEDIA + [medium, "other", "undefined"] + # Only offer the media names preferred by dclab (no aliases). + valid_media = list(SAME_MEDIA) + [medium, "other", "undefined"] choices = [] - for vm in valid_media: - if vm == "CellCarrierB": - name = "CellCarrier B" # [sic] - else: - name = vm - choices.append([name, vm]) + for vm in dict.fromkeys(valid_media): # remove duplicates + choices.append([defaults.get_emodulus_medium_name(vm), vm]) return choices @staticmethod @@ -295,9 +298,7 @@ def _update_emodulus_visc_model_choices(self): self.ui.comboBox_visc_model.blockSignals(True) self.ui.comboBox_visc_model.clear() - choices = {"Herold (2017)": "herold-2017", - "Buyukurganci (2022)": "buyukurganci-2022"} - for name, data in choices.items(): + for name, data in defaults.EMODULUS_VISC_MODELS.items(): self.ui.comboBox_visc_model.addItem(name, data) self.ui.comboBox_visc_model.blockSignals(False) diff --git a/dcscope/gui/bulk/bulk_emodulus.py b/dcscope/gui/bulk/bulk_emodulus.py index 99105a0..a2e3f61 100644 --- a/dcscope/gui/bulk/bulk_emodulus.py +++ b/dcscope/gui/bulk/bulk_emodulus.py @@ -34,13 +34,8 @@ def __init__(self, parent, pipeline, *args, **kwargs): self.ui.comboBox_medium.clear() self.ui.comboBox_medium.addItem("Other", "other") for name in SAME_MEDIA: - for sk in SAME_MEDIA[name]: - if sk.count("Cell"): # just add CellCarrier information - info = f" ({sk})" - break - else: - info = "" - self.ui.comboBox_medium.addItem(name + info, name) + self.ui.comboBox_medium.addItem( + defaults.get_emodulus_medium_name(name), name) self.ui.comboBox_medium.addItem("Not defined", "undefined") self.ui.comboBox_medium.addItem("Unchanged", "unchanged") @@ -60,9 +55,8 @@ def __init__(self, parent, pipeline, *args, **kwargs): emod_defaults = defaults.get_emodulus_defaults(QtCore.QSettings()) self.ui.comboBox_visc_model.clear() - self.ui.comboBox_visc_model.addItem("buyukurganci-2022", - "buyukurganci-2022") - self.ui.comboBox_visc_model.addItem("herold-2017", "herold-2017") + for name, data in defaults.EMODULUS_VISC_MODELS.items(): + self.ui.comboBox_visc_model.addItem(name, data) self.ui.comboBox_visc_model.setCurrentIndex( self.ui.comboBox_visc_model.findData( emod_defaults["emodulus viscosity model"])) @@ -96,7 +90,7 @@ def on_ok(self): # Tell the user that the medium of some datasets was not # changed (#124). names = "\n".join( - f"- {name} ({medium})" for name, medium in skipped) + f"- {name}: {medium}" for name, medium in skipped) QtWidgets.QMessageBox.warning( self, "Medium not changed for some datasets", diff --git a/dcscope/gui/defaults.py b/dcscope/gui/defaults.py index 9baa806..acae1cd 100644 --- a/dcscope/gui/defaults.py +++ b/dcscope/gui/defaults.py @@ -4,6 +4,7 @@ import logging import dclab +from dclab.features.emodulus.viscosity import ALIAS_MEDIA from PyQt6 import QtCore from ..pipeline.plot import DEFAULT_STATE as PLOT_DEFAULT_STATE @@ -25,6 +26,24 @@ EMODULUS_VISC_MODELS = {"Buyukurganci (2022)": "buyukurganci-2022", "Herold (2017)": "herold-2017"} +#: product names of MC-PBS media shown as a hint next to the medium name +EMODULUS_MEDIUM_HINTS = {"0.49% MC-PBS": "CellCarrier", + "0.59% MC-PBS": "CellCarrierB"} + + +def get_emodulus_medium_name(medium): + """Return the medium name preferred by dclab for display + + Aliases (e.g. "CellCarrier") are replaced by the name preferred + by dclab (e.g. "0.49% MC-PBS") and the product name is appended + as a hint (e.g. "0.49% MC-PBS (CellCarrier)"). Unknown media + are returned unchanged. + """ + name = ALIAS_MEDIA.get(medium, medium) + hint = EMODULUS_MEDIUM_HINTS.get(name) + return f"{name} ({hint})" if hint else name + + #: plot state keys that depend on a specific plot or on the data #: and are thus not stored as defaults PLOT_STATE_EXCLUDED = { diff --git a/dcscope/gui/preferences_ui.py b/dcscope/gui/preferences_ui.py index ef4668d..69f697c 100644 --- a/dcscope/gui/preferences_ui.py +++ b/dcscope/gui/preferences_ui.py @@ -115,6 +115,7 @@ def setupUi(self, Dialog): self.pushButton_enc_token.setObjectName("pushButton_enc_token") self.horizontalLayout_2.addWidget(self.pushButton_enc_token) self.label_6 = QtWidgets.QLabel(parent=self.tab_dcor) + self.label_6.setOpenExternalLinks(True) self.label_6.setObjectName("label_6") self.horizontalLayout_2.addWidget(self.label_6) self.verticalLayout_4.addLayout(self.horizontalLayout_2) diff --git a/dcscope/gui/quick_view/qv_main_ui.py b/dcscope/gui/quick_view/qv_main_ui.py index bff8279..3b8f3e0 100644 --- a/dcscope/gui/quick_view/qv_main_ui.py +++ b/dcscope/gui/quick_view/qv_main_ui.py @@ -581,6 +581,7 @@ def retranslateUi(self, Form): self.toolButton_settings.setText(_translate("Form", "S")) self.toolButton_event.setToolTip(_translate("Form", "Event")) self.toolButton_event.setText(_translate("Form", "E")) + self.toolButton_poly.setToolTip(_translate("Form", "Polygon filters")) self.toolButton_poly.setText(_translate("Form", "P")) self.label_7.setText(_translate("Form", "

Plot

")) self.label.setText(_translate("Form", "X")) @@ -594,6 +595,7 @@ def retranslateUi(self, Form): self.checkBox_downsample.setText(_translate("Form", "Downsampling")) self.spinBox_downsample.setSuffix(_translate("Form", " events")) self.checkBox_isoelastics.setText(_translate("Form", "Show isoelasticity lines")) + self.comboBox_lut.setToolTip(_translate("Form", "Look-up table for the isoelasticity lines")) self.checkBox_hue.setText(_translate("Form", "Colorize markers")) self.comboBox_hue.setItemText(0, _translate("Form", "KDE")) self.comboBox_hue.setItemText(1, _translate("Form", "Feature")) diff --git a/docs/scrots/make_scrots_qg_emodulus.py b/docs/scrots/make_scrots_qg_emodulus.py index 44515cf..ce1a9bf 100644 --- a/docs/scrots/make_scrots_qg_emodulus.py +++ b/docs/scrots/make_scrots_qg_emodulus.py @@ -45,19 +45,19 @@ wsl.ui.groupBox_emod.setFixedSize(420, 140) wsl.ui.comboBox_medium.setCurrentIndex( - wsl.ui.comboBox_medium.findData("CellCarrier")) + wsl.ui.comboBox_medium.findData("0.49% MC-PBS")) wsl.ui.comboBox_temp.setCurrentIndex(wsl.ui.comboBox_temp.findData("config")) app.processEvents(QtCore.QEventLoop.ProcessEventsFlag.AllEvents, 300) wsl.ui.groupBox_emod.grab().save("_qg_emodulus_config.png") wsl.ui.comboBox_medium.setCurrentIndex( - wsl.ui.comboBox_medium.findData("CellCarrier")) + wsl.ui.comboBox_medium.findData("0.49% MC-PBS")) wsl.ui.comboBox_temp.setCurrentIndex(wsl.ui.comboBox_temp.findData("feature")) app.processEvents(QtCore.QEventLoop.ProcessEventsFlag.AllEvents, 300) wsl.ui.groupBox_emod.grab().save("_qg_emodulus_feature.png") wsl.ui.comboBox_medium.setCurrentIndex( - wsl.ui.comboBox_medium.findData("CellCarrier")) + wsl.ui.comboBox_medium.findData("0.49% MC-PBS")) wsl.ui.comboBox_temp.setCurrentIndex(wsl.ui.comboBox_temp.findData("manual")) wsl.ui.doubleSpinBox_temp.setValue(38) app.processEvents(QtCore.QEventLoop.ProcessEventsFlag.AllEvents, 300) diff --git a/docs/sec_devs.rst b/docs/sec_devs.rst index 4e1ebb2..2496264 100644 --- a/docs/sec_devs.rst +++ b/docs/sec_devs.rst @@ -85,12 +85,6 @@ to graphically design the user interface. The `.ui` files are located in the `ui` directory in the root of the repository. We use `PyQt6` (not `PySide6`) to interface with Qt. -Note that for some reason, new versions of QtDesigner produce .ui files -that are incompatible with `pyuic6` (which converts the .ui files into -Python code). As a result, we have to use QtCreator 8 in order for things -to work (If you have a better solution, please let us know.): -https://github.com/qt-creator/qt-creator/releases/tag/v8.0.2 - The .ui files are converted to Python files (`*_ui.py`) in the corresponding locations in the `dcscope/gui` directory with the `ui/run_uic.sh` script (which calls `pyuic6`). The generated `*_ui.py` diff --git a/docs/sec_qg_youngs_modulus.rst b/docs/sec_qg_youngs_modulus.rst index 90d13d0..92ee115 100644 --- a/docs/sec_qg_youngs_modulus.rst +++ b/docs/sec_qg_youngs_modulus.rst @@ -36,8 +36,11 @@ The parameters for computing the Young's modulus can be set in the *Dataset* tab of the :ref:`Analysis View `. The Young's modulus is computed using a precomputed look-up table and additionally depends on channel width, flow rate, pixel size (pixelation -correction), and viscosity. For known media, such as CellCarrier, the -viscosity can be derived from channel width, flow rate, and temperature. +correction), and viscosity. For known media, such as 0.49% MC-PBS +(CellCarrier), the viscosity can be derived from channel width, flow rate, +and temperature. DCscope lists the media with the names used by dclab and, +for the MC-PBS media sold by Zellmechanik Dresden, the product name in +brackets. In some RT-DC setups, the chip temperature is recorded during the measurement. For instance, in :numref:`qg_emodulus_config`, the average chip temperature of 22.5°C from the [setup] metadata section is used. The value of the @@ -46,9 +49,10 @@ If the chip temperature is recorded for each event, then the user may select the *From feature* option (:numref:`qg_emodulus_feature`). In this case, the Young's modulus is computed from the individual viscosities for each event. -For MC-PBS media (e.g. CellCarrier and CellCarrier B), you can choose the -viscosity model (Herold 2017 :cite:`Herold2017` or -Buyukurganci 2022 :cite:`Buyukurganci2022`) next to the viscosity value. +For MC-PBS media (e.g. 0.49% MC-PBS (CellCarrier) and 0.59% MC-PBS +(CellCarrierB)), you can choose the viscosity model +(*Buyukurganci (2022)* :cite:`Buyukurganci2022` or +*Herold (2017)* :cite:`Herold2017`) next to the viscosity value. The models are compared in the :ref:`dclab documentation ` (see also :ref:`this example `). diff --git a/tests/test_gui_bulk_emodulus.py b/tests/test_gui_bulk_emodulus.py index d9ebd21..c550ff1 100644 --- a/tests/test_gui_bulk_emodulus.py +++ b/tests/test_gui_bulk_emodulus.py @@ -77,6 +77,10 @@ def test_manual_basic(qtbot, mw): # sanity check: default viscosity model should be "buyukurganci-2022" ivdm = dlg.ui.comboBox_visc_model.findData("buyukurganci-2022") assert dlg.ui.comboBox_visc_model.currentIndex() == ivdm + assert dlg.ui.comboBox_visc_model.currentText() == "Buyukurganci (2022)" + imed = dlg.ui.comboBox_medium.findData("0.59% MC-PBS") + assert dlg.ui.comboBox_medium.itemText(imed) == \ + "0.59% MC-PBS (CellCarrierB)" dlg.ui.comboBox_temp.setCurrentIndex( dlg.ui.comboBox_temp.findData("manual")) @@ -117,7 +121,7 @@ def test_manual_wrong_medium(qtbot, mw, warnings_shown): # The user is informed that the medium was not changed (#124) assert len(warnings_shown) == 1 - assert warnings_shown[0][1].count("(CellCarrier B)") == 2 + assert warnings_shown[0][1].count(": 0.59% MC-PBS (CellCarrierB)") == 2 for slot in mw.pipeline.slots: ds = slot.get_dataset() @@ -302,7 +306,7 @@ def test_wrong_medium_warning_only_for_fixed_media_issue_124( text = warnings_shown[0][1] # only one dataset is listed assert text.count("\n- ") == 1 - assert text.count(f"- {slot_known.name} (CellCarrier)") == 1 + assert text.count(f"- {slot_known.name}: 0.49% MC-PBS (CellCarrier)") == 1 def test_no_warning_for_unchanged_medium(qtbot, mw, warnings_shown): diff --git a/tests/test_gui_emodulus.py b/tests/test_gui_emodulus.py index a659931..d3f3ef9 100644 --- a/tests/test_gui_emodulus.py +++ b/tests/test_gui_emodulus.py @@ -54,7 +54,7 @@ def test_allow_to_set_manual_temperature_for_known_medium(qtbot, mw): wsl = mw.widget_ana_view.ui.widget_slot # 1. test whether we can actually select things in comboBox_temp - ccidx = wsl.ui.comboBox_medium.findData("CellCarrier") + ccidx = wsl.ui.comboBox_medium.findData("0.49% MC-PBS") wsl.ui.comboBox_medium.setCurrentIndex(ccidx) assert wsl.ui.comboBox_temp.isEnabled() @@ -376,3 +376,52 @@ def test_viscosity_defaults_to_buyukurganci_2022(qtbot, mw): idvm_loc = wsl.ui.comboBox_visc_model.findData("buyukurganci-2022") idvm_actual = wsl.ui.comboBox_visc_model.currentIndex() assert idvm_loc == idvm_actual + + +def test_medium_and_viscosity_model_names(qtbot, mw): + """Media are listed with the names preferred by dclab (no aliases)""" + qtbot.addWidget(mw) + path1 = make_dataset(medium=None) + mw.add_dataslot(paths=[path1]) + mw.widget_ana_view.ui.tabWidget.setCurrentWidget( + mw.widget_ana_view.ui.tab_slot) + wsl = mw.widget_ana_view.ui.widget_slot + cbm = wsl.ui.comboBox_medium + assert [cbm.itemData(ii) for ii in range(cbm.count())] == [ + "0.49% MC-PBS", "0.59% MC-PBS", "0.83% MC-PBS", "water", + "other", "undefined"] + assert cbm.itemText(0) == "0.49% MC-PBS (CellCarrier)" + assert cbm.itemText(1) == "0.59% MC-PBS (CellCarrierB)" + assert cbm.itemText(2) == "0.83% MC-PBS" + cbv = wsl.ui.comboBox_visc_model + assert [cbv.itemText(ii) for ii in range(cbv.count())] == [ + "Buyukurganci (2022)", "Herold (2017)"] + + +def test_medium_name_alias_from_metadata(qtbot, mw): + """A medium alias in the metadata is shown with the preferred name""" + qtbot.addWidget(mw) + path1 = make_dataset(medium="CellCarrier B") + mw.add_dataslot(paths=[path1]) + mw.widget_ana_view.ui.tabWidget.setCurrentWidget( + mw.widget_ana_view.ui.tab_slot) + wsl = mw.widget_ana_view.ui.widget_slot + assert not wsl.ui.comboBox_medium.isEnabled() + assert wsl.ui.comboBox_medium.count() == 1 + assert wsl.ui.comboBox_medium.currentData() == "CellCarrier B" + assert wsl.ui.comboBox_medium.currentText() == \ + "0.59% MC-PBS (CellCarrierB)" + + +def test_medium_name_alias_from_session(qtbot, mw): + """A medium alias selected in older versions of DCscope is restored""" + qtbot.addWidget(mw) + path1 = make_dataset(medium=None) + mw.add_dataslot(paths=[path1]) + mw.widget_ana_view.ui.tabWidget.setCurrentWidget( + mw.widget_ana_view.ui.tab_slot) + wsl = mw.widget_ana_view.ui.widget_slot + mw.pipeline.slots[0].config["emodulus"]["emodulus medium"] = \ + "CellCarrier" + wsl.update_content() + assert wsl.ui.comboBox_medium.currentData() == "0.49% MC-PBS" diff --git a/ui/analysis/ana_plot.ui b/ui/analysis/ana_plot.ui index 5c52688..f9f627f 100644 --- a/ui/analysis/ana_plot.ui +++ b/ui/analysis/ana_plot.ui @@ -482,7 +482,11 @@ - + + + Look-up table for the isoelasticity lines + + diff --git a/ui/preferences.ui b/ui/preferences.ui index 3f81e8e..d87739b 100644 --- a/ui/preferences.ui +++ b/ui/preferences.ui @@ -244,6 +244,9 @@ <html><head/><body><p><a href="https://dc.readthedocs.io/en/latest/sec_self_hosting/operations.html#creating-an-encrypted-access-token"><span style=" text-decoration: underline; color:#0000ff;">What are encrypted tokens?</span></a></p></body></html> + + true + diff --git a/ui/quick_view/qv_main.ui b/ui/quick_view/qv_main.ui index 054339f..b2c32c7 100644 --- a/ui/quick_view/qv_main.ui +++ b/ui/quick_view/qv_main.ui @@ -160,6 +160,9 @@ + + Polygon filters + P @@ -400,7 +403,11 @@ - + + + Look-up table for the isoelasticity lines + +