Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_unknown_axes_tags(self):
"""
This test is related to https://github.com/ilastik/ilastik/issues/1487
Here, we generate a 3D tiff file with scikit-learn and try to read it
"""
import tifffile
from distutils import version
# TODO(Dominik) remove version checking once tifffile dependency is fixed
# ilastik tiffile version >= 2000.0.0
# latest tifffile version is 0.13.0 right now
tifffile_version_ilastik_ref = version.StrictVersion("2000.0.0")
tifffile_version_ref = version.StrictVersion("0.7.0")
tifffile_version = version.StrictVersion(tifffile.__version__)
testshapes = [((10, 20), "yx"), ((10, 20, 30), "zyx"), ((10, 20, 30, 3), "zyxc"), ((5, 10, 20, 30, 3), "tzyxc")]
with tempdir() as d:
for test_shape, test_axes in testshapes:
data = numpy.random.randint(0, 256, test_shape).astype(numpy.uint8)
tiff_path = "{}/myfile_{}.tiff".format(d, test_axes)
# TODO(Dominik) remove version checking once dependencies for
# skimage are >= 0.13.0 for all flavours of ilastik
if (tifffile_version > tifffile_version_ilastik_ref) or (tifffile_version < tifffile_version_ref):
tifffile.imsave(tiff_path, data)
else:
tifffile.imsave(tiff_path, data, metadata={"axes": "QQQ"})
op = OpTiffReader(graph=Graph())
op.Filepath.setValue(tiff_path)
assert op.Output.ready()
def test_unknown_axes_tags(self):
"""
This test is related to https://github.com/ilastik/ilastik/issues/1487
Here, we generate a 3D tiff file with scikit-learn and try to read it
"""
import tifffile
from distutils import version
# TODO(Dominik) remove version checking once tifffile dependency is fixed
# ilastik tiffile version >= 2000.0.0
# latest tifffile version is 0.13.0 right now
tifffile_version_ilastik_ref = version.StrictVersion("2000.0.0")
tifffile_version_ref = version.StrictVersion("0.7.0")
tifffile_version = version.StrictVersion(tifffile.__version__)
testshapes = [((10, 20), "yx"), ((10, 20, 30), "zyx"), ((10, 20, 30, 3), "zyxc"), ((5, 10, 20, 30, 3), "tzyxc")]
with tempdir() as d:
for test_shape, test_axes in testshapes:
data = numpy.random.randint(0, 256, test_shape).astype(numpy.uint8)
tiff_path = "{}/myfile_{}.tiff".format(d, test_axes)
# TODO(Dominik) remove version checking once dependencies for
# skimage are >= 0.13.0 for all flavours of ilastik
if (tifffile_version > tifffile_version_ilastik_ref) or (tifffile_version < tifffile_version_ref):
tifffile.imsave(tiff_path, data)
else:
tifffile.imsave(tiff_path, data, metadata={"axes": "QQQ"})
op = OpTiffReader(graph=Graph())
op.Filepath.setValue(tiff_path)
assert op.Output.ready()
def openFile(self):
"""
open a file for reading
"""
imagej = self.style == 'imagej'
if int(tifffile.__version__.split('.')[1]) <= 14:
self.fp = tifffile.TiffWriter(self.fn, software=self.software, imagej=imagej)#, bigtiff=not(imagej))
else:
self.fp = tifffile.TiffWriter(self.fn, imagej=imagej)#, bigtiff=not(imagej))
self.handle = self.fp._fh
self.dataOffset = self.handle.tell()
def read_tiff_header(self):
with warnings.catch_warnings():
warnings.simplefilter("ignore")
with tf.TiffFile(self.tiff.raw[0]) as firstTiff:
self.parameters.shape = firstTiff.series[0].shape
bitstring = 'bits_per_sample'
try:
if int(tf.__version__.split('.')[1]) >= 13:
bitstring = 'bitspersample'
except Exception:
pass
self.tiff.bit_depth = getattr(firstTiff.pages[0], bitstring)
self.parameters.nz, self.parameters.ny, self.parameters.nx = self.parameters.shape
"platform_version": platform.version(),
"architecture": platform.machine(),
"cpu_total_count": psutil.cpu_count(),
"cpu_current_utilization": psutil.cpu_percent(),
"memory_total_gb": psutil.virtual_memory().total / 10e8,
"memory_available_gb": psutil.virtual_memory().available / 10e8,
}
# Store python config
pyversion = sys.version_info
_ = {
"python_version": f"{pyversion.major}.{pyversion.minor}.{pyversion.micro}",
"aicsimageio": aicsimageio.__version__,
"czifile": czifile.__version__,
"imageio": imageio.__version__,
"tifffile": tifffile.__version__,
}
# Run tests
#######################################################################
log.info(f"Running tests: no cluster...")
log.info(f"=" * 80)
all_results["no-cluster"] = _run_benchmark_suite(resources_dir=resources_dir)
#######################################################################
for cluster_config in CLUSTER_CONFIGS:
total_cores = cluster_config["per_worker_cores"] * cluster_config["workers"]
log.info(
f"Running tests: {cluster_config['name']} "