def prune_branch(self, i): # i >= 1 if i == 0: return temp_min, stemx, stemy, stem_index, branchx, branchy, branch_index = self.get_coord_min_distance( i) poly = self.roi_array[i].getFloatPolygon() poly_npoints = poly.npoints poly_index = branch_index if poly_npoints / 2 >= poly_index: # print 'if', i+1 newx = poly.xpoints[poly_index:] newy = poly.ypoints[poly_index:] new_poly = FloatPolygon(newx, newy) else: # print 'else', i+1 newx = reversed(poly.xpoints[:poly_index + 1]) newy = reversed(poly.ypoints[:poly_index + 1]) new_poly = FloatPolygon(newx, newy) new_roi = PolygonRoi(new_poly, Roi.POLYLINE) new_roi.fitSpline() self.RoiManager.setRoi(new_roi, i)
def selectionInterpolateAndFitSpline(roi, interval=1.0, smooth=True): """implement IJ.run(imp, "Interpolate", "interval=1.0 smooth adjust");IJ.run(imp, "Fit Spline", "");""" roi = PolygonRoi(roi.getInterpolatedPolygon(-1.0 * interval, smooth), Roi.FREELINE) if roi.subPixelResolution(): roi = selectionTrimFloatPolygon(roi, roi.getUncalibratedLength()) else: roi = selectionTrimPolygon(roi, roi.getUncalibratedLength()) roi.fitSpline() return roi
def get_distance_from_stem(self, i): if i == 0: return 0 min_len, stemx, stemy, stem_index, _1, _2, _3 = self.get_coord_min_distance( i) stem_x_array = self.roi_array[0].getFloatPolygon().xpoints[:stem_index] stem_y_array = self.roi_array[0].getFloatPolygon().ypoints[:stem_index] new_poly = FloatPolygon(stem_x_array, stem_y_array) new_roi = PolygonRoi(new_poly, Roi.POLYLINE) new_roi.fitSpline() return get_roi_length(new_roi)