From f6f545ec7b8f42c90efd0b1545a383f352d97825 Mon Sep 17 00:00:00 2001 From: Niko Ehrenfeuchter <nikolaus.ehrenfeuchter@unibas.ch> Date: Mon, 4 Mar 2019 11:43:03 +0100 Subject: [PATCH] Add workaround for uncalibrated ICS/IDS exports in BF 6.0 series --- src/imcflibs/imagej/bioformats.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/imcflibs/imagej/bioformats.py b/src/imcflibs/imagej/bioformats.py index 1a9d125..69cc5cb 100644 --- a/src/imcflibs/imagej/bioformats.py +++ b/src/imcflibs/imagej/bioformats.py @@ -72,6 +72,17 @@ def export(imp, filename, overwrite=False): keep existing files, in this case an IOError is raised. """ log.info("Exporting to [%s]", filename) + suffix = filename[-3:].lower() + try: + unit = imp.calibration.unit + log.debug("Detected calibration unit: %s", unit) + except Error as err: + log.error("Unable to detect spatial unit: %s", err) + raise RuntimeError("Error detecting image calibration!") + if unit == 'pixel' and (suffix == 'ics' or suffix == 'ids'): + log.warn("Forcing unit to be 'm' instead of 'pixel' to avoid " + "Bio-Formats 6.0.x Exporter bug!") + imp.calibration.unit = 'm' if os.path.exists(filename): if not overwrite: raise IOError('file [%s] already exists!' % filename) -- GitLab