예제 #1
0
def update_output_rf(slide_path):
    uid = path_leaf(slide_path).replace(".tif", "")
    pickle_file = os.path.join(PREDICTED_HEATMAP_DIR["rf"],
                               uid + ".joblib.pickle")
    slide = WSIReader(slide_path, 40)
    n_cols = int(slide.width / 256)
    n_rows = int(slide.height / 256)

    thumbnail = slide.get_thumbnail((n_cols, n_rows))
    thumbnail = np.array(thumbnail)
    if os.path.isfile(pickle_file):
        thumbnail_predicted = joblib.load(pickle_file)
        fig, ax = plt.subplots()
        plot_blend(thumbnail, thumbnail_predicted, ax, alpha=1)
        # ax.axis('off')
        ax.set_title("RF - Predicted Heatmap")
    else:
        fig, ax = plt.subplots()
        thumbnail = imread(NOT_AVAIL_IMG)
        ax.imshow(thumbnail)
        ax.axis("off")

        # ax.axis('off')
    fig.tight_layout()
    slide.close()
    out_url = fig_to_uri(fig)
    plt.close("all")
    return out_url
예제 #2
0
def get_samples_from_dir(dir):
    # Just assume all files will have tif extension
    wsis = glob.glob(os.path.join(dir, "*.tif"))
    short_names = []
    for wsi in wsis:
        label = path_leaf(wsi).replace(".tif", "")
        # if label in TUMOR_VALIDATE_SLIDES or label in NORMAL_VALIDATE_SLIDES:
        short_names.append({"label": label, "value": wsi})
    return short_names
예제 #3
0
def update_output_rf_mask(slide_path):
    uid = path_leaf(slide_path).replace(".tif", "")
    pickle_file = os.path.join(PREDICTED_HEATMAP_DIR["rf"],
                               uid + ".joblib.pickle")
    if os.path.isfile(pickle_file):
        thumbnail_predicted = joblib.load(pickle_file)
        fig, ax = plt.subplots()
        ax.imshow((thumbnail_predicted > 0.75).astype(np.int),
                  cmap="gray",
                  vmin=0,
                  vmax=1)
        # ax.set_title(' (white=tumor, black=not_tumor)')
        # ax.axis('off')
        ax.set_title("RF - Predicted Mask \n (white=tumor, black=normal)")
    else:
        fig, ax = plt.subplots()
        thumbnail = imread(NOT_AVAIL_IMG)
        ax.imshow(thumbnail)
        ax.axis("off")
    fig.tight_layout()
    out_url = fig_to_uri(fig)
    plt.close("all")
    return out_url