コード例 #1
0
def overlap_mip():
    configure_logger()
    client = cloud.authenticate()
    bucket = client.get_bucket('elvos')

    # iterate through every source directory...
    for location in WHENCE:
        prefix = location + '/'
        logging.info(f"MIPing images from {prefix}")

        # for every blob in the source directory
        for in_blob in bucket.list_blobs(prefix=prefix):
            # blacklist
            if in_blob.name == prefix + 'LAUIHISOEZIM5ILF.npy':
                continue

            file_id = in_blob.name.split('/')[2]
            file_id = file_id.split('.')[0]

            # download the array
            logging.info(f'downloading {in_blob.name}')
            input_arr = cloud.download_array(in_blob)
            logging.info(f"blob shape: {input_arr.shape}")

            # if it's in failure analysis, do the failure analysis MIP
            if file_id in FAILURE_ANALYSIS:
                if location == 'numpy/axial':
                    cropped_arr = transforms.crop_overlap_axial_fa(
                        input_arr, location)
            # otherwise do a normal MIP
            else:
                if location == 'numpy/axial':
                    cropped_arr = transforms.crop_overlap_axial(
                        input_arr, location)
                else:
                    cropped_arr = transforms.crop_overlap_coronal(input_arr)
            not_extreme_arr = transforms.remove_extremes(cropped_arr)
            logging.info(f'removed array extremes')
            mip_arr = transforms.mip_overlap(not_extreme_arr)

            # OPTIONAL: visualize a slice
            # plt.figure(figsize=(6, 6))
            # plt.imshow(mip_arr[10], interpolation='none')
            # plt.show()

            # save to the numpy generator source directory
            cloud.save_npy_to_cloud(mip_arr, file_id, location, 'overlap')
コード例 #2
0
def overlap_mip():
    configure_logger()
    client = cloud.authenticate()
    bucket = client.get_bucket('elvos')

    # iterate through every source directory...
    for location in WHENCE:
        prefix = location + '/'
        logging.info(f"MIPing images from {prefix}")

        for in_blob in bucket.list_blobs(prefix=prefix):
            # blacklist
            if in_blob.name == prefix + 'LAUIHISOEZIM5ILF.npy':
                continue

            file_id = in_blob.name.split('/')[2]
            file_id = file_id.split('.')[0]

            # 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}")
            if location == 'numpy/axial':
                cropped_arr = transforms.crop_overlap_axial(
                    input_arr, location)
            else:
                cropped_arr = transforms.crop_overlap_coronal(
                    input_arr, location)
            not_extreme_arr = transforms.segment_vessels(cropped_arr)
            logging.info(f'removed array extremes')
            mip_arr = transforms.mip_overlap(not_extreme_arr)
            # plt.figure(figsize=(6, 6))
            # plt.imshow(mip_arr[10], interpolation='none')
            # plt.show()

            # save to the numpy generator source directory
            cloud.save_segmented_npy_to_cloud(mip_arr, file_id, location,
                                              'overlap')