@@ -39,31 +39,34 @@ def _get_vnc_data(path, download):
39
39
40
40
with h5py .File (train_path , "w" ) as f :
41
41
_create_volume (f , "raw" , os .path .join (root , "stack1" , "raw" , "*.tif" ))
42
+ # FIXME label doesn't work here due to touching objects
42
43
_create_volume (f , "labels/mitochondria" , os .path .join (root , "stack1" , "mitochondria" , "*.png" ), process = label )
43
44
_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" ))
46
47
47
48
with h5py .File (test_path , "w" ) as f :
48
49
_create_volume (f , "raw" , os .path .join (root , "stack2" , "raw" , "*.tif" ))
49
50
50
51
rmtree (root )
51
52
52
53
53
- def get_vnc_mito_dataset (
54
+ def get_vnc_dataset (
54
55
path ,
56
+ structure ,
55
57
patch_shape ,
56
58
offsets = None ,
57
59
boundaries = False ,
58
60
binary = False ,
59
61
download = False ,
60
62
** kwargs
61
63
):
62
- """Dataset for the segmentation of mitochondria in EM.
64
+ """Dataset for the segmentation of neurons, mitochondria or synapses in EM.
63
65
64
66
This dataset is from https://doi.org/10.6084/m9.figshare.856713.v1.
65
67
Please cite it if you use this dataset for a publication.
66
68
"""
69
+ assert structure in ("mitochondria" , "synapses" , "neurons" )
67
70
_get_vnc_data (path , download )
68
71
data_path = os .path .join (path , "vnc_train.h5" )
69
72
@@ -72,12 +75,13 @@ def get_vnc_mito_dataset(
72
75
)
73
76
74
77
raw_key = "raw"
75
- label_key = "labels/mitochondria "
78
+ label_key = f "labels/{ structure } "
76
79
return torch_em .default_segmentation_dataset (data_path , raw_key , data_path , label_key , patch_shape , ** kwargs )
77
80
78
81
79
- def get_vnc_mito_loader (
82
+ def get_vnc_loader (
80
83
path ,
84
+ structure ,
81
85
patch_shape ,
82
86
batch_size ,
83
87
offsets = None ,
@@ -86,17 +90,11 @@ def get_vnc_mito_loader(
86
90
download = False ,
87
91
** kwargs
88
92
):
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 '."""
90
94
ds_kwargs , loader_kwargs = util .split_kwargs (
91
95
torch_em .default_segmentation_dataset , ** kwargs
92
96
)
93
97
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
95
99
)
96
100
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