Skip to content

Commit 1d0ada4

Browse files
Update VNC WIP
1 parent a8acdd6 commit 1d0ada4

File tree

3 files changed

+15
-17
lines changed

3 files changed

+15
-17
lines changed

scripts/datasets/check_vnc.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
from torch_em.data.datasets import get_vnc_mito_loader
1+
from torch_em.data.datasets import get_vnc_loader
22
from torch_em.util.debug import check_loader
33

44

55
def check_vnc():
6-
loader = get_vnc_mito_loader("./data/vnc", (8, 512, 512), 1, download=True)
6+
loader = get_vnc_loader("./data/vnc", "neurons", (8, 512, 512), 1, download=True)
77
check_loader(loader, 8, instance_labels=True)
88

99

torch_em/data/datasets/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,4 @@
3333
from .tissuenet import get_tissuenet_loader, get_tissuenet_dataset
3434
from .uro_cell import get_uro_cell_loader, get_uro_cell_dataset
3535
from .util import get_bioimageio_dataset_id
36-
from .vnc import get_vnc_mito_loader, get_vnc_mito_dataset
36+
from .vnc import get_vnc_loader, get_vnc_dataset

torch_em/data/datasets/vnc.py

+12-14
Original file line numberDiff line numberDiff line change
@@ -39,31 +39,34 @@ def _get_vnc_data(path, download):
3939

4040
with h5py.File(train_path, "w") as f:
4141
_create_volume(f, "raw", os.path.join(root, "stack1", "raw", "*.tif"))
42+
# FIXME label doesn't work here due to touching objects
4243
_create_volume(f, "labels/mitochondria", os.path.join(root, "stack1", "mitochondria", "*.png"), process=label)
4344
_create_volume(f, "labels/synapses", os.path.join(root, "stack1", "synapses", "*.png"), process=label)
44-
# TODO find the post-processing to go from neuron labels to membrane labels
45-
# _create_volume(f, "labels/neurons", os.path.join(root, "stack1", "membranes", "*.png"))
45+
# TODO post-processing for neurons
46+
_create_volume(f, "labels/neurons", os.path.join(root, "stack1", "membranes", "*.png"))
4647

4748
with h5py.File(test_path, "w") as f:
4849
_create_volume(f, "raw", os.path.join(root, "stack2", "raw", "*.tif"))
4950

5051
rmtree(root)
5152

5253

53-
def get_vnc_mito_dataset(
54+
def get_vnc_dataset(
5455
path,
56+
structure,
5557
patch_shape,
5658
offsets=None,
5759
boundaries=False,
5860
binary=False,
5961
download=False,
6062
**kwargs
6163
):
62-
"""Dataset for the segmentation of mitochondria in EM.
64+
"""Dataset for the segmentation of neurons, mitochondria or synapses in EM.
6365
6466
This dataset is from https://doi.org/10.6084/m9.figshare.856713.v1.
6567
Please cite it if you use this dataset for a publication.
6668
"""
69+
assert structure in ("mitochondria", "synapses", "neurons")
6770
_get_vnc_data(path, download)
6871
data_path = os.path.join(path, "vnc_train.h5")
6972

@@ -72,12 +75,13 @@ def get_vnc_mito_dataset(
7275
)
7376

7477
raw_key = "raw"
75-
label_key = "labels/mitochondria"
78+
label_key = f"labels/{structure}"
7679
return torch_em.default_segmentation_dataset(data_path, raw_key, data_path, label_key, patch_shape, **kwargs)
7780

7881

79-
def get_vnc_mito_loader(
82+
def get_vnc_loader(
8083
path,
84+
structure,
8185
patch_shape,
8286
batch_size,
8387
offsets=None,
@@ -86,17 +90,11 @@ def get_vnc_mito_loader(
8690
download=False,
8791
**kwargs
8892
):
89-
"""Dataloader for the segmentation of mitochondria in EM. See 'get_vnc_mito_loader'."""
93+
"""Dataloader for segmentation of neurons, mitochondria or synapses in EM. See 'get_vnc_dataset'."""
9094
ds_kwargs, loader_kwargs = util.split_kwargs(
9195
torch_em.default_segmentation_dataset, **kwargs
9296
)
9397
ds = get_vnc_mito_dataset(
94-
path, patch_shape, download=download, offsets=offsets, boundaries=boundaries, binary=binary, **kwargs
98+
path, structure, patch_shape, download=download, offsets=offsets, boundaries=boundaries, binary=binary, **kwargs
9599
)
96100
return torch_em.get_data_loader(ds, batch_size=batch_size, **loader_kwargs)
97-
98-
99-
# TODO implement
100-
# TODO extra kwargs for binary / boundaries / affinities
101-
def get_vnc_neuron_loader(path, patch_shape, download=False, **kwargs):
102-
raise NotImplementedError

0 commit comments

Comments
 (0)