Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def display_split_result(graph, agglo_id, cur_eqs, supervoxel_map, split_seeds, image_url,
segmentation_url):
agglo_members = set(graph.get_agglo_members(agglo_id))
state = neuroglancer.ViewerState()
state.layers.append(name='image', layer=neuroglancer.ImageLayer(source=image_url))
state.layers.append(
name='original',
layer=neuroglancer.SegmentationLayer(
source=segmentation_url,
segments=agglo_members,
),
visible=False,
)
state.layers.append(
name='isolated-supervoxels',
layer=neuroglancer.SegmentationLayer(
source=segmentation_url,
segments=set(x for x, seeds in six.viewitems(supervoxel_map) if len(seeds) > 1),
),
visible=False,
)
state.layers.append(
name='split',
layer=neuroglancer.SegmentationLayer(
s.layers.append(
name='original',
layer=neuroglancer.SegmentationLayer(
source=self.segmentation_url,
segments=self.agglo_members,
),
)
s.layers.append(
name='unused',
layer=neuroglancer.SegmentationLayer(source=self.segmentation_url,
),
visible=False,
)
s.layers.append(
name='split-result',
layer=neuroglancer.SegmentationLayer(
source=self.segmentation_url,
segments=self.agglo_members,
),
)
s.concurrent_downloads = 256
self._update_state(s)
with viewer.config_state.txn() as s:
s.status_messages['help'] = ('KEYS: ' + ' | '.join('%s=%s' % (key, command)
for key, command in key_bindings))
for key, command in key_bindings:
s.input_event_bindings.viewer[key] = command
s.input_event_bindings.slice_view[key] = command
s.input_event_bindings.perspective_view[key] = command
self._update_config_state(s)
viewer.actions.add('start-fill', self._start_fill_action)
viewer.actions.add('stop-fill', self._stop_fill_action)
self.dimensions = neuroglancer.CoordinateSpace(
names=['x', 'y', 'z'],
units='nm',
scales=[8, 8, 8],
)
with viewer.config_state.txn() as s:
s.input_event_bindings.data_view['shift+mousedown0'] = 'start-fill'
s.input_event_bindings.data_view['keyt'] = 'stop-fill'
with viewer.txn() as s:
s.layers['image'] = neuroglancer.ImageLayer(
source='precomputed://gs://neuroglancer-public-data/flyem_fib-25/image',
)
s.layers['ground_truth'] = neuroglancer.SegmentationLayer(
source='precomputed://gs://neuroglancer-public-data/flyem_fib-25/ground_truth',
)
s.layers['ground_truth'].visible = False
self.flood_fill_event = None
def __init__(self, state_path, bodies, labels, segmentation_url, image_url, num_to_prefetch):
self.state = State(state_path)
self.num_to_prefetch = num_to_prefetch
self.viewer = neuroglancer.Viewer()
self.bodies = bodies
self.state.load()
self.total_voxels = sum(x.num_voxels for x in bodies)
self.cumulative_voxels = np.cumsum([x.num_voxels for x in bodies])
with self.viewer.txn() as s:
s.layers['image'] = neuroglancer.ImageLayer(source=image_url)
s.layers['segmentation'] = neuroglancer.SegmentationLayer(source=segmentation_url)
s.show_slices = False
s.concurrent_downloads = 256
s.gpu_memory_limit = 2 * 1024 * 1024 * 1024
s.layout = '3d'
key_bindings = [
['bracketleft', 'prev-index'],
['bracketright', 'next-index'],
['home', 'first-index'],
['end', 'last-index'],
['control+keys', 'save'],
]
label_keys = ['keyd', 'keyf', 'keyg', 'keyh']
for label, label_key in zip(labels, label_keys):
key_bindings.append([label_key, 'label-%s' % label])
source=segmentation_url,
segments=agglo_members,
),
visible=False,
)
state.layers.append(
name='isolated-supervoxels',
layer=neuroglancer.SegmentationLayer(
source=segmentation_url,
segments=set(x for x, seeds in six.viewitems(supervoxel_map) if len(seeds) > 1),
),
visible=False,
)
state.layers.append(
name='split',
layer=neuroglancer.SegmentationLayer(
source=segmentation_url,
equivalences=cur_eqs,
segments=set(cur_eqs[x] for x in agglo_members),
))
for label, component in six.viewitems(split_seeds):
state.layers.append(
name='seed%d' % label,
layer=neuroglancer.PointAnnotationLayer(
points=[seed['position'] for seed in component],
),
)
state.show_slices = False
state.layout = '3d'
all_seed_points = [
seed['position'] for component in six.viewvalues(split_seeds) for seed in component
self.viewer.actions.add('prev-batch', lambda s: self.prev_batch())
with self.viewer.config_state.txn() as s:
s.input_event_bindings.viewer['keyj'] = 'next-batch'
s.input_event_bindings.viewer['keyk'] = 'prev-batch'
s.input_event_bindings.viewer['keyc'] = 'add-ccs'
s.input_event_bindings.viewer['keya'] = 'clear-splits'
s.input_event_bindings.viewer['keym'] = 'merge-segments'
s.input_event_bindings.viewer['bracketleft'] = 'split-dec'
s.input_event_bindings.viewer['bracketright'] = 'split-inc'
s.input_event_bindings.viewer['keys'] = 'accept-split'
s.input_event_bindings.data_view['shift+mousedown0'] = 'add-split'
s.input_event_bindings.viewer['keyv'] = 'mark-bad'
with self.viewer.txn() as s:
s.layers['split'] = neuroglancer.SegmentationLayer(
source=s.layers['seg'].source)
s.layers['split'].visible = False
units='nm',
scales=[8, 8, 8],
)
viewer = self.viewer = neuroglancer.Viewer()
viewer.actions.add('select-custom', self._handle_select)
with viewer.config_state.txn() as s:
s.input_event_bindings.data_view['dblclick0'] = 'select-custom'
with viewer.txn() as s:
s.projection_orientation = [0.63240087, 0.01582051, 0.05692779, 0.77238464]
s.dimensions = dimensions
s.position = [3000, 3000, 3000]
s.layers['image'] = neuroglancer.ImageLayer(
source='precomputed://gs://neuroglancer-public-data/flyem_fib-25/image',
)
s.layers['ground_truth'] = neuroglancer.SegmentationLayer(
source='precomputed://gs://neuroglancer-public-data/flyem_fib-25/ground_truth',
)
s.layers['partners'] = neuroglancer.SegmentationLayer(
source='precomputed://gs://neuroglancer-public-data/flyem_fib-25/ground_truth',
)
s.layers['synapses'] = neuroglancer.LocalAnnotationLayer(
dimensions=dimensions,
linked_segmentation_layer='ground_truth')
s.layout = neuroglancer.row_layout([
neuroglancer.LayerGroupViewer(
layout='xy',
layers=['image', 'ground_truth', 'partners', 'synapses'],
),
neuroglancer.LayerGroupViewer(
layout='3d',
layers=['ground_truth', 'synapses'],
viewer = self.viewer = neuroglancer.Viewer()
viewer.actions.add('select-custom', self._handle_select)
with viewer.config_state.txn() as s:
s.input_event_bindings.data_view['dblclick0'] = 'select-custom'
with viewer.txn() as s:
s.projection_orientation = [0.63240087, 0.01582051, 0.05692779, 0.77238464]
s.dimensions = dimensions
s.position = [3000, 3000, 3000]
s.layers['image'] = neuroglancer.ImageLayer(
source='precomputed://gs://neuroglancer-public-data/flyem_fib-25/image',
)
s.layers['ground_truth'] = neuroglancer.SegmentationLayer(
source='precomputed://gs://neuroglancer-public-data/flyem_fib-25/ground_truth',
)
s.layers['partners'] = neuroglancer.SegmentationLayer(
source='precomputed://gs://neuroglancer-public-data/flyem_fib-25/ground_truth',
)
s.layers['synapses'] = neuroglancer.LocalAnnotationLayer(
dimensions=dimensions,
linked_segmentation_layer='ground_truth')
s.layout = neuroglancer.row_layout([
neuroglancer.LayerGroupViewer(
layout='xy',
layers=['image', 'ground_truth', 'partners', 'synapses'],
),
neuroglancer.LayerGroupViewer(
layout='3d',
layers=['ground_truth', 'synapses'],
),
neuroglancer.LayerGroupViewer(
layout='3d',