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))
import intern from intern.remote.dvid import DVIDRemote #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') print("This is your UUID:" + proj) chan_setup = dvid.ChannelResource(proj, "MaskedImg1") #Uploading data dataU = dvid.create_cutout(chan_setup, "xbrain_port9", 0, 0, 390, "/*.tif")
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, :, :])))
#Declare DVIDRemote dvid = DVIDRemote({ "protocol": "http", "host": "localhost:8000", }) chan_setup = dvid.ChannelResource( 'Proj4', 'dyer15_3_maskim', 'maked_images', 'Data uploaded from XBrain experiments through intern') proj = dvid.create_project(chan_setup) # UUID = chan_setup.split("/") # UUID = UUID[0] while iNumS <= iNumE: directory = '/Users/rodrilm2/Documents/APL/GeorgiaTech/data/proj4_masked_390_2014/' # data = np.zeros((2560,2560)) num = format(iNumS, "04") filename = "dyer15_3_maskimg_" + num + ".tif" pathname = os.path.join(directory, filename) print('Processing: ' + filename) img = Image.open(pathname) data = np.array(img) xrang = [0, 256] yrang = [0, 256] zrang = [start, end] volume = dvid.create_cutout(proj, xrang, yrang, zrang, data) end = end + 32 iNumS = iNumS + 1 print(end)
# # Prepare the data img = Image.open("<somedir>/*.png") data_tile = np.asarray(img) print(data_tile.shape) data_tile = np.expand_dims(data_tile, axis=0) data_tile = data_tile.copy(order="C") # Create the project instance_setup_up = DataInstanceResource( DATA_INSTANCE + "_the_second", None, "imagetile", "Upload Test", "Example channel.", datatype="uint8", ) chan_actual_up = dvid.create_project(instance_setup_up) # Create the cutout dvid.create_cutout(instance_setup_up, 0, [0, 454], [0, 480], [0, 1], data_tile) print("Create cutout successful") # Get the cutout got_cutout = dvid.get_cutout(instance_setup_up, 0, [0, 454], [0, 480], [0, 1]) # Check for equality if (got_cutout == data_tile).all(): print("Both tiles equate")