コード例 #1
0
ファイル: dataimport.py プロジェクト: josegutab/scipion
    def _preprocessImageRow(self, img, imgRow):
        from convert import setupCTF, copyOrLinkFileName
        if self._imgPath is not None:
            copyOrLinkFileName(imgRow, self._imgPath, self.protocol._getExtraPath())
        setupCTF(imgRow, self.protocol.samplingRate.get())

        if self._micIdOrName:
            micId = imgRow.getValue('rlnMicrographId', None)
            micName = imgRow.getValue('rlnMicrographName', None)

            # Check which is the key to identify micrographs (id or name)
            if micId is not None:
                micKey = micId
            else:
                micKey = micName

            mic = self.micDict.get(micKey, None)

            # First time I found this micrograph (either by id or name)
            if mic is None:
                mic = Micrograph()
                mic.setObjId(micId)
                if micName is None:
                    micName = self.protocol._getExtraPath('fake_micrograph%6d' % micId)
                mic.setFileName(micName)
                self.micSet.append(mic)
                # Update dict with new Micrograph
                self.micDict[micKey] = mic

            # Update the row to set a MDL_MICROGRAPH_ID
            imgRow.setValue('rlnMicrographId', long(mic.getObjId()))
コード例 #2
0
ファイル: dataimport.py プロジェクト: joshua4289/scipion
    def _preprocessImageRow(self, img, imgRow):
        from convert import setupCTF, copyOrLinkFileName
        if self._imgPath is not None:
            copyOrLinkFileName(imgRow, self._imgPath,
                               self.protocol._getExtraPath())
        setupCTF(imgRow, self.protocol.samplingRate.get())

        if self._micIdOrName:
            micId = imgRow.getValue('rlnMicrographId', None)
            micName = imgRow.getValue('rlnMicrographName', None)

            # Check which is the key to identify micrographs (id or name)
            if micId is not None:
                micKey = micId
            else:
                micKey = micName

            mic = self.micDict.get(micKey, None)

            # First time I found this micrograph (either by id or name)
            if mic is None:
                mic = Micrograph()
                mic.setObjId(micId)
                if micName is None:
                    micName = self.protocol._getExtraPath(
                        'fake_micrograph%6d' % micId)
                mic.setFileName(micName)
                mic.setMicName(os.path.basename(micName))
                self.micSet.append(mic)
                # Update dict with new Micrograph
                self.micDict[micKey] = mic

            # Update the row to set a MDL_MICROGRAPH_ID
            imgRow.setValue('rlnMicrographId', long(mic.getObjId()))
コード例 #3
0
    def _checkNewMics(self, micSet):
        """ Check for already computed CTF and update the output set. """
        micDict = {}
        newMic = False
        for mic in micSet:
            micDict[mic.getFileName()] = True

        if micDict:
            if micSet.getSize():
                micSet.enableAppend()
                micSet.loadAllProperties()
        else:
            micSet.setStreamState(micSet.STREAM_OPEN)
            acquisition = Acquisition()
            acquisition.setMagnification(self._magnification)
            acquisition.setVoltage(self._voltage)
            acquisition.setSphericalAberration(self._sphericalAberration)
            acquisition.setAmplitudeContrast(self._amplitudeContrast)
            micSet.setAcquisition(acquisition)
            micSet.setSamplingRate(self.samplingRate.get())

        mic = Micrograph()

        counter = 0
        for k, v in self.xmippMic.iteritems():
            counter += 1
            if (k not in micDict):
                mic.setFileName(k)
                mic.setMicName(basename(k))
                mic.setObjId(counter)
                micSet.append(mic)
                newMic = True

        return micSet, newMic  #why a dictionary, a boolean may be enought
コード例 #4
0
ファイル: dataimport.py プロジェクト: EyeSeeTea/scipion-web
    def _preprocessParticleRow(self, img, imgRow):
        if self._imgPath:
            # Create a link or copy files to extraPath
            # and update the Row properly
            index, fn = xmippToLocation(imgRow.getValue(md.MDL_IMAGE))
            imgBase = basename(fn)
            imgDst = self.protocol._getExtraPath(imgBase)
            if not exists(imgDst):
                self.copyOrLink(join(self._imgPath, fn), imgDst)
            imgRow.setValue(md.MDL_IMAGE, locationToXmipp(index, imgDst))

        if self._micIdOrName:
            micId = imgRow.getValue(md.MDL_MICROGRAPH_ID, None)
            micName = imgRow.getValue(md.MDL_MICROGRAPH, None)

            # Check which is the key to identify micrographs (id or name)
            if micId is not None:
                micKey = micId
            else:
                micKey = micName

            mic = self.micDict.get(micKey, None)

            # First time I found this micrograph (either by id or name)
            if mic is None:
                mic = Micrograph()
                mic.setObjId(micId)
                if micName is None:
                    micName = self.protocol._getExtraPath(
                        'fake_micrograph%6d' % micId)
                mic.setFileName(micName)
                self.micSet.append(mic)
                # Update dict with new Micrograph
                self.micDict[micKey] = mic

            # Update the row to set a MDL_MICROGRAPH_ID
            imgRow.setValue(md.MDL_MICROGRAPH_ID, long(mic.getObjId()))

        # JMRT: This means that the metadata contains MDL_CTF_MODEL
        # and the files path were found from some root
        # In Xmipp 3.1 the ctfparam metadata in particles
        # was replaced with directly seeting the CTF values
        # so we need to fill those in the particle row
        if self._ctfPath:
            ctfModel = imgRow.getValue(md.MDL_CTF_MODEL)
            if ctfModel in self._ctfDict:
                ctfRow = self._ctfDict[ctfModel]
            else:
                ctfRow = md.Row()
                ctfRow.readFromFile(join(self._ctfPath, ctfModel))
                self._ctfDict[ctfModel] = ctfRow
            imgRow.copyFromRow(ctfRow)
コード例 #5
0
ファイル: dataimport.py プロジェクト: I2PC/scipion
    def _preprocessParticleRow(self, img, imgRow):
        if self._imgPath:
            # Create a link or copy files to extraPath
            # and update the Row properly
            index, fn = xmippToLocation(imgRow.getValue(md.MDL_IMAGE))
            imgBase = basename(fn)
            imgDst = self.protocol._getExtraPath(imgBase)
            if not exists(imgDst):
                self.copyOrLink(join(self._imgPath, fn), imgDst)
            imgRow.setValue(md.MDL_IMAGE, locationToXmipp(index, imgDst))

        if self._micIdOrName:
            micId = imgRow.getValue(md.MDL_MICROGRAPH_ID, None)
            micName = imgRow.getValue(md.MDL_MICROGRAPH, None)

            # Check which is the key to identify micrographs (id or name)
            if micId is not None:
                micKey = micId
            else:
                micKey = micName

            mic = self.micDict.get(micKey, None)

            # First time I found this micrograph (either by id or name)
            if mic is None:
                mic = Micrograph()
                mic.setObjId(micId)
                if micName is None:
                    micName = self.protocol._getExtraPath('fake_micrograph%6d'
                                                          % micId)
                mic.setFileName(micName)
                self.micSet.append(mic)
                # Update dict with new Micrograph
                self.micDict[micKey] = mic

            # Update the row to set a MDL_MICROGRAPH_ID
            imgRow.setValue(md.MDL_MICROGRAPH_ID, long(mic.getObjId()))

        # JMRT: This means that the metadata contains MDL_CTF_MODEL
        # and the files path were found from some root
        # In Xmipp 3.1 the ctfparam metadata in particles
        # was replaced with directly seeting the CTF values
        # so we need to fill those in the particle row
        if self._ctfPath:
            ctfModel = imgRow.getValue(md.MDL_CTF_MODEL)
            if ctfModel in self._ctfDict:
                ctfRow = self._ctfDict[ctfModel]
            else:
                ctfRow = md.Row()
                ctfRow.readFromFile(join(self._ctfPath, ctfModel))
                self._ctfDict[ctfModel] = ctfRow
            imgRow.copyFromRow(ctfRow)
コード例 #6
0
    def _preprocessParticleRow(self, img, imgRow):
        if self._imgPath:
            # Create a link or copy files to extraPath
            # and update the Row properly
            index, fn = xmippToLocation(imgRow.getValue(md.MDL_IMAGE))
            imgBase = basename(fn)
            imgDst = self.protocol._getExtraPath(imgBase)
            if not exists(imgDst):
                self.copyOrLink(join(self._imgPath, fn), imgDst)
            imgRow.setValue(md.MDL_IMAGE, locationToXmipp(index, imgDst))

        if self._micIdOrName:
            micId = imgRow.getValue(md.MDL_MICROGRAPH_ID, None)
            micName = imgRow.getValue(md.MDL_MICROGRAPH, None)

            # Check which is the key to identify micrographs (id or name)
            if micId is not None:
                micKey = micId
            else:
                micKey = micName

            mic = self.micDict.get(micKey, None)

            # First time I found this micrograph (either by id or name)
            if mic is None:
                mic = Micrograph()
                mic.setObjId(micId)
                if micName is None:
                    micName = self.protocol._getExtraPath('fake_micrograph%6d' % micId)
                mic.setFileName(micName)
                self.micSet.append(mic)
                # Update dict with new Micrograph
                self.micDict[micKey] = mic

            # Update the row to set a MDL_MICROGRAPH_ID
            imgRow.setValue(md.MDL_MICROGRAPH_ID, long(mic.getObjId()))