本文整理汇总了Python中vigra.defaultAxistags函数的典型用法代码示例。如果您正苦于以下问题:Python defaultAxistags函数的具体用法?Python defaultAxistags怎么用?Python defaultAxistags使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了defaultAxistags函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: setupOutputs
def setupOutputs(self):
self.fileNameList = []
globStrings = self.globstring.value
# Parse list into separate globstrings and combine them
for globString in sorted(globStrings.split("//")):
self.fileNameList += sorted(glob.glob(globString))
num_files = len(self.fileNameList)
if len(self.fileNameList) == 0:
self.stack.meta.NOTREADY = True
return
try:
self.info = vigra.impex.ImageInfo(self.fileNameList[0])
self.slices_per_file = vigra.impex.numberImages(self.fileNameList[0])
except RuntimeError:
raise OpStackLoader.FileOpenError(self.fileNameList[0])
slice_shape = self.info.getShape()
X, Y, C = slice_shape
if self.slices_per_file == 1:
# If this is a stack of 2D images, we assume xy slices stacked along z
Z = num_files
shape = (Z, Y, X, C)
axistags = vigra.defaultAxistags('zyxc')
else:
# If it's a stack of 3D volumes, we assume xyz blocks stacked along t
T = num_files
Z = self.slices_per_file
shape = (T, Z, Y, X, C)
axistags = vigra.defaultAxistags('tzyxc')
self.stack.meta.shape = shape
self.stack.meta.axistags = axistags
self.stack.meta.dtype = self.info.getDtype()
开发者ID:kumartr,项目名称:lazyflow,代码行数:35,代码来源:ioOperators.py
示例2: setUp
def setUp(self):
self.data2d = numpy.zeros((3, 3, 3))
self.data2d[:, :, 0] = 1
self.data2d[:, :, 1] = 2
self.data2d[:, :, 2] = 3
self.data2d = self.data2d.view(vigra.VigraArray)
self.data2d.axistags = vigra.defaultAxistags("xyc")
self.data3d = numpy.zeros((3, 3, 3, 3))
self.data3d[:, :, :, 0] = 1
self.data3d[:, :, :, 1] = 2
self.data3d[:, :, :, 2] = 3
self.data3d = self.data3d.view(vigra.VigraArray)
self.data3d.axistags = vigra.defaultAxistags("xyzc")
self.data_bad_channel = numpy.zeros((3, 3, 3, 3))
self.data_bad_channel[:, :, 0, :] = 1
self.data_bad_channel[:, :, 1, :] = 2
self.data_bad_channel[:, :, 2, :] = 3
self.data_bad_channel = self.data_bad_channel.view(vigra.VigraArray)
self.data_bad_channel.axistags = vigra.defaultAxistags("xycz")
开发者ID:bheuer,项目名称:lazyflow,代码行数:25,代码来源:testChannelSelector.py
示例3: _get_template_dataset_infos
def _get_template_dataset_infos(self, input_axes=None):
"""
Sometimes the default settings for an input file are not suitable (e.g. the axistags need to be changed).
We assume the LAST non-batch input in the workflow has settings that will work for all batch processing inputs.
Here, we get the DatasetInfo objects from that lane and store them as 'templates' to modify for all batch-processing files.
"""
template_infos = {}
# If there isn't an available dataset to use as a template
if len(self.dataSelectionApplet.topLevelOperator.DatasetGroup) == 0:
num_roles = len(self.dataSelectionApplet.topLevelOperator.DatasetRoles.value)
for role_index in range(num_roles):
template_infos[role_index] = DatasetInfo()
template_infos[role_index].axistags = vigra.defaultAxistags(input_axes)
return template_infos
# Use the LAST non-batch input file as our 'template' for DatasetInfo settings (e.g. axistags)
template_lane = len(self.dataSelectionApplet.topLevelOperator.DatasetGroup) - 1
opDataSelectionTemplateView = self.dataSelectionApplet.topLevelOperator.getLane(template_lane)
for role_index, info_slot in enumerate(opDataSelectionTemplateView.DatasetGroup):
if info_slot.ready():
template_infos[role_index] = info_slot.value
else:
template_infos[role_index] = DatasetInfo()
if input_axes:
# Support the --input_axes arg to override input axis order, same as DataSelection applet.
template_infos[role_index].axistags = vigra.defaultAxistags(input_axes)
return template_infos
开发者ID:sc65,项目名称:ilastik,代码行数:29,代码来源:batchProcessingApplet.py
示例4: setupOutputs
def setupOutputs(self):
self.fileNameList = self.expandGlobStrings(self.globstring.value)
num_files = len(self.fileNameList)
if len(self.fileNameList) == 0:
self.stack.meta.NOTREADY = True
return
try:
self.info = vigra.impex.ImageInfo(self.fileNameList[0])
self.slices_per_file = vigra.impex.numberImages(self.fileNameList[0])
except RuntimeError as e:
logger.error(str(e))
raise OpStackLoader.FileOpenError(self.fileNameList[0])
slice_shape = self.info.getShape()
X, Y, C = slice_shape
if self.slices_per_file == 1:
# If this is a stack of 2D images, we assume xy slices stacked along z
Z = num_files
shape = (Z, Y, X, C)
axistags = vigra.defaultAxistags('zyxc')
else:
# If it's a stack of 3D volumes, we assume xyz blocks stacked along t
T = num_files
Z = self.slices_per_file
shape = (T, Z, Y, X, C)
axistags = vigra.defaultAxistags('tzyxc')
self.stack.meta.shape = shape
self.stack.meta.axistags = axistags
self.stack.meta.dtype = self.info.getDtype()
开发者ID:JensNRAD,项目名称:lazyflow,代码行数:31,代码来源:ioOperators.py
示例5: testChangeBlockshape_masked
def testChangeBlockshape_masked(self):
logger.info("Generating sample data...")
sampleData = numpy.indices((100, 200, 150), dtype=numpy.float32).sum(0)
sampleData = sampleData.view(numpy.ma.masked_array)
sampleData.set_fill_value(numpy.float32(numpy.nan))
sampleData[0] = numpy.ma.masked
graph = Graph()
opData = OpArrayPiper(graph=graph)
opData.Input.meta.has_mask = True
opData.Input.meta.axistags = vigra.defaultAxistags("xyz")
opData.Input.setValue(sampleData)
op = OpCompressedCache(parent=None, graph=graph)
# logger.debug("Setting block shape...")
op.BlockShape.setValue([100, 75, 50])
op.Input.connect(opData.Output)
assert op.Output.ready()
slicing = numpy.s_[0:100, 50:150, 75:150]
expectedData = sampleData[slicing]
# logger.debug("Requesting data...")
readData = op.Output[slicing].wait()
# logger.debug("Checking data...")
assert (
(readData == expectedData).all()
and (readData.mask == expectedData.mask).all()
and (
(readData.fill_value == expectedData.fill_value)
| (numpy.isnan(readData.fill_value) & numpy.isnan(expectedData.fill_value))
).all()
), "Incorrect output!"
# Now change the blockshape and the input and try again...
sampleDataWithChannel = sampleData[..., None]
opData.Input.meta.axistags = vigra.defaultAxistags("xyzc")
opData.Input.setValue(sampleDataWithChannel)
op.BlockShape.setValue([45, 33, 40, 1])
assert op.Output.ready()
slicing = numpy.s_[60:70, 50:110, 60:120, 0:1]
expectedData = sampleDataWithChannel[slicing]
# logger.debug("Requesting data...")
readData = op.Output[slicing].wait()
# logger.debug("Checking data...")
assert (
(readData == expectedData).all()
and (readData.mask == expectedData.mask).all()
and (
(readData.fill_value == expectedData.fill_value)
| (numpy.isnan(readData.fill_value) & numpy.isnan(expectedData.fill_value))
).all()
), "Incorrect output!"
开发者ID:ilastik,项目名称:lazyflow,代码行数:59,代码来源:testOpCompressedCache.py
示例6: setupOutputs
def setupOutputs(self):
# assert len(self.Input.meta.shape) == 1
self.Output.meta.shape = (self.Input.meta.shape[0], 1)
self.Output.meta.dtype = np.float32
self.Output.meta.axistags = vigra.defaultAxistags('tc')
self.Valid.meta.shape = self.Output.meta.shape[:1]
self.Valid.meta.axistags = vigra.defaultAxistags('t')
self.Valid.meta.dtype = np.uint8
开发者ID:burgerdev,项目名称:hostload,代码行数:8,代码来源:integrationdatasets.py
示例7: setUp
def setUp(self):
if 'TRAVIS' in os.environ:
# This test takes a long time, so skip it on Travis-CI.
import nose
raise nose.SkipTest
self.scaleZ = 2
self.scales = [0.3, 0.7, 1, 1.6, 3.5, 5.0, 10.0]
self.featureIds = [ 'GaussianSmoothing', 'LaplacianOfGaussian',\
'GaussianGradientMagnitude',
'DifferenceOfGaussians',
'StructureTensorEigenvalues',
'HessianOfGaussianEigenvalues' ]
#setup the data
self.nx = 50
self.ny = 50
self.nz = 50
self.data3d = numpy.zeros((self.nx, self.ny, self.nz, 1), dtype=numpy.float32)
for i in range(self.data3d.shape[2]):
self.data3d[:, :, i, 0]=i
newRangeZ = self.scaleZ*(self.nz-1)+1
self.data3dInterp = vigra.sampling.resizeVolumeSplineInterpolation(self.data3d.squeeze(), \
shape=(self.nx, self.ny, newRangeZ))
self.data3dInterp = self.data3dInterp.reshape(self.data3dInterp.shape + (1,))
self.data3d = self.data3d.view(vigra.VigraArray)
self.data3d.axistags = vigra.VigraArray.defaultAxistags(4)
self.data3dInterp = self.data3dInterp.view(vigra.VigraArray)
self.data3dInterp.axistags = vigra.VigraArray.defaultAxistags(4)
self.randomData = (numpy.random.random((self.nx, self.ny, self.nz, 1))).astype(numpy.float32)
self.randomDataInterp = vigra.sampling.resizeVolumeSplineInterpolation(self.randomData.squeeze(), \
shape = (self.nx, self.ny, newRangeZ))
self.randomDataInterp = self.randomDataInterp.reshape(self.randomDataInterp.shape+(1,))
self.randomData = self.randomData.view(vigra.VigraArray).astype(numpy.float32)
self.randomData.axistags = vigra.defaultAxistags(4)
self.randomDataInterp = self.randomDataInterp.view(vigra.VigraArray)
self.randomDataInterp.axistags = vigra.defaultAxistags(4)
#data without channels
self.dataNoChannels = self.randomData.squeeze()
self.dataNoChannels = self.dataNoChannels.view(vigra.VigraArray)
self.dataNoChannels.axistags = vigra.defaultAxistags(3, noChannels=True)
#setup the feature selection
rows = 6
cols = 7
self.selectedFeatures = []
#only test 1 feature 1 sigma setup for now
for i in range(rows):
for j in range(cols):
features = numpy.zeros((rows,cols), dtype=bool)
features[i, j]=True
self.selectedFeatures.append(features)
开发者ID:JensNRAD,项目名称:lazyflow,代码行数:58,代码来源:testInterpolatedFeatures.py
示例8: setupOutputs
def setupOutputs(self):
window = self.WindowSize.value
self.Output.meta.shape = (self.Input.meta.shape[0], window)
self.Output.meta.axistags = vigra.defaultAxistags('tc')
self.Output.meta.dtype = self.Input.meta.dtype
self.Valid.meta.shape = (self.Input.meta.shape[0],)
self.Valid.meta.axistags = vigra.defaultAxistags('t')
self.Valid.dtype = np.uint8
开发者ID:burgerdev,项目名称:hostload,代码行数:9,代码来源:recent.py
示例9: setupOutputs
def setupOutputs(self):
assert (len(self.Input.meta.shape) <= 2 or
np.prod(self.Input.meta.shape[1:]) == 1)
self.Output.meta.shape = (self.Input.meta.shape[0], 1)
self.Output.meta.axistags = vigra.defaultAxistags('tc')
self.Output.meta.dtype = np.float32
self.Valid.meta.shape = (self.Input.meta.shape[0],)
self.Valid.meta.axistags = vigra.defaultAxistags('t')
self.Valid.meta.dtype = np.uint8
开发者ID:burgerdev,项目名称:hostload,代码行数:10,代码来源:window.py
示例10: test_2d_vigra_along_z
def test_2d_vigra_along_z(self):
"""Test if 2d files generated through vigra are recognized correctly"""
# Prepare some data set for this case
data = numpy.random.randint(0, 255, (20, 100, 200, 3)).astype(numpy.uint8)
axistags = vigra.defaultAxistags("yxc")
expected_axistags = vigra.defaultAxistags("zyxc")
h5_op = OpStreamingH5N5SequenceReaderM(graph=self.graph)
n5_op = OpStreamingH5N5SequenceReaderM(graph=self.graph)
tempdir = tempfile.TemporaryDirectory()
try:
for sliceIndex, zSlice in enumerate(data):
testDataH5FileName = f"{tempdir.name}/test-{sliceIndex:02d}.h5"
testDataN5FileName = f"{tempdir.name}/test-{sliceIndex:02d}.n5"
# Write the dataset to an hdf5 and a n5 file
# (Note: Don't use vigra to do this, which may reorder the axes)
h5File = h5py.File(testDataH5FileName)
n5File = z5py.N5File(testDataN5FileName)
try:
h5File.create_group("volume")
n5File.create_group("volume")
h5File["volume"].create_dataset("subvolume", data=zSlice)
n5File["volume"].create_dataset("subvolume", data=zSlice)
# Write the axistags attribute
current_path = "volume/subvolume"
h5File[current_path].attrs["axistags"] = axistags.toJSON()
n5File[current_path].attrs["axistags"] = axistags.toJSON()
finally:
h5File.close()
n5File.close()
# Read the data with an operator
hdf5GlobString = f"{tempdir.name}/test-*.h5/volume/subvolume"
n5GlobString = f"{tempdir.name}/test-*.n5/volume/subvolume"
h5_op.SequenceAxis.setValue("z")
n5_op.SequenceAxis.setValue("z")
h5_op.GlobString.setValue(hdf5GlobString)
n5_op.GlobString.setValue(n5GlobString)
assert h5_op.OutputImage.ready()
assert n5_op.OutputImage.ready()
assert h5_op.OutputImage.meta.axistags == expected_axistags
assert n5_op.OutputImage.meta.axistags == expected_axistags
numpy.testing.assert_array_equal(
h5_op.OutputImage.value[5:10, 50:100, 100:150], data[5:10, 50:100, 100:150]
)
numpy.testing.assert_array_equal(
n5_op.OutputImage.value[5:10, 50:100, 100:150], data[5:10, 50:100, 100:150]
)
finally:
h5_op.cleanUp()
n5_op.cleanUp()
开发者ID:ilastik,项目名称:lazyflow,代码行数:54,代码来源:testOpStreamingH5N5SequenceReaderM.py
示例11: setupOutputs
def setupOutputs(self):
self.fileNameList = self.expandGlobStrings(self.globstring.value)
num_files = len(self.fileNameList)
if len(self.fileNameList) == 0:
self.stack.meta.NOTREADY = True
return
try:
self.info = vigra.impex.ImageInfo(self.fileNameList[0])
self.slices_per_file = vigra.impex.numberImages(self.fileNameList[0])
except RuntimeError as e:
logger.error(str(e))
raise OpStackLoader.FileOpenError(self.fileNameList[0]) from e
slice_shape = self.info.getShape()
X, Y, C = slice_shape
if self.slices_per_file == 1:
if self.SequenceAxis.ready():
sequence_axis = str(self.SequenceAxis.value)
assert sequence_axis in "tzc"
else:
sequence_axis = "z"
# For stacks of 2D images, we assume xy slices
if sequence_axis == "c":
shape = (X, Y, C * num_files)
axistags = vigra.defaultAxistags("xyc")
else:
shape = (num_files, Y, X, C)
axistags = vigra.defaultAxistags(sequence_axis + "yxc")
else:
if self.SequenceAxis.ready():
sequence_axis = self.SequenceAxis.value
assert sequence_axis in "tzc"
else:
sequence_axis = "t"
if sequence_axis == "z":
axistags = vigra.defaultAxistags("ztyxc")
elif sequence_axis == "t":
axistags = vigra.defaultAxistags("tzyxc")
else:
axistags = vigra.defaultAxistags("czyx")
# For stacks of 3D volumes, we assume xyz blocks stacked along
# sequence_axis
if sequence_axis == "c":
shape = (num_files * C, self.slices_per_file, Y, X)
else:
shape = (num_files, self.slices_per_file, Y, X, C)
self.stack.meta.shape = shape
self.stack.meta.axistags = axistags
self.stack.meta.dtype = self.info.getDtype()
开发者ID:ilastik,项目名称:lazyflow,代码行数:53,代码来源:ioOperators.py
示例12: test_3d_vigra_along_t
def test_3d_vigra_along_t(self):
"""Test if 3d volumes generated through vigra are recognized correctly"""
# Prepare some data set for this case
data = numpy.random.randint(0, 255, (10, 15, 50, 100, 3)).astype(numpy.uint8)
axistags = vigra.defaultAxistags("zyxc")
expected_axistags = vigra.defaultAxistags("tzyxc")
h5_op = OpStreamingH5N5SequenceReaderS(graph=self.graph)
n5_op = OpStreamingH5N5SequenceReaderS(graph=self.graph)
try:
testDataH5FileName = f"{self.tempdir_normalized_name}/test.h5"
testDataN5FileName = f"{self.tempdir_normalized_name}/test.n5"
# Write the dataset to an hdf5 file
# (Note: Don't use vigra to do this, which may reorder the axes)
h5File = h5py.File(testDataH5FileName)
n5File = z5py.N5File(testDataN5FileName)
try:
h5File.create_group("volumes")
n5File.create_group("volumes")
internalPathString = "subvolume-{sliceIndex:02d}"
for sliceIndex, tSlice in enumerate(data):
subpath = internalPathString.format(sliceIndex=sliceIndex)
h5File["volumes"].create_dataset(subpath, data=tSlice)
n5File["volumes"].create_dataset(subpath, data=tSlice)
# Write the axistags attribute
current_path = "volumes/{}".format(subpath)
h5File[current_path].attrs["axistags"] = axistags.toJSON()
n5File[current_path].attrs["axistags"] = axistags.toJSON()
finally:
h5File.close()
n5File.close()
# Read the data with an operator
hdf5GlobString = f"{testDataH5FileName}/volumes/subvolume-*"
n5GlobString = f"{testDataN5FileName}/volumes/subvolume-*"
h5_op.SequenceAxis.setValue("t")
n5_op.SequenceAxis.setValue("t")
h5_op.GlobString.setValue(hdf5GlobString)
n5_op.GlobString.setValue(n5GlobString)
assert h5_op.OutputImage.ready()
assert n5_op.OutputImage.ready()
assert h5_op.OutputImage.meta.axistags == expected_axistags
assert n5_op.OutputImage.meta.axistags == expected_axistags
numpy.testing.assert_array_equal(h5_op.OutputImage.value, data)
numpy.testing.assert_array_equal(n5_op.OutputImage.value, data)
finally:
h5_op.cleanUp()
n5_op.cleanUp()
开发者ID:ilastik,项目名称:lazyflow,代码行数:53,代码来源:testOpStreamingH5N5SequenceReaderS.py
示例13: setUp
def setUp(self):
self.delta = numpy.zeros((19, 19, 19, 1), dtype=numpy.float32)
self.delta[9, 9, 9, 0]=1
self.delta = self.delta.view(vigra.VigraArray)
self.delta.axistags = vigra.defaultAxistags(4)
self.dataShape = ((100, 100, 100, 1))
self.randomData = (numpy.random.random(self.dataShape) * 100).astype(int)
self.randomData = self.randomData.view(vigra.VigraArray)
self.randomData.axistags = vigra.defaultAxistags(4)
self.anisotropicSigmas = [(3, 3, 1), (1.6, 1.6, 1)]
self.isotropicSigmasTuple = [(3, 3, 3), (1, 1, 1)]
self.isotropicSigmas = [3, 1]
开发者ID:CVML,项目名称:lazyflow,代码行数:14,代码来源:testAnisotropicVigraFeatures.py
示例14: test1
def test1(self):
superpixels = generate_random_voronoi((100,200), 200)
superpixels.axistags = vigra.defaultAxistags('yx')
feature_names = ['edgeregion_edge_regionradii']
rag = Rag( superpixels )
acc = EdgeRegionEdgeAccumulator(rag, feature_names)
features_df = rag.compute_features(None, feature_names, accumulator_set=[acc])
radii = features_df[features_df.columns.values[2:]].values
assert (radii[:,0] >= radii[:,1]).all()
# Transpose superpixels and check again
# Should match (radii are sorted by magnitude).
superpixels.axistags = vigra.defaultAxistags('xy')
rag = Rag( superpixels )
acc = EdgeRegionEdgeAccumulator(rag, feature_names)
transposed_features_df = rag.compute_features(None, feature_names, accumulator_set=[acc])
transposed_radii = transposed_features_df[transposed_features_df.columns.values[2:]].values
assert (transposed_features_df[['sp1', 'sp1']].values == features_df[['sp1', 'sp1']].values).all()
DEBUG = False
if DEBUG:
count_features = rag.compute_features(None, ['standard_edge_count', 'standard_sp_count'])
import pandas as pd
combined_features_df = pd.merge(features_df, transposed_features_df, how='left', on=['sp1', 'sp2'], suffixes=('_orig', '_transposed'))
combined_features_df = pd.merge(combined_features_df, count_features, how='left', on=['sp1', 'sp2'])
problem_rows = np.logical_or(np.isclose(radii[:, 0], transposed_radii[:, 0]) != 1,
np.isclose(radii[:, 1], transposed_radii[:, 1]) != 1)
problem_df = combined_features_df.loc[problem_rows][sorted(list(combined_features_df.columns))]
print(problem_df.transpose())
debug_sp = np.zeros_like(superpixels, dtype=np.uint8)
for sp1 in problem_df['sp1'].values:
debug_sp[superpixels == sp1] = 128
for sp2 in problem_df['sp2'].values:
debug_sp[superpixels == sp2] = 255
vigra.impex.writeImage(debug_sp, '/tmp/debug_sp.png', dtype='NATIVE')
# The first axes should all be close.
# The second axes may differ somewhat in the case of purely linear edges,
# so we allow a higher tolerance.
assert np.isclose(radii[:,0], transposed_radii[:,0]).all()
assert np.isclose(radii[:,1], transposed_radii[:,1], atol=0.001).all()
开发者ID:stuarteberg,项目名称:ilastikrag,代码行数:49,代码来源:test_edgeregion_accumulator.py
示例15: setup
def setup(self):
graph = Graph()
op = OpCompressedUserLabelArray(graph=graph)
arrayshape = (1,100,100,10,1)
op.inputs["shape"].setValue( arrayshape )
blockshape = (1,10,10,10,1) # Why doesn't this work if blockshape is an ndarray?
op.inputs["blockShape"].setValue( blockshape )
op.eraser.setValue(100)
op.Input.meta.axistags = vigra.defaultAxistags('txyzc')
op.Input.meta.has_mask = True
dummyData = numpy.zeros(arrayshape, dtype=numpy.uint8)
dummyData = numpy.ma.masked_array(dummyData, mask=numpy.ma.getmaskarray(dummyData), fill_value=numpy.uint8(0), shrink=False)
op.Input.setValue( dummyData )
slicing = sl[0:1, 1:15, 2:36, 3:7, 0:1]
inDataShape = slicing2shape(slicing)
inputData = ( 3*numpy.random.random(inDataShape) ).astype(numpy.uint8)
inputData = numpy.ma.masked_array(inputData, mask=numpy.ma.getmaskarray(inputData), fill_value=numpy.uint8(0), shrink=False)
inputData[:, 0] = numpy.ma.masked
op.Input[slicing] = inputData
data = numpy.ma.zeros(arrayshape, dtype=numpy.uint8, fill_value=numpy.uint8(0))
data[slicing] = inputData
self.op = op
self.slicing = slicing
self.inData = inputData
self.data = data
开发者ID:slzephyr,项目名称:lazyflow,代码行数:28,代码来源:testOpCompressedUserLabelArray.py
示例16: setUp
def setUp(self):
segimg = segImage()
labels = {0: np.array([0, 1, 2]), 1: np.array([0, 0, 0, 0])}
rawimg = np.indices(segimg.shape).sum(0).astype(np.float32)
rawimg = rawimg.view(vigra.VigraArray)
rawimg.axistags = vigra.defaultAxistags("txyzc")
g = Graph()
objectExtraction.config.selected_features = ["Count"]
self.featsop = OpRegionFeatures(FEATURES, graph=g)
self.featsop.LabelImage.setValue(segimg)
self.featsop.RawImage.setValue(rawimg)
assert self.featsop.Output.ready()
self._opRegFeatsAdaptOutput = OpAdaptTimeListRoi(graph=g)
self._opRegFeatsAdaptOutput.Input.connect(self.featsop.Output)
assert self._opRegFeatsAdaptOutput.Output.ready()
self.trainop = OpObjectTrain(graph=g)
self.trainop.Features.resize(1)
self.trainop.Features[0].connect(self._opRegFeatsAdaptOutput.Output)
self.trainop.Labels.resize(1)
self.trainop.Labels.setValues([labels])
self.trainop.FixClassifier.setValue(False)
self.trainop.ForestCount.setValue(1)
assert self.trainop.Classifier.ready()
self.op = OpObjectPredict(graph=g)
self.op.Classifier.connect(self.trainop.Classifier)
self.op.Features.connect(self._opRegFeatsAdaptOutput.Output)
self.op.LabelsCount.setValue(2)
assert self.op.Predictions.ready()
开发者ID:fblumenthal,项目名称:ilastik,代码行数:35,代码来源:testOperators.py
示例17: 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()
开发者ID:christophdecker,项目名称:lazyflow,代码行数:25,代码来源:testOpExportSlot.py
示例18: _write_slice
def _write_slice(self, roi, slice_data):
"""
Write the data from the given roi into a slice image.
"""
step_axis = self._volume_axes[0]
input_axes = self.Input.meta.getAxisKeys()
tagged_roi = OrderedDict( zip( input_axes, zip( *roi ) ) )
# e.g. tagged_roi={ 'x':(0,1), 'y':(3,4), 'z':(10,20) }
assert tagged_roi[step_axis][1] - tagged_roi[step_axis][0] == 1,\
"Expected roi to be a single slice."
slice_index = tagged_roi[step_axis][0] + self.SliceIndexOffset.value
filepattern = self.FilepathPattern.value
# If the user didn't provide custom formatting for the slice field,
# auto-format to include zero-padding
if '{slice_index}' in filepattern:
filepattern = filepattern.format( slice_index='{' + 'slice_index:0{}'.format(self._max_slice_digits) + '}' )
formatted_path = filepattern.format( slice_index=slice_index )
squeezed_data = slice_data.squeeze()
squeezed_data = vigra.taggedView(squeezed_data, vigra.defaultAxistags("".join(self._volume_axes[1:])))
assert len(squeezed_data.shape) == len(self._volume_axes)-1
#logger.debug( "Writing slice image for roi: {}".format( roi ) )
logger.debug("Writing slice: {}".format(formatted_path) )
vigra.impex.writeImage( squeezed_data, formatted_path )
开发者ID:JensNRAD,项目名称:lazyflow,代码行数:26,代码来源:ioOperators.py
示例19: create_test_files
def create_test_files():
tags = vigra.defaultAxistags("zyxc")
tags['x'].resolution = 1.0
tags['y'].resolution = 1.0
tags['z'].resolution = 45.0
tags['c'].description = 'intensity'
with h5py.File(test_data_path, 'w') as f:
f['zeros'] = numpy.zeros( (10, 100, 200, 1), dtype=numpy.uint8 )
f['zeros'].attrs['axistags'] = tags.toJSON()
import ilastik_main
parsed_args, workflow_cmdline_args = ilastik_main.parser.parse_known_args()
parsed_args.new_project = test_project_path
parsed_args.workflow = "Pixel Classification"
parsed_args.headless = True
shell = ilastik_main.main(parsed_args, workflow_cmdline_args)
data_selection_applet = shell.workflow.dataSelectionApplet
# To configure data selection, start with empty cmdline args and manually fill them in
data_selection_args, _ = data_selection_applet.parse_known_cmdline_args([])
data_selection_args.raw_data = [test_data_path + '/zeros']
# Configure
data_selection_applet.configure_operator_with_parsed_args(data_selection_args)
shell.projectManager.saveProject()
return data_selection_applet
开发者ID:JaimeIvanCervantes,项目名称:ilastik,代码行数:28,代码来源:datasetInfoEditorWidget.py
示例20: setUp
def setUp(self):
segimg = segImage()
rawimg = np.indices(segimg.shape).sum(0).astype(np.float32)
rawimg = rawimg.view(vigra.VigraArray)
rawimg.axistags = vigra.defaultAxistags('txyzc')
feats = {"Vigra Object Features":
{"Count":{}, "RegionCenter":{}, "Coord<Principal<Kurtosis>>":{}, "Coord<Minimum>":{}, "Coord<Maximum>":{}}
}
g = Graph()
self.featsop = OpRegionFeatures(graph=g)
self.featsop.LabelImage.setValue(segimg)
self.featsop.RawImage.setValue( rawimg )
self.featsop.Features.setValue(feats)
self.assertTrue(self.featsop.Output.ready(), "The output of operator {} was not ready after connections took place.".format(self.featsop))
self._opRegFeatsAdaptOutput = OpAdaptTimeListRoi(graph=g)
self._opRegFeatsAdaptOutput.Input.connect(self.featsop.Output)
self.assertTrue(self._opRegFeatsAdaptOutput.Output.ready(), "The output of operator {} was not ready after connections took place.".format(self._opRegFeatsAdaptOutput))
self.op = OpObjectTrain(graph=g)
self.op.Features.resize(1)
self.op.Features[0].connect(self._opRegFeatsAdaptOutput.Output)
self.op.SelectedFeatures.setValue(feats)
self.op.FixClassifier.setValue(False)
self.op.ForestCount.setValue(self.nRandomForests)
开发者ID:bheuer,项目名称:ilastik,代码行数:28,代码来源:testOperators.py
注:本文中的vigra.defaultAxistags函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论