Ejemplo n.º 1
0
    def _defineParams(self, form):
        ProtProcessMovies._defineParams(self, form)
        form.addParam('alignFrameRange', IntParam,
                      default=-1,
                      label='Number frames per movie ',
                      help='How many frames per monie. -1 -> all frames ')
        form.addParam('doApplyDoseFilter', BooleanParam, default=True,
                      label='Apply Dose filter',
                      help='Apply a dose-dependent filter to frames '
                           'before summing them')
        form.addParam('exposurePerFrame', FloatParam,
                      label='Exposure per frame (e/A^2)',
                      help='Exposure per frame, in electrons per square '
                           'Angstrom')

        #group = form.addGroup('Expert Options')
        form.addParam('Bfactor', FloatParam,
                      default=1500.,
                      label='B-factor (A^2)',
                      help='B-factor to apply to images (A^2)',
                      expertLevel=LEVEL_ADVANCED)
        form.addParam('doRestoreNoisePower', BooleanParam,
                      default=True,
                      label='Restore Noise Power? ',
                      help='Restore Noise Power? ',
                      expertLevel=LEVEL_ADVANCED)
        form.addParam('doVerboseOutput', BooleanParam,
                      default=False,
                      label='Verbose Output?',
                      help='Verbose Output?',
                      expertLevel=LEVEL_ADVANCED)
        form.addParallelSection(threads=1, mpi=1)
Ejemplo n.º 2
0
    def _defineParams(self, form):
        ProtProcessMovies._defineParams(self, form)
        form.addParam('alignFrameRange', IntParam,
                      default=-1,
                      label='Number frames per movie ',
                      help='How many frames per monie. -1 -> all frames ')
        form.addParam('doApplyDoseFilter', BooleanParam, default=True,
                      label='Apply Dose filter',
                      help='Apply a dose-dependent filter to frames before summing them')
        form.addParam('exposurePerFrame', FloatParam,
                      label='Exposure per frame (e/A^2)',
                      help='Exposure per frame, in electrons per square Angstrom')

        #group = form.addGroup('Expert Options')
        form.addParam('minShiftInitSearch', FloatParam,
                      default=2.,
                      label='Min. Shift Initial search (A)',
                      help='Initial search will be limited to between the inner and outer radii',
                      expertLevel=LEVEL_ADVANCED)
        form.addParam('OutRadShiftLimit', FloatParam,
                      default=200.,
                      label='Outer radius shift limit (A)',
                      help='The maximum shift of each alignment step will be limited to this value',
                      expertLevel=LEVEL_ADVANCED)
        form.addParam('Bfactor', FloatParam,
                      default=1500.,
                      label='B-factor (A^2)',
                      help='B-factor to apply to images (A^2)',
                      expertLevel=LEVEL_ADVANCED)
        form.addParam('HWVertFourMask', IntParam,
                      default=1,
                      label='Half-width vertical Fourier mask',
                      help='The vertical line mask will be twice this size. The central cross mask helps reduce problems by line artefacts from the detector',
                      expertLevel=LEVEL_ADVANCED)
        form.addParam('HWHoriFourMask', IntParam,
                      default=1,
                      label='Half-width horizontal Fourier mask',
                      help='The horizontal line mask will be twice this size. The central cross mask helps reduce problems by line artefacts from the detector',
                      expertLevel=LEVEL_ADVANCED)
        form.addParam('terminationShiftThreshold', FloatParam,
                      default=0.1,
                      label='Termination shift threshold',
                      help='Alignment will stop at this number, even if the threshold shift is not reached',
                      expertLevel=LEVEL_ADVANCED)
        form.addParam('maximumNumberIterations', IntParam,
                      default=10,
                      label='Maximum number of iterations',
                      help='Maximum number of iterations',
                      expertLevel=LEVEL_ADVANCED)
        form.addParam('doRestoreNoisePower', BooleanParam,
                      default=True,
                      label='Restore Noise Power? ',
                      help='Restore Noise Power? ',
                      expertLevel=LEVEL_ADVANCED)
        form.addParam('doVerboseOutput', BooleanParam,
                      default=False,
                      label='Verbose Output?',
                      help='Verbose Output?',
                      expertLevel=LEVEL_ADVANCED)
        form.addParallelSection(threads=1, mpi=1)
Ejemplo n.º 3
0
    def _defineParams(self, form):
        ProtProcessMovies._defineParams(self, form)
        
        group = form.addGroup('Frame range')
        line1 = group.addLine('Used in alignment',
                             help='First and last frames used in alignment.\n'
                                  'The first frame in the stack is *0*.' )
        line1.addParam('alignFrame0', IntParam, default=0, label='First')
        line1.addParam('alignFrameN', IntParam, default=0, label='Last',
                      help='If *0*, use maximum value')
        
        line2 = group.addLine('Used in final sum',
                             help='First and last frames used in alignment.\n'
                                  'The first frame in the stack is *0*.' )
        line2.addParam('sumFrame0', IntParam, default=0, label='First')
        line2.addParam('sumFrameN', IntParam, default=0, label='Last',
                      help='If *0*, use maximum value')        
        
        form.addParam('gpuId', StringParam, default='0',
                      expertLevel=LEVEL_ADVANCED,
                      label='GPU id',
                      help='GPU device ID')
        
        form.addParam('extraParams', StringParam, default='',
                      expertLevel=LEVEL_ADVANCED,
                      label='Additional parameters',
                      help="""
-bft       150               BFactor in pix^2.
-pbx       96                Box dimension for searching CC peak.
-fod       2                 Number of frame offset for frame comparison.
-nps       0                 Radius of noise peak.
-sub       0                 1: Save as sub-area corrected sum. 0: Not. 
-srs       0                 1: Save uncorrected sum. 0: Not.
-ssc       0                 1: Save aligned stack. 0: Not.
-scc       0                 1: Save CC Map. 0: Not.
-slg       1                 1: Save Log. 0: Not.
-atm       1                 1: Align to middle frame. 0: Not.
-dsp       1                 1: Save quick results. 0: Not.
-fsc       0                 1: Calculate and log FSC. 0: Not.
                      """)
        
        group2 = form.addGroup('Crop and binning')

        line = group2.addLine('Crop offsets (px)')
        line.addParam('cropOffsetX', IntParam, default=0, label='X')
        line.addParam('cropOffsetY', IntParam, default=0, label='Y')
    
        line = group2.addLine('Crop dimensions (px)',
                      help='How many pixels to crop from offset\n'
                           'If equal to 0, use maximum size.')
        line.addParam('cropDimX', IntParam, default=0, label='X')
        line.addParam('cropDimY', IntParam, default=0, label='Y')


        group2.addParam('binFactor', IntParam, default=1, 
                      label='Binning factor',
                      help='1x or 2x. Bin stack before processing.')
              
        form.addParallelSection(threads=1, mpi=1)
Ejemplo n.º 4
0
    def _defineParams(self, form):
        ProtProcessMovies._defineParams(self, form)

        form.addParam('useEst', params.BooleanParam, default=False,
                      label='Use previous estimation?',
                      help='Use previously calculated parameters of '
                           'magnification anisotropy.')
        form.addParam('inputEst', params.PointerParam,
                      pointerClass='ProtMagDistEst', condition='useEst',
                      label='Input protocol',
                      help='Select previously executed estimation protocol.')
        form.addParam('scaleMaj', params.FloatParam, default=1.0,
                      condition='not useEst',
                      label='Major scale factor',
                      help='Major scale factor.')
        form.addParam('scaleMin', params.FloatParam, default=1.0,
                      condition='not useEst',
                      label='Minor scale factor',
                      help='Minor scale factor.')
        form.addParam('angDist', params.FloatParam, default=0.0,
                      condition='not useEst',
                      label='Distortion angle (deg)',
                      help='Distortion angle, in degrees.')
        form.addParam('newPix', params.FloatParam,
                      condition='not useEst',
                      label='New pixel size (A)',
                      help='Assign a new corrected pixel size, in Angstrom.')
        form.addParam('doGain', params.BooleanParam, default=False,
                      expertLevel=params.LEVEL_ADVANCED,
                      label='Do gain correction before undistorting?',
                      help='If Yes, gain reference that you provided during '
                           'movies import will be chosen.')
        form.addParam('doResample', params.BooleanParam, default=False,
                      expertLevel=params.LEVEL_ADVANCED,
                      label='Resample images?',
                      help='Resample images after distortion correction and gain'
                           ' correction, by cropping their Fourier transforms')
        line = form.addLine('New dimensions (px)',
                            expertLevel=params.LEVEL_ADVANCED,
                            condition='doResample')
        line.addParam('newX', params.IntParam, default=2048,
                      label='X',
                      expertLevel=params.LEVEL_ADVANCED,
                      condition='doResample')
        line.addParam('newY', params.IntParam, default=2048,
                      label='Y',
                      expertLevel=params.LEVEL_ADVANCED,
                      condition='doResample')

        form.addParallelSection(threads=2, mpi=1)
Ejemplo n.º 5
0
    def _defineParams(self, form):
        ProtProcessMovies._defineParams(self, form)
        form.addParam(
            "alignFrameRange",
            IntParam,
            default=-1,
            label="Number frames per movie ",
            help="How many frames per monie. -1 -> all frames ",
        )
        form.addParam(
            "doApplyDoseFilter",
            BooleanParam,
            default=True,
            label="Apply Dose filter",
            help="Apply a dose-dependent filter to frames before summing them",
        )
        form.addParam(
            "exposurePerFrame",
            FloatParam,
            label="Exposure per frame (e/A^2)",
            help="Exposure per frame, in electrons per square Angstrom",
        )

        # group = form.addGroup('Expert Options')
        form.addParam(
            "Bfactor",
            FloatParam,
            default=1500.0,
            label="B-factor (A^2)",
            help="B-factor to apply to images (A^2)",
            expertLevel=LEVEL_ADVANCED,
        )
        form.addParam(
            "doRestoreNoisePower",
            BooleanParam,
            default=True,
            label="Restore Noise Power? ",
            help="Restore Noise Power? ",
            expertLevel=LEVEL_ADVANCED,
        )
        form.addParam(
            "doVerboseOutput",
            BooleanParam,
            default=False,
            label="Verbose Output?",
            help="Verbose Output?",
            expertLevel=LEVEL_ADVANCED,
        )
        form.addParallelSection(threads=1, mpi=1)
Ejemplo n.º 6
0
    def _defineParams(self, form):
        ProtProcessMovies._defineParams(self, form)
        form.addParam('alignFrameRange',
                      IntParam,
                      default=-1,
                      label='Number frames per movie ',
                      help='How many frames per monie. -1 -> all frames ')
        form.addParam('doApplyDoseFilter',
                      BooleanParam,
                      default=True,
                      label='Apply Dose filter',
                      help='Apply a dose-dependent filter to frames '
                      'before summing them')
        form.addParam('exposurePerFrame',
                      FloatParam,
                      label='Exposure per frame (e/A^2)',
                      help='Exposure per frame, in electrons per square '
                      'Angstrom')

        #group = form.addGroup('Expert Options')
        form.addParam('Bfactor',
                      FloatParam,
                      default=1500.,
                      label='B-factor (A^2)',
                      help='B-factor to apply to images (A^2)',
                      expertLevel=LEVEL_ADVANCED)
        form.addParam('doRestoreNoisePower',
                      BooleanParam,
                      default=True,
                      label='Restore Noise Power? ',
                      help='Restore Noise Power? ',
                      expertLevel=LEVEL_ADVANCED)
        form.addParam('doVerboseOutput',
                      BooleanParam,
                      default=False,
                      label='Verbose Output?',
                      help='Verbose Output?',
                      expertLevel=LEVEL_ADVANCED)
        form.addParallelSection(threads=1, mpi=1)
Ejemplo n.º 7
0
    def _defineParams(self, form):
        ProtProcessMovies._defineParams(self, form)

        form.addParam(
            "alignMethod",
            EnumParam,
            choices=[
                "optical flow",
                "dosefgpu",
                "dosefgpu + optical flow",
                "average",
                "croscorrelation",
                "croscorrelation + optical flow",
            ],
            label="Alignment method",
            default=AL_OPTICAL,
            display=EnumParam.DISPLAY_COMBO,
            help="Method to use for movie alignment. "
            "dosefgpu requires a GPU. Croscorrelation "
            "and dosefgpu with default parameters are equivalent. "
            "Croscorrelation is a CPU implementation of dosefgpu  "
            "with limited functionality (only aligns whole frames)",
        )

        # GROUP COMMON PARAMETERS
        group = form.addGroup("Common parameters")

        line = group.addLine(
            "Used in alignment",
            help="First and last frames used in alignment.\n" "The first frame in the stack is *0*.",
        )
        line.addParam("alignFrame0", IntParam, default=0, label="First")
        line.addParam("alignFrameN", IntParam, default=0, label="Last", help="If *0*, use maximum value")

        # GROUP GPU PARAMETERS
        group = form.addGroup(
            "GPU",
            condition="alignMethod==%d or (alignMethod==%d and expertLevel==%d)"
            " or (alignMethod==%d and expertLevel==%d)"
            % (AL_OPTICAL, AL_DOSEFGPUOPTICAL, LEVEL_ADVANCED, AL_DOSEFGPU, LEVEL_ADVANCED),
        )
        group.addParam(
            "doGPU",
            BooleanParam,
            default=False,
            label="Use GPU (vs CPU)",
            condition="alignMethod==%d or alignMethod==%d" % (AL_OPTICAL, AL_DOSEFGPUOPTICAL),
            help="Set to true if you want the GPU implementation of Optical Flow",
        )
        group.addParam(
            "GPUCore",
            IntParam,
            default=0,
            expertLevel=LEVEL_ADVANCED,
            label="Choose GPU core",
            condition="doGPU  or alignMethod==%d or alignMethod==%d  " % (AL_DOSEFGPU, AL_DOSEFGPUOPTICAL),
            help="GPU may have several cores. Set it to zero if you do not know what we are talking about. First core index is 0, second 1 and so on.",
        )

        # GROUP OPTICAL FLOW PARAMETERS
        group = form.addGroup(
            "Optical Flow parameters",
            expertLevel=LEVEL_ADVANCED,
            condition="alignMethod==%d or alignMethod==%d " % (AL_OPTICAL, AL_DOSEFGPUOPTICAL),
        )

        group.addParam(
            "winSize",
            IntParam,
            default=150,
            label="Window size",
            expertLevel=LEVEL_ADVANCED,
            help="Window size (shifts are assumed to be constant within this window).",
        )

        # ---------------------------------- DosefGPU Params--------------------------------
        # GROUP DOSEFGPU PARAMETERS
        group = form.addGroup(
            "DosefGPU/Croscorrelation parameters",
            condition="alignMethod==%d "
            "or alignMethod==%d"
            "or alignMethod==%d"
            "or alignMethod==%d" % (AL_DOSEFGPU, AL_DOSEFGPUOPTICAL, AL_CROSSCORRELATION, AL_CROSSCORRELATIONOPTICAL),
        )

        line = group.addLine(
            "Used in final sum",
            help="First and last frames used in alignment.\n" "The first frame in the stack is *0*.",
        )
        line.addParam("sumFrame0", IntParam, default=0, label="First")
        line.addParam("sumFrameN", IntParam, default=0, label="Last", help="If *0*, use maximum value")

        line = group.addLine("Crop offsets (px)")
        line.addParam("cropOffsetX", IntParam, default=0, label="X")
        line.addParam("cropOffsetY", IntParam, default=0, label="Y")

        line = group.addLine(
            "Crop dimensions (px)", help="How many pixels to crop from offset\n" "If equal to 0, use maximum size."
        )
        line.addParam("cropDimX", IntParam, default=0, label="X")
        line.addParam("cropDimY", IntParam, default=0, label="Y")

        group.addParam(
            "binFactor",
            IntParam,
            default=1,
            condition="alignMethod==%d " "or alignMethod==%d" % (AL_DOSEFGPU, AL_DOSEFGPUOPTICAL),
            label="Binning factor",
            help="1x or 2x. Bin stack before processing.",
        )

        group.addParam(
            "filterFactor",
            FloatParam,
            default=4,
            condition="alignMethod==%d " "or alignMethod==%d" % (AL_CROSSCORRELATION, AL_CROSSCORRELATIONOPTICAL),
            label="Filter at (A)",
            help="1x or 2x. Bin stack before processing.",
        )

        group.addParam(
            "extraParams",
            StringParam,
            default="",
            expertLevel=LEVEL_ADVANCED,
            label="Additional parameters",
            help="""
-bft       150               BFactor in pix^2.
-pbx       96                Box dimension for searching CC peak.
-fod       2                 Number of frame offset for frame comparision.
-nps       0                 Radius of noise peak.
-sub       0                 1: Save as sub-area corrected sum. 0: Not.
-srs       0                 1: Save uncorrected sum. 0: Not.
-ssc       0                 1: Save aligned stack. 0: Not.
-scc       0                 1: Save CC Map. 0: Not.
-slg       1                 1: Save Log. 0: Not.
-atm       1                 1: Align to middle frame. 0: Not.
-dsp       1                 1: Save quick results. 0: Not.
-fsc       0                 1: Calculate and log FSC. 0: Not.
                      """,
        )
        form.addParallelSection(threads=1, mpi=1)
 def _defineParams(self, form):
     ProtProcessMovies._defineParams(self, form)
     self._defineAlignmentParams(form)
Ejemplo n.º 9
0
 def _checkNewInput(self):
     if isinstance(self.inputMovies.get(), SetOfMovies):
         ProtProcessMovies._checkNewInput(self)
Ejemplo n.º 10
0
    def _defineParams(self, form):
        ProtProcessMovies._defineParams(self, form)
        form.addParam('inputCoordinates',
                      PointerParam,
                      pointerClass='SetOfCoordinates',
                      important=True,
                      label='Input coordinates')
        form.addParam('boxSize',
                      IntParam,
                      default=0,
                      label='Particle box size (px)',
                      validators=[Positive],
                      help='In pixels. The box size is the size of the boxed '
                      'particles, actual particles may be smaller than '
                      'this.')
        form.addParam('applyAlignment',
                      BooleanParam,
                      default=False,
                      label='Apply movie alignments to extract?',
                      help='If the input movies contains frames alignment, '
                      'you decide whether to use that information '
                      'for extracting the particles taking into account '
                      'the shifts between frames.')
        line = form.addLine(
            'Frames range',
            help='Specify the frames range to extract particles. '
            'The first frame is 1. If you set 0 in the '
            'last frame, it means that you will use until the '
            'last frame of the movie. If you apply the '
            'previous alignment of the movies, you only can use '
            'a frame range equal or less as used to alignment.')
        line.addParam('frame0', IntParam, label='First')
        line.addParam('frameN', IntParam, label='Last')
        # TODO: implement this and extraction from movies, not frames
        #form.addParam('avgFrames', IntParam, default=1,
        #              label='Average every so many frames', validators=[Positive],
        #              help='Average over this number of individual movie frames. '
        #                   'For Relion movie refinement it is recommended to '
        #                   'adjust this value to have a dose of at least '
        #                   'approximately 1 e/A^2 in the averaged frames, '
        #                   'so use a value higher than 1 if you have a '
        #                   'dose of less than 0.5-1 e/A^2 in each '
        #                   'individual movie frame.')
        form.addParam(
            'doBorders',
            BooleanParam,
            default=True,
            label='Fill pixels outside borders',
            help='Xmipp by default create blank particles whose boxes fall '
            'outside of the micrograph borders. Set this '
            'option to True if you want those pixels outside '
            'the borders to be filled with the closest pixel '
            'value available')

        form.addSection(label='Preprocess')
        form.addParam('doRemoveDust',
                      BooleanParam,
                      default=True,
                      important=True,
                      label='Dust removal (Recommended)',
                      help='Sets pixels with unusually large values to random '
                      'values from a Gaussian with zero-mean and '
                      'unity-standard deviation.')
        form.addParam('thresholdDust',
                      FloatParam,
                      default=3.5,
                      condition='doRemoveDust',
                      expertLevel=LEVEL_ADVANCED,
                      label='Threshold for dust removal',
                      help='Pixels with a signal higher or lower than this '
                      'value times the standard deviation of the image '
                      'will be affected. For cryo, 3.5 is a good value. '
                      'For high-contrast negative stain, the signal '
                      'itself may be affected so that a higher value may '
                      'be preferable.')
        form.addParam('doInvert',
                      BooleanParam,
                      default=None,
                      label='Invert contrast',
                      help='Invert the contrast if your particles are black '
                      'over a white background.')
        form.addParam('doNormalize',
                      BooleanParam,
                      default=True,
                      label='Normalize (Recommended)',
                      help='It subtract a ramp in the gray values and '
                      'normalizes so that in the  background there is 0 '
                      'mean and standard deviation 1.')
        form.addParam('normType',
                      EnumParam,
                      choices=['OldXmipp', 'NewXmipp', 'Ramp'],
                      default=2,
                      condition='doNormalize',
                      expertLevel=LEVEL_ADVANCED,
                      display=EnumParam.DISPLAY_COMBO,
                      label='Normalization type',
                      help='OldXmipp (mean(Image)=0, stddev(Image)=1). \n'
                      'NewXmipp (mean(background)=0, '
                      'stddev(background)=1)\n'
                      'Ramp (subtract background+NewXmipp).')
        form.addParam('backRadius',
                      IntParam,
                      default=-1,
                      condition='doNormalize',
                      label='Background radius (px)',
                      help='Pixels outside this circle are assumed to be '
                      'noise and their stddev is set to 1. Radius for '
                      'background circle definition (in pix.). If this '
                      'value is 0, then half the box size is used.',
                      expertLevel=LEVEL_ADVANCED)

        form.addParallelSection(threads=3, mpi=1)
    def _defineParams(self, form):
        ProtProcessMovies._defineParams(self, form)

        form.addParam('alignMethod', EnumParam, choices=['optical flow'
                                                       , 'dosefgpu'
                                                       , 'dosefgpu + optical flow'
                                                       , 'average'
                                                       , 'croscorrelation'
                                                       , 'croscorrelation + optical flow'
                                                        ],
                      label="Alignment method", default=AL_OPTICAL,
                      display=EnumParam.DISPLAY_COMBO,
                      help='Method to use for movie alignment. '
                           'dosefgpu requires a GPU. Croscorrelation '
                           'and dosefgpu with default parameters are equivalent. '
                           'Croscorrelation is a CPU implementation of dosefgpu  '
                           'with limited functionality (only aligns whole frames)'
                      )

        # GROUP COMMON PARAMETERS
        group = form.addGroup('Common parameters')
        
        line = group.addLine('Used in alignment',
                            help='First and last frames used in alignment.\n'
                                  'The first frame in the stack is *0*.' )
        line.addParam('alignFrame0', IntParam, default=0, label='First')
        line.addParam('alignFrameN', IntParam, default=0, label='Last',
                      help='If *0*, use maximum value')
        
        # GROUP GPU PARAMETERS
        group = form.addGroup('GPU',condition="alignMethod==%d or (alignMethod==%d and expertLevel==%d)"
                                                         " or (alignMethod==%d and expertLevel==%d)"
                                                         % (AL_OPTICAL, AL_DOSEFGPUOPTICAL, LEVEL_ADVANCED, AL_DOSEFGPU, LEVEL_ADVANCED))
        group.addParam('doGPU', BooleanParam, default=False,
                      label="Use GPU (vs CPU)",
                      condition="alignMethod==%d or alignMethod==%d" % (AL_OPTICAL, AL_DOSEFGPUOPTICAL),
                      help="Set to true if you want the GPU implementation of Optical Flow")
        group.addParam('GPUCore', IntParam, default=0, expertLevel=LEVEL_ADVANCED,
                      label="Choose GPU core",
                      condition="doGPU  or alignMethod==%d or alignMethod==%d  " % (AL_DOSEFGPU, AL_DOSEFGPUOPTICAL),
                      help="GPU may have several cores. Set it to zero if you do not know what we are talking about. First core index is 0, second 1 and so on.")
        
        # GROUP OPTICAL FLOW PARAMETERS
        group = form.addGroup('Optical Flow parameters', expertLevel=LEVEL_ADVANCED, condition="alignMethod==%d or alignMethod==%d or alignMethod==%d " % (AL_OPTICAL, AL_DOSEFGPUOPTICAL, AL_CROSSCORRELATIONOPTICAL))
        
        group.addParam('winSize', IntParam, default=150,
                      label="Window size", expertLevel=LEVEL_ADVANCED,
                      help="Window size (shifts are assumed to be constant within this window).")

        group.addParam('groupSize', IntParam, default=1,
                      label="Group Size", expertLevel=LEVEL_ADVANCED,
                      help="In cases with low SNR, the average of a number of frames can be used in alignment")

        group.addParam('doSaveMovie', BooleanParam, default=False,
                      label="Save movie", expertLevel=LEVEL_ADVANCED,
                      help="Save Aligned movie")

        #---------------------------------- DosefGPU Params--------------------------------
        # GROUP DOSEFGPU PARAMETERS
        group = form.addGroup('DosefGPU/Croscorrelation parameters',condition="alignMethod==%d "
                                                              "or alignMethod==%d"
                                                              "or alignMethod==%d"
                                                              "or alignMethod==%d" %
                                                              (AL_DOSEFGPU,\
                                                               AL_DOSEFGPUOPTICAL,\
                                                               AL_CROSSCORRELATION,\
                                                               AL_CROSSCORRELATIONOPTICAL)
                              )
        
        line = group.addLine('Used in final sum',
                             help='First and last frames used in alignment.\n'
                                  'The first frame in the stack is *0*.' )
        line.addParam('sumFrame0', IntParam, default=0, label='First')
        line.addParam('sumFrameN', IntParam, default=0, label='Last',
                      help='If *0*, use maximum value')
        
        line = group.addLine('Crop offsets (px)')
        line.addParam('cropOffsetX', IntParam, default=0, label='X')
        line.addParam('cropOffsetY', IntParam, default=0, label='Y')
        
        line = group.addLine('Crop dimensions (px)',
                      help='How many pixels to crop from offset\n'
                           'If equal to 0, use maximum size.')
        line.addParam('cropDimX', IntParam, default=0, label='X')
        line.addParam('cropDimY', IntParam, default=0, label='Y')

        group.addParam('binFactor', IntParam, default=1,condition="alignMethod==%d "
                                                              "or alignMethod==%d" %
                                                                  (AL_DOSEFGPU,\
                                                                   AL_DOSEFGPUOPTICAL\
                       ),
                       label='Binning factor',
                       help='1x or 2x. Bin stack before processing.')

        group.addParam('filterFactor', FloatParam, default=4,condition="alignMethod==%d "
                                                              "or alignMethod==%d" %
                                                                  (AL_CROSSCORRELATION,\
                                                                   AL_CROSSCORRELATIONOPTICAL\
                       ),
                       label='Filter at (A)',
                       help='Maximum frequency for a low pass filter')


        group.addParam('extraParams', StringParam, default='',
                      expertLevel=LEVEL_ADVANCED,
                      label='Additional parameters',
                      help="""
-bft       150               BFactor in pix^2.
-pbx       96                Box dimension for searching CC peak.
-fod       2                 Number of frame offset for frame comparison.
-nps       0                 Radius of noise peak.
-sub       0                 1: Save as sub-area corrected sum. 0: Not.
-srs       0                 1: Save uncorrected sum. 0: Not.
-ssc       0                 1: Save aligned stack. 0: Not.
-scc       0                 1: Save CC Map. 0: Not.
-slg       1                 1: Save Log. 0: Not.
-atm       1                 1: Align to middle frame. 0: Not.
-dsp       1                 1: Save quick results. 0: Not.
-fsc       0                 1: Calculate and log FSC. 0: Not.
                      """)
        form.addParallelSection(threads=1, mpi=1)
    def _defineParams(self, form):
        ProtProcessMovies._defineParams(self, form)
        form.addParam('inputCoordinates', PointerParam,
                      pointerClass='SetOfCoordinates',
                      important=True,
                      label='Input coordinates')
        form.addParam('boxSize', IntParam, default=0,
                      label='Particle box size (px)', validators=[Positive],
                      help='In pixels. The box size is the size of the boxed '
                           'particles, actual particles may be smaller than '
                           'this.')
        form.addParam('applyAlignment', BooleanParam, default=False,
                      label='Apply movie alignments to extract?',
                      help='If the input movies contains frames alignment, '
                           'you decide whether to use that information '
                           'for extracting the particles taking into account '
                           'the shifts between frames.')
        line = form.addLine('Frames range',
                            help='Specify the frames range to extract particles. '
                                 'The first frame is 1. If you set 0 in the '
                                 'last frame, it means that you will use until the '
                                 'last frame of the movie. If you apply the '
                                 'previous alignment of the movies, you only can use '
                                 'a frame range equal or less as used to alignment.')
        line.addParam('frame0', IntParam, label='First')
        line.addParam('frameN',  IntParam, label='Last')
        # TODO: implement this and extraction from movies, not frames
        #form.addParam('avgFrames', IntParam, default=1,
        #              label='Average every so many frames', validators=[Positive],
        #              help='Average over this number of individual movie frames. '
        #                   'For Relion movie refinement it is recommended to '
        #                   'adjust this value to have a dose of at least '
        #                   'approximately 1 e/A^2 in the averaged frames, '
        #                   'so use a value higher than 1 if you have a '
        #                   'dose of less than 0.5-1 e/A^2 in each '
        #                   'individual movie frame.')
        form.addParam('doBorders', BooleanParam, default=True,
                      label='Fill pixels outside borders',
                      help='Xmipp by default create blank particles whose boxes fall '
                           'outside of the micrograph borders. Set this '
                           'option to True if you want those pixels outside '
                           'the borders to be filled with the closest pixel '
                           'value available')

        form.addSection(label='Preprocess')
        form.addParam('doRemoveDust', BooleanParam, default=True,
                      important=True,
                      label='Dust removal (Recommended)', 
                      help='Sets pixels with unusually large values to random '
                           'values from a Gaussian with zero-mean and '
                           'unity-standard deviation.')
        form.addParam('thresholdDust', FloatParam, default=3.5,
                      condition='doRemoveDust', expertLevel=LEVEL_ADVANCED,
                      label='Threshold for dust removal',
                      help='Pixels with a signal higher or lower than this '
                           'value times the standard deviation of the image '
                           'will be affected. For cryo, 3.5 is a good value. '
                           'For high-contrast negative stain, the signal '
                           'itself may be affected so that a higher value may '
                           'be preferable.')
        form.addParam('doInvert', BooleanParam, default=None,
                      label='Invert contrast', 
                      help='Invert the contrast if your particles are black '
                           'over a white background.')
        form.addParam('doNormalize', BooleanParam, default=True,
                      label='Normalize (Recommended)', 
                      help='It subtract a ramp in the gray values and '
                           'normalizes so that in the  background there is 0 '
                           'mean and standard deviation 1.')
        form.addParam('normType', EnumParam,
                      choices=['OldXmipp', 'NewXmipp', 'Ramp'], default=2,
                      condition='doNormalize', expertLevel=LEVEL_ADVANCED,
                      display=EnumParam.DISPLAY_COMBO,
                      label='Normalization type', 
                      help='OldXmipp (mean(Image)=0, stddev(Image)=1). \n'
                           'NewXmipp (mean(background)=0, '
                           'stddev(background)=1)\n'
                           'Ramp (subtract background+NewXmipp).')
        form.addParam('backRadius', IntParam, default=-1,
                      condition='doNormalize',
                      label='Background radius (px)',
                      help='Pixels outside this circle are assumed to be '
                           'noise and their stddev is set to 1. Radius for '
                           'background circle definition (in pix.). If this '
                           'value is 0, then half the box size is used.',
                      expertLevel=LEVEL_ADVANCED)

        form.addParallelSection(threads=3, mpi=1)
Ejemplo n.º 13
0
    def _defineParams(self, form):
        ProtProcessMovies._defineParams(self, form)

        group = form.addGroup('Frame range')
        line1 = group.addLine('Used in alignment',
                              help='First and last frames used in alignment.\n'
                              'The first frame in the stack is *0*.')
        line1.addParam('alignFrame0', IntParam, default=0, label='First')
        line1.addParam('alignFrameN',
                       IntParam,
                       default=0,
                       label='Last',
                       help='If *0*, use maximum value')

        line2 = group.addLine('Used in final sum',
                              help='First and last frames used in alignment.\n'
                              'The first frame in the stack is *0*.')
        line2.addParam('sumFrame0', IntParam, default=0, label='First')
        line2.addParam('sumFrameN',
                       IntParam,
                       default=0,
                       label='Last',
                       help='If *0*, use maximum value')

        form.addParam('gpuId',
                      StringParam,
                      default='0',
                      expertLevel=LEVEL_ADVANCED,
                      label='GPU id',
                      help='GPU device ID')

        form.addParam('extraParams',
                      StringParam,
                      default='',
                      expertLevel=LEVEL_ADVANCED,
                      label='Additional parameters',
                      help="""
-bft       150               BFactor in pix^2.
-pbx       96                Box dimension for searching CC peak.
-fod       2                 Number of frame offset for frame comparison.
-nps       0                 Radius of noise peak.
-sub       0                 1: Save as sub-area corrected sum. 0: Not. 
-srs       0                 1: Save uncorrected sum. 0: Not.
-ssc       0                 1: Save aligned stack. 0: Not.
-scc       0                 1: Save CC Map. 0: Not.
-slg       1                 1: Save Log. 0: Not.
-atm       1                 1: Align to middle frame. 0: Not.
-dsp       1                 1: Save quick results. 0: Not.
-fsc       0                 1: Calculate and log FSC. 0: Not.
                      """)

        group2 = form.addGroup('Crop and binning')

        line = group2.addLine('Crop offsets (px)')
        line.addParam('cropOffsetX', IntParam, default=0, label='X')
        line.addParam('cropOffsetY', IntParam, default=0, label='Y')

        line = group2.addLine('Crop dimensions (px)',
                              help='How many pixels to crop from offset\n'
                              'If equal to 0, use maximum size.')
        line.addParam('cropDimX', IntParam, default=0, label='X')
        line.addParam('cropDimY', IntParam, default=0, label='Y')

        group2.addParam('binFactor',
                        IntParam,
                        default=1,
                        label='Binning factor',
                        help='1x or 2x. Bin stack before processing.')

        form.addParallelSection(threads=1, mpi=1)
    def _defineParams(self, form):
        ProtProcessMovies._defineParams(self, form)

        form.addParam(
            'alignMethod',
            EnumParam,
            choices=[
                'optical flow', 'dosefgpu', 'dosefgpu + optical flow',
                'average', 'croscorrelation', 'croscorrelation + optical flow'
            ],
            label="Alignment method",
            default=AL_OPTICAL,
            display=EnumParam.DISPLAY_COMBO,
            help='Method to use for movie alignment:\n'
            '1. dosefgpu performs in-plane drift correction and requires a GPU.\n'
            '2. Croscorrelation is a CPU implementation of dosefgpu '
            'with limited functionality (only aligns whole frames). With default parameters '
            'it is equivalent to dosefgpu.\n'
            '3. Optical flow works best for correction of local beam-induced motion.\n'
            '4. Average will simply sum the frames together.')

        # GROUP COMMON PARAMETERS
        group = form.addGroup('Common parameters')

        line = group.addLine('Used in alignment',
                             help='First and last frames used in alignment.\n'
                             'The first frame in the stack is *0* '
                             'If the last frame is *0*, use maximum value')
        line.addParam('alignFrame0', IntParam, default=0, label='First')
        line.addParam('alignFrameN', IntParam, default=0, label='Last')

        # GROUP GPU PARAMETERS
        group = form.addGroup(
            'GPU',
            condition="alignMethod==%d or (alignMethod==%d and expertLevel==%d)"
            " or (alignMethod==%d and expertLevel==%d)" %
            (AL_OPTICAL, AL_DOSEFGPUOPTICAL, LEVEL_ADVANCED, AL_DOSEFGPU,
             LEVEL_ADVANCED))
        group.addParam(
            'doGPU',
            BooleanParam,
            default=False,
            label="Use GPU (vs CPU)",
            condition="alignMethod==%d or alignMethod==%d" %
            (AL_OPTICAL, AL_DOSEFGPUOPTICAL),
            help=
            "Set to true if you want the GPU implementation of Optical Flow")
        group.addParam(
            'GPUCore',
            IntParam,
            default=0,
            expertLevel=LEVEL_ADVANCED,
            label="Choose GPU core",
            condition="doGPU  or alignMethod==%d or alignMethod==%d  " %
            (AL_DOSEFGPU, AL_DOSEFGPUOPTICAL),
            help=
            "GPU may have several cores. Set it to zero if you do not know what we are talking about. First core index is 0, second 1 and so on."
        )

        # GROUP OPTICAL FLOW PARAMETERS
        group = form.addGroup(
            'Optical Flow parameters',
            expertLevel=LEVEL_ADVANCED,
            condition="alignMethod==%d or alignMethod==%d or alignMethod==%d "
            % (AL_OPTICAL, AL_DOSEFGPUOPTICAL, AL_CROSSCORRELATIONOPTICAL))

        group.addParam(
            'winSize',
            IntParam,
            default=150,
            label="Window size",
            expertLevel=LEVEL_ADVANCED,
            help=
            "Window size (shifts are assumed to be constant within this window)."
        )

        group.addParam(
            'groupSize',
            IntParam,
            default=1,
            label="Group Size",
            expertLevel=LEVEL_ADVANCED,
            help=
            "In cases with low SNR, the average of a number of frames can be used in alignment"
        )

        group.addParam('doSaveMovie',
                       BooleanParam,
                       default=False,
                       label="Save movie",
                       expertLevel=LEVEL_ADVANCED,
                       help="Save Aligned movie")

        #---------------------------------- DosefGPU Params--------------------------------
        # GROUP DOSEFGPU PARAMETERS
        group = form.addGroup('DosefGPU/Croscorrelation parameters',condition="alignMethod==%d "
                                                              "or alignMethod==%d"
                                                              "or alignMethod==%d"
                                                              "or alignMethod==%d" %
                                                              (AL_DOSEFGPU,\
                                                               AL_DOSEFGPUOPTICAL,\
                                                               AL_CROSSCORRELATION,\
                                                               AL_CROSSCORRELATIONOPTICAL)
                              )

        line = group.addLine('Used in final sum',
                             help='First and last frames used in alignment.\n'
                             'The first frame in the stack is *0*.')
        line.addParam('sumFrame0', IntParam, default=0, label='First')
        line.addParam('sumFrameN',
                      IntParam,
                      default=0,
                      label='Last',
                      help='If *0*, use maximum value')

        line = group.addLine('Crop offsets (px)')
        line.addParam('cropOffsetX', IntParam, default=0, label='X')
        line.addParam('cropOffsetY', IntParam, default=0, label='Y')

        line = group.addLine('Crop dimensions (px)',
                             help='How many pixels to crop from offset\n'
                             'If equal to 0, use maximum size.')
        line.addParam('cropDimX', IntParam, default=0, label='X')
        line.addParam('cropDimY', IntParam, default=0, label='Y')

        group.addParam('binFactor', IntParam, default=1,condition="alignMethod==%d "
                                                              "or alignMethod==%d" %
                                                                  (AL_DOSEFGPU,\
                                                                   AL_DOSEFGPUOPTICAL\
                       ),
                       label='Binning factor',
                       help='1x or 2x. Bin stack before processing.')

        group.addParam('filterFactor', FloatParam, default=4,condition="alignMethod==%d "
                                                              "or alignMethod==%d" %
                                                                  (AL_CROSSCORRELATION,\
                                                                   AL_CROSSCORRELATIONOPTICAL\
                       ),
                       label='Filter at (A)',
                       help='Maximum frequency for a low pass filter')

        group.addParam('extraParams',
                       StringParam,
                       default='',
                       expertLevel=LEVEL_ADVANCED,
                       label='Additional parameters',
                       help="""
-bft       150               BFactor in pix^2.
-pbx       96                Box dimension for searching CC peak.
-fod       2                 Number of frame offset for frame comparison.
-nps       0                 Radius of noise peak.
-sub       0                 1: Save as sub-area corrected sum. 0: Not.
-srs       0                 1: Save uncorrected sum. 0: Not.
-ssc       0                 1: Save aligned stack. 0: Not.
-scc       0                 1: Save CC Map. 0: Not.
-slg       1                 1: Save Log. 0: Not.
-atm       1                 1: Align to middle frame. 0: Not.
-dsp       1                 1: Save quick results. 0: Not.
-fsc       0                 1: Calculate and log FSC. 0: Not.
                      """)
        form.addParallelSection(threads=1, mpi=1)
Ejemplo n.º 15
0
    def _defineParams(self, form):
        ProtProcessMovies._defineParams(self, form)
        form.addParam(
            "alignFrameRange",
            IntParam,
            default=-1,
            label="Number frames per movie ",
            help="How many frames per monie. -1 -> all frames ",
        )
        form.addParam(
            "doApplyDoseFilter",
            BooleanParam,
            default=True,
            label="Apply Dose filter",
            help="Apply a dose-dependent filter to frames before summing them",
        )
        form.addParam(
            "exposurePerFrame",
            FloatParam,
            label="Exposure per frame (e/A^2)",
            help="Exposure per frame, in electrons per square Angstrom",
        )

        # group = form.addGroup('Expert Options')
        form.addParam(
            "minShiftInitSearch",
            FloatParam,
            default=2.0,
            label="Min. Shift Initial search (A)",
            help="Initial search will be limited to between the inner and outer radii",
            expertLevel=LEVEL_ADVANCED,
        )
        form.addParam(
            "OutRadShiftLimit",
            FloatParam,
            default=200.0,
            label="Outer radius shift limit (A)",
            help="The maximum shift of each alignment step will be limited to this value",
            expertLevel=LEVEL_ADVANCED,
        )
        form.addParam(
            "Bfactor",
            FloatParam,
            default=1500.0,
            label="B-factor (A^2)",
            help="B-factor to apply to images (A^2)",
            expertLevel=LEVEL_ADVANCED,
        )
        form.addParam(
            "HWVertFourMask",
            IntParam,
            default=1,
            label="Half-width vertical Fourier mask",
            help="The vertical line mask will be twice this size. The central cross mask helps reduce problems by line artefacts from the detector",
            expertLevel=LEVEL_ADVANCED,
        )
        form.addParam(
            "HWHoriFourMask",
            IntParam,
            default=1,
            label="Half-width horizontal Fourier mask",
            help="The horizontal line mask will be twice this size. The central cross mask helps reduce problems by line artefacts from the detector",
            expertLevel=LEVEL_ADVANCED,
        )
        form.addParam(
            "terminationShiftThreshold",
            FloatParam,
            default=0.1,
            label="Termination shift threshold",
            help="Alignment will stop at this number, even if the threshold shift is not reached",
            expertLevel=LEVEL_ADVANCED,
        )
        form.addParam(
            "maximumNumberIterations",
            IntParam,
            default=10,
            label="Maximum number of iterations",
            help="Maximum number of iterations",
            expertLevel=LEVEL_ADVANCED,
        )
        form.addParam(
            "doRestoreNoisePower",
            BooleanParam,
            default=True,
            label="Restore Noise Power? ",
            help="Restore Noise Power? ",
            expertLevel=LEVEL_ADVANCED,
        )
        form.addParam(
            "doVerboseOutput",
            BooleanParam,
            default=False,
            label="Verbose Output?",
            help="Verbose Output?",
            expertLevel=LEVEL_ADVANCED,
        )
        form.addParallelSection(threads=1, mpi=1)
Ejemplo n.º 16
0
    def _defineParams(self, form):
        ProtProcessMovies._defineParams(self, form)
        form.addParam('alignFrameRange',
                      IntParam,
                      default=-1,
                      label='Number frames per movie ',
                      help='How many frames per monie. -1 -> all frames ')
        form.addParam('doApplyDoseFilter',
                      BooleanParam,
                      default=True,
                      label='Apply Dose filter',
                      help='Apply a dose-dependent filter to frames before '
                      'summing them')
        form.addParam('exposurePerFrame',
                      FloatParam,
                      label='Exposure per frame (e/A^2)',
                      help='Exposure per frame, in electrons per square '
                      'Angstrom')

        #group = form.addGroup('Expert Options')
        form.addParam('minShiftInitSearch',
                      FloatParam,
                      default=2.,
                      label='Min. Shift Initial search (A)',
                      help='Initial search will be limited to between the '
                      'inner and outer radii',
                      expertLevel=LEVEL_ADVANCED)
        form.addParam('OutRadShiftLimit',
                      FloatParam,
                      default=200.,
                      label='Outer radius shift limit (A)',
                      help='The maximum shift of each alignment step will be '
                      'limited to this value',
                      expertLevel=LEVEL_ADVANCED)
        form.addParam('Bfactor',
                      FloatParam,
                      default=1500.,
                      label='B-factor (A^2)',
                      help='B-factor to apply to images (A^2)',
                      expertLevel=LEVEL_ADVANCED)
        form.addParam('HWVertFourMask',
                      IntParam,
                      default=1,
                      label='Half-width vertical Fourier mask',
                      help='The vertical line mask will be twice this size. '
                      'The central cross mask helps reduce problems by '
                      'line artefacts from the detector',
                      expertLevel=LEVEL_ADVANCED)
        form.addParam('HWHoriFourMask',
                      IntParam,
                      default=1,
                      label='Half-width horizontal Fourier mask',
                      help='The horizontal line mask will be twice this size. '
                      'The central cross mask helps reduce problems by '
                      'line artefacts from the detector',
                      expertLevel=LEVEL_ADVANCED)
        form.addParam('terminationShiftThreshold',
                      FloatParam,
                      default=0.1,
                      label='Termination shift threshold',
                      help='Alignment will stop at this number, even if the '
                      'threshold shift is not reached',
                      expertLevel=LEVEL_ADVANCED)
        form.addParam('maximumNumberIterations',
                      IntParam,
                      default=10,
                      label='Maximum number of iterations',
                      help='Maximum number of iterations',
                      expertLevel=LEVEL_ADVANCED)
        form.addParam('doRestoreNoisePower',
                      BooleanParam,
                      default=True,
                      label='Restore Noise Power? ',
                      help='Restore Noise Power? ',
                      expertLevel=LEVEL_ADVANCED)
        form.addParam('doVerboseOutput',
                      BooleanParam,
                      default=False,
                      label='Verbose Output?',
                      help='Verbose Output?',
                      expertLevel=LEVEL_ADVANCED)
        form.addParallelSection(threads=1, mpi=1)