コード例 #1
0
    def _defineAlignmentParams(self, form):
        ProtAlignMovies._defineAlignmentParams(self, form)

        form.addParam('splineOrder',
                      params.EnumParam,
                      condition="doSaveAveMic or doSaveMovie",
                      default=self.INTERP_CUBIC,
                      choices=['linear', 'cubic'],
                      expertLevel=cons.LEVEL_ADVANCED,
                      label='Interpolation',
                      help="linear (faster but lower quality), "
                      "cubic (slower but more accurate).")

        form.addParam('maxFreq',
                      params.FloatParam,
                      default=4,
                      label='Filter at (A)',
                      help="For the calculation of the shifts with Xmipp, "
                      "micrographs are filtered (and downsized "
                      "accordingly) to this resolution. Then shifts are "
                      "calculated, and they are applied to the original "
                      "frames without any filtering and downsampling.")

        form.addParam('doComputePSD',
                      params.BooleanParam,
                      default=True,
                      label="Compute PSD (before/after)?",
                      help="If Yes, the protocol will compute for each movie "
                      "the PSD of the average micrograph (without CC "
                      "alignement) and after that, to compare each PSDs")

        form.addParam('maxShift',
                      params.IntParam,
                      default=30,
                      expertLevel=cons.LEVEL_ADVANCED,
                      label="Maximum shift (pixels)",
                      help='Maximum allowed distance (in pixels) that each '
                      'frame can be shifted with respect to the next.')

        form.addParam('outsideMode',
                      params.EnumParam,
                      choices=['Wrapping', 'Average', 'Value'],
                      default=self.OUTSIDE_WRAP,
                      expertLevel=cons.LEVEL_ADVANCED,
                      label="How to fill borders",
                      help='How to fill the borders when shifting the frames')

        form.addParam('outsideValue',
                      params.FloatParam,
                      default=0.0,
                      expertLevel=cons.LEVEL_ADVANCED,
                      condition="outsideMode==2",
                      label='Fill value',
                      help="Fixed value for filling borders")

        form.addParallelSection(threads=1, mpi=1)
コード例 #2
0
    def _defineAlignmentParams(self, form):
        ProtAlignMovies._defineAlignmentParams(self, form)

        form.addParam('splineOrder', params.EnumParam, condition="doSaveAveMic or doSaveMovie",
                      default=self.INTERP_CUBIC, choices=['linear', 'cubic'],
                      expertLevel=cons.LEVEL_ADVANCED,
                      label='Interpolation',
                      help="linear (faster but lower quality), "
                           "cubic (slower but more accurate).")

        form.addParam('maxFreq', params.FloatParam, default=4,
                       label='Filter at (A)',
                       help="For the calculation of the shifts with Xmipp, "
                            "micrographs are filtered (and downsized "
                            "accordingly) to this resolution. Then shifts are "
                            "calculated, and they are applied to the original "
                            "frames without any filtering and downsampling.")

        form.addParam('doComputePSD', params.BooleanParam, default=True,
                      label="Compute PSD (before/after)?",
                      help="If Yes, the protocol will compute for each movie "
                           "the PSD of the average micrograph (without CC "
                           "alignement) and after that, to compare each PSDs")

        form.addParam('maxShift', params.IntParam, default=30,
                      expertLevel=cons.LEVEL_ADVANCED,
                      label="Maximum shift (pixels)",
                      help='Maximum allowed distance (in pixels) that each '
                           'frame can be shifted with respect to the next.')
        
        form.addParam('outsideMode', params.EnumParam,
                      choices=['Wrapping','Average','Value'],
                      default=self.OUTSIDE_WRAP,
                      expertLevel=cons.LEVEL_ADVANCED,
                      label="How to fill borders",
                      help='How to fill the borders when shifting the frames')

        form.addParam('outsideValue', params.FloatParam, default=0.0,
                       expertLevel=cons.LEVEL_ADVANCED,
                       condition="outsideMode==2",
                       label='Fill value',
                       help="Fixed value for filling borders")

        form.addParallelSection(threads=1, mpi=1)
コード例 #3
0
    def _defineAlignmentParams(self, form):
        form.addParam('gpuMsg',
                      params.LabelParam,
                      default=True,
                      label='WARNING! You need to have installed CUDA'
                      ' libraries and a Nvidia GPU')

        form.addParam('GPUIDs',
                      params.StringParam,
                      default='0',
                      expertLevel=cons.LEVEL_ADVANCED,
                      label="Choose GPU IDs",
                      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."
                      " Motioncor2 can use multiple GPUs - in that case"
                      " set to i.e. *0 1 2*.")

        ProtAlignMovies._defineAlignmentParams(self, form)

        form.addParam('doComputePSD',
                      params.BooleanParam,
                      default=False,
                      expertLevel=cons.LEVEL_ADVANCED,
                      label="Compute PSD (before/after)?",
                      help="If Yes, the protocol will compute for each movie "
                      "the average PSD before and after alignment, "
                      "for comparison")

        form.addParam('doComputeMicThumbnail',
                      params.BooleanParam,
                      expertLevel=cons.LEVEL_ADVANCED,
                      default=False,
                      label='Compute micrograph thumbnail?',
                      help='When using this option, we will compute a '
                      'micrograph thumbnail and keep it with the '
                      'micrograph object for visualization purposes. ')

        form.addParam('computeAllFramesAvg',
                      params.BooleanParam,
                      expertLevel=cons.LEVEL_ADVANCED,
                      default=False,
                      label='Compute all frames average?',
                      help='Computing all the frames average could provide a '
                      'sanity check about the microscope and the camera.')

        form.addParam(
            'extraParams',
            params.StringParam,
            default='',
            expertLevel=cons.LEVEL_ADVANCED,
            label='Additional parameters',
            help="""Extra parameters for motioncorr (NOT motioncor2)\n
        -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.
        -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.addSection(label="Motioncor2")
        form.addParam('useMotioncor2',
                      params.BooleanParam,
                      default=True,
                      label='Use motioncor2',
                      help='Use new *motioncor2* program with local '
                      'patch-based motion correction and dose weighting.')
        form.addParam('doApplyDoseFilter',
                      params.BooleanParam,
                      default=True,
                      condition='useMotioncor2',
                      label='Apply Dose filter',
                      help='Apply a dose-dependent filter to frames before '
                      'summing them. Pre-exposure and dose per frame '
                      'should  be specified during movies import.')

        line = form.addLine(
            'Number of patches',
            condition='useMotioncor2',
            help='Number of patches to be used for patch based '
            'alignment. Set to *0 0* to do only global motion '
            'correction. \n')
        line.addParam('patchX', params.IntParam, default=5, label='X')
        line.addParam('patchY', params.IntParam, default=5, label='Y')

        if self.versionGE('1.0.1'):  # Patch overlap was introduced in 1.0.1
            form.addParam('patchOverlap',
                          params.IntParam,
                          default=0,
                          condition='useMotioncor2',
                          label='Patches Overlap (%)',
                          help='In versions > 1.0.1 it is possible to specify'
                          'the overlapping between patches. '
                          '\nFor example, overlap=20 means that '
                          'each patch will have a 20% overlapping \n'
                          'with its neighboring patches in each dimension.')

        form.addParam('group',
                      params.IntParam,
                      default='1',
                      label='Group N frames',
                      condition='useMotioncor2',
                      help='Group every specified number of frames by adding '
                      'them together. The alignment is then performed on '
                      'the summed frames. By default, no grouping is '
                      'performed.')
        form.addParam(
            'tol',
            params.FloatParam,
            default='0.5',
            label='Tolerance (px)',
            condition='useMotioncor2',
            help='Tolerance for iterative alignment, default *0.5px*.')
        if self._supportsMagCorrection():
            group = form.addGroup('Magnification correction')
            group.addParam('doMagCor',
                           params.BooleanParam,
                           default=False,
                           label='Correct anisotropic magnification?',
                           condition='useMotioncor2',
                           help='Correct anisotropic magnification by '
                           'stretching image along the major axis, '
                           'the axis where the lower magnification is '
                           'detected.')
            group.addParam('useEst',
                           params.BooleanParam,
                           default=True,
                           label='Use previous estimation?',
                           condition='useMotioncor2 and doMagCor',
                           help='Use previously calculated parameters of '
                           'magnification anisotropy (from magnification '
                           'distortion estimation protocol).')
            group.addParam(
                'inputEst',
                params.PointerParam,
                pointerClass='ProtMagDistEst',
                condition='useEst and useMotioncor2 and doMagCor',
                label='Input protocol',
                help='Select previously executed estimation protocol.')
            group.addParam(
                'scaleMaj',
                params.FloatParam,
                default=1.0,
                condition='not useEst and useMotioncor2 and doMagCor',
                label='Major scale factor',
                help='Major scale factor.')
            group.addParam(
                'scaleMin',
                params.FloatParam,
                default=1.0,
                condition='not useEst and useMotioncor2 and doMagCor',
                label='Minor scale factor',
                help='Minor scale factor.')
            group.addParam(
                'angDist',
                params.FloatParam,
                default=0.0,
                condition='not useEst and useMotioncor2 and doMagCor',
                label='Distortion angle (deg)',
                help='Distortion angle, in degrees.')
        else:
            form.addParam('motioncor2Version',
                          params.LabelParam,
                          condition='useMotioncor2',
                          label='Scipion supports some versions of motioncor2 '
                          'that can do magnification correction, '
                          'but they do not seems to be installed. Check '
                          'available versions with: \n'
                          'scipion install --help.\n'
                          'Also, make sure MOTIONCOR2_CUDA_LIB or '
                          'CUDA_LIB point to cuda-8.0/lib path')

        if self.isSemVersion():
            form.addParam(
                'defectFile',
                params.FileParam,
                allowsNull=True,
                expertLevel=cons.LEVEL_ADVANCED,
                condition='useMotioncor2',
                label='Camera defects file',
                help='Defect file that stores entries of defects on camera.\n'
                'Each entry corresponds to a rectangular region in image. '
                'The pixels in such a region are replaced by '
                'neighboring good pixel values. Each entry contains '
                '4 integers x, y, w, h representing the x, y '
                'coordinates, width, and height, respectively.')

        form.addParam('extraParams2',
                      params.StringParam,
                      default='',
                      expertLevel=cons.LEVEL_ADVANCED,
                      condition='useMotioncor2',
                      label='Additional parameters',
                      help="""Extra parameters for motioncor2\n
        -Bft       100        BFactor for alignment, in px^2.
        -Iter      5          Maximum iterations for iterative alignment.
        -MaskCent  0 0        Center of subarea that will be used for alignment,
                              default *0 0* corresponding to the frame center.
        -MaskSize  1.0 1.0    The size of subarea that will be used for alignment,
                              default *1.0 1.0* corresponding full size.
        -Align     1          Generate aligned sum (1) or simple sum (0).
        -FmRef     -1         Specify which frame to be the reference to which
                              all other frames are aligned, by default (-1) the
                              the central frame is chosen. The central frame is
                              at N/2 based upon zero indexing where N is the
                              number of frames that will be summed, i.e., not
                              including the frames thrown away.
        -RotGain   0          Rotate gain reference counter-clockwise: 0 - no rotation,
                              1 - 90 degrees, 2 - 180 degrees, 3 - 270 degrees.
        -FlipGain  0          Flip gain reference after gain rotation: 0 - no flipping,
                              1 - flip upside down, 2 - flip left right.
        -Tilt      0 0        Tilt angle range for a dose fractionated tomographic
                              tilt series, e.g. *-60 60*
                              """)
        form.addParam(
            'doSaveUnweightedMic',
            params.BooleanParam,
            default=True,
            condition='doSaveAveMic and useMotioncor2 and doApplyDoseFilter',
            label="Save unweighted micrographs?",
            help="Yes by default, if you have selected to apply a "
            "dose-dependent filter to the frames")

        # Since only runs on GPU, do not allow neither threads nor mpi
        form.addParallelSection(threads=1, mpi=1)
コード例 #4
0
    def _defineAlignmentParams(self, form):
        ProtAlignMovies._defineAlignmentParams(self, form)
        form.addSection("Aditional Parameters")
        # GROUP GPU PARAMETERS
        #group = form.addGroup('GPU')
        form.addHidden(
            params.USE_GPU,
            params.BooleanParam,
            default=False,
            label="Use GPU (vs CPU)",
            help="Set to true if you want the GPU implementation of "
            "Optical Flow")
        form.addHidden(
            params.GPU_LIST,
            params.StringParam,
            default=0,
            expertLevel=params.LEVEL_ADVANCED,
            label="Choose GPU core",
            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 = form.addGroup('OF Parameters')
        group.addParam('winSize',
                       params.IntParam,
                       default=150,
                       expertLevel=params.LEVEL_ADVANCED,
                       label="Window size",
                       help="Window size (shifts are assumed to be constant "
                       "within this window).")
        group.addParam('groupSize',
                       params.IntParam,
                       default=1,
                       expertLevel=params.LEVEL_ADVANCED,
                       label="Group Size",
                       help="The number of frames in each group at the "
                       "last step")
        group.addParam(
            'useAlignment',
            params.BooleanParam,
            default=True,
            label="Use previous movie alignment to SUM frames?",
            help="Input movies could have alignment information from"
            "a previous protocol. If you select *Yes*, the "
            "previous alignment will be taken into account.")
        group.addParam('doComputePSD',
                       params.BooleanParam,
                       default=True,
                       label="Compute PSD (before/after)?",
                       help="If Yes, the protocol will compute for each movie "
                       "the PSD of the average micrograph (without OF "
                       "alignement) and after that, to compare each PSDs")
        group.addParam(
            'memory',
            params.BooleanParam,
            default=False,
            label="Keep images in RAM ?",
            help="If True, the protocol will increase the demand of "
            "RAM, decreasing disc access")

        group = form.addGroup('Dose Compensation')

        group.addParam('doApplyDoseFilter',
                       params.BooleanParam,
                       default=False,
                       label='Apply Dose filter',
                       help='Apply a dose-dependent filter to frames before '
                       'summing them. Pre-exposure and dose per frame '
                       'should  be specified during movies import.')
        group.addParam('doSaveUnweightedMic',
                       params.BooleanParam,
                       default=True,
                       condition='doSaveAveMic and doApplyDoseFilter',
                       label="Save unweighted micrographs?",
                       help="Yes by default, if you have selected to apply a "
                       "dose-dependent filter to the frames")
        group.addParam('applyDosePreAlign',
                       params.BooleanParam,
                       default=False,
                       condition='doApplyDoseFilter',
                       label="Apply Dose filter before alignment?",
                       help="if *True*, you apply dose filter before perform "
                       "the alignment; else will apply after alignment.")

        form.addParallelSection(threads=8, mpi=1)
コード例 #5
0
ファイル: protocol_motioncorr.py プロジェクト: I2PC/scipion
    def _defineAlignmentParams(self, form):
        form.addParam('gpuMsg', params.LabelParam, default=True,
                      label='WARNING! You need to have installed CUDA'
                            ' libraries and a Nvidia GPU')

        form.addHidden(params.GPU_LIST, params.StringParam, default='0',
                      expertLevel=cons.LEVEL_ADVANCED,
                      label="Choose GPU IDs",
                      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."
                           " Motioncor2 can use multiple GPUs - in that case"
                           " set to i.e. *0 1 2*.")

        ProtAlignMovies._defineAlignmentParams(self, form)

        form.addParam('doComputePSD', params.BooleanParam, default=False,
                      expertLevel=cons.LEVEL_ADVANCED,
                      label="Compute PSD (before/after)?",
                      help="If Yes, the protocol will compute for each movie "
                           "the average PSD before and after alignment, "
                           "for comparison")

        form.addParam('doComputeMicThumbnail', params.BooleanParam,
                      expertLevel=cons.LEVEL_ADVANCED,
                      default=False,
                      label='Compute micrograph thumbnail?',
                      help='When using this option, we will compute a '
                           'micrograph thumbnail and keep it with the '
                           'micrograph object for visualization purposes. ')

        form.addParam('computeAllFramesAvg', params.BooleanParam,
                      expertLevel=cons.LEVEL_ADVANCED,
                      default=False,
                      label='Compute all frames average?',
                      help='Computing all the frames average could provide a '
                           'sanity check about the microscope and the camera.')

        form.addParam('extraParams', params.StringParam, default='',
                      expertLevel=cons.LEVEL_ADVANCED,
                      label='Additional parameters',
                      help="""Extra parameters for motioncorr (NOT motioncor2)\n
        -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.
        -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.addParam('extraProtocolParams', params.StringParam, default='',
                      expertLevel=cons.LEVEL_ADVANCED,
                      label='Additional protocol parameters',
                      help="Here you can provide some extra parameters for the "
                           "protocol, not the underlying motioncor program."
                           "You can provide many options separated by space. "
                           "\n*Options:* \n"
                           "--use_worker_thread \n"
                           " Use an extra thread to compute"
                           " PSD and thumbnail. This will allow a more effective"
                           " use of the GPU card, but requires an extra CPU. ")

        form.addSection(label="Motioncor2")
        form.addParam('useMotioncor2', params.BooleanParam, default=True,
                      label='Use motioncor2',
                      help='Use new *motioncor2* program with local '
                           'patch-based motion correction and dose weighting.')
        form.addParam('doApplyDoseFilter', params.BooleanParam, default=True,
                      condition='useMotioncor2',
                      label='Apply Dose filter',
                      help='Apply a dose-dependent filter to frames before '
                           'summing them. Pre-exposure and dose per frame '
                           'should  be specified during movies import.')

        line = form.addLine('Number of patches', condition='useMotioncor2',
                            help='Number of patches to be used for patch based '
                                 'alignment. Set to *0 0* to do only global motion '
                                 'correction. \n')
        line.addParam('patchX', params.IntParam, default=5, label='X')
        line.addParam('patchY', params.IntParam, default=5, label='Y')

        if self.versionGE('1.0.1'): # Patch overlap was introduced in 1.0.1
            form.addParam('patchOverlap', params.IntParam, default=0,
                          condition='useMotioncor2',
                          label='Patches Overlap (%)',
                          help='In versions > 1.0.1 it is possible to specify'
                                 'the overlapping between patches. '
                                 '\nFor example, overlap=20 means that '
                                 'each patch will have a 20% overlapping \n'
                                 'with its neighboring patches in each dimension.')

        form.addParam('group', params.IntParam, default='1',
                      label='Group N frames', condition='useMotioncor2',
                      help='Group every specified number of frames by adding '
                           'them together. The alignment is then performed on '
                           'the summed frames. By default, no grouping is '
                           'performed.')
        form.addParam('tol', params.FloatParam, default='0.5',
                      label='Tolerance (px)', condition='useMotioncor2',
                      help='Tolerance for iterative alignment, default *0.5px*.')

        if self._supportsMagCorrection():
            group = form.addGroup('Magnification correction')
            group.addParam('doMagCor', params.BooleanParam, default=False,
                           label='Correct anisotropic magnification?',
                           condition='useMotioncor2',
                           help='Correct anisotropic magnification by '
                                'stretching image along the major axis, '
                                'the axis where the lower magnification is '
                                'detected.')
            group.addParam('useEst', params.BooleanParam, default=True,
                           label='Use previous estimation?',
                           condition='useMotioncor2 and doMagCor',
                           help='Use previously calculated parameters of '
                                'magnification anisotropy (from magnification '
                                'distortion estimation protocol).')
            group.addParam('inputEst', params.PointerParam,
                           pointerClass='ProtMagDistEst',
                           condition='useEst and useMotioncor2 and doMagCor',
                           label='Input protocol',
                           help='Select previously executed estimation protocol.')
            group.addParam('scaleMaj', params.FloatParam, default=1.0,
                           condition='not useEst and useMotioncor2 and doMagCor',
                           label='Major scale factor',
                           help='Major scale factor.')
            group.addParam('scaleMin', params.FloatParam, default=1.0,
                           condition='not useEst and useMotioncor2 and doMagCor',
                           label='Minor scale factor',
                           help='Minor scale factor.')
            group.addParam('angDist', params.FloatParam, default=0.0,
                           condition='not useEst and useMotioncor2 and doMagCor',
                           label='Distortion angle (deg)',
                           help='Distortion angle, in degrees.')
        else:
            form.addParam('motioncor2Version', params.LabelParam,
                          condition='useMotioncor2',
                          label='Scipion supports some versions of motioncor2 '
                                'that can do magnification correction, '
                                'but they do not seems to be installed. Check '
                                'available versions with: \n'
                                'scipion install --help.\n'
                                'Also, make sure MOTIONCOR2_CUDA_LIB or '
                                'CUDA_LIB point to cuda-8.0/lib path')

        if self.isSemVersion():
            form.addParam('defectFile', params.FileParam, allowsNull=True,
                          expertLevel=cons.LEVEL_ADVANCED,
                          condition='useMotioncor2',
                          label='Camera defects file',
                          help='Defect file that stores entries of defects on camera.\n'
                               'Each entry corresponds to a rectangular region in image. '
                               'The pixels in such a region are replaced by '
                               'neighboring good pixel values. Each entry contains '
                               '4 integers x, y, w, h representing the x, y '
                               'coordinates, width, and height, respectively.')

        form.addParam('extraParams2', params.StringParam, default='',
                      expertLevel=cons.LEVEL_ADVANCED,
                      condition='useMotioncor2',
                      label='Additional parameters',
                      help="""Extra parameters for motioncor2\n
        -Bft       100        BFactor for alignment, in px^2.
        -Iter      5          Maximum iterations for iterative alignment.
        -MaskCent  0 0        Center of subarea that will be used for alignment,
                              default *0 0* corresponding to the frame center.
        -MaskSize  1.0 1.0    The size of subarea that will be used for alignment,
                              default *1.0 1.0* corresponding full size.
        -Align     1          Generate aligned sum (1) or simple sum (0).
        -FmRef     -1         Specify which frame to be the reference to which
                              all other frames are aligned, by default (-1) the
                              the central frame is chosen. The central frame is
                              at N/2 based upon zero indexing where N is the
                              number of frames that will be summed, i.e., not
                              including the frames thrown away.
        -RotGain   0          Rotate gain reference counter-clockwise: 0 - no rotation,
                              1 - 90 degrees, 2 - 180 degrees, 3 - 270 degrees.
        -FlipGain  0          Flip gain reference after gain rotation: 0 - no flipping,
                              1 - flip upside down, 2 - flip left right.
        -Tilt      0 0        Tilt angle range for a dose fractionated tomographic
                              tilt series, e.g. *-60 60*
    Since version *1.1.0*:
        -GpuMemUsage 0.5      Specify how much GPU memory is used to buffer movie frames.
                              It is recommended when running side by side processes in
                              the same card. By default is 50% (i. e 0.5)
        -InFmMotion 1         Takes into account of motion-induced blurring of
                              each frame. It has shown resolution improvement
                              in some test cases. By default this option is off.
        -Bft 500 150          Since version 1.1.0 this option can take two arguments.
                              First one is used in global-motion measurement and the
                              second one is for local-motion. (default 500 150).
                              """)

        form.addParam('doSaveUnweightedMic', params.BooleanParam, default=True,
                      condition='doSaveAveMic and useMotioncor2 and doApplyDoseFilter',
                      label="Save unweighted micrographs?",
                      help="Yes by default, if you have selected to apply a "
                           "dose-dependent filter to the frames")

        # Since only runs on GPU, do not allow neither threads nor mpi
        form.addParallelSection(threads=1, mpi=1)
コード例 #6
0
    def _defineAlignmentParams(self, form):
        ProtAlignMovies._defineAlignmentParams(self, form)

        form.addParam('splineOrder',
                      params.EnumParam,
                      condition="doSaveAveMic or doSaveMovie",
                      default=self.INTERP_CUBIC,
                      choices=['linear', 'cubic'],
                      expertLevel=cons.LEVEL_ADVANCED,
                      label='Interpolation',
                      help="linear (faster but lower quality), "
                      "cubic (slower but more accurate).")

        form.addHidden(
            params.USE_GPU,
            params.BooleanParam,
            default=True,
            label="Use GPU for execution",
            help="This protocol has both CPU and GPU implementation.\
                       Select the one you want to use.")

        form.addHidden(params.GPU_LIST,
                       params.StringParam,
                       default='0',
                       expertLevel=cons.LEVEL_ADVANCED,
                       label="Choose GPU IDs",
                       help="Add a list of GPU devices that can be used")

        form.addParam('maxFreq',
                      params.FloatParam,
                      default=4,
                      label='Filter at (A)',
                      help="For the calculation of the shifts with Xmipp, "
                      "micrographs are filtered (and downsized "
                      "accordingly) to this resolution. Then shifts are "
                      "calculated, and they are applied to the original "
                      "frames without any filtering and downsampling.")

        form.addParam('doComputePSD',
                      params.BooleanParam,
                      default=True,
                      label="Compute PSD (before/after)?",
                      help="If Yes, the protocol will compute for each movie "
                      "the PSD of the average micrograph (without CC "
                      "alignement) and after that, to compare each PSDs")

        form.addParam('maxShift',
                      params.IntParam,
                      default=30,
                      expertLevel=cons.LEVEL_ADVANCED,
                      label="Maximum shift (pixels)",
                      help='Maximum allowed distance (in pixels) that each '
                      'frame can be shifted with respect to the next.')

        form.addParam('outsideMode',
                      params.EnumParam,
                      choices=['Wrapping', 'Average', 'Value'],
                      default=self.OUTSIDE_WRAP,
                      expertLevel=cons.LEVEL_ADVANCED,
                      label="How to fill borders",
                      help='How to fill the borders when shifting the frames')

        #Local alignment params
        group = form.addGroup('Local alignment')

        group.addParam(
            'doLocalAlignment',
            params.BooleanParam,
            default=True,
            label="Compute local alignment?",
            help=
            "If Yes, the protocol will try to determine local shifts, similarly to MotionCor2."
        )

        group.addParam(
            'autoControlPoints',
            params.BooleanParam,
            default=True,
            label="Auto control points",
            expertLevel=cons.LEVEL_ADVANCED,
            condition='doLocalAlignment',
            help=
            "If on, protocol will automatically determine necessary number of control points."
        )

        line = group.addLine('Number of control points',
                             expertLevel=cons.LEVEL_ADVANCED,
                             help='Number of control points use for BSpline.',
                             condition='not autoControlPoints')
        line.addParam('controlPointX', params.IntParam, default=6, label='X')
        line.addParam('controlPointY', params.IntParam, default=6, label='Y')
        line.addParam('controlPointT', params.IntParam, default=5, label='t')

        line = group.addLine(
            'Number of patches',
            expertLevel=cons.LEVEL_ADVANCED,
            help=
            'Number of patches to be used. Depending on the size of the movie, they may \
                        overlap.',
            condition='doLocalAlignment')
        line.addParam('patchX', params.IntParam, default=10, label='X')
        line.addParam('patchY', params.IntParam, default=10, label='Y')

        group.addParam(
            'groupNFrames',
            params.IntParam,
            default=3,
            expertLevel=cons.LEVEL_ADVANCED,
            label='Group N frames',
            help=
            'Group every specified number of frames by adding them together. \
                        The alignment is then performed on the summed frames.',
            condition='doLocalAlignment')

        form.addParam('outsideValue',
                      params.FloatParam,
                      default=0.0,
                      expertLevel=cons.LEVEL_ADVANCED,
                      condition="outsideMode==2",
                      label='Fill value',
                      help="Fixed value for filling borders")

        form.addParallelSection(threads=1, mpi=1)
コード例 #7
0
    def _defineAlignmentParams(self, form):
        ProtAlignMovies._defineAlignmentParams(self, form)
        form.addSection("Aditional Parameters")
        # GROUP GPU PARAMETERS
        #group = form.addGroup('GPU')
        form.addHidden(params.USE_GPU, params.BooleanParam, default=False,
                       label="Use GPU (vs CPU)",
                       help="Set to true if you want the GPU implementation of "
                           "Optical Flow")
        form.addHidden(params.GPU_LIST, params.StringParam, default=0,
                       expertLevel=params.LEVEL_ADVANCED,
                       label="Choose GPU core",
                       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 = form.addGroup('OF Parameters')
        group.addParam('winSize', params.IntParam, default=150,
                        expertLevel=params.LEVEL_ADVANCED,
                        label="Window size",
                        help="Window size (shifts are assumed to be constant "
                             "within this window).")
        group.addParam('groupSize', params.IntParam, default=1,
                        expertLevel=params.LEVEL_ADVANCED,
                        label="Group Size",
                        help="The number of frames in each group at the "
                             "last step")
        group.addParam('useAlignment', params.BooleanParam, default=True,
                       label="Use previous movie alignment to SUM frames?",
                       help="Input movies could have alignment information from"
                            "a previous protocol. If you select *Yes*, the "
                            "previous alignment will be taken into account.")
        group.addParam('doComputePSD', params.BooleanParam, default=True,
                       label="Compute PSD (before/after)?",
                       help="If Yes, the protocol will compute for each movie "
                            "the PSD of the average micrograph (without OF "
                            "alignement) and after that, to compare each PSDs")
        group.addParam('memory', params.BooleanParam, default=False,
                       label="Keep images in RAM ?",
                       help="If True, the protocol will increase the demand of "
                            "RAM, decreasing disc access")
        
        group = form.addGroup('Dose Compensation')

        group.addParam('doApplyDoseFilter', params.BooleanParam, default=False,
                       label='Apply Dose filter',
                       help='Apply a dose-dependent filter to frames before '
                            'summing them. Pre-exposure and dose per frame '
                            'should  be specified during movies import.')
        group.addParam('doSaveUnweightedMic', params.BooleanParam, default=True,
                       condition='doSaveAveMic and doApplyDoseFilter',
                       label="Save unweighted micrographs?",
                       help="Yes by default, if you have selected to apply a "
                            "dose-dependent filter to the frames")
        group.addParam('applyDosePreAlign', params.BooleanParam, default=False,
                       condition='doApplyDoseFilter',
                       label="Apply Dose filter before alignment?",
                       help="if *True*, you apply dose filter before perform "
                            "the alignment; else will apply after alignment.")

        form.addParallelSection(threads=8, mpi=1)