def DVID_push_cutout(args): rmt = DVIDRemote({"protocol": "http", "host": args.host}) # data is desired range data = np.load(args.input) numpyType = np.uint8 if args.datatype == "uint32": numpyType = np.uint32 elif args.datatype == "uint64": numpyType = np.uint64 if data.dtype != args.datatype: data = data.astype(numpyType) sources = [] if args.source: sources.append(args.source) # Create or get a channel to write to instance_setup = DataInstanceResource( UUID=args.uuid, name=args.data_instance, type=args.type, alias=args.alias, datatype=args.datatype, ) print("Data Instance setup.") chan_actual_up = rmt.create_project(instance_setup) x_rng = [args.xmin, args.xmax] y_rng = [args.ymin, args.ymax] z_rng = [args.zmin, args.zmax] print("Data model setup. UUID: {}".format(chan_actual_up)) # Pipeline Data will be in X,Y,Z format # Change to Z,Y,X for upload data = np.transpose(data, (2, 1, 0)) data = data.copy(order="C") # Verify that the cutout uploaded correctly. attempts = 0 while attempts < 3: try: rmt.create_cutout(instance_setup, args.res, x_rng, y_rng, z_rng, data) break except HTTPError as e: if attempts < 3: attempts += 1 print("These are the dimensions: ") print(data.shape) print("This is the data type:") print(data.dtype) print("Specified data type was:") print(args.dtype) print("Specified image type") print(args.itype) print("Obtained HTTP error from server. Trial {}".format( attempts)) print("The error: {}".format(e)) else: raise Exception("Failed 3 times: {}".format(e))
from subprocess import call import intern from intern.remote.dvid import DVIDRemote # #Starts Dockers # call(["docker-compose", "up"]) #DVID Data fetch: dvid = DVIDRemote({ "protocol": "http", "host": "localhost:8000", }) #Creating Project, and chanel to store boxed data in proj = dvid.create_project('Xbrain_Proj1', 'Data upload test') chan_setup = dvid.ChannelResource(proj, "MaskedImg1") #Uploads Data call([ "docker-compose", "exec", "dvid", "dvid", "node", proj, "MaskedImg1", "load", "0" + "," + "0" + "," + "390", "dataLoad/*.tif" ]) print("The dvid instance has your requested data sample.")
from intern.remote.dvid import DVIDRemote from intern.resource.dvid import DataInstanceResource import numpy as np dvid = DVIDRemote({"protocol": "http", "host": "localhost:8001",}) # Prepare the data data_cube = np.load("/My/dummy/dir/validation_grayscale.npy").astype(np.uint8) data_cube = data_cube[0:512, 0:512, 0:512] data_cube = data_cube.copy(order="C") print(data_cube.dtype) print(data_cube.shape) # Create the project instance_setup_up = DataInstanceResource( alias="local_dvid_test", type="uint8blk", name="validation", UUID=None, datatype="uint8", ) chan_actual_up = dvid.create_project(instance_setup_up) # Create the cutout dvid.create_cutout(instance_setup_up, 0, [0, 512], [0, 512], [0, 512], data_cube) print("Create cutout successful") # Get the cutout got_cutout = dvid.get_cutout(instance_setup_up, 0, [0, 512], [0, 512], [0, 1]) print(got_cutout.shape) print("Arrays match: {}".format(np.array_equal(got_cutout, data_cube[0:1, :, :])))
import intern from intern.remote.boss import BossRemote from intern.resource.boss.resource import ChannelResource from intern.remote.dvid import DVIDRemote import matplotlib.pyplot as plt import numpy as np #DVID Data fetch: dvid = DVIDRemote({ "protocol": "http", "host": "localhost:8000", }) chan_setup = dvid.ChannelResource('Xbrain_Proj_Dummy', 'dyer15_3_maskim_DUmmy', 'masked_images', 'Data upload test', '') proj = dvid.create_project(chan_setup) print(proj) # dvid.delete_project("8ef")
}) DATA_INSTANCE = "ex_EM" ALIAS = "Test_alias" ########### Test Project API ########### ## Create DataInstanceResource and force the creation of a RepositoryResource instance_setup_em = DataInstanceResource(DATA_INSTANCE, None, "uint8blk", ALIAS, "Example channel.", datatype="uint8") # Get the channel and create a project instance_actual_repo = dvid.create_project(instance_setup_em) print("Repo UUID:" + instance_actual_repo) # Create an instance within given repo(UUID) instance_setup_anno = DataInstanceResource( DATA_INSTANCE + "_the_second", instance_actual_repo, "uint8blk", ALIAS, "Example channel.", datatype="uint8", ) instance_actual_anno_uuid = dvid.create_project(instance_setup_anno) print("Data Instance UUID: {}".format(instance_actual_anno_uuid))