Skip to content

Commit

Permalink
Merge pull request #1719 from girder/closer-to-master
Browse files Browse the repository at this point in the history
Merge master into the edit views ui branch
  • Loading branch information
manthey authored Nov 7, 2024
2 parents 9ae784d + 1a7c504 commit fbb2656
Show file tree
Hide file tree
Showing 39 changed files with 901 additions and 208 deletions.
9 changes: 5 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
rev: v5.0.0
hooks:
- id: check-added-large-files
- id: check-ast
Expand Down Expand Up @@ -58,21 +58,22 @@ repos:
hooks:
- id: circleci-config-validate
- repo: https://github.com/ThisIsManta/stylus-supremacy
rev: v2.17.5
rev: v4.0.0
hooks:
- id: stylus-supremacy
language_version: "22.10.0"
args:
- '--options'
- './girder/girder_large_image/web_client/package.json'
- repo: https://github.com/asottile/pyupgrade
rev: v3.17.0
rev: v3.18.0
hooks:
- id: pyupgrade
args:
- --py38-plus
- --keep-percent-format
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.6.1
rev: v0.7.0
hooks:
- id: ruff
args:
Expand Down
28 changes: 28 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,33 @@
# Change Log

## 1.30.3

### Improvements

- Format dates in item lists ([#1707](../../pull/1707))
- Guard dtype types ([#1711](../../pull/1711), [#1714](../../pull/1714), [#1716](../../pull/1716))
- Better handle IndicaLabs tiff files ([#1717](../../pull/1717))

### Changes

- Openslide now requires the binary wheel on appropriate platforms ([#1709](../../pull/1709), [#1710](../../pull/1710))

## 1.30.2

### Features

- Support setting axis actual values in the zarr sink. Display these in the frame selector ([#1625](../../pull/1625))

### Improvements

- Speed up recursive item lists ([#1694](../../pull/1694))
- Better handle images with signed pixel data ([#1695](../../pull/1695))
- Reduce loading geojs when switching views in Girder ([#1699](../../pull/1699))

### Bug Fixes

- Don't compute channel window in zarr sinks ([#1705](../../pull/1705))

## 1.30.1

### Improvements
Expand Down
3 changes: 2 additions & 1 deletion docs/format_examples_datastore.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import pooch
from pathlib import Path

import pooch

EXAMPLES_FOLDER = Path('format_examples')

format_examples = [
Expand Down
5 changes: 3 additions & 2 deletions docs/generate_format_table.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import large_image
from pathlib import Path
from format_examples_datastore import EXAMPLES_FOLDER, format_examples, fetch_all

from format_examples_datastore import EXAMPLES_FOLDER, fetch_all, format_examples

import large_image

TABLE_FILE = Path('./format_table.rst')
NO_MULTIFRAME_SOURCES = ['deepzoom', 'openjpeg', 'openslide']
Expand Down
59 changes: 53 additions & 6 deletions docs/getting_started.rst
Original file line number Diff line number Diff line change
Expand Up @@ -334,25 +334,60 @@ You can also composite a multi-frame image into a false-color output:
Writing an Image
----------------

If you wish to visualize numpy data, large_image can write a tiled tiff. This requires a tile source that supports writing to be installed. As of this writing, the ``large-image-source-zarr`` and ``large-image-source-vips`` sources supports this. If both are installed, the ``large-image-source-zarr`` is the default.
If you wish to visualize numpy data, ``large_image`` can write a tiled image.
This requires a tile source that supports writing to be installed.
As of this writing, the ``large-image-source-zarr`` and ``large-image-source-vips`` sources both support this.
If both are installed, the ``large-image-source-zarr`` is the default.
Some of the API options available for ``large-image-source-zarr`` are not available for ``large-image-source-vips``.

.. code-block:: python
import large_image
source = large_image.new()
for nparray, x, y in fancy_algorithm():
# We could optionally add a mask to limit the output
source.addTile(nparray, x, y)
source.write('/tmp/sample.tiff', lossy=False)
The ``large-image-source-zarr`` can be used to store multiple frame data with arbitrary axes.
Multiple Frames
~~~~~~~~~~~~~~~

``large-image-source-zarr`` can be used to store multiframe data with arbitrary axes.
The example below demonstrates the creation of an image with five axes: T, Z, Y, X, S.

.. code-block:: python
import large_image
time_values = [0.5, 1.5, 2.5, 3.5]
z_values = [3, 6, 9]
tile_pos_values = [0, 1024, 2048, 3072, 4096]
source = large_image.new()
for nparray, x, y, time, param1 in fancy_algorithm():
source.addTile(nparray, x, y, time=time, p1=param1)
for t_index, t_value in enumerate(time_values):
for z_index, z_value in enumerate(z_values):
for y_value in tile_pos_values:
for x_value in tile_pos_values:
# tile is a numpy array with shape (1024, 1024, 3)
# this shape corresponds to the following axes, respectively: (Y, X, S)
tile = get_my_data_tile(x_value, y_value, z_value, t_value)
source.addTile(
tile,
x_value,
y_value,
z=z_index,
time=t_index,
# z_value and t_value are optional parameters to store the
# true values at the provided z index and t index
z_value=z_value,
time_value=t_value,
)
source.frameUnits = dict(t='ms', z='cm')
# The writer supports a variety of formats
source.write('/tmp/sample.zarr.zip', lossy=False)
Expand All @@ -361,31 +396,37 @@ You may also choose to read tiles from one source and write modified tiles to a
.. code-block:: python
import large_image
original_source = large_image.open('path/to/original/image.tiff')
new_source = large_image.new()
for frame in original_source.getMetadata().get('frames', []):
for tile in original_source.tileIterator(frame=frame['Frame'], format='numpy'):
t, x, y = tile['tile'], tile['x'], tile['y']
tile_data, x, y = tile['tile'], tile['x'], tile['y']
kwargs = {
'z': frame['IndexZ'],
'c': frame['IndexC'],
}
modified_tile = modify_tile(t)
modified_tile = modify_tile(tile_data)
new_source.addTile(modified_tile, x=x, y=y, **kwargs)
new_source.write('path/to/new/image.tiff', lossy=False)
Multiple processes
~~~~~~~~~~~~~~~~~~

In some cases, it may be beneficial to write to a single image from multiple processes or threads:

.. code-block:: python
import large_image
import multiprocessing
# Important: Must be a pickleable function
def add_tile_to_source(tilesource, nparray, position):
tilesource.addTile(
nparray,
**position
)
source = large_image.new()
# Important: Maximum size must be allocated before any multiprocess concurrency
add_tile_to_source(source, np.zeros(1, 1, 3), dict(x=max_x, y=max_y, z=max_z))
Expand All @@ -397,4 +438,10 @@ In some cases, it may be beneficial to write to a single image from multiple pro
)
source.write('/tmp/sample.zarr.zip', lossy=False)
More examples
~~~~~~~~~~~~~

To see more examples of using ``large-image-source-zarr`` to write images, see :doc:`notebooks` and the `Zarr Sink Tests <https://github.com/girder/large_image/blob/master/test/test_sink.py>`_.

.. _Girder: https://girder.readthedocs.io/en/latest/
7 changes: 4 additions & 3 deletions docs/girder_annotation_config_options.rst
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ This can be used to specify how annotations are listed on the item page.
columns:
-
# The "record" type is from the default annotation record. The value
# is one of "name", "creator", "created", "updatedId", "updated",
# is one of "name", "creator", "created", "updatedId", "updated".
type: record
value: name
-
Expand All @@ -43,8 +43,9 @@ This can be used to specify how annotations are listed on the item page.
-
type: record
value: created
# A format of date will use the browser's default date format
format: date
# A format of datetime, date, or time will use the browser's default
# date and/or time format
format: datetime
-
# The "metadata" type is taken from the annotations's
# "annotation.attributes" contents. It can be a nested key by using
Expand Down
17 changes: 12 additions & 5 deletions docs/girder_config_options.rst
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,14 @@ This is used to specify how items appear in item lists. There are two settings,
# clicking on an item from showing the item page to another action.
navigate:
# type can be "item": the default, open the item page, "itemList": go
# to the named item page
# to the named item page, or "open" to open an application
type: itemList
# if the type is "itemList", the name is the name of the itemList to
# display.
# display. If the type is "open", the name is the name of the
# registered application that should be opened by preference (e.g.,
# "histomicsui" or "volview"). If that application does not report it
# can open the item or no name is specified, the highest priority
# application that can open the item will be used.
name: studyList
# show these columns in order from left to right. Each column has a
# "type" and "value". It optionally has a "title" used for the column
Expand All @@ -121,7 +125,8 @@ This is used to specify how items appear in item lists. There are two settings,
title: Slide Label
-
# The "record" type is from the default item record. The value is
# one of "name", "size", or "controls".
# one of "name", "description", "created", "updated", "size", or
# "controls".
type: record
value: name
-
Expand All @@ -135,8 +140,10 @@ This is used to specify how items appear in item lists. There are two settings,
# can be a nested key by using dots in its name.
type: metadata
value: Stain
# "format" can be "text", "number", "category". Other values may be
# specified later.
# "format" can be "text", "number", "category", "datetime", "date",
# "time". "datetime", "date", and "time" use the user's browser's
# locale to convert the date and/or time to their browser's preferred
# format. Other values may be specified later.
format: text
-
type: metadata
Expand Down
Loading

0 comments on commit fbb2656

Please sign in to comment.