Skip to content

Boss Download Cutout Tutorial

Tim Gion edited this page Jan 25, 2017 · 7 revisions

Downloading Cutout Data

Assuming data was uploaded as described in the [Boss Uploading Cutout Data](https://github.com/jhuapl-boss/intern/wiki/Boss Upload Cutout Tutorial) tutorial, this tutorial shows how that data can be pulled down to a client.

from intern.remote.boss import BossRemote
from intern.resource.boss.resource import *
import numpy

rmt = BossRemote()

COLL_NAME = 'JHUAPL'
EXP_NAME = 'Mouse17'
CHAN_NAME = 'EM2'

chan = ChannelResource(
    CHAN_NAME, COLL_NAME, EXP_NAME, 'image', datatype='uint16')

# Ranges use the Python convention where the second number is the stop
# value.  Thus, x_rng specifies x values where: 0 <= x < 8.
x_rng = [0, 8]
y_rng = [0, 4]
z_rng = [0, 5]

# Use native resolution.
res = 0

# Download the cutout from the channel.
data = rmt.get_cutout(chan, res, x_rng, y_rng, z_rng)

# Alter the range to get a subsection of the original data.
sub_x = [2, 4]
sub_y = [2, 4]
sub_z = [2, 4]

sub_data = rmt.get_cutout(chan, res, sub_x, sub_y, sub_z)

Cutout data from annotation channels may also be filtered by id so that the cutout region either contains the requested ids or zeros.

ann_chan = ChannelResource(
    'Algorithm1', COLL_NAME, EXP_NAME, type='annotation', datatype='uint64')

filtered_data = rmt.get_cutout(
    ann_chan, res, x_rng, y_rng, z_rng, id_list=[3, 5, 9])