Vous avez reçu un message "Your GitLab account has been locked ..." ? Pas d'inquiétude : lisez cet article https://docs.gricad-pages.univ-grenoble-alpes.fr/help/unlock/

Commit 1d3af8e7 authored by Edward Andò's avatar Edward Andò
Browse files

Resolves #196 -- final TSV from spam-mmr-graphical automatically saved

parent ecd72cda
Pipeline #60356 passed with stages
in 25 minutes and 47 seconds
......@@ -2135,12 +2135,12 @@ class FinalStep(QWidget):
startButton.clicked.connect(self.starCorrelation)
self.grid.addWidget(startButton, 1, 1, 1, 3)
self.automaticallySavedFiles = QLabel("Images saved: ")
self.label = QLabel("Save final phi in a tsv file")
#self.label = QLabel("Save final phi in a tsv file")
#self.nameEntry = QLineEdit("mmr-phi-final-bin{}.tsv".format(self.binning))
self.nameEntry = QLineEdit("{}-{}-PhiFinal-bin{}.tsv".format(self.names[0][0:-4], self.names[1][0:-4], self.binning))
#self.nameEntry = QLineEdit()
self.resultLabel = QLabel()
self.saveButton = QPushButton("Save")
self.saveButton.clicked.connect(self.saveFinalResults)
#self.saveButton = QPushButton("Save")
#self.saveButton.clicked.connect(self.saveFinalResults)
# final step parameters and first rendering
self.margin = 5
......@@ -2210,9 +2210,9 @@ class FinalStep(QWidget):
self.grid.addWidget(self.automaticallySavedFiles, 9, 1)
self.grid.addWidget(self.blankLabel1, 10, 1)
self.grid.addWidget(self.blankLabel2, 11, 1)
self.grid.addWidget(self.label, 10, 1)
self.grid.addWidget(self.nameEntry, 10, 2)
self.grid.addWidget(self.saveButton, 10, 3)
#self.grid.addWidget(self.label, 10, 1)
#self.grid.addWidget(self.nameEntry, 10, 2)
#self.grid.addWidget(self.saveButton, 10, 3)
self.grid.addWidget(self.resultLabel, 11, 2)
self.grid.addWidget(residualLabel, 4, 1)
self.grid.addWidget(phaseLabel, 4, 2)
......@@ -2225,9 +2225,9 @@ class FinalStep(QWidget):
self.grid.addWidget(self.viewerIm1, 7, 1)
self.grid.addWidget(self.viewerIm2, 7, 2)
self.grid.addWidget(self.viewerCheckerBoard, 5, 3, 3, 1)
self.label.hide()
self.nameEntry.hide()
self.saveButton.hide()
#self.label.hide()
#self.nameEntry.hide()
#self.saveButton.hide()
self.resultLabel.hide()
self.automaticallySavedFiles.hide()
......@@ -2235,9 +2235,9 @@ class FinalStep(QWidget):
from PyQt5 import QtTest
self.automaticallySavedFiles.hide()
self.label.hide()
self.nameEntry.hide()
self.saveButton.hide()
#self.label.hide()
#self.nameEntry.hide()
#self.saveButton.hide()
self.resultLabel.hide()
# for matplotlib
......@@ -2430,6 +2430,7 @@ class FinalStep(QWidget):
tifffile.imsave(fileName, phaseField)
dataSaved.append(fileName)
print("{}, ".format(fileName), end="")
fileName = self.rootFileName + "-mmr-residual-bin{}.tif".format(self.binning)
tifffile.imsave(fileName, residualField)
dataSaved.append(fileName)
......@@ -2446,44 +2447,30 @@ class FinalStep(QWidget):
'phaseField': phaseField,
'deltaPhiNorm': deltaPhiNorm}
# 2021-02-11 EA and OS: as per issue #196: save final Phi TSV automatically
fileName = self.rootFileName + "{}-{}-PhiFinal-bin{}.tsv".format(self.names[0][0:-4], self.names[1][0:-4], self.binning)
TSVheader = "Zpos\tYpos\tXpos\tFzz\tFzy\tFzx\tZdisp\tFyz\tFyy\tFyx\tYdisp\tFxz\tFxy\tFxx\tXdisp\tbin\treturnStatus\tdeltaPhiNorm\titerations"
centre = (numpy.array(self.images[0].shape)-1)/2.0
output = numpy.array([[centre[0]], [centre[1]], [centre[2]],
[Phi[0, 0]], [Phi[0, 1]], [Phi[0, 2]],
[Phi[0, 3]], [Phi[1, 0]], [Phi[1, 1]],
[Phi[1, 2]], [Phi[1, 3]], [Phi[2, 0]],
[Phi[2, 1]], [Phi[2, 2]], [Phi[2, 3]],
[self.binning], [self.result['returnStatus']],
[self.result['deltaPhiNorm']], [self.result['iterations']]])
numpy.savetxt(fileName, output.T, fmt='%.7f', delimiter='\t', newline='\n', comments='', header=TSVheader)
#self.resultLabel.setText("Final Phi saved in: {}".format(os.path.join(os.getcwd(), fileName)))
#self.resultLabel.setStyleSheet("QLabel {font-weight: bold; color: green;}")
dataSaved.append(fileName)
print("{}, ".format(fileName), end="")
self.automaticallySavedFiles.setText("Data saved: {}".format(",\n\t ".join(dataSaved)))
self.automaticallySavedFiles.setStyleSheet("QLabel {font-weight: bold; color: green;}")
self.automaticallySavedFiles.show()
self.label.show()
self.nameEntry.show()
self.saveButton.show()
#self.label.show()
#self.nameEntry.show()
#self.saveButton.show()
self.resultLabel.show()
def saveFinalResults(self):
if self.nameEntry.text() != "":
tmp = self.nameEntry.text()
fileName = tmp if tmp.split(".")[-1] in ["tsv"] else tmp + ".tsv"
# save.writeRegistrationTSV(fileName, (numpy.array(self.images[1].shape) - 1) / 2.0, {
# 'PhiCentre': self.Phis[1], "returnStatus": 2, "iterations": self.iterations, "error": 100, "deltaPhiNorm": 0.1})
# transformationRes = self.result['transformation']
# transformationInitialGuess = spam.deformation.decomposePhi(self.phi)
# transformation = {'t': [transformationRes['t'][0] + transformationInitialGuess['t'][0],
# transformationRes['t'][1] + transformationInitialGuess['t'][1],
# transformationRes['t'][2] + transformationInitialGuess['t'][2]],
# 'r': [transformationRes['r'][0] + transformationInitialGuess['r'][0],
# transformationRes['r'][1] + transformationInitialGuess['r'][1],
# transformationRes['r'][2] + transformationInitialGuess['r'][2]],
# 'z': [self.zArray[0], self.zArray[1], self.zArray[2]]}
Phi = self.result['Phi']
TSVheader = "Zpos\tYpos\tXpos\tFzz\tFzy\tFzx\tZdisp\tFyz\tFyy\tFyx\tYdisp\tFxz\tFxy\tFxx\tXdisp\tbin\treturnStatus\tdeltaPhiNorm\titerations"
centre = (numpy.array(self.images[0].shape)-1)/2.0
output = numpy.array([[centre[0]], [centre[1]], [centre[2]],
[Phi[0, 0]], [Phi[0, 1]], [Phi[0, 2]],
[Phi[0, 3]], [Phi[1, 0]], [Phi[1, 1]],
[Phi[1, 2]], [Phi[1, 3]], [Phi[2, 0]],
[Phi[2, 1]], [Phi[2, 2]], [Phi[2, 3]],
[self.binning], [self.result['returnStatus']],
[self.result['deltaPhiNorm']], [self.result['iterations']]])
numpy.savetxt(fileName, output.T, fmt='%.7f', delimiter='\t', newline='\n', comments='', header=TSVheader)
self.resultLabel.setText("Final Phi saved in: {}".format(os.path.join(os.getcwd(), fileName)))
self.resultLabel.setStyleSheet("QLabel {font-weight: bold; color: green;}")
else:
self.resultLabel.setText("Please enter a name")
self.resultLabel.setStyleSheet("QLabel {font-weight: bold; color: orange;}")
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