Commit fb154fb8 authored by Thomas Vincent's avatar Thomas Vincent

remove image binning from widgets (keeping display in info if it is

available in hdf5 file
parent 8115f73f
......@@ -190,7 +190,6 @@ class XsocsGui(Qt.QMainWindow):
widget = QSpaceWidget(self.__project.xsocsFile,
outQSpaceH5=output_f,
qspaceDims=None,
imageBinning=None,
roi=event.roi,
entries=event.entries,
parent=self.sender(),
......
......@@ -53,12 +53,10 @@ class ConversionParamsWidget(Qt.QWidget):
"""
Widget for conversion parameters input :
- normalization counter
- image binning size
- median filter
- qspace dimensions
"""
def __init__(self,
imgBinning=None,
medfiltDims=None,
normalizers=None,
beamEnergy=None,
......@@ -69,7 +67,6 @@ class ConversionParamsWidget(Qt.QWidget):
layout = Qt.QGridLayout(self)
layout.setContentsMargins(0, 0, 0, 0)
# imgBinning = np.array(imgBinning, ndmin=1)
# medfiltDims = np.array(medfiltDims, ndmin=1)
self.__mask = None # Currently selected mask array
......@@ -145,34 +142,6 @@ class ConversionParamsWidget(Qt.QWidget):
self.__normalizationComboBox.addItems(normalizers)
imgGboxLayout.addRow(self.__imgNormCBox, self.__normalizationComboBox)
# Binnning
self.__imgBinCBox = createCheckBox('3. Binning')
inputBase = Qt.QWidget()
inputBase.setEnabled(False)
inputBase.setContentsMargins(0, 0, 0, 0)
imgBinLayout = Qt.QHBoxLayout(inputBase)
imgBinLayout.setContentsMargins(0, 0, 0, 0)
self.__imgBinCBox.toggled.connect(inputBase.setEnabled)
imgBinHEdit = StyledLineEdit(nChar=5)
imgBinHEdit.setValidator(Qt.QIntValidator(imgBinHEdit))
imgBinHEdit.setAlignment(Qt.Qt.AlignRight)
# imgBinHEdit.setText(str(imgBinning[0]))
imgBinVEdit = StyledLineEdit(nChar=5)
imgBinVEdit.setValidator(Qt.QIntValidator(imgBinVEdit))
imgBinVEdit.setAlignment(Qt.Qt.AlignRight)
# imgBinVEdit.setText(str(imgBinning[1]))
imgBinLayout.addWidget(Qt.QLabel('w='))
imgBinLayout.addWidget(imgBinHEdit)
imgBinLayout.addWidget(Qt.QLabel('h='))
imgBinLayout.addWidget(imgBinVEdit)
imgGboxLayout.addRow(self.__imgBinCBox, inputBase)
# Median filter
self.__medfiltCBox = createCheckBox('4. Median filter')
......@@ -201,10 +170,6 @@ class ConversionParamsWidget(Qt.QWidget):
imgGboxLayout.addRow(self.__medfiltCBox, inputBase)
# Mask and binning mutually exclusive
self.__imgMaskCBox.toggled.connect(self.__imgBinCBox.setDisabled)
self.__imgBinCBox.toggled.connect(self.__imgMaskCBox.setDisabled)
layout.addWidget(imageGbox)
# ===========
......@@ -236,8 +201,6 @@ class ConversionParamsWidget(Qt.QWidget):
dimLayout.addWidget(qDimsZEdit)
dimLayout.addStretch(1)
self.__imgBinHEdit = imgBinHEdit
self.__imgBinVEdit = imgBinVEdit
self.__medfiltHEdit = medfiltHEdit
self.__medfiltVEdit = medfiltVEdit
self.__qDimsXEdit = qDimsXEdit
......@@ -246,7 +209,6 @@ class ConversionParamsWidget(Qt.QWidget):
layout.addWidget(qspaceGbox)
self.setImageBinning(imgBinning)
self.setMedfiltDims(medfiltDims)
# ===========
......@@ -348,41 +310,6 @@ class ConversionParamsWidget(Qt.QWidget):
self.__medfiltVEdit.setText(str(medfiltDims[1]))
self.__medfiltCBox.setChecked(not equal)
def getImageBinning(self):
"""
Returns the image binning dimensions, a 2 integers array, or None if
the image binning is not enabled.
:return:
"""
if not self.__imgBinCBox.isChecked():
return None
h_bin = self.__imgBinHEdit.text()
if len(h_bin) == 0:
h_bin = None
else:
h_bin = int(h_bin)
v_bin = self.__imgBinVEdit.text()
if len(v_bin) == 0:
v_bin = None
else:
v_bin = int(v_bin)
return [h_bin, v_bin]
def setImageBinning(self, imageBinning):
"""
Sets the image binning dimensions.
:param imageBinning: a 2 integers array.
:return:
"""
if imageBinning is None:
imageBinning = (1, 1)
imgBinning = np.array(imageBinning, ndmin=1)
equal = np.array_equal(imgBinning, [1, 1])
self.__imgBinHEdit.setText(str(imageBinning[0]))
self.__imgBinVEdit.setText(str(imageBinning[1]))
self.__imgBinCBox.setChecked(not equal)
def getQspaceDims(self):
"""
Returns the qspace dimensions, a 3 integers (> 1) array if set,
......@@ -452,7 +379,6 @@ class QSpaceWidget(Qt.QDialog):
xsocH5File,
outQSpaceH5,
qspaceDims=None,
imageBinning=None,
medfiltDims=None,
roi=None,
entries=None,
......@@ -465,10 +391,8 @@ class QSpaceWidget(Qt.QDialog):
:param xsocH5File: name of the input XsocsH5 file.
:param outQSpaceH5: name of the output hdf5 file
:param qspaceDims: dimensions of the qspace volume
:param imageBinning: binning to apply to the images before conversion.
Default : (1, 1)
:param medfiltDims: dimensions of the kernel used when applying a
a median filter to the images (after the binning, if any).
a median filter to the images (after the mask, if any).
Set to None or (1, 1) to disable the median filter.
:param roi: Roi in sample coordinates (xMin, xMax, yMin, yMax)
:param entries: a list of entry names to convert to qspace. If None,
......@@ -499,7 +423,6 @@ class QSpaceWidget(Qt.QDialog):
self.__converter = QSpaceConverter(xsocH5File,
output_f=outQSpaceH5,
qspace_dims=qspaceDims,
img_binning=imageBinning,
medfilt_dims=medfiltDims,
roi=roi,
entries=entries,
......@@ -622,7 +545,6 @@ class QSpaceWidget(Qt.QDialog):
channelsPerDegree = '', ''
self.__paramsWid = ConversionParamsWidget(
imgBinning=self.__converter.image_binning,
medfiltDims=self.__converter.medfilt_dims,
normalizers=xsocsH5.normalizers(),
beamEnergy=beamEnergy,
......@@ -696,7 +618,6 @@ class QSpaceWidget(Qt.QDialog):
return
normalizer = self.__paramsWid.getNormalizer()
imageBinning = self.__paramsWid.getImageBinning()
medfiltDims = self.__paramsWid.getMedfiltDims()
qspaceDims = self.__paramsWid.getQspaceDims()
beamEnergy = self.__paramsWid.getBeamEnergy()
......@@ -706,7 +627,6 @@ class QSpaceWidget(Qt.QDialog):
try:
converter.normalizer = normalizer
converter.image_binning = imageBinning
converter.medfilt_dims = medfiltDims
converter.qspace_dims = qspaceDims
converter.beam_energy = beamEnergy
......
......@@ -380,18 +380,15 @@ class QSpaceInfoNode(Node):
children.append(node)
##################################################
# Adding image binning.
# Adding image binning if available (deprecated)
##################################################
node = Node(nodeName='Image binning')
imageBinning = qspaceH5.image_binning
# support for previous versions
# TODO : remove eventualy
if imageBinning is None:
text = 'unavailable'
else:
if imageBinning is not None:
node = Node(nodeName='Image binning')
text = '{0}x{1}'.format(*imageBinning)
node._setDataInternal(ModelColumns.ValueColumn, text)
children.append(node)
node._setDataInternal(ModelColumns.ValueColumn, text)
children.append(node)
##################################################
# Adding medfilt.
......
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