Ejemplo n.º 1
0
    # a dictionary to specify where the dataset path should be
    dataset_info = {
        "train": {
            "img": (".png", "dataset/CoNSeP/Train/Images/"),
            "ann": (".mat", "dataset/CoNSeP/Train/Labels/"),
        },
        "valid": {
            "img": (".png", "dataset/CoNSeP/Test/Images/"),
            "ann": (".mat", "dataset/CoNSeP/Test/Labels/"),
        },
    }

    patterning = lambda x: re.sub("([\[\]])", "[\\1]", x)
    parser = get_dataset(dataset_name)
    xtractor = PatchExtractor(win_size, step_size)
    for split_name, split_desc in dataset_info.items():
        img_ext, img_dir = split_desc["img"]
        ann_ext, ann_dir = split_desc["ann"]

        out_dir = "%s/%s/%s/%dx%d_%dx%d/" % (
            save_root,
            dataset_name,
            split_name,
            win_size[0],
            win_size[1],
            step_size[0],
            step_size[1],
        )
        file_list = glob.glob(patterning("%s/*%s" % (ann_dir, ann_ext)))
        file_list.sort()  # ensure same ordering across platform
Ejemplo n.º 2
0
        if cfg.out_preproc is not None:
            normalized = (os.path.exists(cfg.out_preproc[mode]) and \
                len(os.listdir(cfg.out_preproc[mode])) != 0)
        if not normalized: 
            normalized = False
            break
        
    assert (cfg.normalized == normalized)
    print(f"Stain normalization was performed: {normalized}")
    img_dirs = cfg.out_preproc if normalized else cfg.img_dirs

    print(f"Using folders <{list(img_dirs.values())}> as input")
    print(f"Saving results to <{list(cfg.out_extract.values())}>")

    for data_mode in img_dirs.keys():
        xtractor = PatchExtractor(cfg.win_size, cfg.step_size)

        img_dir = img_dirs[data_mode]
        ann_dir = cfg.labels_dirs[data_mode]
        
        file_list = glob.glob(os.path.join(img_dir, '*{}'.format(cfg.img_ext)))
        file_list.sort()
        out_dir = cfg.out_extract[data_mode]

        rm_n_mkdir(out_dir)
        for filename in file_list:
            filename = os.path.basename(filename)
            basename = filename.split('.')[0]
            print('Mode: {}, filename - {}'.format(data_mode, filename))

            img = cv2.imread(os.path.join(img_dir, '{}{}'.format(basename, cfg.img_ext)))
import matplotlib.pyplot as plt
import subprocess

#brca = '/data/images/tcga_data/brca/'
#brcaloc = sys.argv[3]
#quip = '/data/images/'
#quiploc = sys.argv[3]
svs = sys.argv[4]
svsloc = sys.argv[3]

outputDir = sys.argv[5]

extract_type = 'mirror'
step_size = [80, 80]
win_size = [540, 540]
xtractor = PatchExtractor(win_size, step_size)
dumppath = sys.argv[1]
segment = int(sys.argv[6])
polygonpath = sys.argv[7] + '{}/*.csv'
manifest = pd.read_csv(os.path.join(dumppath, sys.argv[2]))
manifest["imagepath"] = manifest["imagepath"].str.replace(svs,
                                                          svsloc,
                                                          regex=False)

remote = int(sys.argv[8])
if remote:
    remoteuser = sys.argv[9]
    remotekey = sys.argv[10]


def downRemoteFile(path):