Esempio n. 1
0
    def _defineParamDict(self):
        """ Define all parameters to run relion_postprocess"""
        volume = self.protRefine.get().outputVolume
        # It seems that in Relion3 now the input should be the map
        # filename and not the prefix as before
        if convert.isVersion3():
            inputFn = self._getFileName('half1')
        else:
            inputFn = self._getInputPath("relion")

        cps = self.calibratedPixelSize.get()
        angpix = cps if cps > 0 else volume.getSamplingRate()

        self.paramDict = {
            '--i': inputFn,
            '--o': self._getExtraPath('relion'),
            '--angpix': angpix,
            '--adhoc_bfac': self.bfactor.get(),
            '--locres': '',
            # Expert options
            '--locres_sampling': self.locResSamp.get(),
            '--locres_maskrad': self.locResMaskRad.get(),
            '--locres_edgwidth': self.locResEdgeWidth.get(),
            '--locres_randomize_at': self.locResRand.get(),
            '--locres_minres': self.locResMin.get()
        }

        mtfFile = self.mtf.get()
        if mtfFile:
            self.paramDict['--mtf'] = mtfFile
    def _defineParamDict(self):
        """ Define all parameters to run relion_postprocess"""
        volume = self.protRefine.get().outputVolume
        cps = self.calibratedPixelSize.get()
        angpix = cps if cps > 0 else volume.getSamplingRate()

        # It seems that in Relion3 now the input should be the map
        # filename and not the prefix as before
        if isVersion3():
            inputFn = self._getFileName('half1')
        else:
            inputFn = self._getInputPath("relion")

        self.paramDict = {
            '--i': inputFn,
            '--o': self._getExtraPath('postprocess'),
            '--angpix': angpix,
            # Expert params
            '--filter_edge_width': self.filterEdgeWidth.get(),
            '--randomize_at_fsc': self.randomizeAtFsc.get(),
            '--mask': self._getFileName('mask')
        }

        mtfFile = self.mtf.get()
        if mtfFile:
            self.paramDict['--mtf'] = mtfFile

        if self.doAutoBfactor:
            self.paramDict['--auto_bfac'] = ''
            self.paramDict['--autob_lowres'] = self.bfactorLowRes.get()
            self.paramDict['--autob_highres'] = self.bfactorHighRes.get()
        else:
            self.paramDict['--adhoc_bfac'] = self.bfactor.get()

        if self.skipFscWeighting:
            self.paramDict['--skip_fsc_weighting'] = ''
            self.paramDict['--low_pass'] = self.lowRes.get()
 def isDisabled(cls):
     return isVersion2() or isVersion3()
    def _defineParams(self, form):
        form.addSection(label='Input')
        form.addParam('inputMicrographs',
                      params.PointerParam,
                      pointerClass='SetOfMicrographs',
                      label='Input micrographs',
                      important=True,
                      help='Select the input micrographs. '
                      'If using the *Optimize* mode, just a subset of '
                      'micrographs are used to compute the FOM maps. '
                      'If in *Compute* mode, all micrographs will be '
                      'auto-picked.')
        form.addParam('ctfRelations',
                      params.RelationParam,
                      relationName=RELATION_CTF,
                      attributeName='getInputMicrographs',
                      label='CTF estimation',
                      help='Choose some CTF estimation related to the '
                      'input micrographs.')

        form.addParam('runType',
                      params.EnumParam,
                      default=RUN_OPTIMIZE,
                      choices=['Optimize params', 'Pick all micrographs'],
                      display=params.EnumParam.DISPLAY_LIST,
                      label='Run type: ',
                      help='Usually, first you should use the *Optimize* mode '
                      'to compute the FOM maps for a few micrographs and '
                      'use them to tune the picking parameters using the '
                      'wizard. After that you can run the job in *Compute*'
                      ' mode and auto-pick all the micrographs. ')

        group = form.addGroup('Micrographs for optimization',
                              condition='runType==%d' % RUN_OPTIMIZE)

        group.addParam('micrographsSelection',
                       params.EnumParam,
                       default=MICS_AUTO,
                       choices=['automatic selection', 'input subset'],
                       display=params.EnumParam.DISPLAY_HLIST,
                       label='Choose micrographs by',
                       help='If you choose "automatic selection", you only '
                       'need to provide the number of microgrphs to use '
                       'and that number will be selected to cover the '
                       'defocus range. ')
        group.addParam('micrographsNumber',
                       params.IntParam,
                       default='10',
                       condition='micrographsSelection==%d' % MICS_AUTO,
                       label='Micrographs for optimization:',
                       help='Select the number of micrographs that you want'
                       'to be used for the parameters optimization. ')
        group.addParam('micrographsSubset',
                       params.PointerParam,
                       condition='micrographsSelection==%d' % MICS_SUBSET,
                       pointerClass='SetOfMicrographs',
                       label='Subset of micrographs',
                       help='Choose as input a subset of micrographs that '
                       'you have previously selected. '
                       '(Probably covering the defocus range).')

        # From Relion 2.+, it can be picked with gaussian blobs, so we
        # need to add these parameters
        refCondition = 'referencesType==%s' % REF_AVERAGES

        group = form.addGroup('References')
        group.addParam('referencesType',
                       params.EnumParam,
                       choices=['References', 'Gaussian blobs'],
                       default=REF_AVERAGES,
                       display=params.EnumParam.DISPLAY_HLIST,
                       label='References type',
                       help='You may select "Gaussian blobs" to be used as '
                       'references. The preferred way to autopick is '
                       'by providing 2D references images that were '
                       'obtained by 2D classification. \n'
                       'The Gaussian blob references may be useful to '
                       'kickstart a new data set.')

        group.addParam('gaussianPeak',
                       params.FloatParam,
                       default=0.1,
                       condition='referencesType==%s' % REF_BLOBS,
                       label='Gaussian peak value',
                       help='The peak value of the Gaussian blob. '
                       'Weaker data will need lower values.')

        pointerClassStr = 'SetOfAverages'
        # In Relion 3 it is also possible to pass a volume as reference for
        # autopicking
        if isVersion3():
            pointerClassStr += ",Volume"

        group.addParam(
            'inputReferences',
            params.PointerParam,
            pointerClass='SetOfAverages',
            condition=refCondition,
            label='Input references',
            important=True,
            help='Input references (SetOfAverages) for auto-pick. \n\n'
            'Note that the absolute greyscale needs to be correct, \n'
            'so only use images with proper normalization. '
            'From Relion 3.0 it is also possible to provide a '
            '3D volume which projections will be used as '
            'references.')

        group.addParam(
            'particleDiameter',
            params.IntParam,
            default=-1,
            label='Mask diameter (A)',
            help='Diameter of the circular mask that will be applied '
            'around the templates in Angstroms. When set to a '
            'negative value, this value is estimated '
            'automatically from the templates themselves.')

        form.addSection('References')

        form.addParam('lowpassFilterRefs',
                      params.IntParam,
                      default=20,
                      condition=refCondition,
                      label='Lowpass filter references (A)',
                      help='Lowpass filter that will be applied to the '
                      'references before template matching. \n'
                      'Do NOT use very high-resolution templates to '
                      'search your micrographs. \n'
                      'The signal will be too weak at high resolution '
                      'anyway, and you may find Einstein from noise...')

        form.addParam('highpassFilterMics',
                      params.IntParam,
                      default=-1,
                      label='Highpass filter (A)',
                      help='Highpass filter that will be applied to the '
                      'micrographs. This may be useful to get rid of '
                      'background ramps due to uneven ice distributions. '
                      'Give a negative value to skip the highpass '
                      'filter.  Useful values are often in the range '
                      'of 200-400 Angstroms.')

        form.addParam(
            'angularSampling',
            params.IntParam,
            default=5,
            label='Angular sampling (deg)',
            help='Angular sampling in degrees for exhaustive searches '
            'of the in-plane rotations for all references.')

        form.addParam('refsHaveInvertedContrast',
                      params.BooleanParam,
                      default=True,
                      label='References have inverted contrast?',
                      help='Set to Yes to indicate that the reference have '
                      'inverted contrast with respect to the particles '
                      'in the micrographs.')

        form.addParam('refsCtfCorrected',
                      params.BooleanParam,
                      default=True,
                      condition=refCondition,
                      label='Are References CTF corrected?',
                      help='Set to Yes if the references were created with '
                      'CTF-correction inside RELION.\n'
                      'If set to Yes, the input micrographs should contain '
                      'the CTF information.')

        form.addParam(
            'ignoreCTFUntilFirstPeak',
            params.BooleanParam,
            condition=refCondition,
            default=False,
            expertLevel=params.LEVEL_ADVANCED,
            label='Ignore CTFs until first peak?',
            help='Set this to Yes, only if this option was also used '
            'to generate the references.')

        form.addSection('Autopicking')

        group = form.addGroup('Autopick')
        group.addParam('pickingThreshold',
                       params.FloatParam,
                       default=0.25,
                       label='Picking threshold:',
                       help='Use lower thresholds to pick more particles '
                       '(and more junk probably)')

        group.addParam('interParticleDistance',
                       params.IntParam,
                       default=-1,
                       label='Minimum inter-particle distance (A):',
                       help='Particles closer together than this distance \n'
                       'will be consider to be a single cluster. \n'
                       'From each cluster, only one particle will be '
                       'picked.')

        group.addParam(
            'maxStddevNoise',
            params.FloatParam,
            default=1.1,
            label='Maximum stddev noise:',
            help='This is useful to prevent picking in carbon areas, '
            'or areas with big contamination features. Peaks in '
            'areas where the background standard deviation in '
            'the normalized micrographs is higher than this '
            'value will be ignored. Useful values are probably '
            'in the range 1.0 to 1.2. Set to -1 to switch off '
            'the feature to eliminate peaks due to high '
            'background standard deviations.')

        group = form.addGroup('Computing')
        group.addParam('shrinkFactor',
                       params.FloatParam,
                       default=0,
                       validators=[
                           params.Range(0, 1, "value should be "
                                        "between 0 and 1. ")
                       ],
                       label='Shrink factor',
                       help='This is useful to speed up the calculations, '
                       'and to make them less memory-intensive. The '
                       'micrographs will be downscaled (shrunk) to '
                       'calculate the cross-correlations, and peak '
                       'searching will be done in the downscaled FOM '
                       'maps. When set to 0, the micrographs will de '
                       'downscaled to the lowpass filter of the '
                       'references, a value between 0 and 1 will '
                       'downscale the micrographs by that factor. '
                       'Note that the results will not be exactly '
                       'the same when you shrink micrographs!')

        group.addParam('doGpu',
                       params.BooleanParam,
                       default=True,
                       label='Use GPU acceleration?',
                       help='If set to Yes, the job will try to use GPU '
                       'acceleration.')

        group.addParam('gpusToUse',
                       params.StringParam,
                       default='',
                       label='Which GPUs to use:',
                       condition='doGpu',
                       help='This argument is not necessary. If left empty, '
                       'the job itself will try to allocate available GPU '
                       'resources. You can override the default '
                       'allocation by providing a list of which GPUs '
                       '(0,1,2,3, etc) to use. MPI-processes are '
                       'separated by ":", threads by ",". '
                       'For example: "0,0:1,1:0,0:1,1"')

        form.addParam(
            'extraParams',
            params.StringParam,
            default='',
            label='Additional arguments:',
            help='In this box command-line arguments may be provided '
            'that are not generated by the GUI. This may be '
            'useful for testing developmental options and/or '
            'expert use of the program. \n'
            'The command "relion_autopick" will print a list '
            'of possible options.')

        form.addSection('Helix')
        form.addParam('fomLabel',
                      params.LabelParam,
                      important=True,
                      label='Helix processing is not implemented still.')

        self._defineStreamingParams(form)

        form.addParallelSection(threads=0, mpi=4)
 def isDisabled(cls):
     return not isVersion3()
# * You should have received a copy of the GNU General Public License
# * along with this program; if not, write to the Free Software
# * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
# * 02111-1307  USA
# *
# *  All comments concerning this program package may be sent to the
# *  e-mail address '*****@*****.**'
# *
# **************************************************************************
from pyworkflow import VERSION_1_1
from pyworkflow.em import ProtCreateMask3D, VolumeMask
from convert import convertBinaryVol, isVersion1, isVersion3
import pyworkflow.protocol.params as params

NOT_VERSION1 = not isVersion1()
IS_V3 = isVersion3()

AND = 0
OR = 1
AND_NOT = 2
OR_NOT = 3


class ProtRelionCreateMask3D(ProtCreateMask3D):
    """ Create a 3D mask.
    The mask is created from a 3d volume or by comparing two input volumes.
    """
    _label = 'create 3d mask'
    _lastUpdateVersion = VERSION_1_1

    # --------------------------- DEFINE param functions ------------------------
 def isDisabled(cls):
     return not convert.isVersion3()