Skip to content

Commit d1c1ba7

Browse files
authored
Update bioformats dependency to 8.0.1 (#231)
* Change URL and hash for jar artifact * Adapt bioformats logging call to avoid spurious message Previously we called enableLogging, but under the latest bioformats that emits one DEBUG-level message during internal logging setup. This message contains a stack trace from an internally caught exception which looks extra-scary even though it's irrelevant. Now we use setRootLevel which suppresses even that message. * Skip y-axis stage coords flip for InCell reader Bioformats 6.4.0 added an explicit correction for the stage y-axis.
1 parent 4027581 commit d1c1ba7

File tree

3 files changed

+21
-17
lines changed

3 files changed

+21
-17
lines changed

MANIFEST.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
include versioneer.py
22
include ashlar/_version.py
3-
recursive-include ashlar/jars *.jar
3+
include ashlar/jars/bioformats_package.jar

ashlar/reg.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@
2828

2929
if not jnius_config.vm_running:
3030
pkg_root = pathlib.Path(__file__).parent.resolve()
31-
bf_jar_path = pkg_root / 'jars' / 'loci_tools.jar'
31+
bf_jar_path = pkg_root / 'jars' / 'bioformats_package.jar'
3232
if not bf_jar_path.exists():
33-
raise RuntimeError("loci_tools.jar missing from distribution"
33+
raise RuntimeError("bioformats_package.jar missing from distribution"
3434
" (expected it at %s)" % bf_jar_path)
3535
jnius_config.add_classpath(str(bf_jar_path))
3636
# These settings constrain the memory used by BioFormats to near the minimum
@@ -48,7 +48,7 @@
4848
ChannelSeparator = jnius.autoclass('loci.formats.ChannelSeparator')
4949
DynamicMetadataOptions = jnius.autoclass('loci.formats.in.DynamicMetadataOptions')
5050
UNITS = jnius.autoclass('ome.units.UNITS')
51-
DebugTools.enableLogging("ERROR")
51+
DebugTools.setRootLevel("ERROR")
5252

5353

5454
# TODO:
@@ -378,9 +378,13 @@ def tile_position(self, i):
378378
value = v.doubleValue()
379379
values.append(value)
380380
position_microns = np.array(values, dtype=float)
381-
# Invert Y so that stage position coordinates and image pixel
382-
# coordinates are aligned (most formats seem to work this way).
383-
position_microns *= [-1, 1]
381+
# Flip the y-axis of the stage coordinate system to align it with the
382+
# image coordinate system, as seems to be required for most formats.
383+
# Skip this for any formats known not to require it.
384+
if self.format_name not in (
385+
"InCell 1000/2000", # As of Bioformats 6.4.0
386+
):
387+
position_microns *= [-1, 1]
384388
position_pixels = position_microns / self.pixel_size
385389
return position_pixels
386390

setup.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -43,32 +43,32 @@
4343
LICENSE = 'MIT License'
4444
HOMEPAGE = 'https://github.com/sorgerlab/ashlar'
4545

46-
LOCI_TOOLS_URL = 'https://downloads.openmicroscopy.org/bio-formats/6.3.1/artifacts/loci_tools.jar'
47-
LOCI_TOOLS_SHA1 = 'bdf1a37b561fea02fd8d1c747bd34db3fc49667b'
46+
BIOFORMATS_JAR_URL = 'https://downloads.openmicroscopy.org/bio-formats/8.0.1/artifacts/bioformats_package.jar'
47+
BIOFORMATS_JAR_SHA256 = '8c7557a9357a83bf40272292fbd676beb466a9a8bab34126e92a49d636c64bc2'
4848

4949
def download_bioformats():
5050
print("Ensuring latest bioformats is present:")
5151
dist_root = os.path.abspath(os.path.dirname(__file__))
5252
jar_dir = os.path.join(dist_root, 'ashlar', 'jars')
53-
lt_jar_path = os.path.join(jar_dir, 'loci_tools.jar')
53+
lt_jar_path = os.path.join(jar_dir, 'bioformats_package.jar')
5454
if not os.access(jar_dir, os.F_OK):
5555
os.mkdir(jar_dir)
5656
try:
5757
with open(lt_jar_path, 'rb') as f:
58-
existing_sha1 = hashlib.sha1(f.read()).hexdigest()
59-
if existing_sha1 == LOCI_TOOLS_SHA1:
58+
existing_sha256 = hashlib.sha256(f.read()).hexdigest()
59+
if existing_sha256 == BIOFORMATS_JAR_SHA256:
6060
print(" Up to date!")
6161
return
6262
except IOError:
6363
pass
64-
print(" Downloading BioFormats from %s ..." % LOCI_TOOLS_URL)
64+
print(" Downloading BioFormats from %s ..." % BIOFORMATS_JAR_URL)
6565
# FIXME add progress bar
66-
content = urlopen(LOCI_TOOLS_URL).read()
67-
content_sha1 = hashlib.sha1(content).hexdigest()
66+
content = urlopen(BIOFORMATS_JAR_URL).read()
67+
content_sha256 = hashlib.sha256(content).hexdigest()
6868
with open(lt_jar_path, 'wb') as f:
6969
f.write(content)
70-
if content_sha1 != LOCI_TOOLS_SHA1:
71-
raise RuntimeError("loci_tools.jar hash mismatch")
70+
if content_sha256 != BIOFORMATS_JAR_SHA256:
71+
raise RuntimeError("bioformats_package.jar hash mismatch")
7272

7373
# Define some distutils command subclasses for a few key commands to trigger
7474
# downloading the BioFormats JAR before they run.

0 commit comments

Comments
 (0)