Beispiel #1
0
    def show(self, form, *params):
        prot = form.protocol
        acquisitionInfo = prot.loadAcquisitionInfo()

        if prot.importFilePath:
            if exists(prot.importFilePath):
                if acquisitionInfo:
                    msg = ''
                    for k, v in acquisitionInfo.iteritems():
                        msg += '%s = %s\n' % (k, v)
                    msg += '\n*Do you want to use detected acquisition values?*'
                    response = dialog.askYesNo("Import acquisition", msg,
                                               form.root)
                    if response:
                        for k, v in acquisitionInfo.iteritems():
                            form.setVar(k, v)
                else:
                    dialog.showWarning("Import failed",
                                       "Could not import acquisition info.",
                                       form.root)
            else:
                dialog.showError(
                    "Input error", "*Import file doesn't exist.*\nFile:\n%s" %
                    prot.importFilePath, form.root)
        else:
            dialog.showError("Input error", "Select import file first",
                             form.root)
    def show(self, form, *args):
        protocol = form.protocol
        provider = self._getProvider(protocol)

        installErrors = Plugin.validateInstallation()

        if installErrors:
            dialog.showError("SPIDER not properly installed.",
                             "\n".join(installErrors), form.root)
            return

        if provider is not None:
            d = SpiderFilterDialog(form.root,
                                   provider,
                                   protocolParent=protocol)
            if d.resultYes():
                if protocol.filterType <= FILTER_FERMI:
                    form.setVar('filterRadius', d.getRadius())
                else:
                    form.setVar('lowFreq', d.getLowFreq())
                    form.setVar('highFreq', d.getHighFreq())
                if protocol.filterType == FILTER_FERMI:
                    form.setVar('temperature', d.getTemperature())
        else:
            dialog.showWarning("Input particles", "Select particles first",
                               form.root)
Beispiel #3
0
    def _select(self):
        projName = self.projName.get().strip()
        projLocation = self.projLocation.get().strip()

        # Validate that project name is not empty
        if not projName:
            showError("Validation error", "Project name is empty", self.root)
        # Validate that project location is not empty
        elif not projLocation:
            showError("Validation error", "Project location is empty",
                      self.root)
        # Validate that project location exists
        elif not os.path.exists(projLocation):
            showError("Validation error", "Project location does not exist",
                      self.root)
        # Validate that project location is a directory
        elif not os.path.isdir(projLocation):
            showError("Validation error",
                      "Project location is not a directory", self.root)
        # Validate that project path (location + name) ddoes not exists
        elif os.path.exists(os.path.join(projLocation, projName)):
            showError("Validation error", "Project path already exists",
                      self.root)
        else:
            self.parent.createNewProject(projName, projLocation)
            self.close()
Beispiel #4
0
def checkFileIntegrityGUI(fn, parent):
    ok = verifyMD5(fn)
    if ok:
        showInfo("File integrity", "File is OK", parent)
    else:
        showError(
            "File integrity",
            "File seems to have been modified since its creation. Not OK",
            parent)
Beispiel #5
0
    def show(self, form, *params):
        acquisitionInfo = form.protocol.loadAcquisitionInfo()

        if isinstance(acquisitionInfo, dict):
            # If acquisitionInfo is None means something is wrong.
            # Now, let's try to show a meanful error message.
            self._setAcquisition(form, acquisitionInfo)
        else:
            # If not dict, it should be an error message
            dialog.showError("Input error", acquisitionInfo, form.root)
Beispiel #6
0
 def renameProject(self, projName):
     newName = askString("Rename project %s" % projName, "Enter new name:", self.root)
     if not newName or newName == projName:
         return
     if self.manager.hasProject(newName):
         showError("Rename cancelled",
                   "Project name already exists: %s" % newName, self.root)
         return
     self.manager.renameProject(projName, newName)
     self.createProjectList(self.text)
Beispiel #7
0
    def show(self, form, *params):
        acquisitionInfo = form.protocol.loadAcquisitionInfo()

        if isinstance(acquisitionInfo, dict):
            # If acquisitionInfo is None means something is wrong.
            # Now, let's try to show a meaningful error message.
            self._setAcquisition(form, acquisitionInfo)
        else:
            # If not dict, it should be an error message
            dialog.showError("Input error", acquisitionInfo, form.root)
Beispiel #8
0
    def validate(self):

        validationMsg = None

        if len(self.textVar.get().strip()) == 0:
            validationMsg = "Label name can't be empty.\n"

        if validationMsg is not None:
            dialog.showError("Validation error", validationMsg, self)
            return False

        return True
Beispiel #9
0
    def validate(self):

        validationMsg = None

        if len(self.textVar.get().strip()) == 0:
            validationMsg = "Label name can't be empty.\n"

        if validationMsg is not None:
            dialog.showError("Validation error", validationMsg, self)
            return False

        return True
Beispiel #10
0
    def show(self, form, *params):
        try:
            acquisitionInfo = form.protocol.loadAcquisitionInfo()
            if isinstance(acquisitionInfo, dict):
                # If acquisitionInfo is None means something is wrong.
                # Now, let's try to show a meaningful error message.
                self._setAcquisition(form, acquisitionInfo)
            else:
                # If not dict, it should be an error message
                dialog.showError("Input error", acquisitionInfo, form.root)

        except FileNotFoundError as e:
            dialog.showInfo(
                "File not found",
                "Metadata file with acquisition not found.\n\n %s" % e,
                form.root)
Beispiel #11
0
    def _select(self):
        projName = self.projName.get().strip()
        projLocation = self.projLocation.get().strip()
        copyFiles = self.tkCheckVar.get() != 0
        searchLocation = self.searchLocation.get().strip()
        manager = Manager()

        # If project name is empty we will use the same name as the source
        if not projName:
            projName = os.path.basename(projLocation)

        errorMessage = ''

        # Validate that project location is not empty
        if not projLocation:
            errorMessage = "Project location is empty\n"

        # Validate that project location exists
        elif not os.path.exists(projLocation):
            errorMessage += "Project location does not exist\n"

        # Validate that project location is a directory
        elif not os.path.isdir(projLocation):
            errorMessage += "Project location is not a directory\n"
        # Validate that the project location is a scipion project folder
        elif not os.path.exists(os.path.join(projLocation,
                                             Project.getDbName())):
            errorMessage += "Project location doesn't look like a scipion folder\n"

        # Validate that there isn't already a project with the same name
        if manager.hasProject(projName):
            errorMessage += "Project [%s] already exists\n" % projName

        # Validate that search location exists
        if searchLocation:
            if not os.path.exists(searchLocation):
                errorMessage += "Raw files location does not exist\n"
            # Validate that search location is a directory
            elif not os.path.isdir(searchLocation):
                errorMessage += "Raw files location is not a directory\n"

        if errorMessage:
            showError("Validation error", errorMessage, self.root)
        else:
            self.parent.importProject(projLocation, copyFiles, projName,
                                      searchLocation)
            self.close()
Beispiel #12
0
    def _showPlot(self, paramName=None):
        views = []
        color = self.colozaxis
        rmax = self.radcut.get()

        if self.displayPlot == TILT_SCATTER:
            views.append(self._createScatterPlot(rmax, colorzaxis=color))
        elif self.displayPlot == TILT_CONTOUR:
            plotFn = self.protocol._getFileName('outputContourPlot')
            if os.path.exists(plotFn):
                views.append(DataView(plotFn))
            else:
                showError("File not found",
                          "Contour plot file not found: %s" % plotFn,
                          self.getTkRoot())

        return views
Beispiel #13
0
    def _select(self):
        projName = self.projName.get().strip()
        projLocation = self.projLocation.get().strip()
        copyFiles = self.tkCheckVar.get() != 0
        searchLocation = self.searchLocation.get().strip()
        manager = Manager()

        # If project name is empty we will use the same name as the source
        if not projName:
            projName = os.path.basename(projLocation)

        errorMessage = ''

        # Validate that project location is not empty
        if not projLocation:
            errorMessage = "Project location is empty\n"

        # Validate that project location exists
        elif not os.path.exists(projLocation):
            errorMessage += "Project location does not exist\n"

        # Validate that project location is a directory
        elif not os.path.isdir(projLocation):
                errorMessage += "Project location is not a directory\n"
        # Validate that the project location is a scipion project folder
        elif not os.path.exists(os.path.join(projLocation, PROJECT_DBNAME)):
            errorMessage += "Project location doesn't look like a scipion folder\n"

        # Validate that there isn't already a project with the same name
        if manager.hasProject(projName):
            errorMessage += "Project [%s] already exists\n" % projName

        # Validate that search location exists
        if searchLocation:
            if not os.path.exists(searchLocation):
                errorMessage += "Raw files location does not exist\n"
            # Validate that search location is a directory
            elif not os.path.isdir(searchLocation):
                errorMessage += "Raw files location is not a directory\n"

        if errorMessage:
            showError("Validation error", errorMessage, self.root)
        else:
            self.parent.importProject(projLocation, copyFiles, projName, searchLocation)
            self.close()
Beispiel #14
0
    def _itemSelected(self, obj):
        
        index = obj.getIndex()
        filename = obj.getFileName()
        if index:
            filename = "%03d@%s" % (index, filename)
        
#        self.image = xmipp.Image()
        self.image = ImageHandler()._img
        
        try:
            self.image.readPreview(filename, self.dim)
            if filename.endswith('.psd'):
                self.image.convertPSD()
            self.Z = self.image.getData()
        except Exception, e:
            from pyworkflow.gui.matplotlib_image import getPngData
            self.Z = getPngData(findResource('no-image.png'))
            dialog.showError("Input particles", "Error reading image <%s>" % filename, self) 
Beispiel #15
0
    def _itemSelected(self, obj):

        index = obj.getIndex()
        filename = emlib.image.ImageHandler.fixXmippVolumeFileName(obj)
        if index:
            filename = "%03d@%s" % (index, filename)

        self.image = emlib.image.ImageHandler()._img

        try:
            self.image.readPreview(filename, self.dim)
            if filename.endswith('.psd'):
                self.image.convertPSD()
            self.Z = self.image.getData()
        except Exception as e:
            from pyworkflow.gui.matplotlib_image import getPngData
            self.Z = getPngData(pw.findResource('no-image.gif'))
            dialog.showError("Input particles",
                             "Error reading image <%s>" % filename, self)
        self.preview.updateData(self.Z)
Beispiel #16
0
    def _select(self):
        projName = self.projName.get().strip()
        projLocation = self.projLocation.get().strip()

        # Validate that project name is not empty
        if not projName:
            showError("Validation error", "Project name is empty", self.root)
        # Validate that project location is not empty
        elif not projLocation:
            showError("Validation error", "Project location is empty", self.root)
        # Validate that project location exists
        elif not os.path.exists(projLocation):
            showError("Validation error", "Project location does not exist", self.root)
        # Validate that project location is a directory
        elif not os.path.isdir(projLocation):
            showError("Validation error", "Project location is not a directory", self.root)
        # Validate that project path (location + name) ddoes not exists
        elif os.path.exists(os.path.join(projLocation, projName)):
            showError("Validation error", "Project path already exists", self.root)
        else:
            self.parent.createNewProject(projName, projLocation)
            self.close()
Beispiel #17
0
 def show(self, form, *params):
     prot = form.protocol
     acquisitionInfo = prot.loadAcquisitionInfo()
     
     if prot.importFilePath:
         if exists(prot.importFilePath):
             if acquisitionInfo:
                 msg = ''
                 for k, v in acquisitionInfo.iteritems():
                     msg += '%s = %s\n' % (k, v)
                 msg += '\n*Do you want to use detected acquisition values?*'
                 response = dialog.askYesNo("Import acquisition", msg, form.root)
                 if response:
                     for k, v in acquisitionInfo.iteritems():
                         form.setVar(k, v)
             else:
                 dialog.showWarning("Import failed", 
                                    "Could not import acquisition info.", form.root)
         else:
             dialog.showError("Input error", "*Import file doesn't exist.*\nFile:\n%s" % prot.importFilePath, form.root)
     else:
         dialog.showError("Input error", "Select import file first", form.root) 
Beispiel #18
0
    def _createAngDistChimera(self, it):
        radius = self.spheresScale.get()
        volumes = self._getVolumeNames()
        self.protocol._execEmanProcess(self.protocol._getRun(), it)
        angularDist = self.protocol._getFileName("angles", iter=it)

        def createSqlite(prefix):
            nparts = self._getNumberOfParticles(it, prefix)
            sqliteFn = self.protocol._getFileName('projections',
                                                  iter=it,
                                                  half=prefix)
            self.createAngDistributionSqlite(sqliteFn,
                                             nparts,
                                             itemDataIterator=self._iterAngles(
                                                 it, prefix))
            return sqliteFn

        if len(volumes) > 1:
            showError(
                "Error",
                "Please select a single volume to show it's angular distribution",
                self.getTkRoot())
        elif not os.path.exists(angularDist):
            showError(
                "Error",
                "Please select a valid iteration to show the angular distribution",
                self.getTkRoot())
        else:
            if self.showHalves.get() == HALF_EVEN:
                sqliteFn = createSqlite('even')
            elif self.showHalves.get() == HALF_ODD:
                sqliteFn = createSqlite('odd')
            elif self.showHalves.get() == FULL_MAP:
                sqliteFn = createSqlite('full')
            else:
                showError(
                    "Error",
                    "Please select a single volume to show it's angular distribution",
                    self.getTkRoot())

            vol = self.protocol.outputVolume
            volOrigin = vol.getOrigin(force=True).getShifts()
            samplingRate = vol.getSamplingRate()
            return ChimeraAngDist(volumes[0],
                                  self.protocol._getTmpPath(),
                                  voxelSize=samplingRate,
                                  volOrigin=volOrigin,
                                  angularDistFile=sqliteFn,
                                  spheresDistance=radius)
Beispiel #19
0
 def _doPreview(self, e=None):
     if self.lastObj is None:
         dialog.showError("Empty selection", "Select an item first before preview", self)
     else:
         self._computeRightPreview()
Beispiel #20
0
def checkFileIntegrityGUI(fn,parent):
    ok = verifyMD5(fn)
    if ok:
        showInfo("File integrity", "File is OK", parent)
    else:
        showError("File integrity","File seems to have been modified since its creation. Not OK", parent)
Beispiel #21
0
 def _doPreview(self, e=None):
     if self.lastObj is None:
         dialog.showError("Empty selection",
                          "Select an item first before preview", self)
     else:
         self._itemSelected(self.lastObj)