diff --git a/CHANGELOG b/CHANGELOG index 4e2102b..c79bbe5 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -27,6 +27,8 @@ offset") to the traces shown in the Quick View (#81) - enh: button for applying the fluorescence crosstalk coefficients to all datasets in the Dataset tab of the Analysis View (#198) + - enh: allow to hide the traces of individual fluorescence channels + in the Quick View (#200) - docs: add quick guide for fluorescence crosstalk correction (#120) - docs: screenshot scripts download missing datasets from figshare and use the icon theme of DCscope diff --git a/dcscope/gui/quick_view/qv_main.py b/dcscope/gui/quick_view/qv_main.py index 41dc275..aa8e44c 100644 --- a/dcscope/gui/quick_view/qv_main.py +++ b/dcscope/gui/quick_view/qv_main.py @@ -143,6 +143,9 @@ def __init__(self, *args, **kwargs): self.on_event_scatter_update) self.ui.checkBox_trace_zoom.stateChanged.connect( self.on_event_scatter_update) + for ii in range(1, 4): + getattr(self.ui, f"checkBox_trace_fl{ii}").stateChanged.connect( + self.on_event_scatter_update) self.ui.tabWidget_event.currentChanged.connect( self.on_event_scatter_update) @@ -334,6 +337,10 @@ def read_pipeline_state(self): "trace legend": self.ui.checkBox_trace_legend.isChecked(), "trace raw": self.ui.checkBox_trace_raw.isChecked(), "trace zoom": self.ui.checkBox_trace_zoom.isChecked(), + # fluorescence channels for which traces are shown (#200) + "trace channels": [ + ii for ii in range(1, 4) + if getattr(self.ui, f"checkBox_trace_fl{ii}").isChecked()], } state = { "plot": plot, @@ -383,6 +390,10 @@ def write_pipeline_state(self, state): self.ui.spinBox_event.setValue(event["index"]) self.ui.checkBox_trace_raw.setChecked(event["trace raw"]) self.ui.checkBox_trace_legend.setChecked(event["trace legend"]) + channels = event.get("trace channels", [1, 2, 3]) + for ii in range(1, 4): + getattr(self.ui, f"checkBox_trace_fl{ii}").setChecked( + ii in channels) def enable_interface(self, value): # Initially, only show the info about how QuickView works @@ -487,10 +498,20 @@ def show_traces(self, tdata): # fluorescence intensity range_fl = [0, 0] + # Show checkboxes only for the channels with traces (#200) + for ii in range(1, 4): + cb = getattr(self.ui, f"checkBox_trace_fl{ii}") + cb.setVisible(any(name.startswith(f"fl{ii}_") for name in tdata)) + if self.slot is not None: + cb.setText(self.slot.fl_name_dict[f"FL-{ii}"]) + for name in dclab.dfn.FLUOR_TRACES: if name.count("raw") and not state["event"]["trace raw"]: # hide raw trace data if user decided so show = False + elif int(name[2]) not in state["event"]["trace channels"]: + # hide traces of this channel if user decided so + show = False else: show = True flid = name.split("_")[0] diff --git a/dcscope/gui/quick_view/qv_main_ui.py b/dcscope/gui/quick_view/qv_main_ui.py index d3fa29a..bff8279 100644 --- a/dcscope/gui/quick_view/qv_main_ui.py +++ b/dcscope/gui/quick_view/qv_main_ui.py @@ -389,6 +389,18 @@ def setupUi(self, Form): self.checkBox_trace_legend = QtWidgets.QCheckBox(parent=self.widget) self.checkBox_trace_legend.setObjectName("checkBox_trace_legend") self.gridLayout_4.addWidget(self.checkBox_trace_legend, 0, 2, 1, 1) + self.checkBox_trace_fl1 = QtWidgets.QCheckBox(parent=self.widget) + self.checkBox_trace_fl1.setChecked(True) + self.checkBox_trace_fl1.setObjectName("checkBox_trace_fl1") + self.gridLayout_4.addWidget(self.checkBox_trace_fl1, 1, 0, 1, 1) + self.checkBox_trace_fl2 = QtWidgets.QCheckBox(parent=self.widget) + self.checkBox_trace_fl2.setChecked(True) + self.checkBox_trace_fl2.setObjectName("checkBox_trace_fl2") + self.gridLayout_4.addWidget(self.checkBox_trace_fl2, 1, 1, 1, 1) + self.checkBox_trace_fl3 = QtWidgets.QCheckBox(parent=self.widget) + self.checkBox_trace_fl3.setChecked(True) + self.checkBox_trace_fl3.setObjectName("checkBox_trace_fl3") + self.gridLayout_4.addWidget(self.checkBox_trace_fl3, 1, 2, 1, 1) self.verticalLayout_6.addLayout(self.gridLayout_4) self.graphicsView_trace = SimplePlotWidget(parent=self.widget) self.graphicsView_trace.setMinimumSize(QtCore.QSize(0, 150)) @@ -600,6 +612,12 @@ def retranslateUi(self, Form): self.checkBox_trace_raw.setText(_translate("Form", "Show raw data")) self.checkBox_trace_zoom.setText(_translate("Form", "Zoom")) self.checkBox_trace_legend.setText(_translate("Form", "Legend")) + self.checkBox_trace_fl1.setToolTip(_translate("Form", "Show the traces of fluorescence channel 1")) + self.checkBox_trace_fl1.setText(_translate("Form", "FL-1")) + self.checkBox_trace_fl2.setToolTip(_translate("Form", "Show the traces of fluorescence channel 2")) + self.checkBox_trace_fl2.setText(_translate("Form", "FL-2")) + self.checkBox_trace_fl3.setToolTip(_translate("Form", "Show the traces of fluorescence channel 3")) + self.checkBox_trace_fl3.setText(_translate("Form", "FL-3")) self.tabWidget_event.setTabText(self.tabWidget_event.indexOf(self.tab_view), _translate("Form", "View")) self.tabWidget_event.setTabText(self.tabWidget_event.indexOf(self.tab_features), _translate("Form", "Features")) self.label_9.setText(_translate("Form", "Polygon Filter")) diff --git a/docs/scrots/ui_qv_event.png b/docs/scrots/ui_qv_event.png index babb591..c223097 100644 Binary files a/docs/scrots/ui_qv_event.png and b/docs/scrots/ui_qv_event.png differ diff --git a/docs/scrots/ui_qv_poly.png b/docs/scrots/ui_qv_poly.png index fa85639..520a111 100644 Binary files a/docs/scrots/ui_qv_poly.png and b/docs/scrots/ui_qv_poly.png differ diff --git a/docs/scrots/ui_qv_settings.png b/docs/scrots/ui_qv_settings.png index f4f4cf7..e8bcefb 100644 Binary files a/docs/scrots/ui_qv_settings.png and b/docs/scrots/ui_qv_settings.png differ diff --git a/docs/sec_interface.rst b/docs/sec_interface.rst index 0dc139c..b6a825c 100644 --- a/docs/sec_interface.rst +++ b/docs/sec_interface.rst @@ -244,7 +244,9 @@ select single events by clicking in the scatter plot or by scrolling through the *Index* spin control. If available, the event image is shown alongside the fluorescence trace of the event. If the legend of the fluorescence trace plot covers parts of the traces, you can move it by dragging it with the -mouse. All features of the event are listed in a separate tab. +mouse. The checkboxes above the trace plot allow you to hide the raw traces +or the traces of individual fluorescence channels. All features of the +event are listed in a separate tab. .. figure:: scrots/ui_qv_event.png :target: _images/ui_qv_event.png diff --git a/tests/test_gui_quickview.py b/tests/test_gui_quickview.py index 3bd2b90..0dda250 100644 --- a/tests/test_gui_quickview.py +++ b/tests/test_gui_quickview.py @@ -1428,14 +1428,61 @@ def test_trace_baseline_offset_issue_81(qtbot, mw, tmp_path): plot_fl1 = qv.trace_plots["fl1_raw"] plot_fl2 = qv.trace_plots["fl2_raw"] - qtbot.waitUntil(lambda: plot_fl1.yData is not None - and plot_fl2.yData is not None, - timeout=5000) index = qv.ui.spinBox_event.value() - 1 with dclab.new_dataset(path) as ds: - fl1 = ds["trace"]["fl1_raw"][index] - fl2 = ds["trace"]["fl2_raw"][index] - # offset only defined for channel 1 - assert np.allclose(plot_fl1.yData, fl1 + 17) - assert np.allclose(plot_fl2.yData, fl2) + fl1 = np.array(ds["trace"]["fl1_raw"][index]) + fl2 = np.array(ds["trace"]["fl2_raw"][index]) + + def traces_shown(): + # The trace plots initially contain placeholder data, so we have + # to wait until the event data are shown. + assert len(plot_fl1.yData) == fl1.size + assert len(plot_fl2.yData) == fl2.size + # offset only defined for channel 1 + assert np.allclose(plot_fl1.yData, fl1 + 17) + assert np.allclose(plot_fl2.yData, fl2) + + qtbot.waitUntil(traces_shown, timeout=5000) + + +def test_hide_fluorescence_channel_traces_issue_200(qtbot, mw): + """Traces of individual fluorescence channels can be hidden (#200)""" + qtbot.addWidget(mw) + mw.add_dataslot(paths=[datapath / "calibration_beads_47.rtdc"]) + mw.pipeline.slots[0].fl_name_dict["FL-2"] = "PE" + + slot_id = mw.pipeline.slot_ids[0] + filt_id = mw.pipeline.filter_ids[0] + em = mw.ui.block_matrix.get_widget(slot_id, filt_id) + qtbot.mouseClick(em, QtCore.Qt.MouseButton.LeftButton) + qtbot.mouseClick(em, QtCore.Qt.MouseButton.LeftButton, + QtCore.Qt.KeyboardModifier.ShiftModifier) + qv = mw.widget_quick_view + qtbot.waitUntil(qv.isVisible, timeout=5000) + qtbot.mouseClick(qv.ui.toolButton_event, + QtCore.Qt.MouseButton.LeftButton) + tp = qv.trace_plots + qtbot.waitUntil(lambda: tp["fl1_raw"].isVisible() + and tp["fl2_raw"].isVisible(), + timeout=5000) + # the checkboxes are labeled with the channel names + assert qv.ui.checkBox_trace_fl2.text() == "PE" + + # hide FL-2 + qv.ui.checkBox_trace_fl2.setChecked(False) + qtbot.waitUntil(lambda: not tp["fl2_raw"].isVisible(), timeout=5000) + assert not tp["fl2_median"].isVisible() + assert tp["fl1_raw"].isVisible() + assert tp["fl1_median"].isVisible() + assert tp["fl3_median"].isVisible() + + # still hidden for the next event + qv.ui.spinBox_event.setValue(qv.ui.spinBox_event.value() + 1) + QtTest.QTest.qWait(500) + assert not tp["fl2_raw"].isVisible() + assert tp["fl1_raw"].isVisible() + + # show FL-2 again + qv.ui.checkBox_trace_fl2.setChecked(True) + qtbot.waitUntil(lambda: tp["fl2_raw"].isVisible(), timeout=5000) diff --git a/ui/quick_view/qv_main.ui b/ui/quick_view/qv_main.ui index 5d7ec1a..054339f 100644 --- a/ui/quick_view/qv_main.ui +++ b/ui/quick_view/qv_main.ui @@ -941,6 +941,45 @@ + + + + Show the traces of fluorescence channel 1 + + + FL-1 + + + true + + + + + + + Show the traces of fluorescence channel 2 + + + FL-2 + + + true + + + + + + + Show the traces of fluorescence channel 3 + + + FL-3 + + + true + + +