Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def __init__(self):
viewer = self.viewer = neuroglancer.Viewer()
viewer.actions.add('inference', self._do_inference)
self.gt_vol = cloudvolume.CloudVolume(
'https://storage.googleapis.com/neuroglancer-public-data/flyem_fib-25/ground_truth',
mip=0,
bounded=True,
progress=False,
provenance={})
self.dimensions = neuroglancer.CoordinateSpace(
names=['x', 'y', 'z'],
units='nm',
scales=self.gt_vol.resolution,
)
self.inf_results = zarr.zeros(
self.gt_vol.bounds.to_list()[3:], chunks=(64, 64, 64), dtype=np.uint8)
self.inf_volume = neuroglancer.LocalVolume(
data=self.inf_results, dimensions=self.dimensions)
with viewer.config_state.txn() as s:
s.input_event_bindings.data_view['shift+mousedown0'] = 'inference'
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(
def __init__(self, synapse_path, top_method='min', num_top_partners=10):
with open(synapse_path, 'r') as f:
synapse_data = json.load(f)['data']
self.synapses_by_id, self.synapse_partner_counts = get_synapses_by_id(synapse_data)
self.top_method = top_method
self.num_top_partners = num_top_partners
dimensions = neuroglancer.CoordinateSpace(
names=['x', 'y', 'z'],
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',
)
def __init__(self):
viewer = self.viewer = neuroglancer.Viewer()
self.gt_vol = cloudvolume.CloudVolume(
'https://storage.googleapis.com/neuroglancer-public-data/flyem_fib-25/ground_truth',
mip=0,
bounded=True,
progress=False,
provenance={})
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
ix, iy, iz = np.meshgrid(* [np.linspace(0, 1, n) for n in a.shape[1:]], indexing='ij')
a[0, :, :, :] = np.abs(np.sin(4 * (ix + iy))) * 255
a[1, :, :, :] = np.abs(np.sin(4 * (iy + iz))) * 255
a[2, :, :, :] = np.abs(np.sin(4 * (ix + iz))) * 255
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['overlay'] = neuroglancer.ImageLayer(
source=neuroglancer.LocalVolume(
a,
dimensions=neuroglancer.CoordinateSpace(
scales=[1, 8, 8, 8],
units=['', 'nm', 'nm', 'nm'],
names=['c^', 'x', 'y', 'z']),
voxel_offset=[0, 3000, 3000, 3000]),
shader="""
void main() {
emitRGB(vec3(toNormalized(getDataValue(0)),
toNormalized(getDataValue(1)),
toNormalized(getDataValue(2))));
}
""",
)
s.voxel_coordinates = [3000, 3000, 3000]
print(viewer.state)
print(viewer)
webbrowser.open_new(viewer.get_viewer_url())
if args.bind_address:
neuroglancer.set_server_bind_address(args.bind_address)
if args.static_content_url:
neuroglancer.set_static_content_source(url=args.static_content_url)
a = np.zeros((3, 100, 100, 100), dtype=np.uint8)
ix, iy, iz = np.meshgrid(* [np.linspace(0, 1, n) for n in a.shape[1:]], indexing='ij')
a[0, :, :, :] = np.abs(np.sin(4 * (ix + iy))) * 255
a[1, :, :, :] = np.abs(np.sin(4 * (iy + iz))) * 255
a[2, :, :, :] = np.abs(np.sin(4 * (ix + iz))) * 255
b = np.cast[np.uint32](np.floor(np.sqrt((ix - 0.5)**2 + (iy - 0.5)**2 + (iz - 0.5)**2) * 10))
b = np.pad(b, 1, 'constant')
viewer = neuroglancer.Viewer()
dimensions = neuroglancer.CoordinateSpace(
names=['x', 'y', 'z'],
units='nm',
scales=[10, 10, 10])
with viewer.txn() as s:
s.dimensions = dimensions
s.layers.append(
name='a',
layer=neuroglancer.LocalVolume(
data=a,
dimensions=neuroglancer.CoordinateSpace(
names=['c^', 'x', 'y', 'z'],
units=['', 'nm','nm','nm'],
scales=[1, 10, 10, 10]),
voxel_offset=(0, 20, 30, 15),
),
shader="""
data_type=np.float32,
num_components=1,
)
def get_skeleton(self, i):
pos = np.unravel_index(i, shape, order='C')
vertex_positions = [pos, pos + np.random.randn(3) * 30]
edges = [0, 1]
return neuroglancer.skeleton.Skeleton(
vertex_positions=vertex_positions,
edges=edges,
vertex_attributes=dict(affinity=np.random.rand(2), affinity2=np.random.rand(2)))
viewer = neuroglancer.Viewer()
dimensions = neuroglancer.CoordinateSpace(
names=['x', 'y', 'z'],
units='nm',
scales=[10, 10, 10],
)
with viewer.txn() as s:
s.layers.append(
name='a',
layer=neuroglancer.SegmentationLayer(
source=[
neuroglancer.LocalVolume(
data=segmentation,
dimensions=dimensions,
),
SkeletonSource(dimensions),
],
skeleton_shader='void main() { emitRGB(colormapJet(affinity)); }',