forked from neurodata/ndio
-
Notifications
You must be signed in to change notification settings - Fork 0
Boss Upload Cutout Tutorial
Tim Gion edited this page Jun 14, 2016
·
1 revision
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/ndio/wiki/Boss Project Setup Tutorial) tutorial.
from ndio.remote.boss.remote import Remote
from ndio.ndresource.boss.resource import *
import numpy
rmt = Remote()
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, datatype='uint16')
chan = rmt.project_create(chan_setup)
# Ranges use the Python convention where the number after the : 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.cutout_create(chan, 0, x_rng, y_rng, z_rng, data)