Skip to content

Commit f6f545e

Browse files
committed
Add workaround for uncalibrated ICS/IDS exports in BF 6.0 series
1 parent 58ab521 commit f6f545e

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

src/imcflibs/imagej/bioformats.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,17 @@ def export(imp, filename, overwrite=False):
7272
keep existing files, in this case an IOError is raised.
7373
"""
7474
log.info("Exporting to [%s]", filename)
75+
suffix = filename[-3:].lower()
76+
try:
77+
unit = imp.calibration.unit
78+
log.debug("Detected calibration unit: %s", unit)
79+
except Error as err:
80+
log.error("Unable to detect spatial unit: %s", err)
81+
raise RuntimeError("Error detecting image calibration!")
82+
if unit == 'pixel' and (suffix == 'ics' or suffix == 'ids'):
83+
log.warn("Forcing unit to be 'm' instead of 'pixel' to avoid "
84+
"Bio-Formats 6.0.x Exporter bug!")
85+
imp.calibration.unit = 'm'
7586
if os.path.exists(filename):
7687
if not overwrite:
7788
raise IOError('file [%s] already exists!' % filename)

0 commit comments

Comments
 (0)