Example #1
0
    def test_transform(self):
        roi = ROI.ROI(polygons=[[0, 0], [0, 2], [2, 2], [2, 0]],
                      im_shape=(3, 3))
        transforms = [np.array([[1, 0, 0], [0, 1, 0]])]  # one per plane

        roi_list = ROI.ROIList([roi])
        assert_equal(roi_list.transform(transforms)[0].coords, roi.coords)
Example #2
0
    def test_postprocess(self):

        centers = [(10, 10), (40, 40), (70, 70), (100, 100)]

        roi_xy = [
            np.arange(self.tiff_ds.sequences[0].shape[2]),
            np.arange(self.tiff_ds.sequences[0].shape[3])
        ]

        rois = ROI.ROIList([
            ROI.ROI(_gaussian_2d(roi_xy, center, (10, 10)))
            for center in centers
        ])

        tobool = segment.SparseROIsFromMasks(n_processes=2)
        smooth = segment.SmoothROIBoundaries(n_processes=2)
        rois = smooth.apply(tobool.apply(rois))

        assert_(len(rois) == len(centers))
        for roi in rois:
            polygon = mplPath.Path(roi.coords[0][:, :2])
            for nc, center in enumerate(centers):
                if polygon.contains_point(center):
                    centers.pop(nc)
                    break
        assert_(len(centers) == 0)