Skip to content
Merged
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
58 changes: 57 additions & 1 deletion image_stitcher/stitcher_gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,15 @@
from PyQt5.QtCore import pyqtSignal as Signal
from PyQt5.QtWidgets import (
QApplication,
QCheckBox,
QComboBox,
QFileDialog,
QLabel,
QLineEdit,
QMessageBox,
QProgressBar,
QPushButton,
QSpinBox,
QVBoxLayout,
QWidget,
)
Expand Down Expand Up @@ -75,10 +77,33 @@ def initUI(self) -> None:
self.layout.addWidget(self.inputDirectoryBtn) # type: ignore

# Output format combo box (full width)
self.outputFormatCombo = QComboBox()
self.outputFormatCombo = QComboBox(self)
self.outputFormatCombo.addItems(["OME-ZARR", "OME-TIFF"])
self.outputFormatCombo.currentTextChanged.connect(self.onFormatChange)
self.layout.addWidget(self.outputFormatCombo) # type: ignore

self.compressionLabel = QLabel("Output compression", self)
self.layout.addWidget(self.compressionLabel)
self.outputCompression = QComboBox(self)
self.outputCompression.addItems(["default", "none"])
self.layout.addWidget(self.outputCompression) # type: ignore

self.pyramidCheckbox = QCheckBox("Infer levels for output image pyramid", self)
self.pyramidCheckbox.setChecked(True)
self.pyramidCheckbox.toggled.connect(self.onPyramidChange)
self.layout.addWidget(self.pyramidCheckbox)

self.pyramidLabel = QLabel(
"Number of output levels for the image pyramid", self
)
self.layout.addWidget(self.pyramidLabel)
self.pyramidLabel.hide()
self.pyramidLevels = QSpinBox(self)
self.pyramidLevels.setMaximum(32)
self.pyramidLevels.setMinimum(1)
self.layout.addWidget(self.pyramidLevels)
self.pyramidLevels.hide()

# Status label
self.statusLabel = QLabel("Status: Ready", self)
self.layout.addWidget(self.statusLabel) # type: ignore
Expand Down Expand Up @@ -106,6 +131,7 @@ def initUI(self) -> None:
self.viewBtn.setEnabled(False)
self.layout.addWidget(self.viewBtn) # type: ignore

self.layout.insertStretch(-1, 1) # type: ignore
self.setWindowTitle("Cephla Image Stitcher")
self.setGeometry(300, 300, 500, 300)
self.show()
Expand Down Expand Up @@ -141,6 +167,11 @@ def onStitchingStart(self) -> None:
scan_pattern=ScanPattern.unidirectional,
)

if self.outputFormatCombo.currentText() == "OME-ZARR":
if not self.pyramidCheckbox.isChecked():
params.num_pyramid_levels = self.pyramidLevels.value()
params.output_compression = self.outputCompression.currentText()

self.stitcher = StitcherThread(
Stitcher(
params,
Expand All @@ -164,6 +195,31 @@ def onStitchingStart(self) -> None:
QMessageBox.critical(self, "Stitching Error", str(e))
self.statusLabel.setText("Status: Error Encountered")

def onFormatChange(self, format: str) -> None:
if format == "OME-ZARR":
self.pyramidCheckbox.show()
self.compressionLabel.show()
self.outputCompression.show()
if not self.pyramidCheckbox.isChecked():
self.pyramidLabel.show()
self.pyramidLevels.show()

else:
assert format == "OME-TIFF"
self.compressionLabel.hide()
self.outputCompression.hide()
self.pyramidCheckbox.hide()
self.pyramidLabel.hide()
self.pyramidLevels.hide()

def onPyramidChange(self, checked: bool) -> None:
if checked:
self.pyramidLevels.hide()
self.pyramidLabel.hide()
else:
self.pyramidLabel.show()
self.pyramidLevels.show()

def setupConnections(self) -> None:
assert self.stitcher is not None
self.update_progress.connect(self.updateProgressBar)
Expand Down