Commit 90feb02f authored by Carsten Richter's avatar Carsten Richter

Merge branch 'default-nb-bins' into 'master'

Change default number of bins and add tooltips

Closes #44

See merge request !104
parents 8ee88989 886f788c
Pipeline #6953 passed with stages
in 5 minutes and 52 seconds
......@@ -102,6 +102,9 @@ class ConversionParamsWidget(Qt.QWidget):
# Maxipix correction
self.__maxipixCorrection = self.__createCheckBox(
'1. Maxipix correction')
self.__maxipixCorrection.setToolTip(
'Enable/Disable Maxipix detector module edges correction '
'on input images')
imgGboxLayout.addRow(self.__maxipixCorrection)
......@@ -124,6 +127,15 @@ class ConversionParamsWidget(Qt.QWidget):
maskLayout = Qt.QHBoxLayout()
maskLayout.addWidget(self.__maskFileLineEdit, 1)
maskLayout.addWidget(maskButton)
tooltip = 'Enable/Disable input images masking ' \
'and select the mask image.<br>' \
'A value different from 0 in the mask image ' \
'masks the corresponding pixel in input images.'
self.__imgMaskCBox.setToolTip(tooltip)
self.__maskFileLineEdit.setToolTip(tooltip)
maskButton.setToolTip(tooltip)
imgGboxLayout.addRow(self.__imgMaskCBox, maskLayout)
# Normalization
......@@ -136,6 +148,12 @@ class ConversionParamsWidget(Qt.QWidget):
if normalizers is not None:
self.__normalizationComboBox.addItems(normalizers)
tooltip = 'Enable/Disable input images normalization<br>' \
'and select the data to use as normalizer'
self.__imgNormCBox.setToolTip(tooltip)
self.__normalizationComboBox.setToolTip(tooltip)
imgGboxLayout.addRow(self.__imgNormCBox, self.__normalizationComboBox)
# Median filter
......@@ -144,8 +162,6 @@ class ConversionParamsWidget(Qt.QWidget):
inputBase = Qt.QWidget()
inputBase.setEnabled(False)
inputBase.setContentsMargins(0, 0, 0, 0)
medfiltLayout = Qt.QHBoxLayout(inputBase)
medfiltLayout.setContentsMargins(0, 0, 0, 0)
self.__medfiltCBox.toggled.connect(inputBase.setEnabled)
......@@ -159,11 +175,18 @@ class ConversionParamsWidget(Qt.QWidget):
self.__medfiltVEdit.setAlignment(Qt.Qt.AlignRight)
# self.__medfiltVEdit.setText(str(medfiltDims[1]))
medfiltLayout = Qt.QHBoxLayout(inputBase)
medfiltLayout.setContentsMargins(0, 0, 0, 0)
medfiltLayout.addWidget(Qt.QLabel('w='))
medfiltLayout.addWidget(self.__medfiltHEdit)
medfiltLayout.addWidget(Qt.QLabel('h='))
medfiltLayout.addWidget(self.__medfiltVEdit)
tooltip = 'Enable/Disable median filter on input images ' \
'and set the window size: <b>W</b>idth and <b>H</b>eight'
self.__medfiltCBox.setToolTip(tooltip)
inputBase.setToolTip(tooltip)
imgGboxLayout.addRow(self.__medfiltCBox, inputBase)
layout.addWidget(imageGbox)
......@@ -204,8 +227,14 @@ class ConversionParamsWidget(Qt.QWidget):
self.__coordinatesComboBox.currentIndexChanged[int].connect(
self.__coordinatesChanged)
tooltip = ['Select the QSpace histogram coordinate system:<br>']
for coordinates in QSpaceCoordinates.ALLOWED:
self.__coordinatesComboBox.addItem(coordinates)
self.__coordinatesComboBox.addItem(coordinates.capitalize())
tooltip.append('- <b>%s</b>: %s, %s and %s axes' %
((coordinates.capitalize(),) +
QSpaceCoordinates.axes_names(coordinates)))
self.__coordinatesComboBox.setToolTip('<br>'.join(tooltip))
qspaceLayout.addRow("Coordinates:", self.__coordinatesComboBox)
layout.addWidget(qspaceGbox)
......@@ -238,7 +267,7 @@ class ConversionParamsWidget(Qt.QWidget):
def __coordinatesChanged(self, index=None):
"""Handle change of QSpace coordinate change"""
coordinates = self.__coordinatesComboBox.currentText()
coordinates = self.getCoordinates()
for coord, widget in self.__qDimWidgets.items():
widget.setVisible(coordinates == coord)
......@@ -350,7 +379,7 @@ class ConversionParamsWidget(Qt.QWidget):
:rtype: List[Union[int,None]]
"""
if coordinates is None:
coordinates = self.__coordinatesComboBox.currentText()
coordinates = self.getCoordinates()
sizes = []
for edit in self.__qDimEdits[coordinates]:
......@@ -368,6 +397,16 @@ class ConversionParamsWidget(Qt.QWidget):
for edit, size in zip(self.__qDimEdits[coordinates], qspaceDims):
edit.setText(str(int(size)))
def setQSpaceRecommendedMaxDims(self, coordinates, qspaceDims):
"""Sets the recommended max qspace dimensions.
:param QSpaceCoordinates coordinates:
:param qspaceDims: A three integers array.
"""
self.__qDimWidgets[coordinates].setToolTip(
'Set the number of bins of the histogram for each dimension.\n'
'Recommended maximum values are: [%d, %d, %d]' % tuple(qspaceDims))
def getBeamEnergy(self):
"""Returns beam energy in eV or None if no input"""
if self.__acqParamWid.isBeamEnergyEnabled():
......@@ -398,7 +437,7 @@ class ConversionParamsWidget(Qt.QWidget):
:rtype: QSpaceCoordinates
"""
return self.__coordinatesComboBox.currentText()
return self.__coordinatesComboBox.currentText().lower()
class QSpaceWidget(Qt.QDialog):
......@@ -480,6 +519,7 @@ class QSpaceWidget(Qt.QDialog):
# ################
inputGbx = GroupBox("Input")
inputGbx.setToolTip("HDF5 'master' data file to process")
layout = Qt.QHBoxLayout(inputGbx)
topLayout.addWidget(inputGbx,
0, 0,
......@@ -593,6 +633,7 @@ class QSpaceWidget(Qt.QDialog):
# ################
outputGbx = GroupBox("Output")
outputGbx.setToolTip('HDF5 file where QSpace will be saved')
layout = Qt.QHBoxLayout(outputGbx)
topLayout.addWidget(outputGbx, 3, 0, 1, 2)
lab = Qt.QLabel('Output :')
......@@ -644,7 +685,6 @@ class QSpaceWidget(Qt.QDialog):
entry = entries[0] # Get default config from first entry
for coordinates in QSpaceCoordinates.ALLOWED:
#if coordinates == QSpaceCoordinates.CARTESIAN or 1:
# Compute Qspace conversion
q_array = qspace_conversion(
img_size=xsocsH5.image_size(entry),
......@@ -666,11 +706,12 @@ class QSpaceWidget(Qt.QDialog):
bins = (abs(dim).max() - abs(dim).min()) / step
maxbin = min(maxbin, bins)
maxbins.append(int(maxbin) + 1)
# TODO estimate bins for spherical coordinates
# CR: it should just work?!
#maxbins = [0, 0, 0]
self.__paramsWid.setQSpaceDims(coordinates, maxbins)
# Set default number of bins to at most 100
self.__paramsWid.setQSpaceDims(
coordinates, [min(maxbin, 100) for maxbin in maxbins])
self.__paramsWid.setQSpaceRecommendedMaxDims(coordinates,
maxbins)
else: # Set to 0 by default
for coordinates in QSpaceCoordinates.ALLOWED:
......
......@@ -73,15 +73,22 @@ class AcqParamsWidget(Qt.QWidget):
# beam energy
# ===========
row = 0
self.__energyWidget = Qt.QWidget()
self.__energyWidget = Qt.QWidget(self)
h_layout = Qt.QHBoxLayout(self.__energyWidget)
self.__beam_nrg_edit = _dblLineEditWidget(12, read_only)
h_layout.addWidget(self.__beam_nrg_edit)
h_layout.addWidget(Qt.QLabel('<b>eV</b>'))
layout.addWidget(Qt.QLabel('Beam energy :'), row, 0)
label = Qt.QLabel('Beam energy:')
layout.addWidget(label, row, 0)
layout.addWidget(self.__energyWidget, row, 1,
alignment=Qt.Qt.AlignLeft | Qt.Qt.AlignTop)
tooltip = 'Incoming beam energy'
label.setToolTip(tooltip)
self.__energyWidget.setToolTip(tooltip)
# ===
row += 1
......@@ -95,8 +102,9 @@ class AcqParamsWidget(Qt.QWidget):
# ===========
row += 1
h_layout = Qt.QHBoxLayout()
layout.addLayout(h_layout, row, 1,
widget = Qt.QWidget(self)
h_layout = Qt.QHBoxLayout(widget)
layout.addWidget(widget, row, 1,
alignment=Qt.Qt.AlignLeft | Qt.Qt.AlignTop)
self.__dir_beam_v_edit = _dblLineEditWidget(6, read_only)
h_layout.addWidget(Qt.QLabel('v='))
......@@ -105,7 +113,13 @@ class AcqParamsWidget(Qt.QWidget):
h_layout.addWidget(Qt.QLabel(' h='))
h_layout.addWidget(self.__dir_beam_h_edit)
h_layout.addWidget(Qt.QLabel('<b>px</b>'))
layout.addWidget(Qt.QLabel('Direct beam :'), row, 0)
label = Qt.QLabel('Direct beam:')
layout.addWidget(label, row, 0)
tooltip = 'Set direct beam <b>V</b>ertical and <b>H</b>orizontal ' \
'calibration position on the detector'
widget.setToolTip(tooltip)
label.setToolTip(tooltip)
# ===
......@@ -120,8 +134,9 @@ class AcqParamsWidget(Qt.QWidget):
# ===========
row += 1
h_layout = Qt.QHBoxLayout()
layout.addLayout(h_layout, row, 1,
widget = Qt.QWidget(self)
h_layout = Qt.QHBoxLayout(widget)
layout.addWidget(widget, row, 1,
alignment=Qt.Qt.AlignLeft | Qt.Qt.AlignTop)
self.__chpdeg_v_edit = _dblLineEditWidget(6, read_only)
h_layout.addWidget(Qt.QLabel('v='))
......@@ -130,7 +145,14 @@ class AcqParamsWidget(Qt.QWidget):
h_layout.addWidget(Qt.QLabel(' h='))
h_layout.addWidget(self.__chpdeg_h_edit)
h_layout.addWidget(Qt.QLabel('<b>px</b>'))
layout.addWidget(Qt.QLabel('Chan. per deg. :'), row, 0)
label = Qt.QLabel('Chan. per deg.:')
layout.addWidget(label, row, 0)
tooltip = 'Set <b>V</b>ertical and <b>H</b>orizontal detector ' \
'pixels per degree calibration information'
widget.setToolTip(tooltip)
label.setToolTip(tooltip)
# ===
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment