-
Notifications
You must be signed in to change notification settings - Fork 33
/
Copy pathlabelmap.go
2999 lines (2374 loc) · 103 KB
/
labelmap.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
Package labelmap handles both volumes of label data as well as indexing to
quickly find and generate sparse volumes of any particular label. It differs
from labelmap in using in-memory label maps to greatly decrease changes
to underlying label data key-value pairs, instead handling all merges through
changes in label maps.
*/
package labelmap
import (
"bytes"
"crypto/md5"
"encoding/binary"
"encoding/gob"
"encoding/json"
"fmt"
"image"
"io/ioutil"
"net/http"
"net/url"
"os"
"strconv"
"strings"
"sync"
"github.com/janelia-flyem/dvid/datastore"
"github.com/janelia-flyem/dvid/datatype/common/labels"
"github.com/janelia-flyem/dvid/datatype/imageblk"
"github.com/janelia-flyem/dvid/dvid"
"github.com/janelia-flyem/dvid/server"
"github.com/janelia-flyem/dvid/storage"
)
const (
Version = "0.1"
RepoURL = "github.com/janelia-flyem/dvid/datatype/labelmap"
TypeName = "labelmap"
)
const helpMessage = `
API for label map data type (github.com/janelia-flyem/dvid/datatype/labelmap)
=============================================================================
Note: UUIDs referenced below are strings that may either be a unique prefix of a
hexadecimal UUID string (e.g., 3FA22) or a branch leaf specification that adds
a colon (":") followed by the case-dependent branch name. In the case of a
branch leaf specification, the unique UUID prefix just identifies the repo of
the branch, and the UUID referenced is really the leaf of the branch name.
For example, if we have a DAG with root A -> B -> C where C is the current
HEAD or leaf of the "master" (default) branch, then asking for "B:master" is
the same as asking for "C". If we add another version so A -> B -> C -> D, then
references to "B:master" now return the data from "D".
----
Denormalizations like sparse volumes are *not* performed for the "0" label, which is
considered a special label useful for designating background. This allows users to define
sparse labeled structures in a large volume without requiring processing of entire volume.
Command-line:
$ dvid repo <UUID> new labelmap <data name> <settings...>
Adds newly named data of the 'type name' to repo with specified UUID.
Example (note anisotropic resolution specified instead of default 8 nm isotropic):
$ dvid repo 3f8c new labelmap superpixels VoxelSize=3.2,3.2,40.0
Arguments:
UUID Hexadecimal string with enough characters to uniquely identify a version node.
data name Name of data to create, e.g., "superpixels"
settings Configuration settings in "key=value" format separated by spaces.
Configuration Settings (case-insensitive keys)
BlockSize Size in voxels (default: %s) Should be multiples of 16.
VoxelSize Resolution of voxels (default: 8.0, 8.0, 8.0)
VoxelUnits Resolution units (default: "nanometers")
IndexedLabels "false" if no sparse volume support is required (default "true")
MaxDownresLevel The maximum down-res level supported. Each down-res is factor of 2.
$ dvid node <UUID> <data name> load <offset> <image glob> <settings...>
Initializes version node to a set of XY label images described by glob of filenames.
The DVID server must have access to the named files. Currently, XY images are required.
Example:
$ dvid node 3f8c superpixels load 0,0,100 "data/*.png" proc=noindex
Arguments:
UUID Hexadecimal string with enough characters to uniquely identify a version node.
data name Name of data to add.
offset 3d coordinate in the format "x,y,z". Gives coordinate of top upper left voxel.
image glob Filenames of label images, preferably in quotes, e.g., "foo-xy-*.png"
$ dvid node <UUID> <data name> composite <uint8 data name> <new rgba8 data name>
Creates a RGBA8 image where the RGB is a hash of the labels and the A is the
grayscale intensity.
Example:
$ dvid node 3f8c bodies composite grayscale bodyview
Arguments:
UUID Hexadecimal string with enough characters to uniquely identify a version node.
data name Name of data to add.
$ dvid node <UUID> <data name> dump <dump type> <file path>
Dumps the internal state of the specified version of labelmap data into a space-delimted file.
The format of the space-delimted files are as follows depending on the <dump type>:
"svcount": Supervoxel counts in a space-delimted file where each block in a supervoxel has a row:
<supervoxel id> <block z> <block y> <block x> <# voxels>
"mappings": Supervoxel to agglomerated label mappings in a space-delimted file where each supervoxel has a row:
<supervoxel id> <label>
Unlike the GET /mappings endpoint, the command-line version is consistent by default and will hold lock at
possible detriment to other users.
"indices": Label indices in a space-delimted file where each supervoxel has a row with its agglomerated label:
<label> <supervoxel id> <block z> <block y> <block x> <# voxels>
Note that the last two dumps can be used by a program to ingest all but the actual voxel labels,
using the POST /mappings and POST /indices endpoints. All three dumps can be used for quality
control. Sorting can be done after the dump by the linux "sort" command:
% sort -g -k1,1 -k2,2 -k3,3 -k4,4 svcount.csv > sorted-svcount.csv
Example:
$ dvid node 3f8c segmentation dump svcount /path/to/counts.csv
Arguments:
UUID Hexadecimal string with enough characters to uniquely identify a version node.
data name Name of data to add.
dump type One of "svcount", "mappings", or "indices".
file path Absolute path to a writable file that the dvid server has write privileges to.
$ dvid node <UUID> <data name> set-nextlabel <label>
Sets the counter for new labels repo-wide for the given labelmap instance.
Note that the next label will be one more than the given label, and the given
label must be 1 or more. If label is 0, then this next label setting will
be ignored and future labels will be determined by the repo-wide max label
as is the default.
This is a dangerous command if you set the next label to a low value because
it will not check if it starts to encroach higher label values, so use with
caution.
Example:
$ dvid node 3f8c segmentation set-nextlabel 999
The next new label, for example in a cleave, will be 1000.
Arguments:
UUID Hexadecimal string with enough characters to uniquely identify a version node.
data name Name of data to add.
label A uint64 label ID
------------------
HTTP API (Level 2 REST):
POST /api/repo/{uuid}/instance
Creates a new instance of the labelmap data type. Expects configuration data in JSON
as the body of the POST. Configuration data is a JSON object with each property
corresponding to a configuration keyword for the particular data type.
JSON name/value pairs:
REQUIRED "typename" Must be "labelmap"
REQUIRED "dataname" Name of the new instance
OPTIONAL "versioned" If "false" or "0", the data is unversioned and acts as if
all UUIDs within a repo become the root repo UUID. (True by default.)
OPTIONAL "BlockSize" Size in pixels (default: 64,64,64 and should be multiples of 16)
OPTIONAL "VoxelSize" Resolution of voxels (default: 8.0,8.0,8.0)
OPTIONAL "VoxelUnits" Resolution units (default: "nanometers")
OPTIONAL "IndexedLabels" "false" if no sparse volume support is required (default "true")
OPTIONAL "MaxDownresLevel" The maximum down-res level supported. Each down-res is factor of 2.
GET <api URL>/node/<UUID>/<data name>/help
Returns data-specific help message.
GET <api URL>/node/<UUID>/<data name>/info
POST <api URL>/node/<UUID>/<data name>/info
Retrieves or puts DVID-specific data properties for these voxels.
Example:
GET <api URL>/node/3f8c/segmentation/info
Returns or posts JSON of configuration settings with the following optional fields:
"BlockSize" Size in pixels (default: 64,64,64 and should be multiples of 16)
"VoxelSize" Resolution of voxels (default: 8.0,8.0,8.0)
"VoxelUnits" Resolution units (default: "nanometers")
"MinPoint" Minimum voxel coordinate as 3d point
"MaxPoint" Maximum voxel coordinate as 3d point
"GridStore" Store identifier in TOML config file that specifies precomputed store.
"MaxDownresLevel" The maximum down-res level supported. Each down-res is factor of 2.
Arguments:
UUID Hexadecimal string with enough characters to uniquely identify a version node.
data name Name of labelmap instance.
POST <api URL>/node/<UUID>/<data name>/extents
Sets the extents for the image volume. This is primarily used when POSTing from multiple
DVID servers not sharing common metadata to a shared backend.
Extents should be in JSON in the following format:
{
"MinPoint": [0,0,0],
"MaxPoint": [300,400,500]
}
POST <api URL>/node/<UUID>/<data name>/resolution
Sets the resolution for the image volume.
Extents should be in JSON in the following format:
[8,8,8]
POST <api URL>/node/<UUID>/<data name>/sync?<options>
Establishes labelvol data instances with which the annotations are synced. Expects JSON to be POSTed
with the following format:
{ "sync": "bodies" }
To delete syncs, pass an empty string of names with query string "replace=true":
{ "sync": "" }
The "sync" property should be followed by a comma-delimited list of data instances that MUST
already exist. Currently, syncs should be created before any annotations are pushed to
the server. If annotations already exist, these are currently not synced.
The labelmap data type accepts syncs to labelvol data instances. It also accepts syncs to
labelmap instances for multiscale.
Query-string Options:
replace Set to "true" if you want passed syncs to replace and not be appended to current syncs.
Default operation is false.
GET <api URL>/node/<UUID>/<data name>/tags
POST <api URL>/node/<UUID>/<data name>/tags?<options>
GET retrieves JSON of tags for this instance.
POST appends or replaces tags provided in POST body. Expects JSON to be POSTed
with the following format:
{ "tag1": "anything you want", "tag2": "something else" }
To delete tags, pass an empty object with query string "replace=true".
POST Query-string Options:
replace Set to "true" if you want passed tags to replace and not be appended to current tags.
Default operation is false (append).
GET <api URL>/node/<UUID>/<data name>/metadata
Retrieves a JSON schema (application/vnd.dvid-nd-data+json) that describes the layout
of bytes returned for n-d images.
GET <api URL>/node/<UUID>/<data name>/specificblocks[?queryopts]
Retrieves blocks corresponding to those specified in the query string. This interface
is useful if the blocks retrieved are not consecutive or if the backend in non ordered.
Example:
GET <api URL>/node/3f8c/grayscale/specificblocks?blocks=x1,y1,z2,x2,y2,z2,x3,y3,z3
This will fetch blocks at position (x1,y1,z1), (x2,y2,z2), and (x3,y3,z3).
The returned byte stream has a list of blocks with a leading block
coordinate (3 x int32) plus int32 giving the # of bytes in this block, and then the
bytes for the value. If blocks are unset within the span, they will not appear in the stream,
so the returned data will be equal to or less than spanX blocks worth of data.
The returned data format has the following format where int32 is in little endian and the bytes
of block data have been compressed in the desired output format, according to the specification
in "compression" query string.
int32 Block 1 coordinate X (Note that this may not be starting block coordinate if it is unset.)
int32 Block 1 coordinate Y
int32 Block 1 coordinate Z
int32 # bytes for first block (N1)
byte0 Bytes of block data in compressed format.
byte1
...
byteN1
int32 Block 2 coordinate X
int32 Block 2 coordinate Y
int32 Block 2 coordinate Z
int32 # bytes for second block (N2)
byte0 Bytes of block data in compressed format.
byte1
...
byteN2
...
If a block is not available, no data will be returned for it.
Arguments:
supervoxels If "true", returns unmapped supervoxels, disregarding any kind of merges.
UUID Hexadecimal string with enough characters to uniquely identify a version node.
data name Name of labelmap instance.
Query-string Options:
blocks x,y,z... block string
scale A number from 0 up to MaxDownresLevel where each level has 1/2 resolution of
previous level. Level 0 (default) is the highest resolution.
compression Allows retrieval of block data in "lz4", "gzip", "blocks" (native DVID
label blocks), or "uncompressed" (uint64 labels). Default is "blocks".
GET <api URL>/node/<UUID>/<data name>/isotropic/<dims>/<size>/<offset>[/<format>][?queryopts]
Retrieves either 2d images (PNG by default) or 3d binary data, depending on the dims parameter.
The 3d binary data response has "Content-type" set to "application/octet-stream" and is an array of
voxel values in ZYX order (X iterates most rapidly).
Example:
GET <api URL>/node/3f8c/segmentation/isotropic/0_1/512_256/0_0_100/jpg:80
Returns an isotropic XY slice (0th and 1st dimensions) with width (x) of 512 voxels and
height (y) of 256 voxels with offset (0,0,100) in JPG format with quality 80.
Additional processing is applied based on voxel resolutions to make sure the retrieved image
has isotropic pixels. For example, if an XZ image is requested and the image volume has
X resolution 3 nm and Z resolution 40 nm, the returned image's height will be magnified 40/3
relative to the raw data.
The example offset assumes the "grayscale" data in version node "3f8c" is 3d.
The "Content-type" of the HTTP response should agree with the requested format.
For example, returned PNGs will have "Content-type" of "image/png", and returned
nD data will be "application/octet-stream".
Arguments:
UUID Hexadecimal string with enough characters to uniquely identify a version node.
data name Name of labelmap instance.
dims The axes of data extraction in form "i_j_k,..." Example: "0_2" can be XZ.
Slice strings ("xy", "xz", or "yz") are also accepted.
size Size in voxels along each dimension specified in <dims>.
offset Gives coordinate of first voxel using dimensionality of data.
format Valid formats depend on the dimensionality of the request and formats
available in server implementation.
2D: "png", "jpg" (default: "png")
jpg allows lossy quality setting, e.g., "jpg:80"
nD: uses default "octet-stream".
Query-string Options:
roi Name of roi data instance used to mask the requested data.
scale A number from 0 up to MaxDownresLevel where each level beyond 0 has 1/2 resolution
of previous level. Level 0 is the highest resolution.
compression Allows retrieval or submission of 3d data in "lz4" and "gzip"
compressed format. The 2d data will ignore this and use
the image-based codec.
throttle Only works for 3d data requests. If "true", makes sure only N compute-intense operation
(all API calls that can be throttled) are handled. If the server can't initiate the API
call right away, a 503 (Service Unavailable) status code is returned.
GET <api URL>/node/<UUID>/<data name>/raw/<dims>/<size>/<offset>[/<format>][?queryopts]
Retrieves either 2d images (PNG by default) or 3d binary data, depending on the dims parameter.
The 3d binary data response has "Content-type" set to "application/octet-stream" and is a packed
array of voxel values (little-endian uint64 per voxel) in ZYX order (X iterates most rapidly).
Example:
GET <api URL>/node/3f8c/segmentation/raw/0_1/512_256/0_0_100/jpg:80
Returns a raw XY slice (0th and 1st dimensions) with width (x) of 512 voxels and
height (y) of 256 voxels with offset (0,0,100) in JPG format with quality 80.
By "raw", we mean that no additional processing is applied based on voxel
resolutions to make sure the retrieved image has isotropic pixels.
The example offset assumes the "grayscale" data in version node "3f8c" is 3d.
The "Content-type" of the HTTP response should agree with the requested format.
For example, returned PNGs will have "Content-type" of "image/png", and returned
nD data will be "application/octet-stream".
Arguments:
UUID Hexadecimal string with enough characters to uniquely identify a version node.
data name Name of labelmap instance.
dims The axes of data extraction in form "i_j_k,..."
Slice strings ("xy", "xz", or "yz") are also accepted.
Example: "0_2" is XZ, and "0_1_2" is a 3d subvolume.
size Size in voxels along each dimension specified in <dims>.
offset Gives coordinate of first voxel using dimensionality of data.
format Valid formats depend on the dimensionality of the request and formats
available in server implementation.
2D: "png", "jpg" (default: "png")
jpg allows lossy quality setting, e.g., "jpg:80"
nD: uses default "octet-stream".
Query-string Options:
supervoxels If "true", returns unmapped supervoxels, disregarding any kind of merges.
roi Name of roi data instance used to mask the requested data.
scale A number from 0 up to MaxDownresLevel where each level beyond 0 has 1/2 resolution
of previous level. Level 0 is the highest resolution.
compression Allows retrieval or submission of 3d data in "lz4","gzip", "google"
(neuroglancer compression format), "googlegzip" (google + gzip)
compressed format. The 2d data will ignore this and use
the image-based codec.
throttle Only works for 3d data requests. If "true", makes sure only N compute-intense operation
(all API calls that can be throttled) are handled. If the server can't initiate the API
call right away, a 503 (Service Unavailable) status code is returned.
POST <api URL>/node/<UUID>/<data name>/raw/0_1_2/<size>/<offset>[?queryopts]
Ingests block-aligned supervoxel data using the block sizes defined for this data instance.
For example, if the BlockSize = 32, offset and size must be multiples of 32.
The POST body should be a packed array of voxel values (little-endian uint64 per voxel) in ZYX order
(X iterates most rapidly).
Example:
POST <api URL>/node/3f8c/segmentation/raw/0_1_2/512_256_128/0_0_32
Arguments:
UUID Hexadecimal string with enough characters to uniquely identify a version node.
data name Name of labelmap instance.
size Size in voxels along each dimension specified in <dims>.
offset Gives coordinate of first voxel using dimensionality of data.
Query-string Options:
roi Name of roi data instance used to mask the requested data.
compression Allows retrieval or submission of 3d data in "lz4" and "gzip"
compressed format.
throttle If "true", makes sure only N compute-intense operation (all API calls that can
be throttled) are handled. If the server can't initiate the API call right away,
a 503 (Service Unavailable) status code is returned.
GET <api URL>/node/<UUID>/<data name>/pseudocolor/<dims>/<size>/<offset>[?queryopts]
Retrieves label data as pseudocolored 2D PNG color images where each label hashed to a different RGB.
Example:
GET <api URL>/node/3f8c/segmentation/pseudocolor/0_1/512_256/0_0_100
Returns an XY slice (0th and 1st dimensions) with width (x) of 512 voxels and
height (y) of 256 voxels with offset (0,0,100) in PNG format.
Arguments:
UUID Hexadecimal string with enough characters to uniquely identify a version node.
data name Name of labelmap instance.
dims The axes of data extraction. Example: "0_2" can be XZ.
Slice strings ("xy", "xz", or "yz") are also accepted.
size Size in voxels along each dimension specified in <dims>.
offset Gives coordinate of first voxel using dimensionality of data.
Query-string Options:
roi Name of roi data instance used to mask the requested data.
compression Allows retrieval or submission of 3d data in "lz4" and "gzip"
compressed format.
throttle If "true", makes sure only N compute-intense operation (all API calls that can be throttled)
are handled. If the server can't initiate the API call right away, a 503 (Service Unavailable)
status code is returned.
GET <api URL>/node/<UUID>/<data name>/label/<coord>[?queryopts]
Returns JSON for the label at the given coordinate:
{ "Label": 23 }
Arguments:
UUID Hexadecimal string with enough characters to uniquely identify a version node.
data name Name of labelmap instance.
coord Coordinate of voxel with underscore as separator, e.g., 10_20_30
Query-string Options:
supervoxels If "true", returns unmapped supervoxel label, disregarding any kind of merges.
scale A number from 0 up to MaxDownresLevel where each level beyond 0 has 1/2 resolution
of previous level. Level 0 is the highest resolution.
GET <api URL>/node/<UUID>/<data name>/labels[?queryopts]
Returns JSON for the labels at a list of coordinates. Expects JSON in GET body:
[ [x0, y0, z0], [x1, y1, z1], ...]
Returns for each POSTed coordinate the corresponding label:
[ 23, 911, ...]
Arguments:
UUID Hexadecimal string with enough characters to uniquely identify a version node.
data name Name of label data.
Query-string Options:
supervoxels If "true", returns unmapped supervoxel label, disregarding any kind of merges.
scale A number from 0 up to MaxDownresLevel where each level beyond 0 has 1/2 resolution
of previous level. Level 0 is the highest resolution.
hash MD5 hash of request body content in hexadecimal string format.
GET <api URL>/node/<UUID>/<data name>/mapping[?queryopts]
Returns JSON for mapped uint64 identifiers (labels). The mapping holds not only the
unique IDs of supervoxels but also newly created IDs for renumbered & cleaved bodies
that will never overlap with supervoxel IDs.
Expects JSON in GET body:
[ label1, label2, label3, ...]
Returns for each POSTed label the corresponding mapped label:
[ 23, 0, 911, ...]
The mapped label can be 0 in the following circumstances:
* The label was a supervoxel ID that was split into two different unique IDs.
* The label is used for a newly generated ID that will be a new renumbered label.
* The label is used for a newly generated ID that will represent a cleaved body ID.
Arguments:
UUID Hexadecimal string with enough characters to uniquely identify a version node.
data name Name of label data.
Query-string Options:
nolookup if "true", dvid won't verify that a supervoxel actually exists by looking up
the label indices. Only use this if supervoxels were known to exist at some time.
hash MD5 hash of request body content in hexadecimal string format.
GET <api URL>/node/<UUID>/<data name>/supervoxel-splits
Returns JSON for all supervoxel splits that have occurred up to this version of the
labelmap instance. The returned JSON is of format:
[
"abc123",
[[<mutid>, <old>, <remain>, <split>],
[<mutid>, <old>, <remain>, <split>],
[<mutid>, <old>, <remain>, <split>]],
"bcd234",
[[<mutid>, <old>, <remain>, <split>],
[<mutid>, <old>, <remain>, <split>],
[<mutid>, <old>, <remain>, <split>]]
]
The UUID examples above, "abc123" and "bcd234", would be full UUID strings and are in order
of proximity to the given UUID. So the first UUID would be the version of interest, then
its parent, and so on.
Arguments:
UUID Hexadecimal string with enough characters to uniquely identify a version node.
data name Name of label data.
GET <api URL>/node/<UUID>/<data name>/blocks/<size>/<offset>[?queryopts]
Gets blocks corresponding to the extents specified by the size and offset. The
subvolume request must be block aligned. This is the most server-efficient way of
retrieving the labelmap data, where data read from the underlying storage engine is
written directly to the HTTP connection possibly after recompression to match the given
query-string compression option. The default labelmap compression
is gzip on compressed DVID label Block serialization ("blocks" option).
Example:
GET <api URL>/node/3f8c/segmentation/blocks/64_64_64/0_0_0
If block size is 32x32x32, this call retrieves up to 8 blocks where the first potential
block is at 0, 0, 0. The returned byte stream has a list of blocks with a leading block
coordinate (3 x int32) plus int32 giving the # of bytes in this block, and then the
bytes for the value. If blocks are unset within the span, they will not appear in the stream,
so the returned data will be equal to or less than spanX blocks worth of data.
The returned data format has the following format where int32 is in little endian and the
bytes of block data have been compressed in the desired output format.
int32 Block 1 coordinate X (Note that this may not be starting block coordinate if it is unset.)
int32 Block 1 coordinate Y
int32 Block 1 coordinate Z
int32 # bytes for first block (N1)
byte0 Block N1 serialization using chosen compression format (see "compression" option below)
byte1
...
byteN1
int32 Block 2 coordinate X
int32 Block 2 coordinate Y
int32 Block 2 coordinate Z
int32 # bytes for second block (N2)
byte0 Block N2 serialization using chosen compression format (see "compression" option below)
byte1
...
byteN2
...
If a block is not available, no data will be returned for it.
Arguments:
UUID Hexadecimal string with enough characters to uniquely identify a version node.
data name Name of data to add.
size Size in voxels along each dimension specified in <dims>.
offset Gives coordinate of first voxel using dimensionality of data.
Query-string Options:
supervoxels If "true", returns unmapped supervoxels, disregarding any kind of merges.
scale A number from 0 up to MaxDownresLevel where each level beyond 0 has 1/2 resolution
of previous level. Level 0 is the highest resolution.
compression Allows retrieval of block data in "lz4" (default), "gzip", blocks" (native DVID
label blocks) or "uncompressed" (uint64 labels).
throttle If "true", makes sure only N compute-intense operation (all API calls that can be
throttled) are handled. If the server can't initiate the API call right away, a 503
(Service Unavailable) status code is returned.
POST <api URL>/node/<UUID>/<data name>/blocks[?queryopts]
Puts properly-sized supervoxel block data. This is the most server-efficient way of
storing labelmap data if you want DVID to also handle indexing and downres computation.
If you are calculating indices and downres supervoxel blocks offline for ingesting into
DVID, use the "POST /ingest-supervoxels" endpoint, since it is even faster.
It's suggested that downres supervoxel blocks should be calculated outside DVID and then
ingested for anything larger than small (Gigavoxel) volumes. Currently, the downres computation
is not robust for non-cubic chunk sizes and because this endpoint must consider parallel
requests using overlapping blocks, a mutex is employed that limits the overall throughput.
Still data read from the HTTP stream is written directly to the underlying storage. The
default (and currently only supported) compression is gzip on compressed DVID label Block
serialization.
Note that maximum label and extents are automatically handled during these calls.
If the optional "scale" query is greater than 0, these ingestions will not trigger
syncing with associated annotations, etc.
Example:
POST <api URL>/node/3f8c/segmentation/blocks
The posted data format should be in the following format where int32 is in little endian and
the bytes of block data have been compressed in the desired output format.
int32 Block 1 coordinate X (Note that this may not be starting block coordinate if it is unset.)
int32 Block 1 coordinate Y
int32 Block 1 coordinate Z
int32 # bytes for first block (N1)
byte0 Block N1 serialization using chosen compression format (see "compression" option below)
byte1
...
byteN1
int32 Block 2 coordinate X
int32 Block 2 coordinate Y
int32 Block 2 coordinate Z
int32 # bytes for second block (N2)
byte0 Block N2 serialization using chosen compression format (see "compression" option below)
byte1
...
byteN2
...
The Block serialization format is as follows:
3 * uint32 values of gx, gy, and gz
uint32 # of labels (N), cannot exceed uint32.
N * uint64 packed labels in little-endian format. Label 0 can be used to represent
deleted labels, e.g., after a merge operation to avoid changing all
sub-block indices.
----- Data below is only included if N > 1, otherwise it is a solid block.
Nsb = # sub-blocks = gx * gy * gz
Nsb * uint16 # of labels for sub-blocks. Each uint16 Ns[i] = # labels for sub-block i.
If Ns[i] == 0, the sub-block has no data (uninitialized), which
is useful for constructing Blocks with sparse data.
Nsb * Ns * uint32 label indices for sub-blocks where Ns = sum of Ns[i] over all sub-blocks.
For each sub-block i, we have Ns[i] label indices of lBits.
Nsb * values sub-block indices for each voxel.
Data encompasses 512 * ceil(log2(Ns[i])) bits, padded so no two
sub-blocks have indices in the same byte.
At most we use 9 bits per voxel for up to the 512 labels in sub-block.
A value gives the sub-block index which points to the index into
the N labels. If Ns[i] <= 1, there are no values. If Ns[i] = 0,
the 8x8x8 voxels are set to label 0. If Ns[i] = 1, all voxels
are the given label index.
Arguments:
UUID Hexadecimal string with enough characters to uniquely identify a version node.
data name Name of data to add.
Query-string Options:
scale A number from 0 up to MaxDownresLevel where each level beyond 0 has 1/2 resolution
of previous level. Level 0 is the highest resolution.
downres "false" (default) or "true", specifies whether the given blocks should be
down-sampled to lower resolution. If "true", scale must be "0" or absent.
compression Specifies compression format of block data: default and only option currently is
"blocks" (native DVID label blocks).
noindexing If "true" (default "false"), will not compute label indices from the received voxel data.
Use this in conjunction with POST /index and /affinities endpoint for faster ingestion.
throttle If "true", makes sure only N compute-intense operation (all API calls that can be
throttled) are handled. If the server can't initiate the API call right away, a 503
(Service Unavailable) status code is returned.
POST <api URL>/node/<UUID>/<data name>/ingest-supervoxels[?queryopts]
Ingests properly-sized supervoxel block data under the assumption that parallel calls to this
endpoint do not use overlapping blocks. This is the most server-efficient way of storing labelmap data,
where data read from the HTTP stream is written directly to the underlying storage. The default
(and currently only supported) compression is gzip on compressed DVID label Block serialization.
Unlike the "POST /blocks" endpoint, this endpoint assumes that the following operations will be done separately:
* label indexing
* syncing to other instances (e.g., annotations)
* calculation and POST /maxlabel
* calculation and POST /extents
* downres calculations of different scales and the POST of the downres supervoxel block data.
This endpoint maximizes write throughput and assumes parallel POST requests will not use overlapping blocks.
No goroutines are spawned so the number of write goroutines is directly related to the number of parallel
calls to this endpoint.
Example:
POST <api URL>/node/3f8c/segmentation/ingest-supervoxels?scale=1
The posted data format should be in the following format where int32 is in little endian and
the bytes of block data have been compressed in the desired output format.
int32 Block 1 coordinate X (Note that this may not be starting block coordinate if it is unset.)
int32 Block 1 coordinate Y
int32 Block 1 coordinate Z
int32 # bytes for first block (N1)
byte0 Block N1 serialization using chosen compression format (see "compression" option below)
byte1
...
byteN1
int32 Block 2 coordinate X
int32 Block 2 coordinate Y
int32 Block 2 coordinate Z
int32 # bytes for second block (N2)
byte0 Block N2 serialization using chosen compression format (see "compression" option below)
byte1
...
byteN2
...
The Block serialization format is as follows:
3 * uint32 values of gx, gy, and gz
uint32 # of labels (N), cannot exceed uint32.
N * uint64 packed labels in little-endian format. Label 0 can be used to represent
deleted labels, e.g., after a merge operation to avoid changing all
sub-block indices.
----- Data below is only included if N > 1, otherwise it is a solid block.
Nsb = # sub-blocks = gx * gy * gz
Nsb * uint16 # of labels for sub-blocks. Each uint16 Ns[i] = # labels for sub-block i.
If Ns[i] == 0, the sub-block has no data (uninitialized), which
is useful for constructing Blocks with sparse data.
Nsb * Ns * uint32 label indices for sub-blocks where Ns = sum of Ns[i] over all sub-blocks.
For each sub-block i, we have Ns[i] label indices of lBits.
Nsb * values sub-block indices for each voxel.
Data encompasses 512 * ceil(log2(Ns[i])) bits, padded so no two
sub-blocks have indices in the same byte.
At most we use 9 bits per voxel for up to the 512 labels in sub-block.
A value gives the sub-block index which points to the index into
the N labels. If Ns[i] <= 1, there are no values. If Ns[i] = 0,
the 8x8x8 voxels are set to label 0. If Ns[i] = 1, all voxels
are the given label index.
Arguments:
UUID Hexadecimal string with enough characters to uniquely identify a version node.
data name Name of data to add.
Query-string Options:
scale A number from 0 up to MaxDownresLevel where each level beyond 0 has 1/2 resolution
of previous level. Level 0 (default) is the highest resolution.
GET <api URL>/node/<UUID>/<data name>/maxlabel
GET returns the maximum label for the version of data in JSON form:
{ "maxlabel": <label #> }
POST <api URL>/node/<UUID>/<data name>/maxlabel/<max label>
Sets the maximum label for the version of data specified by the UUID. This maximum label will be
ignored if it is not greater than the current maximum label. This value is purely informative
(i.e., not used for establishing new labels on split) and can be used to distinguish new labels
in remote stores that may collide with local ones.
If Kafka is enabled, a log message will be posted:
{
"Action": "post-maxlabel",
"Max Label": label,
"UUID": uuid,
"Timestamp": time.Now().String(),
}
GET <api URL>/node/<UUID>/<data name>/nextlabel
GET returns what would be a new label for the version of data in JSON form assuming the version
has not been committed:
{ "nextlabel": <label #> }
POST <api URL>/node/<UUID>/<data name>/nextlabel/<desired # of labels>
POST allows the client to request some # of labels that will be reserved.
This is used if the client wants to introduce new labels.
Response:
{ "start": <starting label #>, "end": <ending label #> }
Unlike POST /maxlabel, which can set the maximum label arbitrarily high, this
endpoint gives incremental new label ids.
If Kafka is enabled, a log message will be posted:
{
"Action": "post-nextlabel",
"Start Label": start,
"End Label": end,
"UUID": uuid,
"Timestamp": time.Now().String(),
}
POST <api URL>/node/<UUID>/<data name>/set-nextlabel/<label>
POST allows the client to request some # of labels that will be reserved.
This is used if the client wants to introduce new labels.
Returns status code 200 (OK) if the next label was successfully set.
If Kafka is enabled, a log message will be posted:
{
"Action": "post-setnextlabel",
"Label": label,
"UUID": uuid,
"Timestamp": time.Now().String(),
}
-------------------------------------------------------------------------------------------------------
--- The following endpoints require the labelmap data instance to have IndexedLabels set to true. ---
-------------------------------------------------------------------------------------------------------
GET <api URL>/node/<UUID>/<data name>/lastmod/<label>
Returns last modification metadata for a label in JSON:
{ "mutation id": 2314, "last mod user": "johndoe", "last mod time": "2000-02-01 12:13:14 +0000 UTC", "last mod app": "Neu3" }
Time is returned in RFC3339 string format. Returns a status code 404 (Not Found)
if label does not exist.
Arguments:
UUID Hexadecimal string with enough characters to uniquely identify a version node.
data name Name of labelmap instance.
label A 64-bit integer label id
GET <api URL>/node/<UUID>/<data name>/supervoxels/<label>
Returns JSON for the supervoxels that have been agglomerated into the given label:
[ 23, 911, ...]
Returns a status code 404 (Not Found) if label does not exist.
Arguments:
UUID Hexadecimal string with enough characters to uniquely identify a version node.
data name Name of labelmap instance.
label A 64-bit integer label id
GET <api URL>/node/<UUID>/<data name>/size/<label>[?supervoxels=true]
Returns the size in voxels for the given label (or supervoxel) in JSON:
{ "voxels": 2314 }
Returns a status code 404 (Not Found) if label does not exist.
Arguments:
UUID Hexadecimal string with enough characters to uniquely identify a version node.
data name Name of labelmap instance.
label A 64-bit integer label id
Query-string Options:
supervoxels If "true", interprets the given label as a supervoxel id, not a possibly merged label.
GET <api URL>/node/<UUID>/<data name>/sizes[?supervoxels=true]
Returns the sizes in voxels for a list of labels (or supervoxels) in JSON. Expects JSON
for the list of labels (or supervoxels) in the body of the request:
[ 1, 2, 3, ... ]
Returns JSON of the sizes for each of the above labels:
[ 19381, 308, 586, ... ]
Returns a size of 0 if label does not exist.
Arguments:
UUID Hexadecimal string with enough characters to uniquely identify a version node.
data name Name of labelmap instance.
Query-string Options:
supervoxels If "true", interprets the given labels as a supervoxel ids.
hash MD5 hash of request body content in hexadecimal string format.
GET <api URL>/node/<UUID>/<data name>/supervoxel-sizes/<label>
Returns the supervoxels and their sizes for the given label in JSON.
Although the position in the lists will match supervoxel label and size,
the supervoxels may not be ordered:
{
"supervoxels": [1,2,4,3,...],
"sizes": [100,200,400,300,...]
}
Returns a status code 404 (Not Found) if label does not exist.
Arguments:
UUID Hexadecimal string with enough characters to uniquely identify a version node.
data name Name of labelmap instance.
label A 64-bit integer label id
GET <api URL>/node/<UUID>/<data name>/sparsevol-size/<label>[?supervoxels=true]
Returns JSON giving the number of voxels, number of native blocks and the coarse bounding box in DVID
coordinates (voxel space):
{ "voxels": 231387, numblocks": 1081, "minvoxel": [0, 11, 23], "maxvoxel": [1723, 1279, 4855]}
Returns a status code 404 (Not Found) if label does not exist.
Note that the minvoxel and maxvoxel coordinates are voxel coordinates that are
accurate to the block, not the voxel.
Query-string Options:
supervoxels If "true", interprets the given label as a supervoxel id, not a possibly merged label.
GET <api URL>/node/<UUID>/<data name>/sparsevol/<label>?<options>
Returns a sparse volume with voxels of the given label in encoded RLE format. The returned
data can be optionally compressed using the "compression" option below.
Returns a status code 404 (Not Found) if label does not exist.
The encoding has the following possible format where integers are little endian and the order