本文整理汇总了Python中libdvid.DVIDNodeService.create_roi方法的典型用法代码示例。如果您正苦于以下问题:Python DVIDNodeService.create_roi方法的具体用法?Python DVIDNodeService.create_roi怎么用?Python DVIDNodeService.create_roi使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类libdvid.DVIDNodeService
的用法示例。
在下文中一共展示了DVIDNodeService.create_roi方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_roi_2
# 需要导入模块: from libdvid import DVIDNodeService [as 别名]
# 或者: from libdvid.DVIDNodeService import create_roi [as 别名]
def test_roi_2(self):
# Create X-shaped ROI
# This ensures that the x-run encoding within our ROI message works properly
# (There used to be a bug in post_roi() that would have broken this test.)
_ = 0
# 8x8 blocks = 256x256 px
roi_mask_yx = numpy.array( [[1,_,_,_,_,_,_,1],
[1,1,_,_,_,_,1,1],
[_,1,1,_,_,1,1,_],
[_,_,1,1,1,1,_,_],
[_,_,_,1,1,_,_,_],
[_,_,1,1,1,1,_,_],
[_,1,1,_,_,1,1,_],
[1,1,_,_,_,_,1,1] ])
roi_mask_zyx = numpy.zeros( (8,8,8) )
roi_mask_zyx[:] = roi_mask_yx[None, :, :]
roi_block_indexes = numpy.transpose( roi_mask_zyx.nonzero() )
ns = DVIDNodeService(TEST_DVID_SERVER, self.uuid, "[email protected]", "test_roi_2_app")
ns.create_roi('test-diagonal-256')
ns.post_roi('test-diagonal-256', roi_block_indexes)
fetched_blocks = ns.get_roi("test-diagonal-256")
fetched_blocks = numpy.array(fetched_blocks)
# Both arrays happen to be sorted already
assert ( fetched_blocks == roi_block_indexes ).all()
示例2: setUpClass
# 需要导入模块: from libdvid import DVIDNodeService [as 别名]
# 或者: from libdvid.DVIDNodeService import create_roi [as 别名]
def setUpClass(cls):
cls.uuid = get_testrepo_root_uuid()
node_service = DVIDNodeService(TEST_DVID_SERVER, cls.uuid, "[email protected]_roi_utils.py", "Test_roi_utils")
node_service.create_roi("src_roi")
node_service.post_roi("src_roi", [(1,2,3),(2,3,4),(4,5,6)])
roi_blocks = node_service.get_roi("src_roi")
示例3: copy_roi
# 需要导入模块: from libdvid import DVIDNodeService [as 别名]
# 或者: from libdvid.DVIDNodeService import create_roi [as 别名]
def copy_roi( src_info, dest_info ):
src_service = DVIDNodeService(src_info.server, src_info.uuid)
dest_service = DVIDNodeService(dest_info.server, dest_info.uuid)
# If necessary, create the ROI on the destination server
try:
info = dest_service.get_typeinfo(dest_info.name)
except DVIDException:
dest_service.create_roi(dest_info.name)
roi_blocks = src_service.get_roi(src_info.name)
dest_service.post_roi(dest_info.name, roi_blocks)
示例4: test_roi_partition
# 需要导入模块: from libdvid import DVIDNodeService [as 别名]
# 或者: from libdvid.DVIDNodeService import create_roi [as 别名]
def test_roi_partition(self):
node_service = DVIDNodeService(TEST_DVID_SERVER, self.uuid)
node_service.create_roi("test_roi_partition")
blocks = [(0,0,0),(1,1,1),(2,2,2),(3,3,3)]
node_service.post_roi("test_roi_partition", blocks)
substacks, packing_factor = node_service.get_roi_partition("test_roi_partition", 4)
self.assertEqual(substacks, [SubstackXYZ(0,0,0,4*32)])
self.assertEqual( packing_factor, float(len(blocks))/(len(substacks) * 4**3) )
blocks += [(4,0,0)]
node_service.post_roi("test_roi_partition", blocks)
substacks, packing_factor = node_service.get_roi_partition("test_roi_partition", 4)
self.assertEqual(substacks, [SubstackXYZ(0,0,0,4*32), SubstackXYZ(128,0,0,4*32)])
示例5: test_roi_3d
# 需要导入模块: from libdvid import DVIDNodeService [as 别名]
# 或者: from libdvid.DVIDNodeService import create_roi [as 别名]
def test_roi_3d(self):
node_service = DVIDNodeService(TEST_DVID_SERVER, self.uuid)
node_service.create_roi("test_roi_3d")
# Create an upside-down L-shaped roi in the first 4 blocks:
#
# 1 1
# 1 0
node_service.post_roi("test_roi_3d", [(0,0,0),(1,0,0),(0,1,0)])
expected_data = numpy.ones((64,64,32), dtype=numpy.uint8, order='C')
expected_data[32:, 32:] = 0
retrieved_data = node_service.get_roi3D( "test_roi_3d", (64,64,32), (0,0,0) )
self.assertEqual( retrieved_data.shape, expected_data.shape )
self.assertTrue( (retrieved_data == expected_data).all() )
示例6: setUpClass
# 需要导入模块: from libdvid import DVIDNodeService [as 别名]
# 或者: from libdvid.DVIDNodeService import create_roi [as 别名]
def setUpClass(cls):
"""
Override. Called by nosetests.
"""
cls.uuid = get_testrepo_root_uuid()
cls.roi_name = "OpDvidRoi_test_roi"
node_service = DVIDNodeService(TEST_DVID_SERVER, cls.uuid)
node_service.create_roi(cls.roi_name)
# Create an upside-down L-shaped roi, something like this:
#
# 1 1 1 1
# 1 1 1 1
# 1 1 0 0
# 1 1 0 0
cls.expected_data = numpy.ones((64, 128, 128), dtype=numpy.uint8, order="C")
cls.expected_data[:, 64:, 64:] = 0
block_values = cls.expected_data[::32, ::32, ::32]
coords = numpy.transpose(numpy.nonzero(block_values))
node_service.post_roi(cls.roi_name, coords)
示例7: create_roi_for_box
# 需要导入模块: from libdvid import DVIDNodeService [as 别名]
# 或者: from libdvid.DVIDNodeService import create_roi [as 别名]
def create_roi_for_box( server, uuid, roi_name, box ):
blocks = roi_blocks_for_box( *box )
node_service = DVIDNodeService(server, uuid)
node_service.create_roi(roi_name)
node_service.post_roi(roi_name, blocks)
示例8: test_roi_ptquery
# 需要导入模块: from libdvid import DVIDNodeService [as 别名]
# 或者: from libdvid.DVIDNodeService import create_roi [as 别名]
def test_roi_ptquery(self):
node_service = DVIDNodeService(TEST_DVID_SERVER, self.uuid)
node_service.create_roi("test_roi")
node_service.post_roi("test_roi", [(1,2,3),(2,3,4),(4,5,6)])
query_results = node_service.roi_ptquery( "test_roi", [(0,0,0), (32, 64, 32*3)] )
self.assertEqual( query_results, [False, True] )
示例9: test_roi
# 需要导入模块: from libdvid import DVIDNodeService [as 别名]
# 或者: from libdvid.DVIDNodeService import create_roi [as 别名]
def test_roi(self):
node_service = DVIDNodeService(TEST_DVID_SERVER, self.uuid)
node_service.create_roi("test_roi")
node_service.post_roi("test_roi", [(1,2,3),(2,3,4),(4,5,6)])
roi_blocks = node_service.get_roi("test_roi")
self.assertEqual(roi_blocks, [(1,2,3),(2,3,4),(4,5,6)])
示例10: init_dvid_database
# 需要导入模块: from libdvid import DVIDNodeService [as 别名]
# 或者: from libdvid.DVIDNodeService import create_roi [as 别名]
def init_dvid_database(test_dir, reuse_last=False):
uuid_file = test_dir + '/uuid-cache.txt'
if reuse_last:
if not os.path.exists(uuid_file):
sys.stderr.write("Could not determine previous test uuids.\n")
sys.exit(1)
with open(uuid_file, 'r') as f:
uuid1, uuid2 = f.read().split()
return uuid1, uuid2
print("Initializing DVID Database")
os.system("gunzip -f --keep " + test_dir + "/resources/labels.bin.gz")
os.system("gunzip -f --keep " + test_dir + "/resources/labels_comp.bin.gz")
os.system("tar zxvf " + test_dir + "/resources/agglom.xml.tgz")
os.system("tar zxvf " + test_dir + "/resources/voxels.ilp.gz")
# initialize DVID datastore and call tests
# Curl must be available
create_repo_command = "curl -X POST 127.0.0.1:8000/api/repos".split()
# create first UUID
repoinfo = subprocess.check_output(create_repo_command).decode()
sys.stdout.write('\n')
data = json.loads(repoinfo)
uuid1 = data["root"]
# create second UUID
repoinfo = subprocess.check_output(create_repo_command).decode()
sys.stdout.write('\n')
data = json.loads(repoinfo)
uuid2 = data["root"]
# create labelmap instance for two uuids
create_instance = 'curl -X POST 127.0.0.1:8000/api/repo/%s/instance -d'
typedata = "{\"typename\": \"labelmap\", \"dataname\" : \"labels\", \"MaxDownresLevel\": \"2\"}"
create_instance1_command = (create_instance % uuid1).split()
create_instance2_command = (create_instance % uuid2).split()
create_instance1_command.append(typedata)
create_instance2_command.append(typedata)
subprocess.check_call(create_instance1_command)
subprocess.check_call(create_instance2_command)
# load binary label data into uuid1
load_data1_command = f'curl -X POST 127.0.0.1:8000/api/node/{uuid1}/labels/raw/0_1_2/512_512_512/0_0_0 --data-binary @{test_dir}/resources/labels.bin'
subprocess.check_call(load_data1_command, shell=True)
# load binary label data into uuid2
load_data2_command = f'curl -X POST 127.0.0.1:8000/api/node/{uuid2}/labels/raw/0_1_2/512_512_512/0_0_0 --data-binary @{test_dir}/resources/labels_comp.bin'
subprocess.check_call(load_data2_command, shell=True)
# create ROI datatype
create_roi_command = f"""curl -X POST 127.0.0.1:8000/api/repo/{uuid1}/instance -d""" + """ '{"typename": "roi", "dataname" : "temproi"}' """
subprocess.check_call(create_roi_command, shell=True)
# load ROI
load_roi_command = f'curl -X POST 127.0.0.1:8000/api/node/{uuid1}/temproi/roi --data-binary @{test_dir}/resources/500roi.json'
subprocess.check_call(load_roi_command, shell=True)
# create synapse key value
create_synapse_command = f'curl -X POST 127.0.0.1:8000/api/repo/{uuid1}/instance -d'
create_synapse_command+= """ '{"typename": "keyvalue", "dataname" : "annotations"}' """
subprocess.check_call(create_synapse_command, shell=True)
# load synapses
load_synapse_command = ('curl -X POST 127.0.0.1:8000/api/node/%s/annotations/key/syn --data-binary @%s/resources/synapse_small.json' % (uuid1, test_dir)).split()
subprocess.check_call(load_synapse_command)
# create synapse annotation
create_synapse_command = f'curl -X POST 127.0.0.1:8000/api/repo/{uuid1}/instance -d'
create_synapse_command+= """ '{"typename": "annotation", "dataname" : "syn"}' """
subprocess.check_call(create_synapse_command, shell=True)
# load synapse annotations
load_synapse_command = ('curl -X POST 127.0.0.1:8000/api/node/%s/syn/elements --data-binary @%s/resources/synapse_small2.json' % (uuid1, test_dir)).split()
subprocess.check_call(load_synapse_command)
# create grayscale data
create_gray = 'curl -X POST 127.0.0.1:8000/api/repo/%s/instance -d'
typedata = "{\"typename\": \"uint8blk\", \"dataname\" : \"grayscale\"}"
create_gray1_command = (create_gray % uuid1).split()
create_gray1_command.append(typedata)
subprocess.check_call(create_gray1_command)
# load grayscale data
load_gray1_command = ('curl -X POST 127.0.0.1:8000/api/node/%s/grayscale/raw/0_1_2/256_256_256/0_0_0 --data-binary @%s/resources/grayscale-256-256-256-uint8.bin' % (uuid1, test_dir)).split()
subprocess.check_call(load_gray1_command)
# Grid grayscale data
# Note that the outer border is only present on
# the bottom Y-half.
#
# + + + + + <-- The '+' here are just a visual cue; they aren't in the data.
# | |
# | |
# +----+---------+----+
#.........这里部分代码省略.........