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,
def set_state_index(self, index):
self._grab_viewer_state()
self.state_index = index
if index is None:
self.viewer.set_state(neuroglancer.ViewerState())
else:
self.viewer.set_state(self.states[index])
other_ids = self.other_state_segment_ids
other_ids.clear()
other_ids[0] = -1
for i, state in enumerate(self.states):
if i == self.state_index:
continue
for x in self.get_state_segment_ids(state):
other_ids[x] = i
self.update_message()
def load(self):
if not os.path.exists(self.filename):
return False
self.state_index = None
with open(self.filename, 'r') as f:
loaded_state = decode_json(f.read())
self.states = [neuroglancer.ViewerState(x) for x in loaded_state['states']]
self.set_state_index(loaded_state['state_index'])
return True
def add_segments_from_state(self, base_state):
if isinstance(base_state, basestring):
base_state = neuroglancer.parse_url(base_state)
elif isinstance(base_state, dict):
base_state = neuroglancer.ViewerState(base_state)
segment_ids = self.get_state_segment_ids(base_state)
existing_segment_ids = self.get_existing_segment_ids()
for segment_id in segment_ids:
if segment_id in existing_segment_ids:
print('Skipping redundant segment id %d' % segment_id)
continue
self.states.append(self.make_initial_state(segment_id, base_state))
if self.state_index is None:
self.next_state()