Skip to content

Commit

Permalink
Merge pull request #463 from girder/bioformats
Browse files Browse the repository at this point in the history
Add a bioformats tilesource.
  • Loading branch information
manthey authored Sep 10, 2020
2 parents dddd80b + c36e54a commit af73827
Show file tree
Hide file tree
Showing 12 changed files with 683 additions and 1 deletion.
2 changes: 2 additions & 0 deletions .circleci/make_wheels.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ cd "$ROOTPATH/girder_annotation"
pip wheel . --no-deps -w ~/wheels && rm -rf build
cd "$ROOTPATH/tasks"
pip wheel . --no-deps -w ~/wheels && rm -rf build
cd "$ROOTPATH/sources/bioformats"
pip wheel . --no-deps -w ~/wheels && rm -rf build
cd "$ROOTPATH/sources/dummy"
pip wheel . --no-deps -w ~/wheels && rm -rf build
cd "$ROOTPATH/sources/gdal"
Expand Down
3 changes: 3 additions & 0 deletions .circleci/release_pypi.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ twine upload --verbose dist/*
cd "$ROOTPATH/tasks"
python setup.py sdist
twine upload --verbose dist/*
cd "$ROOTPATH/sources/bioformats"
python setup.py sdist
twine upload --verbose dist/*
cd "$ROOTPATH/sources/dummy"
python setup.py sdist
twine upload --verbose dist/*
Expand Down
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

## Unreleased

### Features
- Added bioformats tile source (#463)

## Version 1.2.0

### Features
Expand Down
2 changes: 2 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ Large Image consists of several Python modules designed to work together. These

- ``large-image-source-nd2``: A tile source for reading nd2 (NIS Element) images.

- ``large-image-source-bioformats``: A tile source for reading any file handled by the Java Bioformats library.

- ``large-image-source-test``: A tile source that generates test tiles, including a simple fractal pattern. Useful for testing extreme zoom levels.

- ``large-image-source-dummy``: A tile source that does nothing.
Expand Down
10 changes: 9 additions & 1 deletion large_image/tilesource/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,14 @@ def _imageToPIL(image, setMode=None):
image = numpy.resize(image, image.shape[:2])
if image.dtype == numpy.uint16:
image = numpy.floor_divide(image, 256).astype(numpy.uint8)
# TODO: The scaling of float data needs to be identical across all
# tiles of an image. This means that we need a reference to the parent
# tile source or some other way of regulating it.
# elif image.dtype.kind == 'f':
# if numpy.max(image) > 1:
# maxl2 = math.ceil(math.log(numpy.max(image) + 1) / math.log(2))
# image = image / ((2 ** maxl2) - 1)
# image = (image * 255).astype(numpy.uint8)
elif image.dtype != numpy.uint8:
image = image.astype(numpy.uint8)
image = PIL.Image.fromarray(image, mode)
Expand Down Expand Up @@ -1322,7 +1330,7 @@ def _getMinMax(self, minmax, value, dtype, bandidx=None, frame=None):
value = self._bandRanges[frame]['max'][bandidx]
elif dtype == numpy.uint16:
value = 65535
elif dtype == numpy.float:
elif dtype.kind == 'f':
value = 1
else:
value = 255
Expand Down
1 change: 1 addition & 0 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ girder>=3.0.4 ; python_version < '3.8'
girder>=3.0.13.dev6 ; python_version >= '3.8'
girder-jobs>=3.0.3,<3.1 ; python_version < '3.6'
girder-jobs>=3.0.3 ; python_version >= '3.6'
-e sources/bioformats ; python_version >= '3.5'
-e sources/dummy
-e sources/gdal
-e sources/nd2
Expand Down
5 changes: 5 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import os
import platform
from setuptools import setup, find_packages
import sys

with open('README.rst') as readme_file:
readme = readme_file.read()
Expand All @@ -24,6 +25,10 @@
'tiff': ['large-image-source-tiff'],
'test': ['large-image-source-test'],
}
if sys.version_info >= (3, ):
sources.update({
'bioformats': ['large-image-source-bioformats'],
})
extraReqs.update(sources)
extraReqs['sources'] = list(set(itertools.chain.from_iterable(sources.values())))
extraReqs['all'] = list(set(itertools.chain.from_iterable(extraReqs.values())))
Expand Down
Loading

0 comments on commit af73827

Please sign in to comment.