Exemplo n.º 1
0
def test_maxlabel_and_friends(labelmap_setup):
    dvid_server, dvid_repo, _merge_table_path, _mapping_path, _supervoxel_vol = labelmap_setup

    # Need an unlocked node to test these posts
    uuid = post_branch(dvid_server, dvid_repo, 'test_maxlabel_and_friends',
                       'test_maxlabel_and_friends')
    instance_info = (dvid_server, uuid, 'segmentation-scratch')

    max_label = fetch_maxlabel(*instance_info)
    next_label = fetch_nextlabel(*instance_info)
    assert max_label + 1 == next_label

    start, end = post_nextlabel(*instance_info, 5)
    assert start == max_label + 1
    assert end == start + 5 - 1

    max_label = fetch_maxlabel(*instance_info)
    next_label = fetch_nextlabel(*instance_info)
    assert next_label == max_label + 1 == end + 1

    new_max = next_label + 10
    post_maxlabel(*instance_info, new_max)

    max_label = fetch_maxlabel(*instance_info)
    assert max_label == new_max

    next_label = fetch_nextlabel(*instance_info)
    assert max_label + 1 == next_label
Exemplo n.º 2
0
    def determine_next_label(self, num_new_labels, orig_maxes):
        """
        Given a number of new labels we need to use for relabeling the volume,
        determine the first available label value we can use.
        
        In the case of DVID volumes, reserve the number of labels we need
        from the server (unless the user has overridden this via orig-max-label).
        
        If there is no user-specified value, and the output is not a DVID volume,
        Evaluate the given orig_maxes (a dask Bag), which were obtained from the
        input data, and use it to determine the next available label.
        """
        user_specified_max = self.config["connectedcomponents"]["orig-max-label"]
        if user_specified_max:
            next_label = user_specified_max+1
        
        elif isinstance(self.output_service.base_service, DvidVolumeService):
            server, uuid, instance = self.output_service.base_service.instance_triple

            # If the original maxlabel is less than one of values we'll be writing,
            # advance the instance to the new max before reserving yet more labels,
            # for our new segments.
            orig_max = orig_maxes.max().compute()
            maxlabel_output = fetch_maxlabel(server, uuid, instance)
            
            if maxlabel_output < orig_max:
                post_maxlabel(server, uuid, instance, maxlabel_output)
            
            # Now reserve new labels for our new fragments, which we'll be writing next.
            next_label, last_label = post_nextlabel(server, uuid, instance, num_new_labels)
            assert last_label+1 - next_label == num_new_labels

        else:
            next_label = orig_maxes.max().compute() + 1

        return np.uint64(next_label)
Exemplo n.º 3
0
def test_fetch_maxlabel(labelmap_setup):
    dvid_server, dvid_repo, _merge_table_path, _mapping_path, _supervoxel_vol = labelmap_setup
    maxlabel = fetch_maxlabel(dvid_server, dvid_repo, 'segmentation')
    assert maxlabel == 5