コード例 #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)
コード例 #2
0
    def launchBoxingGUIStep(self):
        # Print the eman version, useful to report bugs
        self.runJob(eman2.Plugin.getProgram('e2version.py'), '')
        useNewBoxer = self._useNewBoxer()
        # Program to execute and it arguments
        boxerVersion = 'old' if not useNewBoxer else 'new'
        boxer = eman2.Plugin.getBoxerCommand(boxerVersion=boxerVersion)
        program = eman2.Plugin.getProgram(boxer)
        arguments = "%(inputMics)s"

        if useNewBoxer:
            arguments += " --apix=%(pixSize)f --boxsize=%(boxSize)d"
            arguments += " --ptclsize=%(ptclSize)d --gui --threads=%(thr)d --no_ctf"
            self._params.update({
                'pixSize': self.inputMics.getSamplingRate(),
                'boxSize': self.boxSize.get(),
                'ptclSize': self.particleSize.get(),
                'thr': self.numberOfThreads.get()
            })

        # Run the command with formatted parameters
        self._log.info('Launching: ' + program + ' ' +
                       arguments % self._params)
        self.runJob(program, arguments % self._params)

        # Open dialog to request confirmation to create output
        if askYesNo(Message.TITLE_SAVE_OUTPUT, Message.LABEL_SAVE_OUTPUT,
                    None):
            self.check_gauss()
            self._leaveDir()  # going back to project dir
            self._createOutput(self.getWorkingDir())
コード例 #3
0
 def deleteProject(self, projName):
     if askYesNo(
             Message.TITLE_DELETE_PROJECT,
             "Project *%s*. " % projName + Message.MESSAGE_DELETE_PROJECT,
             self.root):
         self.manager.deleteProject(projName)
         self.createProjectList(self.text)
コード例 #4
0
    def launchBoxingGUIStep(self):
        # Print the eman version, useful to report bugs
        self.runJob(Plugin.getProgram('e2version.py'), '')
        # Program to execute and it arguments
        program = Plugin.getProgram('e2boxer.py')
        arguments = " --apix=%(pixSize)f --boxsize=%(boxSize)d"
        arguments += " --ptclsize=%(ptclSize)d --gui --threads=%(thr)d --no_ctf"

        self._params.update({
            'pixSize': self.inputMics.getSamplingRate(),
            'boxSize': self.boxSize.get(),
            'ptclSize': self.particleSize.get(),
            'thr': self.numberOfThreads.get()
        })
        arguments += " --device=%s" % self.device.get()

        arguments += " %(inputMics)s"

        # Run the command with formatted parameters
        self._log.info('Launching: ' + program + ' ' +
                       arguments % self._params)
        self.runJob(program, arguments % self._params, cwd=self.getCoordsDir())

        # Open dialog to request confirmation to create output
        if askYesNo(Message.TITLE_SAVE_OUTPUT, Message.LABEL_SAVE_OUTPUT,
                    None):
            self._createOutput(self.getCoordsDir())
コード例 #5
0
    def launchBoxingGUIStep(self):

        self.info_path = self._getExtraPath('info')
        lastOutput = None
        if self.getOutputsSize() >= 1:
            pwutils.makePath(self.info_path)
            self.json_files, self.tomo_files = jsonFilesFromSet(self.inputTomograms.get(), self.info_path)
            lastOutput = [output for _, output in self.iterOutputAttributes()][-1]
            _ = setCoords3D2Jsons(self.json_files, lastOutput)

        if lastOutput is not None:
            volIds = lastOutput.aggregate(["MAX", "COUNT"], "_volId", ["_volId"])
            volIds = dict([(d['_volId'], d["COUNT"]) for d in volIds])
        else:
            volIds = dict()

        tomoList = []
        for tomo in self.inputTomograms.get().iterItems():
            tomogram = tomo.clone()
            if tomo.getObjId() in volIds:
                tomogram.count = volIds[tomo.getObjId()]
            else:
                tomogram.count = 0
            tomoList.append(tomogram)

        tomoProvider = TomogramsTreeProvider(tomoList, self.info_path, "json")

        self.dlg = EmanDialog(None, self._getExtraPath(), provider=tomoProvider,)

        # Open dialog to request confirmation to create output
        import tkinter as tk
        frame = tk.Frame()
        if askYesNo(Message.TITLE_SAVE_OUTPUT, Message.LABEL_SAVE_OUTPUT, frame):
            self._createOutput()
コード例 #6
0
ファイル: viewers.py プロジェクト: EyeSeeTea/scipion-em-eman2
    def _showEmanCtf(self, paramName=None):
        program = eman2.Plugin.getProgram('e2ctf.py')
        args = '--allparticles --minptcl=0 --minqual=0'
        args += ' --gui --constbfactor=-1.0 --sf=auto'

        hostConfig = self.protocol.getHostConfig()
        # Create the steps executor
        executor = StepExecutor(hostConfig)
        self.protocol.setStepsExecutor(executor)
        # Finally run the protocol

        self.protocol.runJob(program,
                             args,
                             cwd=self.protocol._getExtraPath(),
                             numberOfMpi=1,
                             numberOfThreads=1)

        # Open dialog to request confirmation to overwrite output
        saveChanges = askYesNo(
            "Save output changes?",
            "Do you want to overwrite output particles with new CTF values?\n"
            "This may take a while depending on the set size.",
            self.getTkRoot())
        if saveChanges:
            self.protocol.createOutputStep()
            showInfo("Output updated",
                     "Output particles were updated with new CTF values.",
                     self.getTkRoot())
コード例 #7
0
 def _deleteLabel(self, e=None):
     selection = self.tree.getSelectedObjects()
     if selection:
         labelsStr = '\n'.join('- %s' % l.getName() for l in selection)
         if dialog.askYesNo(
                 "Delete a label", "Are you sure to delete the "
                 "following label(s)?\n %s" % labelsStr, self):
             for label in selection:
                 self.labels.deleteLabel(label)
             self.tree.update()
コード例 #8
0
ファイル: labels.py プロジェクト: I2PC/scipion
 def _deleteLabel(self, e=None):
     selection = self.tree.getSelectedObjects()
     if selection:
         labelsStr = '\n'.join('- %s' % l.getName() for l in selection)
         if dialog.askYesNo("Delete a label",
                            "Are you sure to delete the "
                            "following label(s)?\n %s" % labelsStr, self):
             for label in selection:
                 self.labels.deleteLabel(label)
             self.tree.update()
コード例 #9
0
    def deleteProject(self, projInfo):

        projName = projInfo.projName

        if askYesNo(
                Message.TITLE_DELETE_PROJECT,
                "Project *%s*. " % projName + Message.MESSAGE_DELETE_PROJECT,
                self.root):
            self.manager.deleteProject(projName)

            #Delete the frame
            self.text.children[self._PROJ_CONTAINER].children[
                projInfo.index].grid_forget()
コード例 #10
0
    def _visualize(self, obj, **kwargs):
        views = []
        cls = type(obj)

        if issubclass(cls, tomo.objects.SetOfCoordinates3D):
            outputCoords = obj
            tomos = outputCoords.getPrecedents()

            volIds = outputCoords.aggregate(["MAX", "COUNT"], "_volId",
                                            ["_volId"])
            volIds = [(d['_volId'], d["COUNT"]) for d in volIds]

            tomoList = []
            for objId in volIds:
                tomogram = tomos[objId[0]].clone()
                tomogram.count = objId[1]
                tomoList.append(tomogram)

            path = self.protocol._getExtraPath()
            info_path = self.protocol._getExtraPath('info')

            tomoProvider = TomogramsTreeProvider(
                tomoList,
                info_path,
                'json',
            )

            if not os.path.exists(info_path):
                pwutils.makePath(info_path)
            json_files, _ = jsonFilesFromSet(tomos, info_path)
            _ = setCoords3D2Jsons(json_files, outputCoords)

            setView = EmanDialog(self._tkRoot, path, provider=tomoProvider)

            import tkinter as tk
            frame = tk.Frame()
            if askYesNo(Message.TITLE_SAVE_OUTPUT, Message.LABEL_SAVE_OUTPUT,
                        frame):
                jsons2SetCoords3D(self.protocol, outputCoords.getPrecedents(),
                                  info_path)

        elif issubclass(cls, ProtImportCoordinates3D):
            if obj.getOutputsSize() >= 1:
                for _, out in obj.iterOutputAttributes(
                        tomo.objects.SetOfCoordinates3D):
                    lastOutput = out
            self._visualize(lastOutput)

        return views
コード例 #11
0
    def launchBoxingGUIStep(self):
        # Print the eman version, useful to report bugs
        self.runJob(eman2.getEmanProgram('e2version.py'), '')
        # Program to execute and it arguments
        program = eman2.getEmanProgram("e2boxer.py")
        arguments = "%(inputMics)s"
        # Run the command with formatted parameters
        self._log.info('Launching: ' + program + ' ' + arguments % self._params)
        self.runJob(program, arguments % self._params)

        # Open dialog to request confirmation to create output
        if askYesNo(Message.TITLE_SAVE_OUTPUT, Message.LABEL_SAVE_OUTPUT, None):
            self.check_gauss()
            self._leaveDir()# going back to project dir
            self._createOutput(self.getWorkingDir())
コード例 #12
0
ファイル: protocol_boxing.py プロジェクト: josegutab/scipion
    def launchBoxingGUIStep(self):
        # First we go to runs directory (we create if it does not exist)
        #path.makePath("runs")
        # Program to execute and it arguments
        program = eman2.getEmanProgram("e2boxer.py")
        arguments = "%(inputMics)s"
        # Run the command with formatted parameters
        self._log.info('Launching: ' + program + ' ' + arguments % self._params)
        self.runJob(program, arguments % self._params)

        # Open dialog to request confirmation to create output
        if askYesNo(Message.TITLE_SAVE_OUTPUT, Message.LABEL_SAVE_OUTPUT, None):
            self.check_gauss()
            self._leaveDir()# going back to project dir
            self._createOutput(self.getWorkingDir())
コード例 #13
0
    def interactiveSelStep(self):
        selection_file = self._getExtraPath('selected_ids.txt')
        metadata = self._getExtraPath(self.CLASSES_MD)
        self.classes = self.inputClasses.get()
        self.mdOut = md.MetaData(metadata)
        if self.intSel.get():
            img_paths = np.unique(
                np.asarray([
                    rep.getFileName()
                    for rep in self.classes.iterRepresentatives()
                ]))
            pos = self.mdOut.getColumnValues(md.MDL_DIMRED)
            img_ids = self.mdOut.getColumnValues(md.MDL_REF)
            occupancy = self.mdOut.getColumnValues(md.MDL_CLASS_COUNT)
            occupancy = np.asarray(occupancy)
            pos = np.vstack(pos)

            # Read selected ids from previous runs (if they exist)
            if os.path.isfile(selection_file):
                self.selection = np.loadtxt(selection_file)
                self.selection = [int(self.selection)] if self.selection.size == 1 else \
                                  self.selection.astype(int).tolist()
            else:
                self.selection = None

            view = ScatterImageMarker(pos=pos,
                                      img_paths=img_paths,
                                      ids=img_ids,
                                      occupancy=occupancy,
                                      prevsel=self.selection)
            view.initializePlot()

            self.selection = view.selected_ids

            # Save selected ids for interactive mode
            np.savetxt(selection_file, np.asarray(self.selection))

            if askYesNo(Message.TITLE_SAVE_OUTPUT, Message.LABEL_SAVE_OUTPUT,
                        None):
                self._createOutputStep()
        else:
            self.selection = [
                self.mdOut.getValue(md.MDL_REF, row.getObjId())
                for row in md.iterRows(self.mdOut)
            ]
            self._createOutputStep()
コード例 #14
0
    def launchParticlePickGUIStep(self):

        # Launch the particle picking GUI
        outputdir = self._getExtraPath()
        for mic in self.inputMics:
            micfile = abspath(mic.getFileName())
            args = "%s %s" % (micfile, outputdir)
            self.runJob("ln -sf", args)

        self._enterDir(outputdir)
        bsoft.loadEnvironment()
        for mic in self.inputMics:
            self.runJob("bshow", basename(mic.getFileName()))

        # Open dialog to request confirmation to create output
        if askYesNo(Message.TITLE_SAVE_OUTPUT, Message.LABEL_SAVE_OUTPUT,
                    None):
            self._leaveDir()  # going back to project dir
            self._createOutput(outputdir)
コード例 #15
0
    def launchParticlePickGUIStep(self):
        
        # Launch the particle picking GUI
        outputdir = self._getExtraPath()
        for mic in self.inputMics:
            micfile = abspath(mic.getFileName())
            args = "%s %s"%(micfile, outputdir)
            self.runJob("ln -sf", args)
            
        self._enterDir(outputdir)
        bsoft.loadEnvironment()
        for mic in self.inputMics:
            self.runJob("bshow", basename(mic.getFileName()))


        # Open dialog to request confirmation to create output
        if askYesNo(Message.TITLE_SAVE_OUTPUT, Message.LABEL_SAVE_OUTPUT, None):
            self._leaveDir()# going back to project dir
            self._createOutput(outputdir)
コード例 #16
0
ファイル: wizard.py プロジェクト: coocoky/scipion
 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) 
コード例 #17
0
ファイル: wizards.py プロジェクト: liz18/scipion
    def _setAcquisition(cls, form, acquisitionInfo):
        """ Ask whether to set the AcquisitionInfo to the protocol parameters.
        Params:
            acquisitionInfo: Should be a dictionary with acquisition values.
                If None, show an error.
        """
        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:
            prot = form.protocol
            comment = ''

            for k, v in acquisitionInfo.iteritems():
                if prot.hasAttribute(k):
                    form.setVar(k, v)
                else:
                    comment += "%s = %s\n" % (k, v)
            if comment:
                prot.setObjComment(comment)
コード例 #18
0
ファイル: wizard.py プロジェクト: I2PC/scipion
    def _setAcquisition(self, form, acquisitionInfo):
        """ Ask whether to set the AcquisitionInfo to the protocol parameters.
        Params:
            acquisitionInfo: Should be a dictionary with acquisition values.
                If None, show an error.
        """
        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:
            prot = form.protocol
            comment = ''

            for k, v in acquisitionInfo.iteritems():
                if prot.hasAttribute(k):
                    form.setVar(k, v)
                else:
                    comment += "%s = %s\n" % (k, v)
            if comment:
                prot.setObjComment(comment)
コード例 #19
0
ファイル: viewprojects.py プロジェクト: I2PC/scipion
 def deleteProject(self, projName):
     if askYesNo(Message.TITLE_DELETE_PROJECT, 
                 "Project *%s*. " % projName + Message.MESSAGE_DELETE_PROJECT, self.root):
         self.manager.deleteProject(projName)
         self.createProjectList(self.text)