示例#1
0
    def interpolate_ot(self, f):

        v = self.result
        if self.adjust_thresholds:
            self.record_threshold_ranks(v)

        changed_f = get_weights(self.rate, f)
        f1, f2, sf1, sf2, v1, v2, vol1, vol2 = self.coefficients(changed_f)
        if v.data is None or v1.data is None or v2.data is None:
            return False

        if self.semi:
            linear_combination(sf1, vol1, sf2, vol2, v, self.subregion,
                               self.step)

        else:
            ot_combination(sf1, v1, sf2, v2, v, self.subregion, self.step,
                           self.niter, self.reg)

        self.f = f

        if self.adjust_thresholds:
            self.set_threshold_ranks(v)

        if self.interpolate_colors:
            interpolate_colors(f1, v1, f2, v2, v)

        return True
示例#2
0
def interpolate_colors(f1, v1, f2, v2, v):

  nc = len(v.surfaces)
  if len(v1.surfaces) == nc and len(v2.surfaces) == nc:
    from chimerax.geometry import linear_combination
    for s, s1, s2 in zip(v.surfaces, v1.surfaces, v2.surfaces):
      s.rgba = linear_combination(f1, s1.rgba, f2, s2.rgba)

  nc = len(v.image_colors)
  if len(v1.image_colors) == nc and len(v2.image_colors) == nc:
    from chimerax.geometry import linear_combination
    scolors = [linear_combination(f1, v1.image_colors[c], f2, v2.image_colors[c])
               for c in range(nc)]
    v.set_parameters(image_colors = scolors)
示例#3
0
def linear_combination(f1, v1, f2, v2, v, subregion, step):

    m = v.full_matrix()
    m1 = v1
    m2 = v2
    if (m.flags.contiguous and m1.flags.contiguous and m2.flags.contiguous
            and m1.dtype == m.dtype and m2.dtype == m.dtype):
        # Optimize calculation of linear combination of matrices.
        # C++ routine is 7x faster (.1 vs .7 sec) than numpy on 256^3 matrix.
        from chimerax.map import linear_combination
        linear_combination(f1, m1, f2, m2, m)
    else:
        m[:, :, :] = f1 * m1[:, :, :] + f2 * m2[:, :, :]

    v.data.values_changed()
示例#4
0
    def interpolate(self, f):

        v = self.result
        if self.adjust_thresholds:
            self.record_threshold_ranks(v)

        f1, f2, sf1, sf2, v1, v2 = self.coefficients(f)
        if v.data is None or v1.data is None or v2.data is None:
            return False

        linear_combination(sf1, v1, sf2, v2, v, self.subregion, self.step)
        self.f = f

        if self.adjust_thresholds:
            self.set_threshold_ranks(v)

        if self.interpolate_colors:
            interpolate_colors(f1, v1, f2, v2, v)

        return True