|
| 1 | +import os |
| 2 | +from pathlib import Path |
| 3 | + |
| 4 | +import pooch |
| 5 | + |
| 6 | + |
| 7 | +def fetch_image_series_example_data(save_directory): |
| 8 | + """Download the sample images for the image series annotator. |
| 9 | + """ |
| 10 | + save_directory = Path(save_directory) |
| 11 | + os.makedirs(save_directory, exist_ok=True) |
| 12 | + print("Example data directory is:", save_directory.resolve()) |
| 13 | + fname = "image-series.zip" |
| 14 | + unpack_filenames = [os.path.join("series", f"im{i}.tif") for i in range(3)] |
| 15 | + unpack = pooch.Unzip(members=unpack_filenames) |
| 16 | + pooch.retrieve( |
| 17 | + url="https://owncloud.gwdg.de/index.php/s/M1zGnfkulWoAhUG/download", |
| 18 | + known_hash="92346ca9770bcaf55248efee590718d54c7135b6ebca15d669f3b77b6afc8706", |
| 19 | + fname=fname, |
| 20 | + path=save_directory, |
| 21 | + progressbar=True, |
| 22 | + processor=unpack, |
| 23 | + ) |
| 24 | + data_folder = os.path.join(save_directory, f"{fname}.unzip", "series") |
| 25 | + assert os.path.exists(data_folder) |
| 26 | + return data_folder |
| 27 | + |
| 28 | + |
| 29 | +def fetch_wholeslide_example_data(save_directory): |
| 30 | + """Download the sample data for the 2d annotator. |
| 31 | +
|
| 32 | + This downloads part of a whole-slide image from the NeurIPS Cell Segmentation Challenge. |
| 33 | + See https://neurips22-cellseg.grand-challenge.org/ for details on the data. |
| 34 | + """ |
| 35 | + save_directory = Path(save_directory) |
| 36 | + os.makedirs(save_directory, exist_ok=True) |
| 37 | + print("Example data directory is:", save_directory.resolve()) |
| 38 | + fname = "whole-slide-example-image.tif" |
| 39 | + pooch.retrieve( |
| 40 | + url="https://owncloud.gwdg.de/index.php/s/6ozPtgBmAAJC1di/download", |
| 41 | + known_hash="3ddb9c9dcc844429932ab951eb0743d5a1af83ee9b0ab54f06ceb2090a606d36", |
| 42 | + fname=fname, |
| 43 | + path=save_directory, |
| 44 | + progressbar=True, |
| 45 | + ) |
| 46 | + return os.path.join(save_directory, fname) |
| 47 | + |
| 48 | + |
| 49 | +def fetch_livecell_example_data(save_directory): |
| 50 | + """Download the sample data for the 2d annotator. |
| 51 | +
|
| 52 | + This downloads a single image from the LiveCELL dataset. |
| 53 | + See https://doi.org/10.1038/s41592-021-01249-6 for details on the data. |
| 54 | + """ |
| 55 | + save_directory = Path(save_directory) |
| 56 | + os.makedirs(save_directory, exist_ok=True) |
| 57 | + print("Example data directory is:", save_directory.resolve()) |
| 58 | + fname = "livecell-2d-image.png" |
| 59 | + pooch.retrieve( |
| 60 | + url="https://owncloud.gwdg.de/index.php/s/fSaOJIOYjmFBjPM/download", |
| 61 | + known_hash="4f190983ea672fc333ac26d735d9625d5abb6e4a02bd4d32523127977a31e8fe", |
| 62 | + fname=fname, |
| 63 | + path=save_directory, |
| 64 | + progressbar=True, |
| 65 | + ) |
| 66 | + return os.path.join(save_directory, fname) |
| 67 | + |
| 68 | + |
| 69 | +def fetch_hela_2d_example_data(save_directory): |
| 70 | + """Download the sample data for the 2d annotator. |
| 71 | +
|
| 72 | + This downloads a single image from the HeLa CTC dataset. |
| 73 | + """ |
| 74 | + save_directory = Path(save_directory) |
| 75 | + os.makedirs(save_directory, exist_ok=True) |
| 76 | + print("Example data directory is:", save_directory.resolve()) |
| 77 | + fname = "hela-2d-image.png" |
| 78 | + pooch.retrieve( |
| 79 | + url="https://owncloud.gwdg.de/index.php/s/2sr1DHQ34tV7WEb/download", |
| 80 | + known_hash="908fa00e4b273610aa4e0a9c0f22dfa64a524970852f387908f3fa65238259c7", |
| 81 | + fname=fname, |
| 82 | + path=save_directory, |
| 83 | + progressbar=True, |
| 84 | + ) |
| 85 | + return os.path.join(save_directory, fname) |
| 86 | + |
| 87 | + |
| 88 | +def fetch_3d_example_data(save_directory): |
| 89 | + """Download the sample data for the 3d annotator. |
| 90 | +
|
| 91 | + This downloads the Lucchi++ datasets from https://casser.io/connectomics/. |
| 92 | + It is a dataset for mitochondria segmentation in EM. |
| 93 | + """ |
| 94 | + save_directory = Path(save_directory) |
| 95 | + os.makedirs(save_directory, exist_ok=True) |
| 96 | + print("Example data directory is:", save_directory.resolve()) |
| 97 | + unpack_filenames = [os.path.join("Lucchi++", "Test_In", f"mask{str(i).zfill(4)}.png") for i in range(165)] |
| 98 | + unpack = pooch.Unzip(members=unpack_filenames) |
| 99 | + fname = "lucchi_pp.zip" |
| 100 | + pooch.retrieve( |
| 101 | + url="http://www.casser.io/files/lucchi_pp.zip", |
| 102 | + known_hash="770ce9e98fc6f29c1b1a250c637e6c5125f2b5f1260e5a7687b55a79e2e8844d", |
| 103 | + fname=fname, |
| 104 | + path=save_directory, |
| 105 | + progressbar=True, |
| 106 | + processor=unpack, |
| 107 | + ) |
| 108 | + lucchi_dir = save_directory.joinpath(f"{fname}.unzip", "Lucchi++", "Test_In") |
| 109 | + return str(lucchi_dir) |
| 110 | + |
| 111 | + |
| 112 | +def fetch_tracking_example_data(save_directory): |
| 113 | + """Download the sample data for the tracking annotator. |
| 114 | +
|
| 115 | + This data is the cell tracking challenge dataset DIC-C2DH-HeLa. |
| 116 | + Cell tracking challenge webpage: http://data.celltrackingchallenge.net |
| 117 | + HeLa cells on a flat glass |
| 118 | + Dr. G. van Cappellen. Erasmus Medical Center, Rotterdam, The Netherlands |
| 119 | + Training dataset: http://data.celltrackingchallenge.net/training-datasets/DIC-C2DH-HeLa.zip (37 MB) |
| 120 | + Challenge dataset: http://data.celltrackingchallenge.net/challenge-datasets/DIC-C2DH-HeLa.zip (41 MB) |
| 121 | + """ |
| 122 | + save_directory = Path(save_directory) |
| 123 | + os.makedirs(save_directory, exist_ok=True) |
| 124 | + print("Example data directory is:", save_directory.resolve()) |
| 125 | + unpack_filenames = [os.path.join("DIC-C2DH-HeLa", "01", f"t{str(i).zfill(3)}.tif") for i in range(84)] |
| 126 | + unpack = pooch.Unzip(members=unpack_filenames) |
| 127 | + fname = "DIC-C2DH-HeLa.zip" |
| 128 | + pooch.retrieve( |
| 129 | + url="http://data.celltrackingchallenge.net/training-datasets/DIC-C2DH-HeLa.zip", # 37 MB |
| 130 | + known_hash="fac24746fa0ad5ddf6f27044c785edef36bfa39f7917da4ad79730a7748787af", |
| 131 | + fname=fname, |
| 132 | + path=save_directory, |
| 133 | + progressbar=True, |
| 134 | + processor=unpack, |
| 135 | + ) |
| 136 | + cell_tracking_dir = save_directory.joinpath(f"{fname}.unzip", "DIC-C2DH-HeLa", "01") |
| 137 | + assert os.path.exists(cell_tracking_dir) |
| 138 | + return str(cell_tracking_dir) |
0 commit comments