def start_server():

    ## add some error checking
    if not os.path.isfile('/mnt/data/info'):
        logging.info('no valid volume found, using test data')
        arr = np.random.random_integers(0, high=255, size=(128,128, 128))
        arr = np.asarray(arr, dtype=np.uint8)
        vol = CloudVolume.from_numpy(arr, max_mip=1)
    else:
        logging.info('using mounted dataset')
        vol = CloudVolume('file:///mnt/data',parallel=2,cache=True)

    logging.info('volume created: {}'.format(vol[1,1,1]))

    logging.info('patching viewer to allow connections on all IPs')
    funcType = types.MethodType
    vol.viewer = funcType(localviewer, vol)

    logging.info('starting cloudvolume service')

    vol.viewer(port=1337)
code to run neuroglancer after generating precomputed volumes
goal is to overlay raw data + atlas and make videos/screenshots of key structures
before running scripts, activate lightsheet env in each window that has neuroglancer and cloud volume installed
make sure you are connected to Princeton VPN and mounted on scratch/bucket
"""

###WINDOW 1###
#in a new ipython window:
from cloudvolume import CloudVolume

brainname = "20200701_12_55_28_20170207_db_bl6_crii_rpv_01"
port = 1350
layer_dir = "/jukebox/scratch/zmd/save/contra_ipsi_projection_studies_20191125/%s/647" % brainname
vol = CloudVolume(f"file://{layer_dir}")
vol.viewer(port=port)

###WINDOW 2###
#to add another layer (aka the atlas), in a new ipython window:
from cloudvolume import CloudVolume

brainname = "20200701_12_55_28_20170207_db_bl6_crii_rpv_01"
port = 1350
layer_dir = "/jukebox/scratch/zmd/save/contra_ipsi_projection_studies_20191125/%s/atlas" % brainname
vol = CloudVolume(f"file://{layer_dir}")
vol.viewer(port=port + 1)  #make sure this port is different from the first

###WINDOW 3###
#in another ipython window run:
import neuroglancer