Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
21 changes: 21 additions & 0 deletions dcscope/gui/quick_view/qv_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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]
Expand Down
18 changes: 18 additions & 0 deletions dcscope/gui/quick_view/qv_main_ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down Expand Up @@ -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", "<b>Polygon Filter</b>"))
Expand Down
Binary file modified docs/scrots/ui_qv_event.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/scrots/ui_qv_poly.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/scrots/ui_qv_settings.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 3 additions & 1 deletion docs/sec_interface.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
63 changes: 55 additions & 8 deletions tests/test_gui_quickview.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
39 changes: 39 additions & 0 deletions ui/quick_view/qv_main.ui
Original file line number Diff line number Diff line change
Expand Up @@ -941,6 +941,45 @@
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QCheckBox" name="checkBox_trace_fl1">
<property name="toolTip">
<string>Show the traces of fluorescence channel 1</string>
</property>
<property name="text">
<string>FL-1</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QCheckBox" name="checkBox_trace_fl2">
<property name="toolTip">
<string>Show the traces of fluorescence channel 2</string>
</property>
<property name="text">
<string>FL-2</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QCheckBox" name="checkBox_trace_fl3">
<property name="toolTip">
<string>Show the traces of fluorescence channel 3</string>
</property>
<property name="text">
<string>FL-3</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
<item>
Expand Down
Loading