Skip to content

Boss Upload Cutout Tutorial

Tim Gion edited this page Nov 1, 2016 · 5 revisions

Uploading Cutout Data

Before uploading cutout data, make sure you can answer yes to the following questions.

Cutout checklist:

  • Is the cutout within the dimensions of the experiment's coordinate frame?
  • Does the data's type match the data type of the channel or layer?
  • Is the numpy array arranged properly (Z-Y-X or time-Z-Y-X)?
  • Are the coordinate ranges specified using Python's range convention (second number is the stop value)?

This tutorial uses the collection and experiment shown in the [Boss Project Setup](https://github.com/jhuapl-boss/intern/wiki/Boss Project Setup Tutorial) tutorial.

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'

# Create a new channel that uses uint16 data.
chan_setup = ChannelResource(CHAN_NAME, COLL_NAME, EXP_NAME, 'image', datatype='uint16')
chan = rmt.create_project(chan_setup)

# 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]

# Note that the numpy matrix is in Z, Y, X order.
data = numpy.random.randint(0, 3000, (5, 4, 8))
# Make data match what was specified for the channel.
data = data.astype(numpy.uint16)

# Upload the cutout to the channel.  The zero parameter specifies native
# resolution.
rmt.create_cutout(chan, 0, x_rng, y_rng, z_rng, data)