-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
712f4c5
commit 499759f
Showing
6 changed files
with
124 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -160,4 +160,5 @@ cython_debug/ | |
#.idea/ | ||
|
||
*/node_modules/ | ||
examples/datasets | ||
examples/datasets/ | ||
datasets/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import argparse | ||
import webbrowser | ||
import neuroglancer | ||
import numpy as np | ||
import neuroglancer.cli | ||
|
||
|
||
def add_image_layer(state): | ||
shape = (40,) * 3 | ||
dimensions = neuroglancer.CoordinateSpace( | ||
names=["x", "y", "z"], units="nm", scales=[40, 40, 40] | ||
) | ||
data = np.zeros(shape=shape, dtype=np.uint8) | ||
data[:10] = 0 | ||
data[10:20] = 1 | ||
data[20:30] = 2 | ||
data[30:] = 3 | ||
local_volume = neuroglancer.LocalVolume(data, dimensions) | ||
state.layers.append( | ||
name="image", | ||
layer=neuroglancer.ImageLayer( | ||
source=local_volume, | ||
volume_rendering_mode="max", | ||
volume_rendering_depth_samples=40, | ||
), | ||
shader=""" | ||
#uicontrol invlerp normalized(range=[1,2]) | ||
void main() { | ||
emitGrayscale(normalized()); | ||
} | ||
""", | ||
) | ||
|
||
|
||
def launch_nglancer(): | ||
ap = argparse.ArgumentParser() | ||
neuroglancer.cli.add_server_arguments(ap) | ||
args = ap.parse_args() | ||
neuroglancer.cli.handle_server_arguments(args) | ||
viewer = neuroglancer.Viewer() | ||
return viewer | ||
|
||
|
||
def main(): | ||
viewer = launch_nglancer() | ||
with viewer.txn() as s: | ||
add_image_layer(s) | ||
webbrowser.open_new(viewer.get_viewer_url()) | ||
|
||
if __name__ == "__main__": | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import argparse | ||
import webbrowser | ||
import neuroglancer | ||
import numpy as np | ||
import neuroglancer.cli | ||
|
||
|
||
def add_image_layer(state): | ||
shape = (50,) * 3 | ||
dimensions = neuroglancer.CoordinateSpace( | ||
names=["x", "y", "z"], units="nm", scales=[40, 40, 40] | ||
) | ||
data = np.full(shape=shape, fill_value=255, dtype=np.uint8) | ||
local_volume = neuroglancer.LocalVolume(data, dimensions) | ||
state.layers.append( | ||
name="image", | ||
layer=neuroglancer.ImageLayer( | ||
source=local_volume, | ||
volume_rendering_mode="max", | ||
volume_rendering_depth_samples=400, | ||
), | ||
shader=""" | ||
void main() { | ||
emitIntensity(1.0); | ||
emitRGBA(vec4(1.0, 1.0, 1.0, 0.01)); | ||
} | ||
""", | ||
) | ||
state.layout = "3d" | ||
|
||
|
||
def launch_nglancer(): | ||
ap = argparse.ArgumentParser() | ||
neuroglancer.cli.add_server_arguments(ap) | ||
args = ap.parse_args() | ||
neuroglancer.cli.handle_server_arguments(args) | ||
viewer = neuroglancer.Viewer() | ||
return viewer | ||
|
||
|
||
def main(): | ||
viewer = launch_nglancer() | ||
with viewer.txn() as s: | ||
add_image_layer(s) | ||
webbrowser.open_new(viewer.get_viewer_url()) | ||
|
||
if __name__ == "__main__": | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,12 @@ | ||
from neuroglancer_utils.create_datasets.create_full_cube import create_cube | ||
from neuroglancer_utils.create_datasets.create_sphere import create_sphere | ||
from neuroglancer_utils.create_datasets.create_allen_multi import create_allen_multi | ||
from neuroglancer_utils.create_datasets.create_cdf_example import create_cdf_example | ||
from neuroglancer_utils.local_server import create_server | ||
|
||
create_cube() | ||
create_sphere() | ||
create_allen_multi() | ||
create_server(directory="datasets") | ||
create_cdf_example() | ||
input("Press enter to continue") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
from cloudvolume import CloudVolume | ||
import numpy as np | ||
|
||
|
||
def create_cdf_example(output_path="file://datasets/cdf"): | ||
shape = (40,) * 3 | ||
data = np.zeros(shape=shape, dtype=np.uint8) | ||
data[:10] = 0 | ||
data[10:20] = 1 | ||
data[20:30] = 2 | ||
data[30:] = 3 | ||
CloudVolume.from_numpy( | ||
data, | ||
vol_path=output_path, | ||
resolution=(40, 40, 40), | ||
chunk_size=(40, 40, 40), | ||
layer_type="image", | ||
progress=True, | ||
compress=False, | ||
) |