Skip to content

Reading Public Data Examples

William Silversmith edited this page Jun 13, 2019 · 15 revisions

If you're new to CloudVolume, it can be helpful to try using it with a public dataset to get a feel for it.

We'll use the dataset by Kasthuri et al for these examples. Open Viewer

Kasthuri, Narayanan, et al. "Saturated reconstruction of a volume of neocortex." Cell 162.3 (2015): 648-661. (link)

Downloading EM Images

Neuroglancer datasets are often accessed as precomputed://protocol://bucket/dataset/layer. To initialize a CloudVolume instance, we can omit the precomputed:// part. In this example, we'll use the gs:// protocol, which means it's on Google Cloud Storage, but s3:// and other protocols are possible as well. For public datasets hosted on Google Cloud Storage, if you replace the gs:// protocol with https://storage.googleapis.com, you'll be able to read them without an authentication token.

In this example, we download a 512x512x64 voxel patch of electron microscope images from the Kasthrui et al dataset at the highest resolution.

from cloudvolume import CloudVolume, view

# 1. Initialize a CloudVolume object which will know how to read from this dataset layer. 
cv = CloudVolume(
   'https://storage.googleapis.com/neuroglancer-public-data/kasthuri2011/image_color_corrected', 
    progress=True, # shows progress bar
    cache=True, # cache to disk to avoid repeated downloads
    # parallel=True, # uncomment to try parallel download!
)

# 2. Download context around the point in the Neuroglancer link above
#    into a numpy array.
# argument one is the (x,y,z) coordinate from neuroglancer
# mip=resolution level (smaller mips are higher resolution, highest is 0)
# size is in voxels
img = cv.download_point( (5188, 9096, 1198), mip=0, size=(512, 512, 64) )

# 3. Visualize the image! 
# Open your browser to https://localhost:8080 to view
# Press ctrl-C to continue script execution.
view(img)

# 4. When you're done experimenting, clean up the space we used on disk.
# cv.cache.flush()