本文整理汇总了Python中lazyflow.operators.ioOperators.OpExportSlot类的典型用法代码示例。如果您正苦于以下问题:Python OpExportSlot类的具体用法?Python OpExportSlot怎么用?Python OpExportSlot使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了OpExportSlot类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testBasic_Npy
def testBasic_Npy(self):
data = numpy.random.random((100, 100)).astype(numpy.float32)
data = vigra.taggedView(data, vigra.defaultAxistags("xy"))
graph = Graph()
opPiper = OpArrayPiper(graph=graph)
opPiper.Input.setValue(data)
opExport = OpExportSlot(graph=graph)
opExport.Input.connect(opPiper.Output)
opExport.OutputFormat.setValue("numpy")
opExport.OutputFilenameFormat.setValue(self._tmpdir + "/test_export_x{x_start}-{x_stop}_y{y_start}-{y_stop}")
opExport.CoordinateOffset.setValue((10, 20))
assert opExport.ExportPath.ready()
assert os.path.split(opExport.ExportPath.value)[1] == "test_export_x10-110_y20-120.npy"
# print "exporting data to: {}".format( opExport.ExportPath.value )
opExport.run_export()
opRead = OpInputDataReader(graph=graph)
try:
opRead.FilePath.setValue(opExport.ExportPath.value)
expected_data = data.view(numpy.ndarray)
read_data = opRead.Output[:].wait()
assert (read_data == expected_data).all(), "Read data didn't match exported data!"
finally:
opRead.cleanUp()
示例2: testBasic_Hdf5
def testBasic_Hdf5(self):
data = numpy.random.random( (100,100) ).astype( numpy.float32 )
data = vigra.taggedView( data, vigra.defaultAxistags('xy') )
graph = Graph()
opExport = OpExportSlot(graph=graph)
opExport.Input.setValue(data)
opExport.OutputFormat.setValue( 'hdf5' )
opExport.OutputFilenameFormat.setValue( self._tmpdir + '/test_export_x{x_start}-{x_stop}_y{y_start}-{y_stop}' )
opExport.OutputInternalPath.setValue('volume/data')
opExport.CoordinateOffset.setValue( (10, 20) )
assert opExport.ExportPath.ready()
export_file = PathComponents( opExport.ExportPath.value ).externalPath
assert os.path.split(export_file)[1] == 'test_export_x10-110_y20-120.h5'
#print "exporting data to: {}".format( opExport.ExportPath.value )
opExport.run_export()
opRead = OpInputDataReader( graph=graph )
opRead.FilePath.setValue( opExport.ExportPath.value )
expected_data = data.view(numpy.ndarray)
read_data = opRead.Output[:].wait()
assert (read_data == expected_data).all(), "Read data didn't match exported data!"
opRead.cleanUp()
示例3: testBasic_2d_Sequence
def testBasic_2d_Sequence(self):
data = 255 * numpy.random.random((10, 50, 100, 3))
data = data.astype(numpy.uint8)
data = vigra.taggedView(data, vigra.defaultAxistags("zyxc"))
# Must run this through an operator
# Can't use opExport.setValue() because because OpStackWriter can't work with ValueRequests
graph = Graph()
opData = OpBlockedArrayCache(graph=graph)
opData.BlockShape.setValue(data.shape)
opData.Input.setValue(data)
filepattern = self._tmpdir + "/test_export_x{x_start}-{x_stop}_y{y_start}-{y_stop}_z{slice_index}"
opExport = OpExportSlot(graph=graph)
opExport.Input.connect(opData.Output)
opExport.OutputFormat.setValue("png sequence")
opExport.OutputFilenameFormat.setValue(filepattern)
opExport.CoordinateOffset.setValue((10, 20, 30, 0))
opExport.run_export()
export_pattern = opExport.ExportPath.value
globstring = export_pattern.format(slice_index=999)
globstring = globstring.replace("999", "*")
opReader = OpStackLoader(graph=graph)
try:
opReader.globstring.setValue(globstring)
assert opReader.stack.meta.shape == data.shape, "Exported files were of the wrong shape or number."
assert (opReader.stack[:].wait() == data.view(numpy.ndarray)).all(), "Exported data was not correct"
finally:
opReader.cleanUp()
示例4: testBasic_2d
def testBasic_2d(self):
data = 255 * numpy.random.random((50, 100))
data = data.astype(numpy.uint8)
data = vigra.taggedView(data, vigra.defaultAxistags("yx"))
graph = Graph()
opPiper = OpArrayPiper(graph=graph)
opPiper.Input.setValue(data)
opExport = OpExportSlot(graph=graph)
opExport.Input.connect(opPiper.Output)
opExport.OutputFormat.setValue("png")
opExport.OutputFilenameFormat.setValue(self._tmpdir + "/test_export_x{x_start}-{x_stop}_y{y_start}-{y_stop}")
opExport.CoordinateOffset.setValue((10, 20))
assert opExport.ExportPath.ready()
assert os.path.split(opExport.ExportPath.value)[1] == "test_export_x20-120_y10-60.png"
opExport.run_export()
opRead = OpInputDataReader(graph=graph)
try:
opRead.FilePath.setValue(opExport.ExportPath.value)
expected_data = data.view(numpy.ndarray)
read_data = opRead.Output[:].wait()
# Note: vigra inserts a channel axis, so read_data is xyc
assert (read_data[..., 0] == expected_data).all(), "Read data didn't match exported data!"
finally:
opRead.cleanUp()
示例5: test_via_OpExportSlot
def test_via_OpExportSlot(self):
data = 255 * numpy.random.random( (64, 128, 128, 1) )
data = data.astype( numpy.uint8 )
data = vigra.taggedView( data, vigra.defaultAxistags('zyxc') )
graph = Graph()
opPiper = OpArrayPiper(graph=graph)
opPiper.Input.setValue( data )
opExport = OpExportSlot(graph=graph)
opExport.Input.connect( opPiper.Output )
opExport.OutputFormat.setValue( 'dvid' )
url = 'http://{hostname}/api/node/{data_uuid}/{data_name}'.format( **self.__dict__ )
opExport.OutputFilenameFormat.setValue( url )
assert opExport.ExportPath.ready()
assert opExport.ExportPath.value == url
opExport.run_export()
opRead = OpInputDataReader( graph=graph )
try:
opRead.FilePath.setValue( opExport.ExportPath.value )
expected_data = data.view(numpy.ndarray)
read_data = opRead.Output( *roiFromShape(data.shape) ).wait()
assert (read_data == expected_data).all(), "Read data didn't match exported data!"
finally:
opRead.cleanUp()
示例6: testBasic_MultipageTiffSequence
def testBasic_MultipageTiffSequence(self):
data = 255 * numpy.random.random( (5, 10, 50,100, 3) )
data = data.astype( numpy.uint8 )
data = vigra.taggedView( data, vigra.defaultAxistags('tzyxc') )
# Must run this through an operator
# Can't use opExport.setValue() because because OpStackWriter can't work with ValueRequests
graph = Graph()
opData = OpArrayCache( graph=graph )
opData.blockShape.setValue( data.shape )
opData.Input.setValue( data )
filepattern = self._tmpdir + '/test_export_x{x_start}-{x_stop}_y{y_start}-{y_stop}_t{slice_index}'
opExport = OpExportSlot(graph=graph)
opExport.Input.connect( opData.Output )
opExport.OutputFormat.setValue( 'multipage tiff sequence' )
opExport.OutputFilenameFormat.setValue( filepattern )
opExport.CoordinateOffset.setValue( (7, 10, 20, 30, 0) )
opExport.run_export()
export_pattern = opExport.ExportPath.value
globstring = export_pattern.format( slice_index=999 )
globstring = globstring.replace('999', '*')
opReader = OpStackLoader( graph=graph )
opReader.globstring.setValue( globstring )
# (The OpStackLoader produces txyzc order.)
opReorderAxes = OpReorderAxes( graph=graph )
opReorderAxes.AxisOrder.setValue( 'tzyxc' )
opReorderAxes.Input.connect( opReader.stack )
assert opReorderAxes.Output.meta.shape == data.shape, "Exported files were of the wrong shape or number."
assert (opReorderAxes.Output[:].wait() == data.view( numpy.ndarray )).all(), "Exported data was not correct"
示例7: testBasic_Dvid
def testBasic_Dvid(self):
if _skip_dvid:
raise nose.SkipTest
# Spin up a mock dvid server to test with.
dvid_dataset, data_uuid, data_name = "datasetA", "abcde", "indices_data"
mockserver_data_file = self._tmpdir + '/mockserver_data.h5'
with H5MockServerDataFile( mockserver_data_file ) as test_h5file:
test_h5file.add_node( dvid_dataset, data_uuid )
server_proc, shutdown_event = H5MockServer.create_and_start( mockserver_data_file, "localhost", 8000,
same_process=False, disable_server_logging=True )
try:
data = 255 * numpy.random.random( (100,100, 4) )
data = data.astype( numpy.uint8 )
data = vigra.taggedView( data, vigra.defaultAxistags('xyc') )
graph = Graph()
opPiper = OpArrayPiper(graph=graph)
opPiper.Input.setValue( data )
opExport = OpExportSlot(graph=graph)
opExport.Input.connect( opPiper.Output )
opExport.OutputFormat.setValue( 'dvid' )
url = 'http://localhost:8000/api/node/{data_uuid}/{data_name}'.format( **locals() )
opExport.OutputFilenameFormat.setValue( url )
assert opExport.ExportPath.ready()
assert opExport.ExportPath.value == url
opExport.run_export()
try:
opRead = OpInputDataReader( graph=graph )
opRead.FilePath.setValue( opExport.ExportPath.value )
expected_data = data.view(numpy.ndarray)
read_data = opRead.Output[:].wait()
assert (read_data == expected_data).all(), "Read data didn't match exported data!"
finally:
opRead.cleanUp()
finally:
shutdown_event.set()
server_proc.join()