-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9ad6238
commit 67a6039
Showing
3 changed files
with
81 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import os | ||
from glob import glob | ||
|
||
import imageio.v3 as imageio | ||
import napari | ||
from skimage.measure import label | ||
|
||
|
||
IMAGE_ROOT = "../data/for_annotation" | ||
LABEL_ROOT = "../data/consensus_labels/automatic" | ||
OUT_ROOT = "../data/consensus_labels/proofread" | ||
|
||
|
||
def proofread_split(split, skip_proofread): | ||
image_folder = os.path.join(IMAGE_ROOT, f"split{split}") | ||
split_images = sorted(glob(os.path.join(image_folder, "*.tif"))) | ||
|
||
label_folder = os.path.join(LABEL_ROOT, f"split{split}") | ||
split_labels = sorted(glob(os.path.join(label_folder, "*.tif"))) | ||
assert len(split_images) == len(split_labels) | ||
|
||
out_folder = os.path.join(OUT_ROOT, f"split{split}") | ||
os.makedirs(out_folder, exist_ok=True) | ||
|
||
for im_path, label_path in zip(split_images, split_labels): | ||
im = imageio.imread(im_path) | ||
labels = imageio.imread(label_path) | ||
|
||
out_path = os.path.join(out_folder, os.path.basename(im_path)) | ||
if os.path.exists(out_path) and skip_proofread: | ||
print("Skipping already proof-read file", out_path) | ||
continue | ||
|
||
v = napari.Viewer() | ||
v.add_image(im) | ||
v.add_labels(labels) | ||
|
||
@v.bind_key("s") | ||
def save_labels(v): | ||
labels = v.layers["labels"].data | ||
labels = label(labels) | ||
print("Saving labels to", out_path) | ||
imageio.imwrite(out_path, labels, compression="zlib") | ||
|
||
napari.run() | ||
|
||
|
||
def main(): | ||
skip_proofread = True | ||
for split in [1, 2, 3]: | ||
proofread_split(split, skip_proofread=skip_proofread) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import os | ||
import imageio.v3 as imageio | ||
|
||
import h5py | ||
|
||
root = "" | ||
image_name = "VID532_H12_1_11d16h00m.tif" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters