예제 #1
0
파일: wizard.py 프로젝트: liz18/scipion
 def _computeRightPreview(self):
     """ This function should compute the right preview
     using the self.lastObj that was selected
     """
     xmippLib.gaussianFilter(self.rightImage,
                             ImageHandler.locationToXmipp(self.lastObj),
                             self.getFreqSigma(), self.dim)
예제 #2
0
파일: wizard.py 프로젝트: liz18/scipion
 def _computeRightPreview(self):
     """ This function should compute the right preview
     using the self.lastObj that was selected
     """
     xmippLib.bandPassFilter(self.rightImage,
                             ImageHandler.locationToXmipp(self.lastObj),
                             self.getLowFreq(), self.getHighFreq(),
                             self.getFreqDecay(), self.dim)
예제 #3
0
    def _loadPath(self, path):
        self._tableName = None

        # If path is a tuple, we will convert to the filename format
        # as expected by Showj
        if isinstance(path, tuple):
            self._path = ImageHandler.locationToXmipp(path)
        # Check if there is a table name with @ in path
        # in that case split table name and path
        # table names can never starts with a number
        # this is considering an image inside an stack
        elif isinstance(path, basestring):
            if '@' in path and path[0] not in '0123456789':
                self._tableName, self._path = path.split('@')
            else:
                self._path = path
        else:
            raise Exception("Invalid input path, "
                            "should be 'string' or 'tuple'")
예제 #4
0
def writeSetOfMicrographs(micSet, filename):
    """ Simplified function borrowed from xmipp. """
    mdata = md.MetaData()

    for img in micSet:
        objId = mdata.addObject()
        imgRow = md.Row()
        imgRow.setValue(md.MDL_ITEM_ID, long(objId))

        index, fname = img.getLocation()
        fn = ImageHandler.locationToXmipp((index, fname))
        imgRow.setValue(md.MDL_MICROGRAPH, fn)

        if img.isEnabled():
            enabled = 1
        else:
            enabled = -1
        imgRow.setValue(md.MDL_ENABLED, enabled)
        imgRow.writeToMd(mdata, objId)

    mdata.write('Micrographs@%s' % filename)
예제 #5
0
    def _visualize(self, obj, **kwargs):
        cls = type(obj)

        if issubclass(cls, em.Volume):
            fn = ImageHandler.locationToXmipp(obj)
            self._addObjView(obj, fn, {
                showj.RENDER: 'image',
                showj.SAMPLINGRATE: obj.getSamplingRate()
            })

        elif issubclass(cls, em.Image):
            fn = ImageHandler.locationToXmipp(obj)
            self._addObjView(obj, fn)

        elif issubclass(cls, em.SetOfPDBs):
            fn = obj.getFileName()
            labels = 'id _filename '
            self._addObjView(
                obj, fn, {
                    showj.ORDER: labels,
                    showj.VISIBLE: labels,
                    showj.MODE: showj.MODE_MD,
                    showj.RENDER: "no"
                })

        elif issubclass(cls, em.SetOfMovies):
            fn = obj.getFileName()
            # Enabled for the future has to be available
            labels = ('id _filename _samplingRate _acquisition._dosePerFrame '
                      '_acquisition._doseInitial ')
            moviesView = self._addObjView(
                obj, fn, {
                    showj.ORDER: labels,
                    showj.VISIBLE: labels,
                    showj.MODE: showj.MODE_MD,
                    showj.RENDER: "no"
                })
            # For movies increase the JVM memory by 1 GB, just in case
            moviesView.setMemory(showj.getJvmMaxMemory() + 1)

        elif issubclass(cls, em.SetOfMicrographs):
            self._views.append(
                views.MicrographsView(self._project, obj, **kwargs))

        elif issubclass(cls, em.MicrographsTiltPair):
            labels = 'id enabled _untilted._filename _tilted._filename'
            renderLabels = '_untilted._filename _tilted._filename'
            self._addObjView(
                obj, obj.getFileName(), {
                    showj.ORDER: labels,
                    showj.VISIBLE: labels,
                    showj.MODE: showj.MODE_MD,
                    showj.RENDER: renderLabels
                })

        elif issubclass(cls, em.ParticlesTiltPair):
            labels = 'id enabled _untilted._filename _tilted._filename'
            renderLabels = '_untilted._filename _tilted._filename'
            self._addObjView(
                obj, obj.getFileName(), {
                    showj.ORDER: labels,
                    showj.VISIBLE: labels,
                    showj.RENDER: renderLabels,
                    showj.MODE: showj.MODE_MD
                })

        elif issubclass(cls, em.SetOfCoordinates):
            # FIXME: Remove dependency on xmipp3 plugin to visualize coordinates
            xmipp3 = pwutils.importFromPlugin(
                'xmipp3',
                errorMsg="xmipp3 plugin is required "
                "now to visualize coordinates.")
            micSet = obj.getMicrographs(
            )  # accessing mics to provide metadata file
            if micSet is None:
                raise Exception(
                    'visualize: SetOfCoordinates has no micrographs set.')

            mdFn = getattr(micSet, '_xmippMd', None)
            if mdFn:
                fn = mdFn.get()
            else:  # happens if protocol is not an xmipp one
                fn = self._getTmpPath(micSet.getName() + '_micrographs.xmd')
                xmipp3.convert.writeSetOfMicrographs(micSet, fn)
            tmpDir = self._getTmpPath(obj.getName())
            pwutils.cleanPath(tmpDir)
            pwutils.makePath(tmpDir)
            # FIXME: (JMRT) We are always writing the SetOfCoordinates and removing
            # the tmpDir, we need to take into account if the user have pick
            # some particles in the tmpDir and have not save them, that now
            # will loose all picked particles.
            # A possible solution could be to alert that changes have not been
            # written during modification of tmpDir or create a new Xmipp picking
            # protocol to continue picking later without loosing the coordinates.
            xmipp3.convert.writeSetOfCoordinates(tmpDir, obj)
            self._views.append(
                views.CoordinatesObjectView(self._project,
                                            fn,
                                            tmpDir,
                                            self.protocol,
                                            inTmpFolder=True))

        elif issubclass(cls, em.SetOfParticles):
            fn = obj.getFileName()
            labels = (
                'id enabled _index _filename _xmipp_zScore _xmipp_cumulativeSSNR '
                '_sampling _xmipp_scoreByVariance _xmipp_scoreEmptiness '
                '_ctfModel._defocusU _ctfModel._defocusV _ctfModel._defocusAngle '
                '_transform._matrix')
            self._addObjView(
                obj, fn, {
                    showj.ORDER: labels,
                    showj.VISIBLE: labels,
                    showj.SORT_BY: '_xmipp_zScore asc',
                    showj.RENDER: '_filename'
                })

        elif issubclass(cls, em.SetOfVolumes):
            fn = obj.getFileName()
            labels = 'id enabled comment _filename '
            self._addObjView(
                obj, fn, {
                    showj.MODE: showj.MODE_MD,
                    showj.ORDER: labels,
                    showj.VISIBLE: labels,
                    showj.RENDER: '_filename'
                })

        elif issubclass(cls, em.SetOfClasses2D):
            self._views.append(
                views.ClassesView(self._project, obj.strId(),
                                  obj.getFileName(), **kwargs))

        elif issubclass(cls, em.SetOfClasses3D):
            self._views.append(
                views.Classes3DView(self._project, obj.strId(),
                                    obj.getFileName()))

        elif issubclass(cls, em.SetOfImages):
            self._views.append(
                views.ObjectView(self._project, obj.strId(), obj.getFileName(),
                                 **kwargs))

        elif issubclass(cls, em.SetOfCTF):
            self._views.append(views.CtfView(self._project, obj))

        elif issubclass(cls, em.CoordinatesTiltPair):
            # FIXME: Remove dependency on xmipp3 plugin to visualize coordinates
            xmipp3 = pwutils.importFromPlugin(
                'xmipp3',
                errorMsg="xmipp3 plugin is required "
                "now to visualize coordinates.")
            tmpDir = self._getTmpPath(obj.getName())
            pwutils.makePath(tmpDir)

            mdFn = os.path.join(tmpDir, 'input_micrographs.xmd')
            xmipp3.convert.writeSetOfMicrographsPairs(
                obj.getUntilted().getMicrographs(),
                obj.getTilted().getMicrographs(), mdFn)
            parentProtId = obj.getObjParentId()
            parentProt = self.getProject().mapper.selectById(parentProtId)
            extraDir = parentProt._getExtraPath()

            #           extraDir = parentProt._getExtraPath()
            # TODO: Review this if ever a non Xmipp CoordinatesTiltPair is available
            xmipp3.convert.writeSetOfCoordinates(tmpDir, obj.getUntilted())
            xmipp3.convert.writeSetOfCoordinates(tmpDir, obj.getTilted())
            showj.launchTiltPairPickerGUI(mdFn, tmpDir, self.protocol)

        elif issubclass(cls, em.ProtParticlePicking):
            if obj.getOutputsSize() >= 1:
                self._visualize(obj.getCoords())

        elif issubclass(cls, em.ProtImportMovies):
            movs = obj.outputMovies
            self._visualize(movs)
            gainFn = movs.getGain()
            if gainFn is not None:
                if os.path.exists(gainFn):
                    self._views.append(views.DataView(gainFn))

        return self._views