forked from google/neuroglancer
-
Notifications
You must be signed in to change notification settings - Fork 10
local Precomputed
Ignacio Tartavull edited this page Jun 16, 2017
·
10 revisions
Create a local layer by modifying this script
import numpy as np
from neuroglancer.pipeline import Storage, Precomputed
from neuroglancer.pipeline.task_creation import (upload_build_chunks,
create_info_file_from_build,
MockTaskQueue, create_ingest_task)
def create_layer(layer_name, data):
storage = Storage('file:///tmp/neuroglancer/'+ layer_name)
upload_build_chunks(storage, random_data)
# Jpeg encoding is lossy so it won't work
create_info_file_from_build(storage, layer_type= 'image', encoding="raw",
force_chunk=[64,64,64])
create_ingest_task(storage, MockTaskQueue())
if __name__ == '__main__':
#x,y,z,channels
random_data = np.random.randint(255, size=(1024,1024,128,1), dtype=np.uint8)
create_layer('image', random_data)
Serve the layer(s) using a web server. This webserver has to support https and needs to send the correct cors headers If you don't already have some certificates, create one
openssl req -new -x509 -keyout server.pem -out server.pem -days 365 -nodes
Put this file in the /tmp/neuroglancer Create a file in /tmp/neuroglancer/server.py with this contnent
#!/usr/bin/env python2
from SimpleHTTPServer import SimpleHTTPRequestHandler
import BaseHTTPServer
import ssl
class CORSRequestHandler (SimpleHTTPRequestHandler):
def do_GET(self):
# Hack required because we are compressing everything
# but the info file
if 'info' in self.path:
self.is_compressed = False
else:
self.is_compressed = True
return SimpleHTTPRequestHandler.do_GET(self)
def end_headers(self):
if self.is_compressed:
self.send_header('content-encoding', 'gzip')
self.send_header('Access-Control-Allow-Origin', '*')
SimpleHTTPRequestHandler.end_headers(self)
if __name__ == '__main__':
httpd = BaseHTTPServer.HTTPServer(('localhost', 4443), CORSRequestHandler)
httpd.socket = ssl.wrap_socket (httpd.socket, certfile='./server.pem',
server_side=True)
httpd.serve_forever()
You should be able to see your the files in /tmp/neuroglancer by going to https://localhost:4443
You can now open https://neuromancer-seung-import.appspot.com/
and create a layer precomputed://https://localhost:4443/layer_name