Example #1
0
               ["centroid_x", "centroid_y", "centroid_z", "intensity", "size"],
               ["position"])  #, "contrast", "ratio"])


if __name__ == '__main__':
    from time import time
    from copy import deepcopy
    from itertools import product
    from skimage.morphology import watershed, local_minima
    from skimage.color import rgb2gray
    import scipy.ndimage as ndi
    from display_utils import display_segments_as_lines, display_solution

    print("Loading a single patient... ", end="", flush=True)
    t0 = time()
    model_patient = Patient.build_from_folder("data/4")
    print("Done. {:.4f}s".format(time() - t0))

    # Splitting the background into 3 labels
    model_patient.labelmaps[
        "t2"].data += 2  # Adding space for the extra labels at the start
    model_patient.labelmaps["t2"].data[np.logical_and(
        model_patient.volumes["t2"].data < 10,
        model_patient.labelmaps["t2"].data ==
        2)] = 0  # posterior background is 0
    model_patient.labelmaps["t2"].data[
        model_patient.labelmaps["t2"].data.shape[1] //
        2:, :, :][model_patient.labelmaps["t2"].data[
            model_patient.labelmaps["t2"].data.shape[1] //
            2:, :, :] == 0] = 1  # anterior background is 1
    model_patient.labelmaps["t2"].header["num_labels"] += 2