コード例 #1
0
 def createOutputStep(self):
     inputMovies = self.inputMovies.get()
     micSet = self._createSetOfMicrographs()
     micSet.copyInfo(inputMovies)
     # Also create a Set of Movies with the alignment parameters
     movieSet = self._createSetOfMovies()
     movieSet.copyInfo(inputMovies)
     
     for movie in inputMovies:
         movieId = movie.getObjId()
         micName = self._getMicName(movieId)
         movieFolder = self._getMovieFolder(movieId)
       
         mic = micSet.ITEM_TYPE()
         mic.setObjId(movieId)
         mic.setFileName(self._getExtraPath(micName))
         micSet.append(mic)
         
         # Parse the alignment parameters and store the log files
         alignedMovie = movie.clone()
         logFile = self._getExtraPath(self._getLogFile(movieId))
         alignment = parseMovieAlignment(logFile)
         alignedMovie.setAlignment(alignment)
         movieSet.append(alignedMovie)
         
     self._defineOutputs(outputMicrographs=micSet)
     self._defineTransformRelation(inputMovies, micSet)
     
     self._defineOutputs(outputMovies=movieSet)
     self._defineTransformRelation(inputMovies, movieSet)
コード例 #2
0
ファイル: protocol_import.py プロジェクト: coocoky/scipion
 def importAlignmentStep(self, micsId, pattern):
     """ Copy alignment matching the filename pattern
     """
     inputMovies = self.inputMovies.get()
     # Also create a Set of Movies with the alignment parameters
     movieSet = self._createSetOfMovies()
     movieSet.copyInfo(inputMovies)
     
     alignmentFiles = self._getFilePaths(pattern)
     movieDict = {}
     
     for fn in alignmentFiles:
         # Try to match the micrograph id from filename
         # this is set by the user by using #### format in the pattern
         match = self._idRegex.match(fn)
         if match is None:
             raise Exception("File '%s' doesn't match the pattern '%s'" % (fn, self.pattern.get()))
         movieId = int(match.group(1))
         movieDict[movieId] = fn
         
     for movie in inputMovies:
         movieId = movie.getObjId()
         if movieId in movieDict:
             # Parse the alignment parameters and store the log files
             alignedMovie = movie.clone()
             logFileSrc = movieDict[movieId]
             alignment = parseMovieAlignment(logFileSrc)
             alignedMovie.setAlignment(alignment)
             movieSet.append(alignedMovie)
         else:
             self.warning("Alignment for movie with id %d was not found. DISCARDED!!!" % movieId)
         
     self._defineOutputs(outputMovies=movieSet)
     self._defineTransformRelation(inputMovies, movieSet)          
コード例 #3
0
    def createOutputStep(self):
        inputMovies = self.inputMovies.get()
        micSet = self._createSetOfMicrographs()
        micSet.copyInfo(inputMovies)
        # Also create a Set of Movies with the alignment parameters
        movieSet = self._createSetOfMovies()
        movieSet.copyInfo(inputMovies)

        for movie in inputMovies:
            movieId = movie.getObjId()
            micName = self._getMicName(movieId)
            movieFolder = self._getMovieFolder(movieId)

            mic = micSet.ITEM_TYPE()
            mic.setObjId(movieId)
            mic.setFileName(self._getExtraPath(micName))
            micSet.append(mic)

            # Parse the alignment parameters and store the log files
            alignedMovie = movie.clone()
            logFile = self._getExtraPath(self._getLogFile(movieId))
            alignment = parseMovieAlignment(logFile)
            alignedMovie.setAlignment(alignment)
            movieSet.append(alignedMovie)

        self._defineOutputs(outputMicrographs=micSet)
        self._defineTransformRelation(inputMovies, micSet)

        self._defineOutputs(outputMovies=movieSet)
        self._defineTransformRelation(inputMovies, movieSet)
コード例 #4
0
 def _getMovieShifts(self, movie):
     """ Returns the x and y shifts for the alignment of this movie.
     The shifts should refer to the original micrograph without any binning.
     In case of a binning greater than 1, the shifts should be scaled.
     """
     logPath = self._getExtraPath(self._getMovieLogFile(movie))
     binning = self.binFactor.get()
     if not self.useMotioncor2:
         xShifts, yShifts = parseMovieAlignment(logPath)
     else:
         xShifts, yShifts = parseMovieAlignment2(logPath)
     xSfhtsCorr = [x * binning for x in xShifts]
     ySfhtsCorr = [y * binning for y in yShifts]
     return xSfhtsCorr, ySfhtsCorr
コード例 #5
0
ファイル: protocol_motioncorr.py プロジェクト: I2PC/scipion
 def _getMovieShifts(self, movie):
     """ Returns the x and y shifts for the alignment of this movie.
     The shifts should refer to the original micrograph without any binning.
     In case of a binning greater than 1, the shifts should be scaled.
     """
     logPath = self._getExtraPath(self._getMovieLogFile(movie))
     binning = self.binFactor.get()
     if not self.useMotioncor2:
         xShifts, yShifts = parseMovieAlignment(logPath)
     else:
         xShifts, yShifts = parseMovieAlignment2(logPath)
     # ROB: this is wrong, shifts are given in "original pixels"
     # even if bin is requested
     # xSfhtsCorr = [x * binning for x in xShifts]
     # ySfhtsCorr = [y * binning for y in yShifts]
     # return xSfhtsCorr, ySfhtsCorr
     return xShifts, yShifts
コード例 #6
0
    def importAlignmentStep(self, micsId, pattern):
        """ Copy alignment matching the filename pattern
        """
        inputMovies = self.inputMovies.get()
        # Also create a Set of Movies with the alignment parameters
        movieSet = self._createSetOfMovies()
        movieSet.copyInfo(inputMovies)

        alignmentFiles = self._getFilePaths(pattern)
        movieDict = {}

        for fn in alignmentFiles:
            # Try to match the micrograph id from filename
            # this is set by the user by using #### format in the pattern
            match = self._idRegex.match(fn)
            if match is None:
                raise Exception("File '%s' doesn't match the pattern '%s'" %
                                (fn, self.pattern.get()))
            movieId = int(match.group(1))
            movieDict[movieId] = fn

        for movie in inputMovies:
            movieId = movie.getObjId()
            if movieId in movieDict:
                # Parse the alignment parameters and store the log files
                alignedMovie = movie.clone()
                logFileSrc = movieDict[movieId]
                alignment = parseMovieAlignment(logFileSrc)
                alignedMovie.setAlignment(alignment)
                movieSet.append(alignedMovie)
            else:
                self.warning(
                    "Alignment for movie with id %d was not found. DISCARDED!!!"
                    % movieId)

        self._defineOutputs(outputMovies=movieSet)
        self._defineTransformRelation(inputMovies, movieSet)