Exemplo n.º 1
0
def get_stripped_mip():
    """
    A script to get stripped and segmented MIP images to then do analysis on

    :return:
    """
    configure_logger()
    client = cloud.authenticate()
    bucket = client.get_bucket('elvos')

    # for every blob
    for in_blob in bucket.list_blobs(prefix=PREFIX):

        # perform the normal MIPing procedure
        logging.info(f"downloading {in_blob.name}")
        input_arr = cloud.download_array(in_blob)
        logging.info(f"blob shape: {input_arr.shape}")
        cropped_arr = transforms.crop_strip_skull(input_arr, LOCATION)
        logging.info("mipping numpy array")
        mip_arr = transforms.mip_normal(cropped_arr)

        # strip skull and grey matter to segment blood vessels
        logging.info("segment blood vessels")
        stripped_arr = transforms.segment_vessels(mip_arr, LOCATION)

        # save to cloud
        save_to_cloud(stripped_arr, in_blob)
Exemplo n.º 2
0
def get_stripped_mip():
    for location in LOCATIONS:
        prefix = location + '/'
        for in_blob in set_cloud().list_blobs(prefix=prefix):
            # test: only using one patient's mipped scans for now
            # if in_blob.name != prefix + '0RB9KGMO90G1YQZD.npy':
            #     continue

            # perform the normal MIPing procedure
            logging.info(f'downloading {in_blob.name}')
            input_arr = cloud.download_array(in_blob)
            logging.info(f"blob shape: {input_arr.shape}")
            cropped_arr = transforms.crop_strip_skull(input_arr, location)
            logging.info(f"mipping numpy array")
            mip_arr = transforms.mip_normal(cropped_arr)

            print(mip_arr)

            # strip skull and segment blood vessels
            logging.info(f"segment blood vessels")
            stripped_arr = transforms.segment_vessels(mip_arr, location)

            print(stripped_arr)

            get_og_mip(cropped_arr)

            plt.figure(figsize=(6, 6))
            plt.imshow(stripped_arr, interpolation='none')
            plt.show()
Exemplo n.º 3
0
def get_og_mip(cropped_arr: np.ndarray):
    # perform the normal MIPing procedure
    not_extreme_arr = transforms.remove_extremes(cropped_arr)
    logging.info(f'removed array extremes')
    mip_arr = transforms.mip_normal(not_extreme_arr)

    plt.figure(figsize=(6, 6))
    plt.imshow(mip_arr, interpolation='none')
    plt.show()
Exemplo n.º 4
0
def get_og_mip(cropped_arr: np.ndarray):
    """
    Gets and shows normal MIP for comparison

    :param cropped_arr: array to MIP
    :return:
    """
    # perform the normal MIPing procedure
    not_extreme_arr = transforms.remove_extremes(cropped_arr)
    logging.info("removed array extremes")
    mip_arr = transforms.mip_normal(not_extreme_arr)

    plt.figure(figsize=(6, 6))
    plt.imshow(mip_arr, interpolation='none')
    plt.show()
Exemplo n.º 5
0
def get_stripped_mip():
    configure_logger()
    client = cloud.authenticate()
    bucket = client.get_bucket('elvos')

    for in_blob in bucket.list_blobs(prefix=prefix):
        # perform the normal MIPing procedure
        logging.info(f"downloading {in_blob.name}")
        input_arr = cloud.download_array(in_blob)
        logging.info(f"blob shape: {input_arr.shape}")
        cropped_arr = transforms.crop_strip_skull(input_arr, location)
        logging.info("mipping numpy array")
        mip_arr = transforms.mip_normal(cropped_arr)

        # strip skull and grey matter to segment blood vessels
        logging.info("segment blood vessels")
        stripped_arr = transforms.segment_vessels(mip_arr, location)

        save_to_cloud(stripped_arr, in_blob)