Esempio n. 1
0
    def parse_options(self):
        """Validate list of parameters.

    Raises:
        omero_scrits_processing.invalid_parameter
    """
        try:
            self.options = self.schema(self.options)
        except voluptuous.Invalid as e:
            raise omero_scripts_processing.invalid_parameter(str(e))
Esempio n. 2
0
  def parse_options(self):
    """Build list of input args to call ndsafir.

    Raises:
        omero_scripts_processing.invalid_parameter
    """
    super(ndsafir, self).parse_options()

    ## FIXME our version of nd-safir crashes if we don't use time
    self.options["time"] = True

    try:
      self.options = self.schema(self.options)
    except voluptuous.Invalid as e:
      raise omero_scripts_processing.invalid_parameter(str(e))

    ## Maximum number of iterations is less when using time
    if self.options["time"] and self.options["iterations"] > 5:
      raise omero_scripts_processing.invalid_parameter(
        "if `time', `iterations' must be less than 6")

    opts = [] # list for command line options

    ## Handle the dimensionality option.
    ## For 2D and 5D, it is simple but for the other case, we must
    ## specify the number of dimensions and the dimension type,
    ## e.g., -4d=zt or -3d=w
    dims = ""
    for key in ["z-slices", "time", "wavelength"]:
      if self.options[key]:
        dims += key[0]
    ndims = 2 + len(dims)
    if ndims == 2:
      dopt = "-2d"
    elif ndims > 2 and ndims < 5:
      dopt = "-%id=%s" % (ndims, dims)
    else:
      dopt = "-5d"
    opts.append(dopt)

    ## The option value for "gaussian + poisson" is just "poisson"
    if self.options["noise_model"] == "gaussian + poisson":
      self.options["noise_model"] = "poisson"

    ## The "sampling" option is a bit trickier because it is optional,
    ## and its default is patch radius +1.
    ## XXX: There will be no keys for non-set, optional values, not even
    ## None, see https://github.com/openmicroscopy/openmicroscopy/issues/2462
    if "sampling" not in self.options:
      self.options["sampling"] = float(self.options["patch_radius"] +1)

    opts += [
      "-iter=%i"      % (self.options["iterations"]),
      "-p=%i"         % (self.options["patch_radius"]),
      "-noise=%s"     % (self.options["noise_model"]),
      ## FIXME https://github.com/openmicroscopy/openmicroscopy/issues/2449
#      "-adapt=%f"     % (self.options["adaptability"]),
      "-island=%f"    % (self.options["island_threshold"]),
      "-sampling=%i"  % (self.options["sampling"]),
    ]

    self.bin_opts = opts