Exemplo n.º 1
0
    def __init__(self, title, graphType, graphDisplay, parentWindow):

        super(dockPlot, self).__init__()

        if graphDisplay == 0:  #default options for 3D plots
            self.scatter = 0
            self.projection = [False, False]
        if graphDisplay == 5:  #default options for TrueStrain plot
            self.averageImageNb = 1
        self.graphDisplay = graphDisplay
        self.parentWindow = parentWindow
        self.parentWindow.setTabPosition(Qt.LeftDockWidgetArea,
                                         QTabWidget.West)
        self.parentWindow.setTabPosition(Qt.RightDockWidgetArea,
                                         QTabWidget.East)

        self.setWindowTitle(title)
        self.setAllowedAreas(
            Qt.TopDockWidgetArea | Qt.LeftDockWidgetArea
            | Qt.RightDockWidgetArea)  #bottom is reserved for DevMode
        self.dockWidget = DIC_Global.matplotlibWidget(graphType,
                                                      self)  #init 3d plot
        self.setWidget(self.dockWidget)
        self.setFeatures(
            QDockWidget.DockWidgetClosable
            | QDockWidget.DockWidgetMovable)  #do not allow floatable widget
        dockPlot.instances.append(self)  #add the new instance to the list
Exemplo n.º 2
0
    def __init__(self, parent):

        QDialog.__init__(self)

        self.setWindowTitle('Mask Grid Instance')
        self.setMinimumWidth(600)

        dialogLayout = QVBoxLayout()

        dialogLabel = QLabel('Chose grid instances you want to display on the visualisation panel.')
        dialogLabel.setAlignment(Qt.AlignCenter)

        self.plotArea = DIC_Global.matplotlibWidget()
        self.plotArea.setFocusPolicy(Qt.ClickFocus)
        self.plotArea.setFocus()

        infosLayout = QHBoxLayout()

        allButton = QPushButton('(De)Select *')
        allButton.setMaximumWidth(80)
        allButton.clicked.connect(self.allSelect)

        infoLbl = QLabel('Active Instances:')
        self.infoValue = QLabel('0')

        infosLayout.addStretch(1)
        infosLayout.addWidget(allButton)
        infosLayout.addStretch(1)
        infosLayout.addWidget(infoLbl)
        infosLayout.addWidget(self.infoValue)
        infosLayout.addStretch(1)


        buttonLayout = QHBoxLayout()
        self.dialogButton = QPushButton('Apply')
        self.dialogButton.setMaximumWidth(100)
        self.dialogButton.clicked.connect(lambda: self.showSelection(parent))
        buttonLayout.addStretch(1)
        buttonLayout.addWidget(self.dialogButton)
        buttonLayout.addStretch(1)


        noteLbl = QLabel('No masks will be created. Deactivated instances will only be hidden temporaly.')
        noteLbl.setAlignment(Qt.AlignCenter)

        dialogLayout.addWidget(dialogLabel)
        dialogLayout.addWidget(self.plotArea)
        dialogLayout.addLayout(infosLayout)
        dialogLayout.addLayout(buttonLayout)
        dialogLayout.addWidget(noteLbl)

        self.setLayout(dialogLayout)
Exemplo n.º 3
0
def maskData(parentWindow,
             mask,
             progressBar=None,
             dataList=None,
             toRecalculate=None):

    if progressBar is not None:
        progressBar.currentTitle = 'Applying masks...'

    calculatingThread = DIC_Global.createThread(
        parentWindow.parentWindow,
        [parentWindow, progressBar, mask, toRecalculate],
        initData.initPlottedData,
        signal=1)
    calculatingThread.signal.threadSignal.connect(
        lambda: newMasksCalculated(parentWindow, progressBar))
    calculatingThread.start()
Exemplo n.º 4
0
    def startCalculation(self, parent):

        recalculateCoordinates = [
            self.corrBox.isChecked(),
            self.xStrainBox.isChecked(),
            self.yStrainBox.isChecked()
        ]
        progressBar = progressWidget.progressBarDialog(
            'Starting calculation...')
        self.close()
        calculatingThread = DIC_Global.createThread(
            parent.parentWindow,
            [parent, progressBar, parent.currentMask, recalculateCoordinates],
            initData.initPlottedData,
            signal=1)
        calculatingThread.signal.threadSignal.connect(
            lambda: masks.newMasksCalculated(parent, progressBar))
        calculatingThread.start()
Exemplo n.º 5
0
    def displayInfos(self):

        infoFrame = QFrame()
        infoFrame.setFrameShape(QFrame.StyledPanel)
        nameLayout = QHBoxLayout()
        nameLayout.setAlignment(Qt.AlignCenter)
        nameLbl = QLabel('Name:')
        nameLblValue = QLabel('<b>' + str(self.infos[0]) + '</b>')
        versionLbl = QLabel('Version:')
        versionName = self.parent.analysisWidget.controlWidget.currentVersion.text(
        )
        versionLblValue = QLabel('<b>' + str(versionName) + '</b>')
        authorLbl = QLabel('Author:')
        authorLblValue = QLabel('<b>' + str(self.infos[9]) + '</b>')

        simpleSeparator = QFrame()
        simpleSeparator.setFrameShape(QFrame.VLine)
        simpleSeparator2 = QFrame()
        simpleSeparator2.setFrameShape(QFrame.VLine)
        nameLayout.addWidget(nameLbl)
        nameLayout.addWidget(nameLblValue)
        nameLayout.addWidget(simpleSeparator)
        nameLayout.addWidget(versionLbl)
        nameLayout.addWidget(versionLblValue)
        nameLayout.addWidget(simpleSeparator2)
        nameLayout.addWidget(authorLbl)
        nameLayout.addWidget(authorLblValue)

        infoFrame.setLayout(nameLayout)

        globalInfosLayout = QHBoxLayout()
        globalInfosLayout.setContentsMargins(50, 0, 20, 20)
        #globalInfosLayout.setAlignment(Qt.AlignCenter)
        imageOriginalLbl = QLabel(
            '<u><font color="Gray">Original Version:</font></u>')
        imagesLbl = QLabel('<font color="Gray">Nb. Images:</font>')
        imagesLbl.setContentsMargins(20, 0, 0, 0)
        imagesLblValue = QLabel('<font color="Gray"><b>' + str(self.infos[5]) +
                                '</b></font>')
        markersLbl = QLabel('<font color="Gray">Nb. Markers:</font>')
        markersLblValue = QLabel('<font color="Gray"><b>' +
                                 str(self.infos[7]) + '</b> (' +
                                 str(self.infos[6]) + '/image)</font>')
        #globalInfosLayout.addStretch(1)
        globalInfosLayout.addWidget(imageOriginalLbl)
        globalInfosLayout.addWidget(imagesLbl)
        globalInfosLayout.addWidget(imagesLblValue)
        globalInfosLayout.addWidget(markersLbl)
        globalInfosLayout.addWidget(markersLblValue)

        currentInfosLayout = QHBoxLayout()
        currentInfosLayout.setContentsMargins(50, 20, 20, 0)
        #currentInfosLayout.setAlignment(Qt.AlignCenter)
        imageCurrentLbl = QLabel('<u>Current Version:</u>')
        currentImagesLbl = QLabel('Nb. Images:')
        currentImagesLbl.setContentsMargins(20, 0, 0, 0)
        self.nbActiveImages = self.parent.analysisWidget.controlWidget.totalActive.text(
        )
        currentImagesLblValue = QLabel('<b>' + str(self.nbActiveImages) +
                                       '</b>')
        currentMarkersLbl = QLabel('Nb. Markers:')
        nbActiveMarkers = self.parent.analysisWidget.controlWidget.nonMaskedMarkers.text(
        )
        currentMarkersLblValue = QLabel('<b>' + str(nbActiveMarkers) + '</b>')
        #currentInfosLayout.addStretch(1)
        currentInfosLayout.addWidget(imageCurrentLbl)
        currentInfosLayout.addWidget(currentImagesLbl)
        currentInfosLayout.addWidget(currentImagesLblValue)
        currentInfosLayout.addWidget(currentMarkersLbl)
        currentInfosLayout.addWidget(currentMarkersLblValue)

        otherInfosLbl = QLabel('- ADDITIONAL INFORMATIONS -')
        otherInfosLbl.setContentsMargins(0, 0, 0, 10)
        otherInfosLbl.setAlignment(Qt.AlignCenter)

        otherInfosLayout = QHBoxLayout()
        otherInfosLayout.setContentsMargins(0, 0, 0, 10)
        #otherInfosLayout.setAlignment(Qt.AlignCenter)
        corrsizeLbl = QLabel('CorrSize:')
        corrsizeLbl.setContentsMargins(20, 0, 0, 0)
        corrsizeLblValue = QLabel('<b>' + str(self.infos[2]) + '</b>')
        referenceLbl = QLabel('Reference:')
        referenceLbl.setContentsMargins(20, 0, 0, 0)
        if self.infos[1] == '0':
            referenceLblTxt = 'Previous'
        elif self.infos[1] == '1':
            referenceLblTxt = 'First'
        else:
            referenceLblTxt = 'Shifted'
        referenceLblValue = QLabel('<b>' + referenceLblTxt + '</b>')
        instanceLbl = QLabel('Nb. Grid Instances:')
        instanceLbl.setContentsMargins(20, 0, 0, 0)
        instanceLblValue = QLabel(
            '<b>' +
            str(len(np.atleast_1d(self.parent.analysisWidget.grid_instances)))
            + '</b> (Active: ' +
            str(len(self.parent.analysisWidget.activeInstances)) + ')')
        nbVersionsLbl = QLabel('Nb. Versions:')
        nbVersionsLbl.setContentsMargins(20, 0, 0, 0)
        nbVersionsLblValue = QLabel(
            '<b>' + str(masks.openMask(self.parent, getNbMasks=1)) + '</b>')
        nbVersionsLblValue.setContentsMargins(0, 0, 20, 0)
        otherInfosLayout.addWidget(corrsizeLbl)
        otherInfosLayout.addWidget(corrsizeLblValue)
        otherInfosLayout.addWidget(referenceLbl)
        otherInfosLayout.addWidget(referenceLblValue)
        otherInfosLayout.addWidget(instanceLbl)
        otherInfosLayout.addWidget(instanceLblValue)
        otherInfosLayout.addWidget(nbVersionsLbl)
        otherInfosLayout.addWidget(nbVersionsLblValue)

        extraInfosLayout = QHBoxLayout()
        extraInfosLayout.setAlignment(Qt.AlignLeft)
        processingLbl = QLabel('Correlation processing time:')
        processingLbl.setContentsMargins(20, 0, 0, 0)
        processingLblValue = QLabel('<b>' + str(self.infos[4]) + '</b>')
        nbProcessesLbl = QLabel('Nb. Processes:')
        nbProcessesLbl.setContentsMargins(20, 0, 0, 0)
        nbProcessesLblValue = QLabel('<b>' + str(self.infos[3]) + '</b>')
        shiftCorrectionLbl = QLabel('Shift Correction:')
        shiftCorrectionLbl.setContentsMargins(20, 0, 0, 0)
        if self.infos[8] == '0':
            shiftCorrectionLblTxt = 'No'
        else:
            shiftCorrectionLblTxt = 'Yes'
        shiftCorrectionLblValue = QLabel('<b>' + shiftCorrectionLblTxt +
                                         '</b>')
        filterLbl = QLabel('Filters:')
        filterLbl.setContentsMargins(20, 0, 0, 0)
        filterList = self.parent.analysisWidget.filterList
        if filterList is None:
            filterApplied = 0
        else:
            filterApplied = len(np.atleast_1d(filterList))
        filterLblValue = QLabel('<b>' + str(filterApplied) + '</b>')
        #filterLblValue.setContentsMargins(0,0,20,0)
        extraInfosLayout.addWidget(processingLbl)
        extraInfosLayout.addWidget(processingLblValue)
        extraInfosLayout.addWidget(nbProcessesLbl)
        extraInfosLayout.addWidget(nbProcessesLblValue)
        extraInfosLayout.addWidget(shiftCorrectionLbl)
        extraInfosLayout.addWidget(shiftCorrectionLblValue)
        extraInfosLayout.addWidget(filterLbl)
        extraInfosLayout.addWidget(filterLblValue)

        plotListLayout = QHBoxLayout()
        plotListLayout.setAlignment(Qt.AlignLeft)
        plotListLayout.setContentsMargins(20, 25, 0, 0)
        plotListLbl = QLabel('Display:')
        self.plotListBox = QComboBox()
        self.plotListBox.setMinimumWidth(200)
        availablePlots = ['Correlation Errors', 'Poisson Ratio']
        for plot in availablePlots:
            self.plotListBox.addItem(plot)
        self.plotListOptions = QComboBox()
        self.plotListOptions.setMinimumWidth(150)
        self.plotListCheckBox = QCheckBox('Only Active Images')
        self.plotListCheckBox.setContentsMargins(30, 0, 0, 0)
        plotListLayout.addWidget(plotListLbl)
        plotListLayout.addWidget(self.plotListBox)
        plotListLayout.addWidget(self.plotListOptions)
        plotListLayout.addWidget(self.plotListCheckBox)

        matplotlibLayout = QHBoxLayout()
        matplotlibLayout.setContentsMargins(0, 0, 0, 0)
        self.matplotlibPlot = DIC_Global.matplotlibWidget()
        self.matplotlibPlot.setContentsMargins(0, 0, 0, 0)
        matplotlibLayout.addStretch(1)
        matplotlibLayout.addWidget(self.matplotlibPlot)
        matplotlibLayout.addStretch(1)
        self.plotListBox.currentIndexChanged.connect(self.plotOptions)
        self.plotListOptions.currentIndexChanged.connect(self.plotInfos)
        self.plotListCheckBox.stateChanged.connect(
            lambda: self.plotInfos(self.plotListOptions.currentIndex()))

        self.mainLayout.addWidget(infoFrame)
        self.mainLayout.addLayout(currentInfosLayout)
        self.mainLayout.addLayout(globalInfosLayout)
        self.mainLayout.addWidget(otherInfosLbl)
        self.mainLayout.addLayout(otherInfosLayout)
        self.mainLayout.addLayout(extraInfosLayout)
        self.mainLayout.addLayout(plotListLayout)
        self.mainLayout.addLayout(matplotlibLayout)
        self.plotOptions(0)
Exemplo n.º 6
0
    def __init__(self, parent):

        super(filterCreationWidget, self).__init__()

        self.parent = parent

        verticalLayout = QVBoxLayout()
        verticalLayout.setAlignment(Qt.AlignCenter)
        verticalLayout.setContentsMargins(0, 0, 0, 0)

        self.filterListLbl = QLabel('Filters')

        self.availableFilters = QListWidget()

        #filterlist
        self.filterList = [[
            'Zoom', 'Width', 'Height', 'Top-Left Coord.', 200, 100, '0,0'
        ], ['Blur', 'Kernel Width', 'Kernel Height', '', 5, 5, 0],
                           [
                               'Gaussian', 'Kernel Width', 'Kernel Height',
                               'Standard Dev.', 9, 9, '0,0'
                           ],
                           ['Brightness', 'Phi', 'Theta', 'Degree', 1, 1, '2'],
                           ['Darkness', 'Phi', 'Theta', 'Degree', 1, 1, '2'],
                           ['Contrast', 'Phi', 'Theta', 'Degree', 1, 1, '2']]
        #end filterlist
        for element in self.filterList:
            currentFilter = QListWidgetItem(element[0])
            self.availableFilters.addItem(currentFilter)

        self.availableFilters.itemSelectionChanged.connect(self.itemSelected)

        filterParameterLayout = QHBoxLayout()
        filterParameterLayout.setAlignment(Qt.AlignCenter)
        filterParameterLayout.setContentsMargins(0, 0, 0, 0)

        filterParameterLblLayout = QVBoxLayout()
        filterParameterLblLayout.setContentsMargins(0, 0, 0, 0)
        self.parameterLbls = [QLabel('-'), QLabel('-'), QLabel('-')]
        for label in self.parameterLbls:
            filterParameterLblLayout.addWidget(label)

        filterParameterValueLayout = QVBoxLayout()
        filterParameterValueLayout.setContentsMargins(0, 0, 0, 0)
        self.parameterValues = [QSpinBox(), QSpinBox(), QLineEdit()]
        for values in self.parameterValues:
            filterParameterValueLayout.addWidget(values)
        filterParameterLayout.addLayout(filterParameterLblLayout)
        filterParameterLayout.addLayout(filterParameterValueLayout)

        saveButtonLayout = QHBoxLayout()
        saveButtonLayout.setContentsMargins(0, 0, 0, 0)
        self.previewButton = QToolButton()
        self.previewButton.setText('Preview')
        self.previewButton.setDisabled(True)
        self.previewButton.mousePressEvent = lambda x: self.parent.plotImage(
            filterPreview=[
                self.availableFilters.currentItem().text(),
                self.parameterValues[0].value(), self.parameterValues[1].value(
                ), self.parameterValues[2].text()
            ])
        self.previewButton.mouseReleaseEvent = lambda x: self.parent.plotImage(
        )
        self.saveButton = QToolButton()
        self.saveButton.setText('Apply Filter')
        self.saveButton.setDisabled(True)
        self.saveButton.clicked.connect(self.addFilterToApply)
        saveButtonLayout.addStretch(1)
        saveButtonLayout.addWidget(self.previewButton)
        saveButtonLayout.addWidget(self.saveButton)
        saveButtonLayout.addStretch(1)

        self.appliedFiltersLbl = QLabel('Applied Filter(s)')

        self.appliedFilters = QListWidget()
        self.appliedFiltersList = []

        deleteButtonLayout = QHBoxLayout()
        deleteButtonLayout.setContentsMargins(0, 0, 0, 0)
        self.deleteButton = QToolButton()
        self.deleteButton.setText('Delete Selection')
        self.deleteButton.setContentsMargins(0, 0, 0, 0)
        self.deleteButton.setDisabled(True)
        self.deleteButton.clicked.connect(self.deleteAppliedFilter)
        deleteButtonLayout.addStretch(1)
        deleteButtonLayout.addWidget(self.deleteButton)
        deleteButtonLayout.addStretch(1)

        self.histoPlot = DIC_Global.matplotlibWidget()

        verticalLayout.addWidget(self.filterListLbl)
        verticalLayout.addWidget(self.availableFilters)
        verticalLayout.addLayout(filterParameterLayout)
        verticalLayout.addLayout(saveButtonLayout)
        verticalLayout.addWidget(self.appliedFiltersLbl)
        verticalLayout.addWidget(self.appliedFilters)
        verticalLayout.addLayout(deleteButtonLayout)
        verticalLayout.addWidget(self.histoPlot)

        self.setLayout(verticalLayout)
Exemplo n.º 7
0
    def __init__(self, parent, currentImage):  #initiate the main layout

        QDialog.__init__(self)
        self.parent = parent
        self.fileDataPath = parent.parentWindow.fileDataPath
        self.currentMask = copy.deepcopy(parent.currentMask)
        self.activeImages = parent.activeImages
        self.activeMarkers = parent.activeMarkers
        self.activeInstances = parent.activeInstances
        self.gridInstances = parent.grid_instances
        self.data_x = parent.data_x
        self.data_y = parent.data_y
        self.disp_x = parent.disp_x
        self.disp_y = parent.disp_y

        self.setWindowTitle('Dispersion vs Position')
        self.setMinimumWidth(500)
        dialogLayout = QVBoxLayout()

        dialogLabel = QLabel(
            'Clean markers by linear displacement analysis. Draw rectangles over the markers you want to select.'
        )
        dialogLabel.setAlignment(Qt.AlignHCenter)
        dialogLabel.setMinimumHeight(30)

        checkBoxOptions = QHBoxLayout()
        checkBoxOptions.setAlignment(Qt.AlignHCenter)
        checkBoxOptions.setSpacing(10)
        #layout items
        self.displayXMarkers = QCheckBox('Displacement along X')
        self.displayXMarkers.setChecked(True)
        self.displayYMarkers = QCheckBox('Displacement along Y')
        #ComboBox to select instance
        instanceSelectLbl = QLabel('Display Instance(s):')
        self.instanceSelect = QComboBox(self)
        self.instanceSelect.addItem('All')
        for instance in self.activeInstances:
            self.instanceSelect.addItem(str(instance))
        #add items to layout
        checkBoxOptions.addStretch(1)
        checkBoxOptions.addWidget(self.displayXMarkers)
        checkBoxOptions.addWidget(self.displayYMarkers)
        checkBoxOptions.addStretch(1)
        checkBoxOptions.addWidget(instanceSelectLbl)
        checkBoxOptions.addWidget(self.instanceSelect)
        checkBoxOptions.addStretch(1)

        #checkBox clicked
        self.displayXMarkers.stateChanged.connect(self.plotDispersion)
        self.displayYMarkers.stateChanged.connect(self.plotDispersion)
        #comboBox index changed
        self.instanceSelect.currentIndexChanged.connect(self.plotDispersion)

        self.plotArea = DIC_Global.matplotlibWidget()
        self.plotArea.setFocusPolicy(Qt.ClickFocus)
        self.plotArea.setFocus()

        buttonBox = QHBoxLayout()
        self.deleteButton = QPushButton('Delete Selection')
        self.deleteButton.setMinimumWidth(120)
        self.imageSelectSpinBox = QSpinBox(self)
        self.imageSelectSpinBox.setRange(1,
                                         len(np.atleast_1d(self.activeImages)))
        self.imageSelectSpinBox.setValue(currentImage)
        self.allImagesCheckBox = QCheckBox('Apply on all images.')
        self.allImagesCheckBox.setChecked(True)
        buttonBox.addStretch(1)
        buttonBox.addWidget(self.deleteButton)
        buttonBox.addWidget(self.imageSelectSpinBox)
        buttonBox.addWidget(self.allImagesCheckBox)
        buttonBox.addStretch(1)
        #actions
        self.deleteButton.clicked.connect(self.maskSelection)
        self.imageSelectSpinBox.valueChanged.connect(self.plotDispersion)

        #Dialog Window Layout
        dialogLayout.addWidget(dialogLabel)
        dialogLayout.addLayout(checkBoxOptions)
        dialogLayout.addWidget(self.plotArea)
        dialogLayout.addLayout(buttonBox)

        self.setLayout(dialogLayout)
        self.plotDispersion()
Exemplo n.º 8
0
def prepareCorrelations(fileNameList, gridX, gridY, corrsize, baseMode,
                        floatStep, parentWidget, parentWindow, largeDisp,
                        filterInfos, thread):

    startTime = time.time()
    # getting the images filename list
    #fileName = parentWindow.fileDataPath+'/filenamelist.dat'
    #fileNameList = getData.testReadFile(fileName)

    infosThread = thread.signal.threadSignal

    infosAnalysis = []
    isLargeDisp = 1
    # Name
    # Reference Mode
    # CorrSize
    # nbProcesses
    # total processing time
    # nbImages
    # nbMarkers
    # nbImages * nbMarkers
    # largeDisp YES/NO
    # User Profile

    for image in range(len(fileNameList)):
        fileNameList[image] = fileNameList[image].rstrip()
    fileNameList = np.array(fileNameList)

    activeImages = np.array(parentWidget.imageActiveList).astype(np.int)

    if fileNameList is None:
        return

    if largeDisp is None:
        largeDisp = np.zeros((len(fileNameList), 2))
        isLargeDisp = 0

    numOfBasePoints = len(gridX)
    numOfImages = len(fileNameList)

    #parentWidget.calculationBar.changeValue(1, 'Starting Processes...')

    # Adding some informations to the DevMode widget
    parentWindow.devWindow.addInfo('Starting the correlation process with ' +
                                   str(numOfBasePoints) + ' markers on ' +
                                   str(numOfImages) + ' images.')
    if baseMode == 0:
        parentWindow.devWindow.addInfo('Reference Image : Previous')
    elif baseMode == 1:
        parentWindow.devWindow.addInfo('Reference Image : First')
    elif baseMode == 2:
        parentWindow.devWindow.addInfo('Reference Image : Shifted (' +
                                       str(floatStep) + ')')

    # Setting up the processes
    PROCESSES = int(
        parentWindow.profileData['nbProcesses'][parentWindow.currentProfile])
    args = []
    nbMarkersPerProcess = numOfBasePoints / PROCESSES
    if nbMarkersPerProcess < 2:
        nbMarkersPerProcess = 2
        PROCESSES = int(numOfBasePoints / 2) + 1
    parentWindow.devWindow.addInfo('Number of processes used: ' +
                                   str(PROCESSES))
    for i in range(0, PROCESSES):
        start = int(i * nbMarkersPerProcess)
        if i >= PROCESSES - 1:  #last process do all the last images
            end = numOfBasePoints
        else:
            end = int((i + 1) * nbMarkersPerProcess)
        args.append((fileNameList, activeImages, parentWindow.filePath,
                     gridX[start:end], gridY[start:end], baseMode, corrsize,
                     floatStep, largeDisp, filterInfos))

    result = DIC_Global.createProcess(parentWindow, processCorrelation, args,
                                      PROCESSES, parentWidget.calculationBar,
                                      '(1/2) Processing images...')

    parentWindow.devWindow.addInfo('Calculation finished. Saving data files.')

    #neighbors calculation
    #parentWidget.calculationBar.changeValue(1, '(2/2) Calculating neighborhood...')
    parentWidget.calculationBar.percent = 0
    parentWidget.calculationBar.currentTitle = '(2/2) Calculating neighborhood...'
    activeMarkers = np.linspace(0,
                                numOfBasePoints,
                                num=numOfBasePoints,
                                endpoint=False).astype(np.int)
    minNeighbors = 16
    initData.calculateNeighbors(activeMarkers,
                                result[0][:, activeImages[0]],
                                result[1][:, activeImages[0]],
                                minNeighbors,
                                parentWindow.fileDataPath,
                                progressBar=parentWidget.calculationBar)

    #data saving
    parentWidget.calculationBar.percent = 0
    parentWidget.calculationBar.currentTitle = 'Saving validx.csv...'
    Save('validx', result[0], parentWindow.fileDataPath)
    parentWidget.calculationBar.percent = 10
    parentWidget.calculationBar.currentTitle = 'Saving validy.csv...'
    Save('validy', result[1], parentWindow.fileDataPath)
    parentWidget.calculationBar.percent = 20
    parentWidget.calculationBar.currentTitle = 'Saving stdx.csv...'
    Save('stdx', result[3], parentWindow.fileDataPath)
    parentWidget.calculationBar.percent = 30
    parentWidget.calculationBar.currentTitle = 'Saving stdy.csv...'
    Save('stdy', result[4], parentWindow.fileDataPath)
    parentWidget.calculationBar.percent = 40
    parentWidget.calculationBar.currentTitle = 'Saving corrcoef.csv...'
    Save('corrcoef', result[2], parentWindow.fileDataPath)
    parentWidget.calculationBar.percent = 50
    parentWidget.calculationBar.currentTitle = 'Saving dispx.csv...'
    Save('dispx', result[5], parentWindow.fileDataPath)
    parentWidget.calculationBar.percent = 60
    parentWidget.calculationBar.currentTitle = 'Saving dispy.csv...'
    Save('dispy', result[6], parentWindow.fileDataPath)
    parentWidget.calculationBar.percent = 70
    parentWidget.calculationBar.currentTitle = 'Saving filenamelist.csv...'
    Save('filenamelist', fileNameList, parentWindow.fileDataPath)
    parentWidget.calculationBar.percent = 80
    parentWidget.calculationBar.currentTitle = 'Saving infoMarkers.csv...'
    Save('infoMarkers', result[7].astype(int), parentWindow.fileDataPath)
    if len(filterInfos) > 0:
        filterFunctions.saveOpenFilter(parentWindow.fileDataPath,
                                       filterList=filterInfos)

    parentWindow.devWindow.addInfo('Calculation done. Data files saved.')
    totalTime = time.time() - startTime

    infosAnalysis.append(os.path.basename(parentWindow.fileDataPath))
    infosAnalysis.append(baseMode)
    infosAnalysis.append(corrsize)
    infosAnalysis.append(PROCESSES)
    infosAnalysis.append(totalTime)
    infosAnalysis.append(numOfImages)
    infosAnalysis.append(numOfBasePoints)
    infosAnalysis.append(numOfImages * numOfBasePoints)
    infosAnalysis.append(isLargeDisp)
    infosAnalysis.append(
        str(parentWindow.profileData['User'][parentWindow.currentProfile]))

    parentWidget.calculationBar.percent = 90
    parentWidget.calculationBar.currentTitle = 'Saving infoAnalysis.csv...'
    Save('infoAnalysis', np.array(infosAnalysis), parentWindow.fileDataPath)
    if isLargeDisp:
        parentWidget.calculationBar.percent = 95
        parentWidget.calculationBar.currentTitle = 'Saving largeDisp.csv...'
        Save('largeDisp', largeDisp, parentWindow.fileDataPath)

    parentWindow.devWindow.addInfo('Processing Time : ' + str(totalTime))
    infosThread.emit([1])
    return
Exemplo n.º 9
0
    def __init__(self, parent, currentImage): #create the layout of the window dialog

        QDialog.__init__(self)

        self.setWindowTitle('Mask markers')
        self.setMinimumWidth(500)
        dialogLayout = QVBoxLayout()

        #init_Variables
        self.parentWidget = parent
        self.fileDataPath = parent.parentWindow.fileDataPath
        self.filePath = parent.parentWindow.filePath
        self.filenamelist = parent.fileNameList
        self.filterList = parent.filterList
        self.currentMask = copy.deepcopy(parent.currentMask)
        self.activeImages = parent.activeImages
        self.activeMarkers = parent.activeMarkers
        self.activeInstances = parent.activeInstances
        self.gridInstances = parent.grid_instances
        self.data_x = parent.data_x
        self.data_y = parent.data_y
        self.disp_x = parent.disp_x
        self.disp_y = parent.disp_y
        self.graphDisplay = 99 #temporary toolbar fix

        dialogLabel = QLabel('Select markers you want to mask.<br>A first click initiate the selection, a second click confirms the selection.')
        dialogLabel.setAlignment(Qt.AlignHCenter)
        dialogLabel.setMinimumHeight(30)

        checkBoxOptions = QHBoxLayout()
        checkBoxOptions.setSpacing(10)
        self.baseMarkers = QCheckBox('Base Grid Markers')
        self.baseMarkers.setChecked(True)
        self.dispMarkers = QCheckBox('Displacement Arrows')
        #ComboBox to select instance
        instanceSelectLbl = QLabel('Display Instance(s):')
        self.instanceSelect = QComboBox(self)
        self.instanceSelect.addItem('All')
        for instance in self.activeInstances:
            self.instanceSelect.addItem(str(instance))
        checkBoxOptions.addStretch(1)
        checkBoxOptions.addWidget(self.baseMarkers)
        checkBoxOptions.addWidget(self.dispMarkers)
        checkBoxOptions.addStretch(1)
        checkBoxOptions.addWidget(instanceSelectLbl)
        checkBoxOptions.addWidget(self.instanceSelect)
        checkBoxOptions.addStretch(1)

        #checkBox clicked
        self.baseMarkers.stateChanged.connect(lambda: self.selectMarkers())
        self.dispMarkers.stateChanged.connect(lambda: self.selectMarkers())
        #comboBox index changed
        self.instanceSelect.currentIndexChanged.connect(lambda: self.selectMarkers())

        self.plotArea = DIC_Global.matplotlibWidget(self, parent=self, toolbar=1) #toolbar != None for horizontal toolbar
        self.plotArea.setMinimumHeight(self.plotArea.canvas.height())
        self.plotArea.canvas.setFocusPolicy(Qt.ClickFocus)
        self.plotArea.canvas.setFocus()

        deleteButtonBox = QHBoxLayout()
        deleteButton = QPushButton('Delete Selection')
        deleteButton.setMinimumWidth(120)
        deleteButton.clicked.connect(self.maskSelection)
        self.imageSelectSpinBox = QSpinBox(self)
        self.imageSelectSpinBox.setRange(1, len(self.activeImages))
        self.imageSelectSpinBox.setValue(currentImage)
        self.imageSelectSpinBox.valueChanged.connect(lambda: self.selectMarkers())
        self.allImagesCheckBox = QCheckBox('Apply on all images.')
        self.allImagesCheckBox.setChecked(True)

        deleteButtonBox.addStretch(1)
        deleteButtonBox.addWidget(deleteButton)
        deleteButtonBox.addWidget(self.imageSelectSpinBox)
        deleteButtonBox.addWidget(self.allImagesCheckBox)
        deleteButtonBox.addStretch(1)

        #Dialog Window Layout
        dialogLayout.addWidget(dialogLabel)
        dialogLayout.addLayout(checkBoxOptions)
        dialogLayout.addWidget(self.plotArea)
        dialogLayout.addLayout(deleteButtonBox)

        self.setLayout(dialogLayout)

        #init Plot
        self.unselectedMarkersPlot = []
        self.selectedMarkersPlot = []
        self.arrowsPlot = []
        self.selectMarkers()
Exemplo n.º 10
0
    def __init__(self, parent, fileNameList, filePath):

        QDialog.__init__(self)
        dialogLayout = QVBoxLayout()
        dialogLayout.setSpacing(20)
        self.setWindowTitle('Analysis Creation')
        self.setMaximumWidth(500)
        self.setMaximumHeight(600)
        self.filePath = filePath

        infoLbl = QLabel('Please verify the automatic image selection.')
        infoLbl.setAlignment(Qt.AlignCenter)

        imageLayout = QHBoxLayout()
        self.plotArea = DIC_Global.matplotlibWidget()
        self.plotArea.setMaximumHeight(300)
        self.imageList = QListView()
        self.imageList.setMinimumWidth(200)
        self.imageList.setMaximumHeight(300)
        self.imageList.setContentsMargins(0, 20, 0, 20)
        self.imageModel = QStandardItemModel(self.imageList)
        for image in fileNameList:
            imageItem = QStandardItem(image)
            imageItem.setCheckable(True)
            imageItem.setCheckState(Qt.Checked)
            self.imageModel.appendRow(imageItem)
        self.imageList.setModel(self.imageModel)
        self.imageList.setCurrentIndex(
            self.imageModel.indexFromItem(self.imageModel.item(0)))
        self.imageList.clicked.connect(lambda: self.displayImage(fileNameList))
        imageLayout.addWidget(self.plotArea)
        imageLayout.addWidget(self.imageList)

        totalImageNb = len(np.atleast_1d(fileNameList))
        imageNumberLayout = QHBoxLayout()
        imageNumberLayout.setSpacing(5)
        self.fromImage = QSpinBox()
        self.fromImage.setRange(0, totalImageNb)
        toImageLbl = QLabel('to')
        self.toImage = QSpinBox()
        self.toImage.setRange(0, totalImageNb)
        invertBtn = QPushButton('Invert')
        invertBtn.clicked.connect(self.invertSelection)
        imageLbl = QLabel('Selection:')
        self.imageSelected = QLabel('-')
        totalImage = QLabel('/ ' + str(totalImageNb))
        imageNumberLayout.addStretch(1)
        imageNumberLayout.addWidget(self.fromImage)
        imageNumberLayout.addWidget(toImageLbl)
        imageNumberLayout.addWidget(self.toImage)
        imageNumberLayout.addWidget(invertBtn)
        imageNumberLayout.addStretch(2)
        imageNumberLayout.addWidget(imageLbl)
        imageNumberLayout.addWidget(self.imageSelected)
        imageNumberLayout.addWidget(totalImage)
        imageNumberLayout.addStretch(1)

        analysisName = QHBoxLayout()
        analysisName.setSpacing(20)
        self.analysisLbl = QLabel('-')
        self.analysisInput = QLineEdit()
        self.analysisInput.setCursorPosition(0)
        self.analysisInput.setTextMargins(3, 3, 3, 3)
        currentFont = self.analysisInput.font()
        currentFont.setPointSize(15)
        self.analysisInput.setFont(currentFont)
        self.analysisInput.setMinimumWidth(200)
        self.analysisInput.setMinimumHeight(40)
        validatorRx = QRegExp("\\w+")
        validator = QRegExpValidator(validatorRx, self)
        self.analysisInput.setValidator(validator)
        analysisName.addStretch(1)
        analysisName.addWidget(self.analysisLbl)
        analysisName.addWidget(self.analysisInput)
        analysisName.addStretch(1)

        buttonLayout = QHBoxLayout()
        buttonLayout.setSpacing(40)
        cancelButton = QPushButton('Cancel')
        cancelButton.setMaximumWidth(100)
        cancelButton.setMinimumHeight(30)
        self.createButton = QPushButton('Start Analysis')
        self.createButton.setMinimumWidth(150)
        self.createButton.setMinimumHeight(30)
        self.createButton.setEnabled(False)
        buttonLayout.addStretch(1)
        buttonLayout.addWidget(cancelButton)
        buttonLayout.addWidget(self.createButton)
        buttonLayout.addStretch(1)

        self.analysisInput.textChanged.connect(
            lambda: self.textChanged(self.analysisInput.text()))
        self.createButton.clicked.connect(
            lambda: self.createAnalysis(parent, self.analysisInput.text()))
        cancelButton.clicked.connect(self.reject)

        dialogLayout.addWidget(infoLbl)
        dialogLayout.addLayout(imageLayout)
        dialogLayout.addLayout(imageNumberLayout)
        dialogLayout.addLayout(analysisName)
        dialogLayout.addLayout(buttonLayout)

        self.setLayout(dialogLayout)
        self.textChanged('')
        self.displayImage(fileNameList)