示例#1
0
        # Segment image
        Y_h, post, theta = UGM.segment(X)

        # Set cluster assignments to correct tissue labels
        Y_h = set_classes(Y_h, z)

        # Compute error
        err[1, n, r] = np.mean(Y_h[M] != Y[M])
        dcc[1, n, r] = dice(Y_h[M], Y[M])

        if vis:

            fn_segs = fn + 'UGM_segs_p' + str(n + 1) + '_r' + str(r +
                                                                  1) + '.png'
            plot_clustering(X[:, :, 0], Y_h, mode='subpixel', savefn=fn_segs)
        ''' Semi-supervised Gaussian Mixture '''

        # Initialize model
        SGM = SemisupervisedGaussianMixture(num_components=K,
                                            num_channels=D,
                                            max_iter=max_iter,
                                            tol=x_tol,
                                            init_params='nn')

        # Segment image
        Y_h, post, theta = SGM.segment(X, y)

        # Compute error
        err[2, n, r] = np.mean(Y_h[M] != Y[M])
        dcc[2, n, r] = dice(Y_h[M], Y[M])
示例#2
0
        # Set cluster assignments to correct tissue labels
        Y_h = set_classes(Y_h, z)

        # Compute error
        err[0, n, r] = np.mean(Y_h[M] != Y[M])
        dcc[0, n, r] = dice(Y_h[M], Y[M])

        if vis:

            fn_segs = fn + 'SCK_segs' + str(n + 1) + '_r' + str(r + 1) + '.png'
            plot_segmentation(Y_h[30:-30, 30:-30], savefn=fn_segs)

            fn_segs = fn + 'SCK_segl' + str(n + 1) + '_r' + str(r + 1) + '.png'
            plot_clustering(X[30:-30, 30:-30, 0],
                            Y_h[30:-30, 30:-30],
                            mode='subpixel',
                            savefn=fn_segs)
        ''' Unsupervised Gaussian Mixture '''

        # Initialize model
        UGM = UnsupervisedGaussianMixture(num_components=K,
                                          num_channels=D,
                                          max_iter=max_iter,
                                          tol=x_tol,
                                          init_params='kmeans')

        # Segment image
        Y_h, post, theta = UGM.segment(X)

        # Set cluster assignments to correct tissue labels
        Y_h = set_classes(Y_h, z)