google / neuroglancer

WebGL-based viewer for volumetric data
Apache License 2.0
1.07k stars 295 forks source link

Change segment colour of SegmentationLayer linked to another SegmentationLayer with a LocalVolume #303

Closed hash-ir closed 3 years ago

hash-ir commented 3 years ago

Hi,

I am rendering organelle meshes along with the segmentation data, skeletons, and object meshes. The latter three are wrapped in a LocalVolume source inside a SegmentationLayer. Everything works fine by double-clicking an object and the similarly coloured object meshes and skeletons are rendered.

I have another SegmentationLayer that consists of a precomputed source serving organelle meshes. This layer has the linked_segmentation_layer property set to the layer above in order to have the double-clicking triggered. Besides, I am also using the segment_colors property of SegmentationLayer and assigned a fixed color to all the segment IDs. However, when I double click, each source is assigned the same colour of the object as seen in the segmentation data.

This is the code snippet:

state.layers.append(
    name='segmentation',
    layer=neuroglancer.SegmentationLayer(
        source=[
            neuroglancer.LocalVolume(
                dataset=seg_dataset,
                dimensions=dimensions,
            ),
            SkeletonSource(dimensions)
        ],
    )
)    

state.layers.append(
    name='mitochondria',
    layer=neuroglancer.SegmentationLayer(
         source='precomputed://http://127.0.0.1:8000/mi',
         segment_colors={id: '#FF0000' for id in backend.ssv_list().get('ssvs')},
         linked_segmentation_layer='segmentation',
    )
)

How do I change the workflow so that the colours are what I pass in the segment_colors property?

Thank you, Hashir

jbms commented 3 years ago

This is actually fixed in ddf4ccc098122acd22e91bb01e1062f020920cc0

The linked_segmentation_layer property on SegmentationLayer was a bug. The correct property is linked_segmentation_group.

By default, setting linked_segmentation_group will also set linked_segmentation_color_group. However, you can also set linked_segmentation_color_group = False, and then separately specify segment_colors or segment_default_color for the layer.