示例#1
0
def main():
    global config
    args = get_args.train25d()

    config = path_utils.update_is_augment(args, config)

    data_path, _, _, _, _ = path_utils.get_training_h5_paths(BRATS_DIR, args)
    if args.overwrite or not os.path.exists(data_path):
        prepare_data(args)

    train(args)
示例#2
0
def main():
    args = get_args.train25d()

    depth_unet = args.depth_unet
    n_base_filters_unet = args.n_base_filters_unet
    patch_shape = args.patch_shape
    is_crf = args.is_crf
    batch_size = args.batch_size
    is_hist_match = args.is_hist_match
    loss = args.loss

    header = ("dice_WholeTumor", "dice_TumorCore", "dice_EnhancingTumor")
    model_scores = list()
    model_ids = list()

    for is_augment in ["1"]:
        args.is_augment = is_augment
        for model_name in ["unet"]:
            args.model = model_name
            for is_denoise in ["0"]:
                args.is_denoise = is_denoise
                for is_normalize in ["z"]:
                    args.is_normalize = is_normalize
                    for is_hist_match in ["0"]:
                        args.is_hist_match = is_hist_match
                        for loss in ["weighted"]:
                            args.loss = loss
                            # for patch_shape in ["160-192-3", "160-192-5", "160-192-7", "160-192-9", "160-192-11", "160-192-13", "160-192-15", "160-192-17"]:
                            for patch_shape in [
                                    "160-192-11", "160-192-13", "160-192-15",
                                    "160-192-17"
                            ]:
                                args.patch_shape = patch_shape
                                args.model_dim = 25

                                print("=" * 120)
                                print(
                                    ">> processing model-{}{}, depth-{}, filters-{}, patch_shape-{}, is_denoise-{}, is_normalize-{}, is_hist_match-{}, loss-{}"
                                    .format(model_name, args.model_dim,
                                            depth_unet, n_base_filters_unet,
                                            patch_shape, is_denoise,
                                            is_normalize, is_hist_match, loss))
                                is_test = "0"
                                predict(args)
                                # print("="*60)
                                print(">> finished")
                                print("=" * 120)
                                gc.collect()
                                from keras import backend as K
                                K.clear_session()

    print(list_already_predicted)
    print(len(list_already_predicted))
示例#3
0
    model_path = os.path.join(
        BRATS_DIR, "database/model", model_filename)
    if os.path.exists(model_path):
        print("{} exists. Will skip!!".format(model_path))
    else:
        try:
            print(">> RUNNING:", cmd)
        except:
            print("something wrong")

        from keras import backend as K
        os.system(cmd)
        K.clear_session()


args = get_args.train25d()
task = "brats/train25d"
args.is_test = "0"

model_list = list()
cmd_list = list()
out_file_list = list()

for is_augment in ["1"]:
    args.is_augment = is_augment
    for model_name in ["unet"]:
        args.model = model_name
        for is_denoise in ["0"]:
            args.is_denoise = is_denoise
            for is_normalize in ["z"]:
                args.is_normalize = is_normalize
def main():
    args = get_args.train25d()

    depth_unet = args.depth_unet
    n_base_filters_unet = args.n_base_filters_unet
    patch_shape = args.patch_shape
    is_crf = args.is_crf
    batch_size = args.batch_size
    is_hist_match = args.is_hist_match
    loss = args.loss

    header = ("dice_WholeTumor", "dice_TumorCore", "dice_EnhancingTumor")
    model_scores = list()
    model_ids = list()

    for is_augment in ["1"]:
        args.is_augment = is_augment
        for model_name in ["unet"]:
            args.model = model_name
            for is_denoise in ["0"]:
                args.is_denoise = is_denoise
                for is_normalize in ["z"]:
                    args.is_normalize = is_normalize
                    for is_hist_match in ["0"]:
                        args.is_hist_match = is_hist_match
                        for loss in ["weighted"]:
                            args.loss = loss
                            for patch_shape in ["160-192-3", "160-192-5", "160-192-7", "160-192-9", "160-192-11", "160-192-13", "160-192-15", "160-192-17"]:
                            # for patch_shape in ["160-192-3", "160-192-5", "160-192-7", "160-192-9", "160-192-11"]:
                                # for patch_shape in ["160-192-3", "160-192-13", "160-192-15", "160-192-17"]:
                                args.patch_shape = patch_shape
                                model_dim = 25

                                print("="*120)
                                print(
                                    ">> processing model-{}{}, depth-{}, filters-{}, patch_shape-{}, is_denoise-{}, is_normalize-{}, is_hist_match-{}, loss-{}".format(
                                        model_name,
                                        model_dim,
                                        depth_unet,
                                        n_base_filters_unet,
                                        patch_shape,
                                        is_denoise,
                                        is_normalize,
                                        is_hist_match,
                                        loss))
                                is_test = "0"
                                model_score, model_path = evaluate(args)
                                if model_score is not None:
                                    print("="*120)
                                    print(">> finished:")

                                    model_ids.append(
                                        get_filename_without_extension(model_path))

                                    row = get_model_info_header(args.challenge, args.year, args.image_shape, args.is_bias_correction,
                                                                args.is_denoise, args.is_normalize, args.is_hist_match,
                                                                model_name, model_dim, patch_shape, loss,
                                                                depth_unet, n_base_filters_unet)
                                    score = [np.mean(model_score["dice_WholeTumor"]),
                                             np.mean(
                                        model_score["dice_TumorCore"]),
                                        np.mean(
                                        model_score["dice_EnhancingTumor"]),
                                        (np.mean(model_score["dice_WholeTumor"])+np.mean(model_score["dice_TumorCore"])+np.mean(model_score["dice_EnhancingTumor"]))/3]

                                    row.extend(score)
                                    model_scores.append(row)

    header = ("challenge", "year", "image_shape", "is_bias_correction",
              "is_denoise", "is_normalize", "is_hist_match",
              "model_name", "model_dim", "depth_unet",
              "n_base_filters_unet", "loss", "patch_shape",
              "dice_WholeTumor", "dice_TumorCore",
              "dice_EnhancingTumor", "dice_Mean")

    final_df = pd.DataFrame.from_records(
        model_scores, columns=header, index=model_ids)

    print(final_df)

    prediction_df_csv_folder = os.path.join(
        BRATS_DIR, "database/prediction/csv/")
    make_dir(prediction_df_csv_folder)

    to_file = prediction_df_csv_folder + "compile.csv"

    final_df.to_csv(to_file)