def test_synthetic_data_segmentation(self):
        """
        Function uses organ_segmentation  for synthetic box object
        segmentation.
        """

        data3d, segm, voxelsize_mm, slab = self.synthetic_data()
# @TODO je tam bug, prohlížeč neumí korektně pracovat s doubly
#        app = QApplication(sys.argv)
#        #pyed = QTSeedEditor(noise )
#        pyed = QTSeedEditor(data3d)
#        pyed.exec_()
#        #img3d = np.zeros([256,256,80], dtype=np.int16)

        # pyed = sed3.sed3(data3d)
        # pyed.show()

        outputTmp = segmentation.vesselSegmentation(
            data3d,  # .astype(np.uint8),
            segmentation=(segm == slab['liver']),  # .astype(np.uint8),
            # segmentation = oseg.orig_scale_segmentation,
            voxelsize_mm=voxelsize_mm,
            threshold=180,
            inputSigma=0.15,
            dilationIterations=2,
            nObj=1,
            interactivity=False,
            biggestObjects=True,
            binaryClosingIterations=5,
            binaryOpeningIterations=1)

# ověření výsledku
        # pyed = sed3.sed3(outputTmp, contour=segm==slab['porta'])
        # pyed.show()

# @TODO opravit chybu v vesselSegmentation
        outputTmp = (outputTmp == 2)
        errim = np.abs(
            outputTmp.astype(np.int) - (segm == slab['porta']).astype(np.int)
        )

# ověření výsledku
        # pyed = sed3.sed3(errim, contour=segm==slab['porta'])
        # pyed.show()
# evaluation
        sum_of_wrong_voxels = np.sum(errim)
        sum_of_voxels = np.prod(segm.shape)

        # print "wrong ", sum_of_wrong_voxels
        # print "voxels", sum_of_voxels

        errorrate = sum_of_wrong_voxels/sum_of_voxels

        # import pdb; pdb.set_trace()

        self.assertLess(errorrate, 0.1)
    def test_synthetic_data_segmentation(self):
        """
        Function uses organ_segmentation  for synthetic box object
        segmentation.
        """

        data3d, segm, voxelsize_mm, slab = self.synthetic_data()
# @TODO je tam bug, prohlížeč neumí korektně pracovat s doubly
#        app = QApplication(sys.argv)
#        #pyed = QTSeedEditor(noise )
#        pyed = QTSeedEditor(data3d)
#        pyed.exec_()
#        #img3d = np.zeros([256,256,80], dtype=np.int16)

        # pyed = sed3.sed3(data3d)
        # pyed.show()

        outputTmp = segmentation.vesselSegmentation(
            data3d,  # .astype(np.uint8),
            segmentation=(segm == slab['liver']),  # .astype(np.uint8),
            # segmentation = oseg.orig_scale_segmentation,
            voxelsize_mm=voxelsize_mm,
            threshold=180,
            inputSigma=0.15,
            dilationIterations=2,
            nObj=1,
            interactivity=False,
            biggestObjects=True,
            binaryClosingIterations=5,
            binaryOpeningIterations=1)

# ověření výsledku
        # pyed = sed3.sed3(outputTmp, contour=segm==slab['porta'])
        # pyed.show()

# @TODO opravit chybu v vesselSegmentation
        outputTmp = (outputTmp == 2)
        errim = np.abs(
            outputTmp.astype(np.int) - (segm == slab['porta']).astype(np.int)
        )

# ověření výsledku
        # pyed = sed3.sed3(errim, contour=segm==slab['porta'])
        # pyed.show()
# evaluation
        sum_of_wrong_voxels = np.sum(errim)
        sum_of_voxels = np.prod(segm.shape)

        # print "wrong ", sum_of_wrong_voxels
        # print "voxels", sum_of_voxels

        errorrate = sum_of_wrong_voxels/sum_of_voxels

        # import pdb; pdb.set_trace()

        self.assertLess(errorrate, 0.1)
Exemple #3
0
    def test_ui_threshold_same_params_as_portal_segmentation(self):

        params = {
            'threshold': -1,
            'inputSigma': 0.15,
            'dilationIterations': 10,
            'nObj': 1,
            'biggestObjects': False,
            'useSeedsOfCompactObjects': True,
            'interactivity': True,
            'binaryClosingIterations': 2,
            'binaryOpeningIterations': 0
        }
        import imtools
        import imtools.sample_data
        datap = imtools.sample_data.generate()
        app = QApplication(sys.argv)
        outputTmp = segmentation.vesselSegmentation(
            datap['data3d'],
            datap['segmentation'],
            # datap['voxelsize_mm'],
            **params)
    def test_ui_threshold_same_params_as_portal_segmentation(self):

        params = {
            'threshold': -1,
            'inputSigma': 0.15,
            'dilationIterations': 10,
            'nObj': 1,
            'biggestObjects': False,
            'useSeedsOfCompactObjects': True,
            'interactivity': True,
            'binaryClosingIterations': 2,
            'binaryOpeningIterations': 0
        }
        import imtools
        import imtools.sample_data
        datap = imtools.sample_data.generate()
        app = QApplication(sys.argv)
        outputTmp = segmentation.vesselSegmentation(
            datap['data3d'],
            datap['segmentation'],
            # datap['voxelsize_mm'],
            **params)
Exemple #5
0
    def do_segmentation_with_connected_threshold(self,
                                                 image: np.ndarray,
                                                 resolution: np.ndarray,
                                                 time_resolution: float,
                                                 qapp=None):
        from imtools import segmentation as imsegmentation

        params = {
            # 'threshold': threshold,
            'inputSigma': 0.15,
            'aoi_dilation_iterations': 0,
            'nObj': 1,
            'biggestObjects': False,
            'useSeedsOfCompactObjects': True,
            'interactivity': True,
            'binaryClosingIterations': 2,
            'binaryOpeningIterations': 0,
            # 'seeds': seeds,
        }
        # params.update(inparams)
        # logger.debug("ogran_label ", organ_label)
        # target_segmentation = (self.segmentation == self.nlabels(organ_label)).astype(np.int8)
        import imma.image_manipulation as ima
        # target_segmentation = ima.select_labels(
        #     self.segmentation, organ_label, self.slab
        # )
        vxsz_mm = np.array([1.0, resolution[0] * 1000, resolution[1] * 1000])
        outputSegmentation = imsegmentation.vesselSegmentation(
            image,
            voxelsize_mm=vxsz_mm,
            # target_segmentation,
            segmentation=np.ones(image.shape, dtype=np.uint8),
            aoi_label=1,
            # aoi_label=organ_label,
            # forbidden_label=forbidden_label,
            # slab=self.slab,
            # debug=self.debug_mode,
            **params)